Skip to content

list_services async

list_services(
    *,
    config_overrides: Optional[AsyncECSClientConfig] = None,
    cluster: Optional[String] = None,
    next_token: Optional[String] = None,
    max_results: Optional[BoxedInteger] = None,
    launch_type: Optional[LaunchType] = None,
    scheduling_strategy: Optional[SchedulingStrategy] = None,
    resource_management_type: Optional[ResourceManagementType] = None,
) -> ListServicesResponse

Returns a list of services. You can filter the results by cluster, launch type, and scheduling strategy.

Parameters:

  • cluster (Optional[String], default: None ) –

    The short name or full Amazon Resource Name (ARN) of the cluster to use when filtering the ListServices results. If you do not specify a cluster, the default cluster is assumed.

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

    The nextToken value returned from a ListServices request indicating that more results are available to fulfill the request and further calls will be needed. If maxResults was provided, it is possible the number of results to be fewer than maxResults.

    This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.

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

    The maximum number of service results that ListServices returned in paginated output. When this parameter is used, ListServices only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListServices request with the returned nextToken value. This value can be between 1 and 100. If this parameter isn't used, then ListServices returns up to 10 results and a nextToken value if applicable.

  • launch_type (Optional[LaunchType], default: None ) –

    The launch type to use when filtering the ListServices results.

  • scheduling_strategy (Optional[SchedulingStrategy], default: None ) –

    The scheduling strategy to use when filtering the ListServices results.

  • resource_management_type (Optional[ResourceManagementType], default: None ) –

    The resourceManagementType type to use when filtering the ListServices results.

Raises:

  • AccessDeniedException –

    You don't have authorization to perform the requested action.

  • ClientException –

    These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.

  • ClusterNotFoundException –

    The specified cluster wasn't found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region specific.

  • InvalidParameterException –

    The specified parameter isn't valid. Review the available parameters for the API request.

    For more information about service event errors, see Amazon ECS service event messages.

  • ServerException –

    These errors are usually caused by a server issue.

  • UnknownServiceError –

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

Examples:

To list the services in a cluster This example lists the services running in the default cluster for an account.

>>> await client.list_services()
Source code in docs_src/capo_ecs/_services/async_ecs.py
async def list_services(
    self,
    *,
    config_overrides: Optional[AsyncECSClientConfig] = None,
    cluster: Optional["capo_ecs.types.string.String"] = None,
    next_token: Optional["capo_ecs.types.string.String"] = None,
    max_results: Optional["capo_ecs.types.boxed_integer.BoxedInteger"] = None,
    launch_type: Optional["capo_ecs.types.launch_type.LaunchType"] = None,
    scheduling_strategy: Optional[
        "capo_ecs.types.scheduling_strategy.SchedulingStrategy"
    ] = None,
    resource_management_type: Optional[
        "capo_ecs.types.resource_management_type.ResourceManagementType"
    ] = None,
) -> "capo_ecs.types.list_services_response.ListServicesResponse":
    """<p>Returns a list of services. You can filter the results by cluster, launch type, and scheduling strategy.</p>

    Args:
        cluster: <p>The short name or full Amazon Resource Name (ARN) of the cluster to use when filtering the <code>ListServices</code> results. If you do not specify a cluster, the default cluster is assumed.</p>
        next_token: <p>The <code>nextToken</code> value returned from a <code>ListServices</code> request indicating that more results are available to fulfill the request and further calls will be needed. If <code>maxResults</code> was provided, it is possible the number of results to be fewer than <code>maxResults</code>.</p> <note> <p>This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.</p> </note>
        max_results: <p>The maximum number of service results that <code>ListServices</code> returned in paginated output. When this parameter is used, <code>ListServices</code> only returns <code>maxResults</code> results in a single page along with a <code>nextToken</code> response element. The remaining results of the initial request can be seen by sending another <code>ListServices</code> request with the returned <code>nextToken</code> value. This value can be between 1 and 100. If this parameter isn't used, then <code>ListServices</code> returns up to 10 results and a <code>nextToken</code> value if applicable.</p>
        launch_type: <p>The launch type to use when filtering the <code>ListServices</code> results.</p>
        scheduling_strategy: <p>The scheduling strategy to use when filtering the <code>ListServices</code> results.</p>
        resource_management_type: <p>The resourceManagementType type to use when filtering the <code>ListServices</code> results.</p>

    Raises:
        capo_ecs.errors.access_denied_exception.AccessDeniedException: <p>You don't have authorization to perform the requested action.</p>
        capo_ecs.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.</p>
        capo_ecs.errors.cluster_not_found_exception.ClusterNotFoundException: <p>The specified cluster wasn't found. You can view your available clusters with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListClusters.html">ListClusters</a>. Amazon ECS clusters are Region specific.</p>
        capo_ecs.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter isn't valid. Review the available parameters for the API request.</p> <p>For more information about service event errors, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages-list.html">Amazon ECS service event messages</a>. </p>
        capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list the services in a cluster
        This example lists the services running in the default cluster for an account.

        >>> await client.list_services()
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ecs.types.list_services_request.ListServicesRequest]",
    ) -> AsyncOperationResponse[
        "capo_ecs.types.list_services_response.ListServicesResponse"
    ]:
        import capo_ecs._operations.amazon_ec2_container_service_v20141113.list_services

        (
            output,
            http_response,
        ) = await capo_ecs._operations.amazon_ec2_container_service_v20141113.list_services.async_list_services(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListServices")
    )
    input_: capo_ecs.types.list_services_request.ListServicesRequest = {}
    if cluster is not None:
        input_["cluster"] = cluster
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if launch_type is not None:
        input_["launch_type"] = launch_type
    if scheduling_strategy is not None:
        input_["scheduling_strategy"] = scheduling_strategy
    if resource_management_type is not None:
        input_["resource_management_type"] = resource_management_type

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