Skip to content

list_tasks async

list_tasks(
    agent_context_id: AgentContextIdentifier,
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    status: Optional[TaskStatus] = None,
    type: Optional[TaskType] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[PaginationToken] = None,
) -> ListTasksResponse

Lists an agent context's tasks, newest first.

Parameters:

  • agent_context_id (AgentContextIdentifier) –

    The agent context, as an ID or ARN.

  • status (Optional[TaskStatus], default: None ) –

    Specify a status to list only the tasks with that status.

  • type (Optional[TaskType], default: None ) –

    Specify a type to list only the tasks of that type.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of tasks to return in one page, from 1–100. The service can return fewer. Defaults to 20. A value outside 1–100 fails with ValidationException.

  • next_token (Optional[PaginationToken], default: None ) –

    The pagination token from a previous ListTasks response. Omit it for the first page, and keep the status and type filters the same on every page.

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.

  • ResourceNotFoundException –

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

  • UnknownServiceError –

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

Examples:

List the tasks of an agent context The following example lists the tasks of an agent context, newest first.

>>> await client.list_tasks(agent_context_id='ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53', max_results=10)
Source code in docs_src/capo_context/_services/async_context.py
async def list_tasks(
    self,
    agent_context_id: "capo_context.types.agent_context_identifier.AgentContextIdentifier",
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    status: Optional["capo_context.types.task_status.TaskStatus"] = None,
    type: Optional["capo_context.types.task_type.TaskType"] = None,
    max_results: Optional["capo_context.types.max_results.MaxResults"] = None,
    next_token: Optional[
        "capo_context.types.pagination_token.PaginationToken"
    ] = None,
) -> "capo_context.types.list_tasks_response.ListTasksResponse":
    """<p>Lists an agent context's tasks, newest first.</p>

    Args:
        agent_context_id: <p>The agent context, as an ID or ARN.</p>
        status: <p>Specify a status to list only the tasks with that status.</p>
        type: <p>Specify a type to list only the tasks of that type.</p>
        max_results: <p>The maximum number of tasks to return in one page, from 1–100. The service can return fewer. Defaults to 20. A value outside 1–100 fails with <code>ValidationException</code>.</p>
        next_token: <p>The pagination token from a previous ListTasks response. Omit it for the first page, and keep the <code>status</code> and <code>type</code> filters the same on every page.</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.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.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        List the tasks of an agent context
        The following example lists the tasks of an agent context, newest first.

        >>> await client.list_tasks(agent_context_id='ac-3f9c2e7a1b8d4c56a0e4f7b29d1c8e53', max_results=10)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_context.types.list_tasks_request.ListTasksRequest]",
    ) -> AsyncOperationResponse[
        "capo_context.types.list_tasks_response.ListTasksResponse"
    ]:
        import capo_context._operations.context.list_tasks

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

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

        return capo_context.types.list_tasks_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListTasks", redact_output=_redact_output),
    )
    input_: capo_context.types.list_tasks_request.ListTasksRequest = {
        "agent_context_id": agent_context_id
    }
    if status is not None:
        input_["status"] = status
    if type is not None:
        input_["type"] = type
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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