Skip to content

list_clusters async

list_clusters(
    *,
    config_overrides: Optional[AsyncEKSClientConfig] = None,
    max_results: Optional[ListClustersRequestMaxResults] = None,
    next_token: Optional[String] = None,
    include: Optional[IncludeClustersList] = None,
) -> ListClustersResponse

Lists the Amazon EKS clusters in your Amazon Web Services account in the specified Amazon Web Services Region.

Parameters:

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

    The maximum number of results, returned in paginated output. You receive maxResults in a single page, along with a nextToken response element. You can see the remaining results of the initial request by sending another request with the returned nextToken value. This value can be between 1 and 100. If you don't use this parameter, 100 results and a nextToken value, if applicable, are returned.

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

    The nextToken value returned from a previous paginated request, where maxResults was used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the nextToken value. This value is null when there are no more results to return.

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

  • include (Optional[IncludeClustersList], default: None ) –

    Indicates whether external clusters are included in the returned list. Use 'all' to return https://docs.aws.amazon.com/eks/latest/userguide/eks-connector.htmlconnected clusters, or blank to return only Amazon EKS clusters. 'all' must be in lowercase otherwise an error occurs.

Raises:

  • ClientException –

    These errors are usually caused by a client action. Actions can include using an action or resource on behalf of an IAM principal that doesn't have permissions to use the action or resource or specifying an identifier that is not valid.

  • InvalidParameterException –

    The specified parameter is invalid. Review the available parameters for the API request.

  • ServerException –

    These errors are usually caused by a server-side issue.

  • ServiceUnavailableException –

    The service is unavailable. Back off and retry the operation.

  • UnknownServiceError –

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

Examples:

To list your available clusters This example command lists all of your available clusters in your default region.

>>> await client.list_clusters()
Source code in docs_src/capo_eks/_services/async_eks.py
async def list_clusters(
    self,
    *,
    config_overrides: Optional[AsyncEKSClientConfig] = None,
    max_results: Optional[
        "capo_eks.types.list_clusters_request_max_results.ListClustersRequestMaxResults"
    ] = None,
    next_token: Optional["capo_eks.types.string.String"] = None,
    include: Optional[
        "capo_eks.types.include_clusters_list.IncludeClustersList"
    ] = None,
) -> "capo_eks.types.list_clusters_response.ListClustersResponse":
    """<p>Lists the Amazon EKS clusters in your Amazon Web Services account in the specified Amazon Web Services Region.</p>

    Args:
        max_results: <p>The maximum number of results, returned in paginated output. You receive <code>maxResults</code> in a single page, along with a <code>nextToken</code> response element. You can see the remaining results of the initial request by sending another request with the returned <code>nextToken</code> value. This value can be between 1 and 100. If you don't use this parameter, 100 results and a <code>nextToken</code> value, if applicable, are returned.</p>
        next_token: <p>The <code>nextToken</code> value returned from a previous paginated request, where <code>maxResults</code> was used and the results exceeded the value of that parameter. Pagination continues from the end of the previous results that returned the <code>nextToken</code> value. This value is null when there are no more results to return.</p> <note> <p>This token should be treated as an opaque identifier that is used only to retrieve the next items in a list and not for other programmatic purposes.</p> </note>
        include: <p>Indicates whether external clusters are included in the returned list. Use '<code>all</code>' to return <a href="https://docs.aws.amazon.com/eks/latest/userguide/eks-connector.html">https://docs.aws.amazon.com/eks/latest/userguide/eks-connector.html</a>connected clusters, or blank to return only Amazon EKS clusters. '<code>all</code>' must be in lowercase otherwise an error occurs.</p>

    Raises:
        capo_eks.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. Actions can include using an action or resource on behalf of an <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html">IAM principal</a> that doesn't have permissions to use the action or resource or specifying an identifier that is not valid.</p>
        capo_eks.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter is invalid. Review the available parameters for the API request.</p>
        capo_eks.errors.server_exception.ServerException: <p>These errors are usually caused by a server-side issue.</p>
        capo_eks.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is unavailable. Back off and retry the operation.</p>
        capo_eks.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list your available clusters
        This example command lists all of your available clusters in your default region.

        >>> await client.list_clusters()
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_eks.types.list_clusters_request.ListClustersRequest]",
    ) -> AsyncOperationResponse[
        "capo_eks.types.list_clusters_response.ListClustersResponse"
    ]:
        import capo_eks._operations.aws_wesley_frontend.list_clusters

        (
            output,
            http_response,
        ) = await capo_eks._operations.aws_wesley_frontend.list_clusters.async_list_clusters(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListClusters")
    )
    input_: capo_eks.types.list_clusters_request.ListClustersRequest = {}
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if include is not None:
        input_["include"] = include

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