Skip to content

create_change_set async

create_change_set(
    agent_context_id: AgentContextIdentifier,
    operations: ChangeSetOperationList,
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    access_control_config: Optional[AccessControlConfig] = None,
) -> CreateChangeSetResponse

Proposes a change to an agent context, as ChangeSetOperation items (the same items that ListChangeSetOperations returns), each setting one of put, update, or delete.

Parameters:

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

    A unique, case-sensitive identifier that you provide to make the request idempotent. A retry with the same token returns the same change set.

  • access_control_config (Optional[AccessControlConfig], default: None ) –

    Who can read the nodes that this change set writes. AWS Context refuses it on a change set that only deletes. If you omit it, every reader of the agent context can read a node that the change creates, and every other node keeps its access control. If you specify it, it replaces the access control of every node that the change set writes, and an absent or empty accessControlList lets nobody read them.

  • agent_context_id (AgentContextIdentifier) –

    The agent context to change, by its ID or ARN.

  • operations (ChangeSetOperationList) –

    The operations to write, each a ChangeSetOperation, from 1 to 1,000. If the list is empty or names the same entity twice, the request fails with ValidationException.

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 or replace the retrieval instructions The following example creates or replaces the retrieval instructions of an agent context with one update operation on the fixed instructions node. No curation policy holds direct changes, so AWS Context applies the change set right away.

>>> await client.create_change_set(agent_context_id='ac-4f2a9c1e7b3d4a6f8e0c2b5d7a9f1e3c', client_token='3d5f7a9c-1e2b-4d6f-8a0c-4e6b8d0f2a5c', operations=[{'update': {'entity': {'nodeId': 'https://ontology.context.aws.dev/retrievalInstruction:default'}, 'properties': {'nodeType': {'stringValue': 'AWS::CONTEXT::RETRIEVAL_INSTRUCTION'}, 'retrievalInstructionId': {'stringValue': 'default'}, 'retrievalInstructionText': {'stringValue': '# Rules for every query\n- If two sources disagree, use the most recent one.'}}}}])
Create a relationship in a change set that only one group can read
The following example adds a relationship between two existing concepts. Because the request specifies accessControlConfig, only members of the group can read the change set's operations, and the change set is ACL_RESTRICTED. The relationship itself is visible to anyone who can read both concepts. AWS Context applies the change set right away because no curation policy holds it.
>>> await client.create_change_set(agent_context_id='ac-4f2a9c1e7b3d4a6f8e0c2b5d7a9f1e3c', client_token='6f8b0d2a-4c6e-4a8b-9d1f-5b7d9f1a3c6e', access_control_config={'accessControlList': [{'access': 'ALLOW', 'principalId': '94a8f4e8-60d1-70a4-b2c3-1f5e9d7c3a20', 'principalType': 'GROUP'}]}, operations=[{'put': {'entity': {'edgeId': {'from': 'concept:forecast-margin', 'to': 'concept:gross-margin'}}, 'properties': {'edgeType': {'stringValue': 'AWS::CONTEXT::RELATED_TO'}}}}])
Source code in docs_src/capo_context/_services/async_context.py
async def create_change_set(
    self,
    agent_context_id: "capo_context.types.agent_context_identifier.AgentContextIdentifier",
    operations: "capo_context.types.change_set_operation_list.ChangeSetOperationList",
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    client_token: Optional["capo_context.types.client_token.ClientToken"] = None,
    access_control_config: Optional[
        "capo_context.types.access_control_config.AccessControlConfig"
    ] = None,
) -> "capo_context.types.create_change_set_response.CreateChangeSetResponse":
    r"""<p>Proposes a change to an agent context, as ChangeSetOperation items (the same items that ListChangeSetOperations returns), each setting one of <code>put</code>, <code>update</code>, or <code>delete</code>.</p>

    Args:
        client_token: <p>A unique, case-sensitive identifier that you provide to make the request idempotent. A retry with the same token returns the same change set.</p>
        access_control_config: <p>Who can read the nodes that this change set writes. AWS Context refuses it on a change set that only deletes. If you omit it, every reader of the agent context can read a node that the change creates, and every other node keeps its access control. If you specify it, it replaces the access control of every node that the change set writes, and an absent or empty <code>accessControlList</code> lets nobody read them.</p>
        agent_context_id: <p>The agent context to change, by its ID or ARN.</p>
        operations: <p>The operations to write, each a <code>ChangeSetOperation</code>, from 1 to 1,000. If the list is empty or names the same entity twice, the request fails with <code>ValidationException</code>.</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 or replace the retrieval instructions
        The following example creates or replaces the retrieval instructions of an agent context with one update operation on the fixed instructions node. No curation policy holds direct changes, so AWS Context applies the change set right away.

        >>> await client.create_change_set(agent_context_id='ac-4f2a9c1e7b3d4a6f8e0c2b5d7a9f1e3c', client_token='3d5f7a9c-1e2b-4d6f-8a0c-4e6b8d0f2a5c', operations=[{'update': {'entity': {'nodeId': 'https://ontology.context.aws.dev/retrievalInstruction:default'}, 'properties': {'nodeType': {'stringValue': 'AWS::CONTEXT::RETRIEVAL_INSTRUCTION'}, 'retrievalInstructionId': {'stringValue': 'default'}, 'retrievalInstructionText': {'stringValue': '# Rules for every query\n- If two sources disagree, use the most recent one.'}}}}])
        Create a relationship in a change set that only one group can read
        The following example adds a relationship between two existing concepts. Because the request specifies accessControlConfig, only members of the group can read the change set's operations, and the change set is ACL_RESTRICTED. The relationship itself is visible to anyone who can read both concepts. AWS Context applies the change set right away because no curation policy holds it.

        >>> await client.create_change_set(agent_context_id='ac-4f2a9c1e7b3d4a6f8e0c2b5d7a9f1e3c', client_token='6f8b0d2a-4c6e-4a8b-9d1f-5b7d9f1a3c6e', access_control_config={'accessControlList': [{'access': 'ALLOW', 'principalId': '94a8f4e8-60d1-70a4-b2c3-1f5e9d7c3a20', 'principalType': 'GROUP'}]}, operations=[{'put': {'entity': {'edgeId': {'from': 'concept:forecast-margin', 'to': 'concept:gross-margin'}}, 'properties': {'edgeType': {'stringValue': 'AWS::CONTEXT::RELATED_TO'}}}}])
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_context.types.create_change_set_request.CreateChangeSetRequest]",
    ) -> AsyncOperationResponse[
        "capo_context.types.create_change_set_response.CreateChangeSetResponse"
    ]:
        import capo_context._operations.context.create_change_set

        (
            output,
            http_response,
        ) = await capo_context._operations.context.create_change_set.async_create_change_set(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_context.types.create_change_set_request.CreateChangeSetRequest",
    ) -> dict[str, Any]:
        import capo_context.types.create_change_set_request

        return capo_context.types.create_change_set_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateChangeSet", redact_input=_redact_input),
    )
    input_: capo_context.types.create_change_set_request.CreateChangeSetRequest = {
        "agent_context_id": agent_context_id,
        "operations": operations,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if access_control_config is not None:
        input_["access_control_config"] = access_control_config

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output