software.amazon.awssdk.services.servicediscovery.DefaultServiceDiscoveryAsyncClient Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.servicediscovery;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.AsyncClientHandler;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.util.VersionInfo;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.servicediscovery.model.CreateHttpNamespaceRequest;
import software.amazon.awssdk.services.servicediscovery.model.CreateHttpNamespaceResponse;
import software.amazon.awssdk.services.servicediscovery.model.CreatePrivateDnsNamespaceRequest;
import software.amazon.awssdk.services.servicediscovery.model.CreatePrivateDnsNamespaceResponse;
import software.amazon.awssdk.services.servicediscovery.model.CreatePublicDnsNamespaceRequest;
import software.amazon.awssdk.services.servicediscovery.model.CreatePublicDnsNamespaceResponse;
import software.amazon.awssdk.services.servicediscovery.model.CreateServiceRequest;
import software.amazon.awssdk.services.servicediscovery.model.CreateServiceResponse;
import software.amazon.awssdk.services.servicediscovery.model.CustomHealthNotFoundException;
import software.amazon.awssdk.services.servicediscovery.model.DeleteNamespaceRequest;
import software.amazon.awssdk.services.servicediscovery.model.DeleteNamespaceResponse;
import software.amazon.awssdk.services.servicediscovery.model.DeleteServiceRequest;
import software.amazon.awssdk.services.servicediscovery.model.DeleteServiceResponse;
import software.amazon.awssdk.services.servicediscovery.model.DeregisterInstanceRequest;
import software.amazon.awssdk.services.servicediscovery.model.DeregisterInstanceResponse;
import software.amazon.awssdk.services.servicediscovery.model.DiscoverInstancesRequest;
import software.amazon.awssdk.services.servicediscovery.model.DiscoverInstancesResponse;
import software.amazon.awssdk.services.servicediscovery.model.DuplicateRequestException;
import software.amazon.awssdk.services.servicediscovery.model.GetInstanceRequest;
import software.amazon.awssdk.services.servicediscovery.model.GetInstanceResponse;
import software.amazon.awssdk.services.servicediscovery.model.GetInstancesHealthStatusRequest;
import software.amazon.awssdk.services.servicediscovery.model.GetInstancesHealthStatusResponse;
import software.amazon.awssdk.services.servicediscovery.model.GetNamespaceRequest;
import software.amazon.awssdk.services.servicediscovery.model.GetNamespaceResponse;
import software.amazon.awssdk.services.servicediscovery.model.GetOperationRequest;
import software.amazon.awssdk.services.servicediscovery.model.GetOperationResponse;
import software.amazon.awssdk.services.servicediscovery.model.GetServiceRequest;
import software.amazon.awssdk.services.servicediscovery.model.GetServiceResponse;
import software.amazon.awssdk.services.servicediscovery.model.InstanceNotFoundException;
import software.amazon.awssdk.services.servicediscovery.model.InvalidInputException;
import software.amazon.awssdk.services.servicediscovery.model.ListInstancesRequest;
import software.amazon.awssdk.services.servicediscovery.model.ListInstancesResponse;
import software.amazon.awssdk.services.servicediscovery.model.ListNamespacesRequest;
import software.amazon.awssdk.services.servicediscovery.model.ListNamespacesResponse;
import software.amazon.awssdk.services.servicediscovery.model.ListOperationsRequest;
import software.amazon.awssdk.services.servicediscovery.model.ListOperationsResponse;
import software.amazon.awssdk.services.servicediscovery.model.ListServicesRequest;
import software.amazon.awssdk.services.servicediscovery.model.ListServicesResponse;
import software.amazon.awssdk.services.servicediscovery.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.servicediscovery.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.servicediscovery.model.NamespaceAlreadyExistsException;
import software.amazon.awssdk.services.servicediscovery.model.NamespaceNotFoundException;
import software.amazon.awssdk.services.servicediscovery.model.OperationNotFoundException;
import software.amazon.awssdk.services.servicediscovery.model.RegisterInstanceRequest;
import software.amazon.awssdk.services.servicediscovery.model.RegisterInstanceResponse;
import software.amazon.awssdk.services.servicediscovery.model.RequestLimitExceededException;
import software.amazon.awssdk.services.servicediscovery.model.ResourceInUseException;
import software.amazon.awssdk.services.servicediscovery.model.ResourceLimitExceededException;
import software.amazon.awssdk.services.servicediscovery.model.ResourceNotFoundException;
import software.amazon.awssdk.services.servicediscovery.model.ServiceAlreadyExistsException;
import software.amazon.awssdk.services.servicediscovery.model.ServiceDiscoveryException;
import software.amazon.awssdk.services.servicediscovery.model.ServiceDiscoveryRequest;
import software.amazon.awssdk.services.servicediscovery.model.ServiceNotFoundException;
import software.amazon.awssdk.services.servicediscovery.model.TagResourceRequest;
import software.amazon.awssdk.services.servicediscovery.model.TagResourceResponse;
import software.amazon.awssdk.services.servicediscovery.model.TooManyTagsException;
import software.amazon.awssdk.services.servicediscovery.model.UntagResourceRequest;
import software.amazon.awssdk.services.servicediscovery.model.UntagResourceResponse;
import software.amazon.awssdk.services.servicediscovery.model.UpdateHttpNamespaceRequest;
import software.amazon.awssdk.services.servicediscovery.model.UpdateHttpNamespaceResponse;
import software.amazon.awssdk.services.servicediscovery.model.UpdateInstanceCustomHealthStatusRequest;
import software.amazon.awssdk.services.servicediscovery.model.UpdateInstanceCustomHealthStatusResponse;
import software.amazon.awssdk.services.servicediscovery.model.UpdatePrivateDnsNamespaceRequest;
import software.amazon.awssdk.services.servicediscovery.model.UpdatePrivateDnsNamespaceResponse;
import software.amazon.awssdk.services.servicediscovery.model.UpdatePublicDnsNamespaceRequest;
import software.amazon.awssdk.services.servicediscovery.model.UpdatePublicDnsNamespaceResponse;
import software.amazon.awssdk.services.servicediscovery.model.UpdateServiceRequest;
import software.amazon.awssdk.services.servicediscovery.model.UpdateServiceResponse;
import software.amazon.awssdk.services.servicediscovery.paginators.GetInstancesHealthStatusPublisher;
import software.amazon.awssdk.services.servicediscovery.paginators.ListInstancesPublisher;
import software.amazon.awssdk.services.servicediscovery.paginators.ListNamespacesPublisher;
import software.amazon.awssdk.services.servicediscovery.paginators.ListOperationsPublisher;
import software.amazon.awssdk.services.servicediscovery.paginators.ListServicesPublisher;
import software.amazon.awssdk.services.servicediscovery.transform.CreateHttpNamespaceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.CreatePrivateDnsNamespaceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.CreatePublicDnsNamespaceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.CreateServiceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.DeleteNamespaceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.DeleteServiceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.DeregisterInstanceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.DiscoverInstancesRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.GetInstanceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.GetInstancesHealthStatusRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.GetNamespaceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.GetOperationRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.GetServiceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.ListInstancesRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.ListNamespacesRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.ListOperationsRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.ListServicesRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.RegisterInstanceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.UpdateHttpNamespaceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.UpdateInstanceCustomHealthStatusRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.UpdatePrivateDnsNamespaceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.UpdatePublicDnsNamespaceRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.UpdateServiceRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link ServiceDiscoveryAsyncClient}.
*
* @see ServiceDiscoveryAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultServiceDiscoveryAsyncClient implements ServiceDiscoveryAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultServiceDiscoveryAsyncClient.class);
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultServiceDiscoveryAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Creates an HTTP namespace. Service instances registered using an HTTP namespace can be discovered using a
* DiscoverInstances
request but can't be discovered using DNS.
*
*
* For the current quota on the number of namespaces that you can create using the same account, see Cloud Map quotas in the Cloud
* Map Developer Guide.
*
*
* @param createHttpNamespaceRequest
* @return A Java Future containing the result of the CreateHttpNamespace operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - NamespaceAlreadyExistsException The namespace that you're trying to create already exists.
* - ResourceLimitExceededException The resource can't be created because you've reached the quota on the
* number of resources.
* - DuplicateRequestException The operation is already in progress.
* - TooManyTagsException The list of tags on the resource is over the quota. The maximum number of tags
* that can be applied to a resource is 50.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.CreateHttpNamespace
* @see AWS API Documentation
*/
@Override
public CompletableFuture createHttpNamespace(
CreateHttpNamespaceRequest createHttpNamespaceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, createHttpNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateHttpNamespace");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateHttpNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateHttpNamespace")
.withMarshaller(new CreateHttpNamespaceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(createHttpNamespaceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = createHttpNamespaceRequest.overrideConfiguration().orElse(
null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Creates a private namespace based on DNS, which is visible only inside a specified Amazon VPC. The namespace
* defines your service naming scheme. For example, if you name your namespace example.com
and name
* your service backend
, the resulting DNS name for the service is backend.example.com
.
* Service instances that are registered using a private DNS namespace can be discovered using either a
* DiscoverInstances
request or using DNS. For the current quota on the number of namespaces that you
* can create using the same account, see Cloud Map quotas in the Cloud
* Map Developer Guide.
*
*
* @param createPrivateDnsNamespaceRequest
* @return A Java Future containing the result of the CreatePrivateDnsNamespace operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - NamespaceAlreadyExistsException The namespace that you're trying to create already exists.
* - ResourceLimitExceededException The resource can't be created because you've reached the quota on the
* number of resources.
* - DuplicateRequestException The operation is already in progress.
* - TooManyTagsException The list of tags on the resource is over the quota. The maximum number of tags
* that can be applied to a resource is 50.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.CreatePrivateDnsNamespace
* @see AWS API Documentation
*/
@Override
public CompletableFuture createPrivateDnsNamespace(
CreatePrivateDnsNamespaceRequest createPrivateDnsNamespaceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, createPrivateDnsNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreatePrivateDnsNamespace");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreatePrivateDnsNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreatePrivateDnsNamespace")
.withMarshaller(new CreatePrivateDnsNamespaceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(createPrivateDnsNamespaceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = createPrivateDnsNamespaceRequest.overrideConfiguration()
.orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Creates a public namespace based on DNS, which is visible on the internet. The namespace defines your service
* naming scheme. For example, if you name your namespace example.com
and name your service
* backend
, the resulting DNS name for the service is backend.example.com
. You can
* discover instances that were registered with a public DNS namespace by using either a
* DiscoverInstances
request or using DNS. For the current quota on the number of namespaces that you
* can create using the same account, see Cloud Map quotas in the Cloud
* Map Developer Guide.
*
*
* @param createPublicDnsNamespaceRequest
* @return A Java Future containing the result of the CreatePublicDnsNamespace operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - NamespaceAlreadyExistsException The namespace that you're trying to create already exists.
* - ResourceLimitExceededException The resource can't be created because you've reached the quota on the
* number of resources.
* - DuplicateRequestException The operation is already in progress.
* - TooManyTagsException The list of tags on the resource is over the quota. The maximum number of tags
* that can be applied to a resource is 50.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.CreatePublicDnsNamespace
* @see AWS API Documentation
*/
@Override
public CompletableFuture createPublicDnsNamespace(
CreatePublicDnsNamespaceRequest createPublicDnsNamespaceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, createPublicDnsNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreatePublicDnsNamespace");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreatePublicDnsNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreatePublicDnsNamespace")
.withMarshaller(new CreatePublicDnsNamespaceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(createPublicDnsNamespaceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = createPublicDnsNamespaceRequest.overrideConfiguration()
.orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Creates a service. This action defines the configuration for the following entities:
*
*
* -
*
* For public and private DNS namespaces, one of the following combinations of DNS records in Amazon Route 53:
*
*
* -
*
* A
*
*
* -
*
* AAAA
*
*
* -
*
* A
and AAAA
*
*
* -
*
* SRV
*
*
* -
*
* CNAME
*
*
*
*
* -
*
* Optionally, a health check
*
*
*
*
* After you create the service, you can submit a RegisterInstance request,
* and Cloud Map uses the values in the configuration to create the specified entities.
*
*
* For the current quota on the number of instances that you can register using the same namespace and using the
* same service, see Cloud Map
* quotas in the Cloud Map Developer Guide.
*
*
* @param createServiceRequest
* @return A Java Future containing the result of the CreateService operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - ResourceLimitExceededException The resource can't be created because you've reached the quota on the
* number of resources.
* - NamespaceNotFoundException No namespace exists with the specified ID.
* - ServiceAlreadyExistsException The service can't be created because a service with the same name
* already exists.
* - TooManyTagsException The list of tags on the resource is over the quota. The maximum number of tags
* that can be applied to a resource is 50.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.CreateService
* @see AWS API Documentation
*/
@Override
public CompletableFuture createService(CreateServiceRequest createServiceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, createServiceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateService");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateServiceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateService")
.withMarshaller(new CreateServiceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(createServiceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = createServiceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Deletes a namespace from the current account. If the namespace still contains one or more services, the request
* fails.
*
*
* @param deleteNamespaceRequest
* @return A Java Future containing the result of the DeleteNamespace operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - NamespaceNotFoundException No namespace exists with the specified ID.
* - ResourceInUseException The specified resource can't be deleted because it contains other resources.
* For example, you can't delete a service that contains any instances.
* - DuplicateRequestException The operation is already in progress.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.DeleteNamespace
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteNamespace(DeleteNamespaceRequest deleteNamespaceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteNamespace");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteNamespace")
.withMarshaller(new DeleteNamespaceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(deleteNamespaceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = deleteNamespaceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Deletes a specified service. If the service still contains one or more registered instances, the request fails.
*
*
* @param deleteServiceRequest
* @return A Java Future containing the result of the DeleteService operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - ServiceNotFoundException No service exists with the specified ID.
* - ResourceInUseException The specified resource can't be deleted because it contains other resources.
* For example, you can't delete a service that contains any instances.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.DeleteService
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteService(DeleteServiceRequest deleteServiceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteServiceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteService");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteServiceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteService")
.withMarshaller(new DeleteServiceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(deleteServiceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = deleteServiceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Deletes the Amazon Route 53 DNS records and health check, if any, that Cloud Map created for the specified
* instance.
*
*
* @param deregisterInstanceRequest
* @return A Java Future containing the result of the DeregisterInstance operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - DuplicateRequestException The operation is already in progress.
* - InvalidInputException 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.
* - InstanceNotFoundException No instance exists with the specified ID, or the instance was recently
* registered, and information about the instance hasn't propagated yet.
* - ResourceInUseException The specified resource can't be deleted because it contains other resources.
* For example, you can't delete a service that contains any instances.
* - ServiceNotFoundException No service exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.DeregisterInstance
* @see AWS API Documentation
*/
@Override
public CompletableFuture deregisterInstance(DeregisterInstanceRequest deregisterInstanceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, deregisterInstanceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeregisterInstance");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeregisterInstanceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeregisterInstance")
.withMarshaller(new DeregisterInstanceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(deregisterInstanceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = deregisterInstanceRequest.overrideConfiguration()
.orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Discovers registered instances for a specified namespace and service. You can use DiscoverInstances
* to discover instances for any type of namespace. For public and private DNS namespaces, you can also use DNS
* queries to discover instances.
*
*
* @param discoverInstancesRequest
* @return A Java Future containing the result of the DiscoverInstances operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ServiceNotFoundException No service exists with the specified ID.
* - NamespaceNotFoundException No namespace exists with the specified ID.
* - InvalidInputException 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.
* - RequestLimitExceededException The operation can't be completed because you've reached the quota for
* the number of requests. For more information, see Cloud Map API request throttling
* quota in the Cloud Map Developer Guide.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.DiscoverInstances
* @see AWS API Documentation
*/
@Override
public CompletableFuture discoverInstances(DiscoverInstancesRequest discoverInstancesRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, discoverInstancesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DiscoverInstances");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DiscoverInstancesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
String hostPrefix = "data-";
String resolvedHostExpression = "data-";
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DiscoverInstances")
.withMarshaller(new DiscoverInstancesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).hostPrefixExpression(resolvedHostExpression)
.withInput(discoverInstancesRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = discoverInstancesRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Gets information about a specified instance.
*
*
* @param getInstanceRequest
* @return A Java Future containing the result of the GetInstance operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InstanceNotFoundException No instance exists with the specified ID, or the instance was recently
* registered, and information about the instance hasn't propagated yet.
* - InvalidInputException 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.
* - ServiceNotFoundException No service exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.GetInstance
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getInstance(GetInstanceRequest getInstanceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getInstanceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetInstance");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetInstanceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetInstance").withMarshaller(new GetInstanceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getInstanceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getInstanceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* 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.
*
*
*
* @param getInstancesHealthStatusRequest
* @return A Java Future containing the result of the GetInstancesHealthStatus operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InstanceNotFoundException No instance exists with the specified ID, or the instance was recently
* registered, and information about the instance hasn't propagated yet.
* - InvalidInputException 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.
* - ServiceNotFoundException No service exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.GetInstancesHealthStatus
* @see AWS API Documentation
*/
@Override
public CompletableFuture getInstancesHealthStatus(
GetInstancesHealthStatusRequest getInstancesHealthStatusRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getInstancesHealthStatusRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetInstancesHealthStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetInstancesHealthStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetInstancesHealthStatus")
.withMarshaller(new GetInstancesHealthStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getInstancesHealthStatusRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getInstancesHealthStatusRequest.overrideConfiguration()
.orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* 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.
*
*
*
* This is a variant of
* {@link #getInstancesHealthStatus(software.amazon.awssdk.services.servicediscovery.model.GetInstancesHealthStatusRequest)}
* operation. The return type is a custom publisher that can be subscribed to request a stream of response pages.
* SDK will internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.GetInstancesHealthStatusPublisher publisher = client.getInstancesHealthStatusPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.GetInstancesHealthStatusPublisher publisher = client.getInstancesHealthStatusPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.servicediscovery.model.GetInstancesHealthStatusResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #getInstancesHealthStatus(software.amazon.awssdk.services.servicediscovery.model.GetInstancesHealthStatusRequest)}
* operation.
*
*
* @param getInstancesHealthStatusRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InstanceNotFoundException No instance exists with the specified ID, or the instance was recently
* registered, and information about the instance hasn't propagated yet.
* - InvalidInputException 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.
* - ServiceNotFoundException No service exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.GetInstancesHealthStatus
* @see AWS API Documentation
*/
public GetInstancesHealthStatusPublisher getInstancesHealthStatusPaginator(
GetInstancesHealthStatusRequest getInstancesHealthStatusRequest) {
return new GetInstancesHealthStatusPublisher(this, applyPaginatorUserAgent(getInstancesHealthStatusRequest));
}
/**
*
* Gets information about a namespace.
*
*
* @param getNamespaceRequest
* @return A Java Future containing the result of the GetNamespace operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - NamespaceNotFoundException No namespace exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.GetNamespace
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getNamespace(GetNamespaceRequest getNamespaceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetNamespace");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetNamespace").withMarshaller(new GetNamespaceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getNamespaceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getNamespaceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Gets information about any operation that returns an operation ID in the response, such as a
* CreateService
request.
*
*
*
* To get a list of operations that match specified criteria, see ListOperations.
*
*
*
* @param getOperationRequest
* @return A Java Future containing the result of the GetOperation operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - OperationNotFoundException No operation exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.GetOperation
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getOperation(GetOperationRequest getOperationRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperation");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetOperationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetOperation").withMarshaller(new GetOperationRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getOperationRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getOperationRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Gets the settings for a specified service.
*
*
* @param getServiceRequest
* @return A Java Future containing the result of the GetService operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - ServiceNotFoundException No service exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.GetService
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getService(GetServiceRequest getServiceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, getServiceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetService");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetServiceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams().withOperationName("GetService")
.withMarshaller(new GetServiceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(getServiceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = getServiceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists summary information about the instances that you registered by using a specified service.
*
*
* @param listInstancesRequest
* @return A Java Future containing the result of the ListInstances operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ServiceNotFoundException No service exists with the specified ID.
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListInstances
* @see AWS API Documentation
*/
@Override
public CompletableFuture listInstances(ListInstancesRequest listInstancesRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listInstancesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListInstances");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListInstancesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListInstances")
.withMarshaller(new ListInstancesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listInstancesRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listInstancesRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists summary information about the instances that you registered by using a specified service.
*
*
*
* This is a variant of
* {@link #listInstances(software.amazon.awssdk.services.servicediscovery.model.ListInstancesRequest)} operation.
* The return type is a custom publisher that can be subscribed to request a stream of response pages. SDK will
* internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.ListInstancesPublisher publisher = client.listInstancesPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.ListInstancesPublisher publisher = client.listInstancesPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.servicediscovery.model.ListInstancesResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listInstances(software.amazon.awssdk.services.servicediscovery.model.ListInstancesRequest)}
* operation.
*
*
* @param listInstancesRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ServiceNotFoundException No service exists with the specified ID.
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListInstances
* @see AWS API Documentation
*/
public ListInstancesPublisher listInstancesPaginator(ListInstancesRequest listInstancesRequest) {
return new ListInstancesPublisher(this, applyPaginatorUserAgent(listInstancesRequest));
}
/**
*
* Lists summary information about the namespaces that were created by the current account.
*
*
* @param listNamespacesRequest
* @return A Java Future containing the result of the ListNamespaces operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListNamespaces
* @see AWS API Documentation
*/
@Override
public CompletableFuture listNamespaces(ListNamespacesRequest listNamespacesRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listNamespacesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListNamespaces");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListNamespacesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListNamespaces")
.withMarshaller(new ListNamespacesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listNamespacesRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listNamespacesRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists summary information about the namespaces that were created by the current account.
*
*
*
* This is a variant of
* {@link #listNamespaces(software.amazon.awssdk.services.servicediscovery.model.ListNamespacesRequest)} operation.
* The return type is a custom publisher that can be subscribed to request a stream of response pages. SDK will
* internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.ListNamespacesPublisher publisher = client.listNamespacesPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.ListNamespacesPublisher publisher = client.listNamespacesPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.servicediscovery.model.ListNamespacesResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listNamespaces(software.amazon.awssdk.services.servicediscovery.model.ListNamespacesRequest)}
* operation.
*
*
* @param listNamespacesRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListNamespaces
* @see AWS API Documentation
*/
public ListNamespacesPublisher listNamespacesPaginator(ListNamespacesRequest listNamespacesRequest) {
return new ListNamespacesPublisher(this, applyPaginatorUserAgent(listNamespacesRequest));
}
/**
*
* Lists operations that match the criteria that you specify.
*
*
* @param listOperationsRequest
* @return A Java Future containing the result of the ListOperations operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListOperations
* @see AWS API Documentation
*/
@Override
public CompletableFuture listOperations(ListOperationsRequest listOperationsRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listOperationsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListOperations");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListOperationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListOperations")
.withMarshaller(new ListOperationsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listOperationsRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listOperationsRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists operations that match the criteria that you specify.
*
*
*
* This is a variant of
* {@link #listOperations(software.amazon.awssdk.services.servicediscovery.model.ListOperationsRequest)} operation.
* The return type is a custom publisher that can be subscribed to request a stream of response pages. SDK will
* internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.ListOperationsPublisher publisher = client.listOperationsPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.ListOperationsPublisher publisher = client.listOperationsPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.servicediscovery.model.ListOperationsResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listOperations(software.amazon.awssdk.services.servicediscovery.model.ListOperationsRequest)}
* operation.
*
*
* @param listOperationsRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListOperations
* @see AWS API Documentation
*/
public ListOperationsPublisher listOperationsPaginator(ListOperationsRequest listOperationsRequest) {
return new ListOperationsPublisher(this, applyPaginatorUserAgent(listOperationsRequest));
}
/**
*
* Lists summary information for all the services that are associated with one or more specified namespaces.
*
*
* @param listServicesRequest
* @return A Java Future containing the result of the ListServices operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListServices
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture listServices(ListServicesRequest listServicesRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listServicesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListServices");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListServicesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListServices").withMarshaller(new ListServicesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listServicesRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listServicesRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists summary information for all the services that are associated with one or more specified namespaces.
*
*
*
* This is a variant of
* {@link #listServices(software.amazon.awssdk.services.servicediscovery.model.ListServicesRequest)} operation. The
* return type is a custom publisher that can be subscribed to request a stream of response pages. SDK will
* internally handle making service calls for you.
*
*
* When the operation is called, an instance of this class is returned. At this point, no service calls are made yet
* and so there is no guarantee that the request is valid. If there are errors in your request, you will see the
* failures only after you start streaming the data. The subscribe method should be called as a request to start
* streaming data. For more info, see
* {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe
* method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the
* starting request.
*
*
*
* The following are few ways to use the response class:
*
* 1) Using the subscribe helper method
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.ListServicesPublisher publisher = client.listServicesPaginator(request);
* CompletableFuture future = publisher.subscribe(res -> { // Do something with the response });
* future.get();
* }
*
*
* 2) Using a custom subscriber
*
*
* {@code
* software.amazon.awssdk.services.servicediscovery.paginators.ListServicesPublisher publisher = client.listServicesPaginator(request);
* publisher.subscribe(new Subscriber() {
*
* public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... };
*
*
* public void onNext(software.amazon.awssdk.services.servicediscovery.model.ListServicesResponse response) { //... };
* });}
*
*
* As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2.
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listServices(software.amazon.awssdk.services.servicediscovery.model.ListServicesRequest)} operation.
*
*
* @param listServicesRequest
* @return A custom publisher that can be subscribed to request a stream of response pages.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListServices
* @see AWS
* API Documentation
*/
public ListServicesPublisher listServicesPaginator(ListServicesRequest listServicesRequest) {
return new ListServicesPublisher(this, applyPaginatorUserAgent(listServicesRequest));
}
/**
*
* Lists tags for the specified resource.
*
*
* @param listTagsForResourceRequest
* @return A Java Future containing the result of the ListTagsForResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The operation can't be completed because the resource was not found.
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public CompletableFuture listTagsForResource(
ListTagsForResourceRequest listTagsForResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource")
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(listTagsForResourceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = listTagsForResourceRequest.overrideConfiguration().orElse(
null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Creates or updates one or more records and, optionally, creates a health check based on the settings in a
* specified service. When you submit a RegisterInstance
request, the following occurs:
*
*
* -
*
* For each DNS record that you define in the service that's specified by ServiceId
, a record is
* created or updated in the hosted zone that's associated with the corresponding namespace.
*
*
* -
*
* If the service includes HealthCheckConfig
, a health check is created based on the settings in the
* health check configuration.
*
*
* -
*
* The health check, if any, is associated with each of the new or updated records.
*
*
*
*
*
* One RegisterInstance
request must complete before you can submit another request and specify the
* same service ID and instance ID.
*
*
*
* For more information, see CreateService.
*
*
* When Cloud Map receives a DNS query for the specified DNS name, it returns the applicable value:
*
*
* -
*
* If the health check is healthy: returns all the records
*
*
* -
*
* If the health check is unhealthy: returns the applicable value for the last healthy instance
*
*
* -
*
* If you didn't specify a health check configuration: returns all the records
*
*
*
*
* For the current quota on the number of instances that you can register using the same namespace and using the
* same service, see Cloud Map
* quotas in the Cloud Map Developer Guide.
*
*
* @param registerInstanceRequest
* @return A Java Future containing the result of the RegisterInstance operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - DuplicateRequestException The operation is already in progress.
* - InvalidInputException 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.
* - ResourceInUseException The specified resource can't be deleted because it contains other resources.
* For example, you can't delete a service that contains any instances.
* - ResourceLimitExceededException The resource can't be created because you've reached the quota on the
* number of resources.
* - ServiceNotFoundException No service exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.RegisterInstance
* @see AWS API Documentation
*/
@Override
public CompletableFuture registerInstance(RegisterInstanceRequest registerInstanceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, registerInstanceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "RegisterInstance");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, RegisterInstanceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("RegisterInstance")
.withMarshaller(new RegisterInstanceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(registerInstanceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = registerInstanceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Adds one or more tags to the specified resource.
*
*
* @param tagResourceRequest
* @return A Java Future containing the result of the TagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The operation can't be completed because the resource was not found.
* - TooManyTagsException The list of tags on the resource is over the quota. The maximum number of tags
* that can be applied to a resource is 50.
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.TagResource
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture tagResource(TagResourceRequest tagResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("TagResource").withMarshaller(new TagResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(tagResourceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = tagResourceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Removes one or more tags from the specified resource.
*
*
* @param untagResourceRequest
* @return A Java Future containing the result of the UntagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ResourceNotFoundException The operation can't be completed because the resource was not found.
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.UntagResource
* @see AWS API Documentation
*/
@Override
public CompletableFuture untagResource(UntagResourceRequest untagResourceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UntagResource")
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(untagResourceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = untagResourceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates an HTTP namespace.
*
*
* @param updateHttpNamespaceRequest
* @return A Java Future containing the result of the UpdateHttpNamespace operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - NamespaceNotFoundException No namespace exists with the specified ID.
* - ResourceInUseException The specified resource can't be deleted because it contains other resources.
* For example, you can't delete a service that contains any instances.
* - DuplicateRequestException The operation is already in progress.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.UpdateHttpNamespace
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateHttpNamespace(
UpdateHttpNamespaceRequest updateHttpNamespaceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateHttpNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateHttpNamespace");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateHttpNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateHttpNamespace")
.withMarshaller(new UpdateHttpNamespaceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(updateHttpNamespaceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = updateHttpNamespaceRequest.overrideConfiguration().orElse(
null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Submits a request to change the health status of a custom health check to healthy or unhealthy.
*
*
* You can use UpdateInstanceCustomHealthStatus
to change the status only for custom health checks,
* which you define using HealthCheckCustomConfig
when you create a service. You can't use it to change
* the status for Route 53 health checks, which you define using HealthCheckConfig
.
*
*
* For more information, see HealthCheckCustomConfig.
*
*
* @param updateInstanceCustomHealthStatusRequest
* @return A Java Future containing the result of the UpdateInstanceCustomHealthStatus operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InstanceNotFoundException No instance exists with the specified ID, or the instance was recently
* registered, and information about the instance hasn't propagated yet.
* - ServiceNotFoundException No service exists with the specified ID.
* - CustomHealthNotFoundException The health check for the instance that's specified by
*
ServiceId
and InstanceId
isn't a custom health check.
* - InvalidInputException 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.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.UpdateInstanceCustomHealthStatus
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateInstanceCustomHealthStatus(
UpdateInstanceCustomHealthStatusRequest updateInstanceCustomHealthStatusRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration,
updateInstanceCustomHealthStatusRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateInstanceCustomHealthStatus");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, UpdateInstanceCustomHealthStatusResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateInstanceCustomHealthStatus")
.withMarshaller(new UpdateInstanceCustomHealthStatusRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(updateInstanceCustomHealthStatusRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = updateInstanceCustomHealthStatusRequest
.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates a private DNS namespace.
*
*
* @param updatePrivateDnsNamespaceRequest
* @return A Java Future containing the result of the UpdatePrivateDnsNamespace operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - NamespaceNotFoundException No namespace exists with the specified ID.
* - ResourceInUseException The specified resource can't be deleted because it contains other resources.
* For example, you can't delete a service that contains any instances.
* - DuplicateRequestException The operation is already in progress.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.UpdatePrivateDnsNamespace
* @see AWS API Documentation
*/
@Override
public CompletableFuture updatePrivateDnsNamespace(
UpdatePrivateDnsNamespaceRequest updatePrivateDnsNamespaceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, updatePrivateDnsNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdatePrivateDnsNamespace");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdatePrivateDnsNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdatePrivateDnsNamespace")
.withMarshaller(new UpdatePrivateDnsNamespaceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(updatePrivateDnsNamespaceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = updatePrivateDnsNamespaceRequest.overrideConfiguration()
.orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates a public DNS namespace.
*
*
* @param updatePublicDnsNamespaceRequest
* @return A Java Future containing the result of the UpdatePublicDnsNamespace operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidInputException 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.
* - NamespaceNotFoundException No namespace exists with the specified ID.
* - ResourceInUseException The specified resource can't be deleted because it contains other resources.
* For example, you can't delete a service that contains any instances.
* - DuplicateRequestException The operation is already in progress.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.UpdatePublicDnsNamespace
* @see AWS API Documentation
*/
@Override
public CompletableFuture updatePublicDnsNamespace(
UpdatePublicDnsNamespaceRequest updatePublicDnsNamespaceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, updatePublicDnsNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdatePublicDnsNamespace");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdatePublicDnsNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdatePublicDnsNamespace")
.withMarshaller(new UpdatePublicDnsNamespaceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(updatePublicDnsNamespaceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = updatePublicDnsNamespaceRequest.overrideConfiguration()
.orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Submits a request to perform the following operations:
*
*
* -
*
* Update the TTL setting for existing DnsRecords
configurations
*
*
* -
*
* Add, update, or delete HealthCheckConfig
for a specified service
*
*
*
* You can't add, update, or delete a HealthCheckCustomConfig
configuration.
*
*
*
*
* For public and private DNS namespaces, note the following:
*
*
* -
*
* If you omit any existing DnsRecords
or HealthCheckConfig
configurations from an
* UpdateService
request, the configurations are deleted from the service.
*
*
* -
*
* If you omit an existing HealthCheckCustomConfig
configuration from an UpdateService
* request, the configuration isn't deleted from the service.
*
*
*
*
* When you update settings for a service, Cloud Map also updates the corresponding settings in all the records and
* health checks that were created by using the specified service.
*
*
* @param updateServiceRequest
* @return A Java Future containing the result of the UpdateService operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - DuplicateRequestException The operation is already in progress.
* - InvalidInputException 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.
* - ServiceNotFoundException No service exists with the specified ID.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - ServiceDiscoveryException Base class for all service exceptions. Unknown exceptions will be thrown as
* an instance of this type.
*
* @sample ServiceDiscoveryAsyncClient.UpdateService
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateService(UpdateServiceRequest updateServiceRequest) {
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateServiceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "ServiceDiscovery");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateService");
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateServiceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateService")
.withMarshaller(new UpdateServiceRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withMetricCollector(apiCallMetricCollector).withInput(updateServiceRequest));
AwsRequestOverrideConfiguration requestOverrideConfig = updateServiceRequest.overrideConfiguration().orElse(null);
CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
});
executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture);
return executeFuture;
} catch (Throwable t) {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public void close() {
clientHandler.close();
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(ServiceDiscoveryException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("RequestLimitExceeded")
.exceptionBuilderSupplier(RequestLimitExceededException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceInUse")
.exceptionBuilderSupplier(ResourceInUseException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("DuplicateRequest")
.exceptionBuilderSupplier(DuplicateRequestException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceAlreadyExists")
.exceptionBuilderSupplier(ServiceAlreadyExistsException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceNotFound")
.exceptionBuilderSupplier(ServiceNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InstanceNotFound")
.exceptionBuilderSupplier(InstanceNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("OperationNotFound")
.exceptionBuilderSupplier(OperationNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("TooManyTagsException")
.exceptionBuilderSupplier(TooManyTagsException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidInput")
.exceptionBuilderSupplier(InvalidInputException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("NamespaceAlreadyExists")
.exceptionBuilderSupplier(NamespaceAlreadyExistsException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("NamespaceNotFound")
.exceptionBuilderSupplier(NamespaceNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("CustomHealthNotFound")
.exceptionBuilderSupplier(CustomHealthNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceLimitExceeded")
.exceptionBuilderSupplier(ResourceLimitExceededException::builder).build());
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private T applyPaginatorUserAgent(T request) {
Consumer userAgentApplier = b -> b.addApiName(ApiName.builder()
.version(VersionInfo.SDK_VERSION).name("PAGINATED").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(userAgentApplier).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
}