Skip to content

list_instances

list_instances(
    service_id: Arn,
    *,
    config_overrides: Optional[ServiceDiscoveryClientConfig] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
) -> ListInstancesResponse

Lists summary information about the instances that you registered by using a specified service.

Parameters:

  • service_id (Arn) –

    The ID or Amazon Resource Name (ARN) of the service that you want to list instances for. For services created in a shared namespace, specify the service ARN. For more information about shared namespaces, see Cross-account Cloud Map namespace sharing in the Cloud Map Developer Guide.

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

    For the first ListInstances request, omit this value.

    If more than MaxResults instances match the specified criteria, you can submit another ListInstances request to get the next group of results. Specify the value of NextToken from the previous response in the next request.

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

    The maximum number of instances that you want Cloud Map to return in the response to a ListInstances request. If you don't specify a value for MaxResults, Cloud Map returns up to 100 instances.

Raises:

  • InvalidInput –

    One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.

  • ServiceNotFound –

    No service exists with the specified ID.

  • UnknownServiceError –

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

Examples:

Example: List service instances Example: List service instances

>>> client.list_instances(service_id='srv-qzpwvt2tfqcegapy')
List instances using service ARN for shared namespace
This example lists instances using a service ARN instead of service ID. This is useful for listing instances associated with shared namespaces.
>>> client.list_instances(service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-e4anhexample0004')
Source code in docs_src/capo_servicediscovery/_services/service_discovery.py
def list_instances(
    self,
    service_id: "capo_servicediscovery.types.arn.Arn",
    *,
    config_overrides: Optional[ServiceDiscoveryClientConfig] = None,
    next_token: Optional["capo_servicediscovery.types.next_token.NextToken"] = None,
    max_results: Optional[
        "capo_servicediscovery.types.max_results.MaxResults"
    ] = None,
) -> "capo_servicediscovery.types.list_instances_response.ListInstancesResponse":
    """<p>Lists summary information about the instances that you registered by using a specified service.</p>

    Args:
        service_id: <p>The ID or Amazon Resource Name (ARN) of the service that you want to list instances for. For services created in a shared namespace, specify the service ARN. For more information about shared namespaces, see <a href="https://docs.aws.amazon.com/cloud-map/latest/dg/sharing-namespaces.html">Cross-account Cloud Map namespace sharing</a> in the <i>Cloud Map Developer Guide</i>.</p>
        next_token: <p>For the first <code>ListInstances</code> request, omit this value.</p> <p>If more than <code>MaxResults</code> instances match the specified criteria, you can submit another <code>ListInstances</code> request to get the next group of results. Specify the value of <code>NextToken</code> from the previous response in the next request.</p>
        max_results: <p>The maximum number of instances that you want Cloud Map to return in the response to a <code>ListInstances</code> request. If you don't specify a value for <code>MaxResults</code>, Cloud Map returns up to 100 instances.</p>

    Raises:
        capo_servicediscovery.errors.invalid_input.InvalidInput: <p>One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.</p>
        capo_servicediscovery.errors.service_not_found.ServiceNotFound: <p>No service exists with the specified ID.</p>
        capo_servicediscovery.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Example: List service instances
        Example: List service instances

        >>> client.list_instances(service_id='srv-qzpwvt2tfqcegapy')
        List instances using service ARN for shared namespace
        This example lists instances using a service ARN instead of service ID. This is useful for listing instances associated with shared namespaces.

        >>> client.list_instances(service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-e4anhexample0004')
    """

    def _handler(
        req: "OperationRequest[capo_servicediscovery.types.list_instances_request.ListInstancesRequest]",
    ) -> OperationResponse[
        "capo_servicediscovery.types.list_instances_response.ListInstancesResponse"
    ]:
        import capo_servicediscovery._operations.route53_auto_naming_v20170314.list_instances

        output, http_response = (
            capo_servicediscovery._operations.route53_auto_naming_v20170314.list_instances.list_instances(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListInstances")
    )
    input_: capo_servicediscovery.types.list_instances_request.ListInstancesRequest = {
        "service_id": service_id
    }
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output