Gets the current health status (Healthy, Unhealthy, or Unknown) of one or more instances that are associated with a specified service.
There's a brief delay between when you register an instance and when the health status for the instance is available.
Parameters:
-
service_id
(Arn)
–
The ID or Amazon Resource Name (ARN) of the service that the instance is associated with. 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.
-
instances
(Optional[InstanceIdList], default:
None
)
–
An array that contains the IDs of all the instances that you want to get the health status for.
If you omit Instances, Cloud Map returns the health status for all the instances that are associated with the specified service.
To get the IDs for the instances that you've registered by using a specified service, submit a ListInstances request.
-
max_results
(Optional[MaxResults], default:
None
)
–
The maximum number of instances that you want Cloud Map to return in the response to a GetInstancesHealthStatus request. If you don't specify a value for MaxResults, Cloud Map returns up to 100 instances.
-
next_token
(Optional[NextToken], default:
None
)
–
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.
Raises:
-
InstanceNotFound
–
No instance exists with the specified ID, or the instance was recently registered, and information about the instance hasn't propagated yet.
-
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:
GetInstancesHealthStatus example
This example gets the current health status of one or more instances that are associate with a specified service.
>>> await client.get_instances_health_status(service_id='srv-e4anhexample0004')
Get instances health status using service ARN for shared namespace
This example gets the current health status of instances using a service ARN instead of service ID. This is useful for checking health status of instances associated with shared namespaces.
>>> await client.get_instances_health_status(service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-e4anhexample0004')
Source code in docs_src/capo_servicediscovery/_services/async_service_discovery.py
| async def get_instances_health_status(
self,
service_id: "capo_servicediscovery.types.arn.Arn",
*,
config_overrides: Optional[AsyncServiceDiscoveryClientConfig] = None,
instances: Optional[
"capo_servicediscovery.types.instance_id_list.InstanceIdList"
] = None,
max_results: Optional[
"capo_servicediscovery.types.max_results.MaxResults"
] = None,
next_token: Optional["capo_servicediscovery.types.next_token.NextToken"] = None,
) -> "capo_servicediscovery.types.get_instances_health_status_response.GetInstancesHealthStatusResponse":
"""<p>Gets the current health status (<code>Healthy</code>, <code>Unhealthy</code>, or <code>Unknown</code>) of one or more instances that are associated with a specified service.</p> <note> <p>There's a brief delay between when you register an instance and when the health status for the instance is available. </p> </note>
Args:
service_id: <p>The ID or Amazon Resource Name (ARN) of the service that the instance is associated with. 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>
instances: <p>An array that contains the IDs of all the instances that you want to get the health status for.</p> <p>If you omit <code>Instances</code>, Cloud Map returns the health status for all the instances that are associated with the specified service.</p> <note> <p>To get the IDs for the instances that you've registered by using a specified service, submit a <a href="https://docs.aws.amazon.com/cloud-map/latest/api/API_ListInstances.html">ListInstances</a> request.</p> </note>
max_results: <p>The maximum number of instances that you want Cloud Map to return in the response to a <code>GetInstancesHealthStatus</code> request. If you don't specify a value for <code>MaxResults</code>, Cloud Map returns up to 100 instances.</p>
next_token: <p>For the first <code>GetInstancesHealthStatus</code> request, omit this value.</p> <p>If more than <code>MaxResults</code> instances match the specified criteria, you can submit another <code>GetInstancesHealthStatus</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>
Raises:
capo_servicediscovery.errors.instance_not_found.InstanceNotFound: <p>No instance exists with the specified ID, or the instance was recently registered, and information about the instance hasn't propagated yet.</p>
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:
GetInstancesHealthStatus example
This example gets the current health status of one or more instances that are associate with a specified service.
>>> await client.get_instances_health_status(service_id='srv-e4anhexample0004')
Get instances health status using service ARN for shared namespace
This example gets the current health status of instances using a service ARN instead of service ID. This is useful for checking health status of instances associated with shared namespaces.
>>> await client.get_instances_health_status(service_id='arn:aws:servicediscovery:us-west-2:123456789012:service/srv-e4anhexample0004')
"""
async def _handler(
req: "AsyncOperationRequest[capo_servicediscovery.types.get_instances_health_status_request.GetInstancesHealthStatusRequest]",
) -> AsyncOperationResponse[
"capo_servicediscovery.types.get_instances_health_status_response.GetInstancesHealthStatusResponse"
]:
import capo_servicediscovery._operations.route53_auto_naming_v20170314.get_instances_health_status
(
output,
http_response,
) = await capo_servicediscovery._operations.route53_auto_naming_v20170314.get_instances_health_status.async_get_instances_health_status(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("GetInstancesHealthStatus")
)
input_: capo_servicediscovery.types.get_instances_health_status_request.GetInstancesHealthStatusRequest = {
"service_id": service_id
}
if instances is not None:
input_["instances"] = instances
if max_results is not None:
input_["max_results"] = max_results
if next_token is not None:
input_["next_token"] = next_token
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|