listInstances method

Future<ListInstancesResponse> listInstances({
  1. required String serviceId,
  2. int? maxResults,
  3. String? nextToken,
})

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

May throw ServiceNotFound. May throw InvalidInput.

Parameter serviceId : The ID of the service that you want to list instances for.

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

Parameter nextToken : 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.

Implementation

Future<ListInstancesResponse> listInstances({
  required String serviceId,
  int? maxResults,
  String? nextToken,
}) async {
  ArgumentError.checkNotNull(serviceId, 'serviceId');
  _s.validateStringLength(
    'serviceId',
    serviceId,
    0,
    64,
    isRequired: true,
  );
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    100,
  );
  _s.validateStringLength(
    'nextToken',
    nextToken,
    0,
    4096,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Route53AutoNaming_v20170314.ListInstances'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ServiceId': serviceId,
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return ListInstancesResponse.fromJson(jsonResponse.body);
}