Skip to content

start_task async

start_task(
    agent_context_id: AgentContextIdentifier,
    input_configuration: TaskInputConfiguration,
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    description: Optional[TaskDescription] = None,
    access_control_config: Optional[AccessControlConfig] = None,
) -> StartTaskResponse

Starts a task that imports a data dictionary, verified queries, or ontologies into an agent context. The task runs asynchronously and records the changes it makes as change sets. GetTask returns its status.

Parameters:

  • agent_context_id (AgentContextIdentifier) –

    The agent context, as an ID or ARN.

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

    A unique, case-sensitive identifier that you provide to ensure that the request completes no more than one time. The token is scoped to your account and the agent context. If you reuse a token on the same agent context with different parameters, the request fails with ValidationException.

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

    A description of the task. Up to 1,024 characters, with no control characters.

  • input_configuration (TaskInputConfiguration) –

    What the task imports. Set exactly one member. The member that you set determines the task's type.

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

    Who can see the content that the task adds to the agent context. AWS Context supports only one entry: ALLOW with principalId *, so that every reader of the agent context can see it. If you omit it or send no entries, AWS Context uses that entry. If you name any other principal, include a DENY entry, or send more than one entry, the request fails with ValidationException, and no task is started.

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:

Import a data dictionary into an agent context The following example starts a task that imports a CSV data dictionary that describes the columns of a sales table.

>>> await client.start_task(agent_context_id='ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53', client_token='3c8f1a2e-6b4d-4f9a-8e2c-1d7b5a9f0e64', description='Import the sales data dictionary', input_configuration={'importDataDictionary': {'documents': [{'name': 'sales-columns.csv', 'contentType': 'CSV', 'content': 'Y29sdW1uLHRhYmxlLGRlc2NyaXB0aW9uCm9yZGVyX3RvdGFsLHNhbGVzLm9yZGVycyxPcmRlciBhbW91bnQgaW4gVVNEIGFmdGVyIGRpc2NvdW50cwpyZWdpb25fY29kZSxzYWxlcy5vcmRlcnMsVHdvLWxldHRlciBzYWxlcyByZWdpb24gY29kZQo='}]}})
Import an ontology into an agent context
The following example starts a task that imports version 1.2.0 of an ontology into an agent context.
>>> await client.start_task(agent_context_id='ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53', input_configuration={'importOntology': {'ontologies': [{'ontologyId': 'ont-5b8e1f4a9c2d4e7fb3a6c0d9e8f1a274', 'ontologyVersion': '1.2.0'}]}}, access_control_config={'accessControlList': [{'access': 'ALLOW', 'principalId': '*'}]})
Source code in docs_src/capo_context/_services/async_context.py
async def start_task(
    self,
    agent_context_id: "capo_context.types.agent_context_identifier.AgentContextIdentifier",
    input_configuration: "capo_context.types.task_input_configuration.TaskInputConfiguration",
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    client_token: Optional["capo_context.types.client_token.ClientToken"] = None,
    description: Optional[
        "capo_context.types.task_description.TaskDescription"
    ] = None,
    access_control_config: Optional[
        "capo_context.types.access_control_config.AccessControlConfig"
    ] = None,
) -> "capo_context.types.start_task_response.StartTaskResponse":
    """<p>Starts a task that imports a data dictionary, verified queries, or ontologies into an agent context. The task runs asynchronously and records the changes it makes as change sets. GetTask returns its status.</p>

    Args:
        agent_context_id: <p>The agent context, as an ID or ARN.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure that the request completes no more than one time. The token is scoped to your account and the agent context. If you reuse a token on the same agent context with different parameters, the request fails with <code>ValidationException</code>.</p>
        description: <p>A description of the task. Up to 1,024 characters, with no control characters.</p>
        input_configuration: <p>What the task imports. Set exactly one member. The member that you set determines the task's <code>type</code>.</p>
        access_control_config: <p>Who can see the content that the task adds to the agent context. AWS Context supports only one entry: <code>ALLOW</code> with <code>principalId</code> <code>*</code>, so that every reader of the agent context can see it. If you omit it or send no entries, AWS Context uses that entry. If you name any other principal, include a <code>DENY</code> entry, or send more than one entry, the request fails with <code>ValidationException</code>, and no task is started.</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:
        Import a data dictionary into an agent context
        The following example starts a task that imports a CSV data dictionary that describes the columns of a sales table.

        >>> await client.start_task(agent_context_id='ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53', client_token='3c8f1a2e-6b4d-4f9a-8e2c-1d7b5a9f0e64', description='Import the sales data dictionary', input_configuration={'importDataDictionary': {'documents': [{'name': 'sales-columns.csv', 'contentType': 'CSV', 'content': 'Y29sdW1uLHRhYmxlLGRlc2NyaXB0aW9uCm9yZGVyX3RvdGFsLHNhbGVzLm9yZGVycyxPcmRlciBhbW91bnQgaW4gVVNEIGFmdGVyIGRpc2NvdW50cwpyZWdpb25fY29kZSxzYWxlcy5vcmRlcnMsVHdvLWxldHRlciBzYWxlcyByZWdpb24gY29kZQo='}]}})
        Import an ontology into an agent context
        The following example starts a task that imports version 1.2.0 of an ontology into an agent context.

        >>> await client.start_task(agent_context_id='ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53', input_configuration={'importOntology': {'ontologies': [{'ontologyId': 'ont-5b8e1f4a9c2d4e7fb3a6c0d9e8f1a274', 'ontologyVersion': '1.2.0'}]}}, access_control_config={'accessControlList': [{'access': 'ALLOW', 'principalId': '*'}]})
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_context.types.start_task_request.StartTaskRequest]",
    ) -> AsyncOperationResponse[
        "capo_context.types.start_task_response.StartTaskResponse"
    ]:
        import capo_context._operations.context.start_task

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

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

        return capo_context.types.start_task_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_context.types.start_task_response.StartTaskResponse",
    ) -> dict[str, Any]:
        import capo_context.types.start_task_response

        return capo_context.types.start_task_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "StartTask", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_context.types.start_task_request.StartTaskRequest = {
        "agent_context_id": agent_context_id,
        "input_configuration": input_configuration,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    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