getInstancesHealthStatus method

Future<GetInstancesHealthStatusResponse> getInstancesHealthStatus({
  1. required String serviceId,
  2. List<String>? instances,
  3. int? maxResults,
  4. String? nextToken,
})

Gets the current health status (Healthy, Unhealthy, or Unknown) of one or more instances that are associated with a specified service.

May throw InstanceNotFound. May throw InvalidInput. May throw ServiceNotFound.

Parameter serviceId : The ID of the service that the instance is associated with.

Parameter instances : An array that contains the IDs of all the instances that you want to get the health status for.

If you omit Instances, AWS Cloud Map returns the health status for all the instances that are associated with the specified service.

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

Parameter nextToken : For the first GetInstancesHealthStatus request, omit this value.

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

Implementation

Future<GetInstancesHealthStatusResponse> getInstancesHealthStatus({
  required String serviceId,
  List<String>? instances,
  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.GetInstancesHealthStatus'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ServiceId': serviceId,
      if (instances != null) 'Instances': instances,
      if (maxResults != null) 'MaxResults': maxResults,
      if (nextToken != null) 'NextToken': nextToken,
    },
  );

  return GetInstancesHealthStatusResponse.fromJson(jsonResponse.body);
}