Skip to content

list_agents async

list_agents(
    *,
    config_overrides: Optional[AsyncDataSyncClientConfig] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[NextToken] = None,
) -> ListAgentsResponse

Returns a list of DataSync agents that belong to an Amazon Web Services account in the Amazon Web Services Region specified in the request.

With pagination, you can reduce the number of agents returned in a response. If you get a truncated list of agents in a response, the response contains a marker that you can specify in your next request to fetch the next page of agents.

Parameters:

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

    Specifies the maximum number of DataSync agents to list in a response. By default, a response shows a maximum of 100 agents.

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

    Specifies an opaque string that indicates the position to begin the next list of results in the response.

Raises:

Source code in docs_src/capo_datasync/_services/async_data_sync.py
async def list_agents(
    self,
    *,
    config_overrides: Optional[AsyncDataSyncClientConfig] = None,
    max_results: Optional["capo_datasync.types.max_results.MaxResults"] = None,
    next_token: Optional["capo_datasync.types.next_token.NextToken"] = None,
) -> "capo_datasync.types.list_agents_response.ListAgentsResponse":
    """<p>Returns a list of DataSync agents that belong to an Amazon Web Services account in the Amazon Web Services Region specified in the request.</p> <p>With pagination, you can reduce the number of agents returned in a response. If you get a truncated list of agents in a response, the response contains a marker that you can specify in your next request to fetch the next page of agents.</p>

    Args:
        max_results: <p>Specifies the maximum number of DataSync agents to list in a response. By default, a response shows a maximum of 100 agents.</p>
        next_token: <p>Specifies an opaque string that indicates the position to begin the next list of results in the response.</p>

    Raises:
        capo_datasync.errors.internal_exception.InternalException: <p>This exception is thrown when an error occurs in the DataSync service.</p>
        capo_datasync.errors.invalid_request_exception.InvalidRequestException: <p>This exception is thrown when the client submits a malformed request.</p>
        capo_datasync.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_datasync.types.list_agents_request.ListAgentsRequest]",
    ) -> AsyncOperationResponse[
        "capo_datasync.types.list_agents_response.ListAgentsResponse"
    ]:
        if req.options.protocol == "awsJson1_1":
            import capo_datasync._operations.fmrs_service.aws_json1_1.list_agents

            (
                output,
                http_response,
            ) = await capo_datasync._operations.fmrs_service.aws_json1_1.list_agents.async_list_agents(
                req.options, req.input
            )
        elif req.options.protocol == "rpcv2Cbor":
            import capo_datasync._operations.fmrs_service.rpcv2_cbor.list_agents

            (
                output,
                http_response,
            ) = await capo_datasync._operations.fmrs_service.rpcv2_cbor.list_agents.async_list_agents(
                req.options, req.input
            )
        else:
            raise ValueError(f"unknown protocol {req.options.protocol!r}")
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListAgents")
    )
    input_: capo_datasync.types.list_agents_request.ListAgentsRequest = {}
    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