Skip to content

create_agent_context

create_agent_context(
    connection_mappings: ConnectionMappingList,
    *,
    config_overrides: Optional[ContextClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    name: Optional[ResourceName] = None,
    description: Optional[UserDefinedString] = None,
    trace_analysis_config: Optional[TraceAnalysisConfig] = None,
    workforce_sign_in_config: Optional[WorkforceSignInConfig] = None,
    entity_resolution_config: Optional[EntityResolutionConfig] = None,
    trusted_identity_sources: Optional[TrustedIdentitySourceList] = None,
    tags: Optional[TagMap] = None,
    curation_policy_ids: Optional[CurationPolicyIdentifierList] = None,
) -> CreateAgentContextResponse

Creates an agent context over one or more connections. Creation is asynchronous. GetAgentContext returns its status.

Parameters:

  • client_token (Optional[ClientToken], default: None ) –

    Client idempotency token. The AWS SDKs generate one when it is absent. An identical request with the same token returns the existing agent context. The same token with a different request returns ValidationException. trustedIdentitySources with the same entries in another order is the same request.

  • name (Optional[ResourceName], default: None ) –

    Optional. The name of the agent context. If you omit it, the name is default. You can change it later with UpdateAgentContext.

  • description (Optional[UserDefinedString], default: None ) –

    Optional human-readable description of the agent context. An empty string is the same as none.

  • connection_mappings (ConnectionMappingList) –

    The connection mappings for this agent context, up to 20. CreateAgentContext requires at least one: an empty list returns ValidationException. Each entry binds a connection to one or more ontologies, optionally scoped by a data filter, extraction depth, and path segments. Each referenced connection must exist, be owned by your account, and be ACTIVE. Order is significant. When several connections reach the same AWS Glue Data Catalog table, AWS Context tries the connection mapped first, with its own access, and then the next.

  • trace_analysis_config (Optional[TraceAnalysisConfig], default: None ) –

    The agent context's trace analysis settings. Optional. You can change it with UpdateAgentContext.

  • workforce_sign_in_config (Optional[WorkforceSignInConfig], default: None ) –

    Optional workforce sign-in settings. A config with signInUrl turns sign-in on (status defaults to ENABLED). status ENABLED without signInUrl is a ValidationException. You can change it with UpdateAgentContext.

  • entity_resolution_config (Optional[EntityResolutionConfig], default: None ) –

    Optional entity resolution settings. When the config or its status is absent, status reads ENABLED. You can change it with UpdateAgentContext.

  • trusted_identity_sources (Optional[TrustedIdentitySourceList], default: None ) –

    Optional identity sources to trust in addition to your account. At most 100 unique entries, each with exactly one member. Order is not significant. An empty list and an absent member are the same value: only your account is trusted. You can change it with UpdateAgentContext.

  • tags (Optional[TagMap], default: None ) –

    Tags to add to the agent context when you create it: up to 200 in the request, of which at most 50 can be user tags. Keys can't start with aws:. To add tags, you also need context:TagResource permission on the new agent context. If you specify more than 50 user tags, the request fails with ServiceQuotaExceededException, as on TagResource. If an AWS Organizations tag policy refuses a tag, the request fails with ValidationException.

  • curation_policy_ids (Optional[CurationPolicyIdentifierList], default: None ) –

    Curation policies to associate with the new agent context, as IDs or ARNs, instead of the default curation policies. If you omit it or the list is empty, AWS Context associates the default curation policies. Each policy must be ACTIVE and owned by your account, and you need context:AssociateCurationPolicy permission on each. AWS Context checks both again on a clientToken retry. If a policy doesn't exist, the request fails with ResourceNotFoundException. If one has been deleted, it fails with ConflictException. Change the policies later with AssociateCurationPolicy and DisassociateCurationPolicy.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.

  • InternalServerException –

    The request failed because of an internal error. Retry the request.

  • ThrottlingException –

    The request was denied because it exceeded a request rate quota. Wait, then retry the request.

  • ValidationException –

    The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.

  • ConflictException –

    The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.

  • ResourceNotFoundException –

    The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.

  • ServiceQuotaExceededException –

    The request would exceed a service quota. Check the quota that quotaCode names, reduce your usage, and then retry the request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Create an agent context The following example creates an agent context over one AWS Glue Data Catalog connection, scoped to the sales database and mapped to the AWS managed Data ontology.

>>> client.create_agent_context(client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE11111', name='sales-analytics', description='Sales pipeline and revenue tables for the analytics agents.', connection_mappings=[{'connectionId': 'conn-7b1e4d9a2c6f4b08a3e5d1c9f2a6b4e7', 'ontologyMappings': [{'ontologyId': 'arn:aws:context:us-east-1::ontology/data'}], 'pathSegments': [{'level': 'glueDatabase', 'id': 'sales'}]}], tags={'team': 'sales-analytics'})
Source code in docs_src/capo_context/_services/context.py
def create_agent_context(
    self,
    connection_mappings: "capo_context.types.connection_mapping_list.ConnectionMappingList",
    *,
    config_overrides: Optional[ContextClientConfig] = None,
    client_token: Optional["capo_context.types.client_token.ClientToken"] = None,
    name: Optional["capo_context.types.resource_name.ResourceName"] = None,
    description: Optional[
        "capo_context.types.user_defined_string.UserDefinedString"
    ] = None,
    trace_analysis_config: Optional[
        "capo_context.types.trace_analysis_config.TraceAnalysisConfig"
    ] = None,
    workforce_sign_in_config: Optional[
        "capo_context.types.workforce_sign_in_config.WorkforceSignInConfig"
    ] = None,
    entity_resolution_config: Optional[
        "capo_context.types.entity_resolution_config.EntityResolutionConfig"
    ] = None,
    trusted_identity_sources: Optional[
        "capo_context.types.trusted_identity_source_list.TrustedIdentitySourceList"
    ] = None,
    tags: Optional["capo_context.types.tag_map.TagMap"] = None,
    curation_policy_ids: Optional[
        "capo_context.types.curation_policy_identifier_list.CurationPolicyIdentifierList"
    ] = None,
) -> "capo_context.types.create_agent_context_response.CreateAgentContextResponse":
    """<p>Creates an agent context over one or more connections. Creation is asynchronous. GetAgentContext returns its status.</p>

    Args:
        client_token: <p>Client idempotency token. The AWS SDKs generate one when it is absent. An identical request with the same token returns the existing agent context. The same token with a different request returns ValidationException. <code>trustedIdentitySources</code> with the same entries in another order is the same request.</p>
        name: <p>Optional. The name of the agent context. If you omit it, the name is <code>default</code>. You can change it later with UpdateAgentContext.</p>
        description: <p>Optional human-readable description of the agent context. An empty string is the same as none.</p>
        connection_mappings: <p>The connection mappings for this agent context, up to 20. CreateAgentContext requires at least one: an empty list returns <code>ValidationException</code>. Each entry binds a connection to one or more ontologies, optionally scoped by a data filter, extraction depth, and path segments. Each referenced connection must exist, be owned by your account, and be <code>ACTIVE</code>. Order is significant. When several connections reach the same AWS Glue Data Catalog table, AWS Context tries the connection mapped first, with its own access, and then the next.</p>
        trace_analysis_config: <p>The agent context's trace analysis settings. Optional. You can change it with UpdateAgentContext.</p>
        workforce_sign_in_config: <p>Optional workforce sign-in settings. A config with <code>signInUrl</code> turns sign-in on (<code>status</code> defaults to ENABLED). <code>status</code> ENABLED without <code>signInUrl</code> is a ValidationException. You can change it with UpdateAgentContext.</p>
        entity_resolution_config: <p>Optional entity resolution settings. When the config or its <code>status</code> is absent, <code>status</code> reads ENABLED. You can change it with UpdateAgentContext.</p>
        trusted_identity_sources: <p>Optional identity sources to trust in addition to your account. At most 100 unique entries, each with exactly one member. Order is not significant. An empty list and an absent member are the same value: only your account is trusted. You can change it with UpdateAgentContext.</p>
        tags: <p>Tags to add to the agent context when you create it: up to 200 in the request, of which at most 50 can be user tags. Keys can't start with <code>aws:</code>. To add tags, you also need <code>context:TagResource</code> permission on the new agent context. If you specify more than 50 user tags, the request fails with <code>ServiceQuotaExceededException</code>, as on TagResource. If an AWS Organizations tag policy refuses a tag, the request fails with <code>ValidationException</code>.</p>
        curation_policy_ids: <p>Curation policies to associate with the new agent context, as IDs or ARNs, instead of the default curation policies. If you omit it or the list is empty, AWS Context associates the default curation policies. Each policy must be <code>ACTIVE</code> and owned by your account, and you need <code>context:AssociateCurationPolicy</code> permission on each. AWS Context checks both again on a <code>clientToken</code> retry. If a policy doesn't exist, the request fails with <code>ResourceNotFoundException</code>. If one has been deleted, it fails with <code>ConflictException</code>. Change the policies later with AssociateCurationPolicy and DisassociateCurationPolicy.</p>

    Raises:
        capo_context.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.</p>
        capo_context.errors.internal_server_exception.InternalServerException: <p>The request failed because of an internal error. Retry the request.</p>
        capo_context.errors.throttling_exception.ThrottlingException: <p>The request was denied because it exceeded a request rate quota. Wait, then retry the request.</p>
        capo_context.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.</p>
        capo_context.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.</p>
        capo_context.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.</p>
        capo_context.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a service quota. Check the quota that <code>quotaCode</code> names, reduce your usage, and then retry the request.</p>
        capo_context.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Create an agent context
        The following example creates an agent context over one AWS Glue Data Catalog connection, scoped to the sales database and mapped to the AWS managed Data ontology.

        >>> client.create_agent_context(client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE11111', name='sales-analytics', description='Sales pipeline and revenue tables for the analytics agents.', connection_mappings=[{'connectionId': 'conn-7b1e4d9a2c6f4b08a3e5d1c9f2a6b4e7', 'ontologyMappings': [{'ontologyId': 'arn:aws:context:us-east-1::ontology/data'}], 'pathSegments': [{'level': 'glueDatabase', 'id': 'sales'}]}], tags={'team': 'sales-analytics'})
    """

    def _handler(
        req: "OperationRequest[capo_context.types.create_agent_context_request.CreateAgentContextRequest]",
    ) -> OperationResponse[
        "capo_context.types.create_agent_context_response.CreateAgentContextResponse"
    ]:
        import capo_context._operations.context.create_agent_context

        output, http_response = (
            capo_context._operations.context.create_agent_context.create_agent_context(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAgentContext")
    )
    input_: capo_context.types.create_agent_context_request.CreateAgentContextRequest = {
        "connection_mappings": connection_mappings
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if trace_analysis_config is not None:
        input_["trace_analysis_config"] = trace_analysis_config
    if workforce_sign_in_config is not None:
        input_["workforce_sign_in_config"] = workforce_sign_in_config
    if entity_resolution_config is not None:
        input_["entity_resolution_config"] = entity_resolution_config
    if trusted_identity_sources is not None:
        input_["trusted_identity_sources"] = trusted_identity_sources
    if tags is not None:
        input_["tags"] = tags
    if curation_policy_ids is not None:
        input_["curation_policy_ids"] = curation_policy_ids

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output