All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.servicediscovery.DefaultServiceDiscoveryClient 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.function.Consumer;
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.AwsSyncClientHandler;
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.ClientExecutionParams;
import software.amazon.awssdk.core.client.handler.SyncClientHandler;
import software.amazon.awssdk.core.exception.SdkClientException;
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.UpdateInstanceCustomHealthStatusRequest;
import software.amazon.awssdk.services.servicediscovery.model.UpdateInstanceCustomHealthStatusResponse;
import software.amazon.awssdk.services.servicediscovery.model.UpdateServiceRequest;
import software.amazon.awssdk.services.servicediscovery.model.UpdateServiceResponse;
import software.amazon.awssdk.services.servicediscovery.paginators.GetInstancesHealthStatusIterable;
import software.amazon.awssdk.services.servicediscovery.paginators.ListInstancesIterable;
import software.amazon.awssdk.services.servicediscovery.paginators.ListNamespacesIterable;
import software.amazon.awssdk.services.servicediscovery.paginators.ListOperationsIterable;
import software.amazon.awssdk.services.servicediscovery.paginators.ListServicesIterable;
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.UpdateInstanceCustomHealthStatusRequestMarshaller;
import software.amazon.awssdk.services.servicediscovery.transform.UpdateServiceRequestMarshaller;
import software.amazon.awssdk.utils.Logger;

/**
 * Internal implementation of {@link ServiceDiscoveryClient}.
 *
 * @see ServiceDiscoveryClient#builder()
 */
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultServiceDiscoveryClient implements ServiceDiscoveryClient {
    private static final Logger log = Logger.loggerFor(DefaultServiceDiscoveryClient.class);

    private final SyncClientHandler clientHandler;

    private final AwsJsonProtocolFactory protocolFactory;

    private final SdkClientConfiguration clientConfiguration;

    protected DefaultServiceDiscoveryClient(SdkClientConfiguration clientConfiguration) {
        this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
        this.clientConfiguration = clientConfiguration;
        this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
    }

    @Override
    public final String serviceName() {
        return SERVICE_NAME;
    }

    /**
     * 

* Creates an HTTP namespace. Service instances that you register 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 AWS account, see AWS Cloud Map quotas in the * AWS Cloud Map Developer Guide. *

* * @param createHttpNamespaceRequest * @return Result of the CreateHttpNamespace operation returned by the service. * @throws 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. * @throws NamespaceAlreadyExistsException * The namespace that you're trying to create already exists. * @throws ResourceLimitExceededException * The resource can't be created because you've reached the quota on the number of resources. * @throws DuplicateRequestException * The operation is already in progress. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.CreateHttpNamespace * @see AWS API Documentation */ @Override public CreateHttpNamespaceResponse createHttpNamespace(CreateHttpNamespaceRequest createHttpNamespaceRequest) throws InvalidInputException, NamespaceAlreadyExistsException, ResourceLimitExceededException, DuplicateRequestException, TooManyTagsException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, CreateHttpNamespaceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("CreateHttpNamespace").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(createHttpNamespaceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new CreateHttpNamespaceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Creates a private namespace based on DNS, which will be 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 will be * backend.example.com. For the current quota on the number of namespaces that you can create using the * same AWS account, see AWS Cloud * Map Limits in the AWS Cloud Map Developer Guide. *

* * @param createPrivateDnsNamespaceRequest * @return Result of the CreatePrivateDnsNamespace operation returned by the service. * @throws 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. * @throws NamespaceAlreadyExistsException * The namespace that you're trying to create already exists. * @throws ResourceLimitExceededException * The resource can't be created because you've reached the quota on the number of resources. * @throws DuplicateRequestException * The operation is already in progress. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.CreatePrivateDnsNamespace * @see AWS API Documentation */ @Override public CreatePrivateDnsNamespaceResponse createPrivateDnsNamespace( CreatePrivateDnsNamespaceRequest createPrivateDnsNamespaceRequest) throws InvalidInputException, NamespaceAlreadyExistsException, ResourceLimitExceededException, DuplicateRequestException, TooManyTagsException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, CreatePrivateDnsNamespaceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler .execute(new ClientExecutionParams() .withOperationName("CreatePrivateDnsNamespace").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(createPrivateDnsNamespaceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new CreatePrivateDnsNamespaceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Creates a public namespace based on DNS, which will be 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 will be backend.example.com. For the * current quota on the number of namespaces that you can create using the same AWS account, see AWS Cloud Map Limits in the * AWS Cloud Map Developer Guide. *

* * @param createPublicDnsNamespaceRequest * @return Result of the CreatePublicDnsNamespace operation returned by the service. * @throws 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. * @throws NamespaceAlreadyExistsException * The namespace that you're trying to create already exists. * @throws ResourceLimitExceededException * The resource can't be created because you've reached the quota on the number of resources. * @throws DuplicateRequestException * The operation is already in progress. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.CreatePublicDnsNamespace * @see AWS API Documentation */ @Override public CreatePublicDnsNamespaceResponse createPublicDnsNamespace( CreatePublicDnsNamespaceRequest createPublicDnsNamespaceRequest) throws InvalidInputException, NamespaceAlreadyExistsException, ResourceLimitExceededException, DuplicateRequestException, TooManyTagsException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, CreatePublicDnsNamespaceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler .execute(new ClientExecutionParams() .withOperationName("CreatePublicDnsNamespace").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(createPublicDnsNamespaceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new CreatePublicDnsNamespaceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Creates a service, which 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 AWS 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 AWS Cloud Map * Limits in the AWS Cloud Map Developer Guide. *

* * @param createServiceRequest * @return Result of the CreateService operation returned by the service. * @throws 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. * @throws ResourceLimitExceededException * The resource can't be created because you've reached the quota on the number of resources. * @throws NamespaceNotFoundException * No namespace exists with the specified ID. * @throws ServiceAlreadyExistsException * The service can't be created because a service with the same name already exists. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.CreateService * @see AWS * API Documentation */ @Override public CreateServiceResponse createService(CreateServiceRequest createServiceRequest) throws InvalidInputException, ResourceLimitExceededException, NamespaceNotFoundException, ServiceAlreadyExistsException, TooManyTagsException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, CreateServiceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("CreateService").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(createServiceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new CreateServiceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Deletes a namespace from the current account. If the namespace still contains one or more services, the request * fails. *

* * @param deleteNamespaceRequest * @return Result of the DeleteNamespace operation returned by the service. * @throws 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. * @throws NamespaceNotFoundException * No namespace exists with the specified ID. * @throws 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. * @throws DuplicateRequestException * The operation is already in progress. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.DeleteNamespace * @see AWS API Documentation */ @Override public DeleteNamespaceResponse deleteNamespace(DeleteNamespaceRequest deleteNamespaceRequest) throws InvalidInputException, NamespaceNotFoundException, ResourceInUseException, DuplicateRequestException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeleteNamespaceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DeleteNamespace").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(deleteNamespaceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DeleteNamespaceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Deletes a specified service. If the service still contains one or more registered instances, the request fails. *

* * @param deleteServiceRequest * @return Result of the DeleteService operation returned by the service. * @throws 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. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.DeleteService * @see AWS * API Documentation */ @Override public DeleteServiceResponse deleteService(DeleteServiceRequest deleteServiceRequest) throws InvalidInputException, ServiceNotFoundException, ResourceInUseException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeleteServiceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DeleteService").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(deleteServiceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DeleteServiceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Deletes the Amazon Route 53 DNS records and health check, if any, that AWS Cloud Map created for the specified * instance. *

* * @param deregisterInstanceRequest * @return Result of the DeregisterInstance operation returned by the service. * @throws DuplicateRequestException * The operation is already in progress. * @throws 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. * @throws InstanceNotFoundException * No instance exists with the specified ID, or the instance was recently registered, and information about * the instance hasn't propagated yet. * @throws 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. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.DeregisterInstance * @see AWS API Documentation */ @Override public DeregisterInstanceResponse deregisterInstance(DeregisterInstanceRequest deregisterInstanceRequest) throws DuplicateRequestException, InvalidInputException, InstanceNotFoundException, ResourceInUseException, ServiceNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DeregisterInstanceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DeregisterInstance").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(deregisterInstanceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DeregisterInstanceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* 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 Result of the DiscoverInstances operation returned by the service. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws NamespaceNotFoundException * No namespace exists with the specified ID. * @throws 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. * @throws RequestLimitExceededException * The operation can't be completed because you've reached the quota for the number of requests. For more * information, see AWS Cloud Map * API request throttling quota in the AWS Cloud Map Developer Guide. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.DiscoverInstances * @see AWS API Documentation */ @Override public DiscoverInstancesResponse discoverInstances(DiscoverInstancesRequest discoverInstancesRequest) throws ServiceNotFoundException, NamespaceNotFoundException, InvalidInputException, RequestLimitExceededException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DiscoverInstancesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); String hostPrefix = "data-"; String resolvedHostExpression = "data-"; return clientHandler.execute(new ClientExecutionParams() .withOperationName("DiscoverInstances").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).hostPrefixExpression(resolvedHostExpression) .withInput(discoverInstancesRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new DiscoverInstancesRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Gets information about a specified instance. *

* * @param getInstanceRequest * @return Result of the GetInstance operation returned by the service. * @throws InstanceNotFoundException * No instance exists with the specified ID, or the instance was recently registered, and information about * the instance hasn't propagated yet. * @throws 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. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.GetInstance * @see AWS * API Documentation */ @Override public GetInstanceResponse getInstance(GetInstanceRequest getInstanceRequest) throws InstanceNotFoundException, InvalidInputException, ServiceNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, GetInstanceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("GetInstance").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(getInstanceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new GetInstanceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

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

* *

* There is a brief delay between when you register an instance and when the health status for the instance is * available. *

*
* * @param getInstancesHealthStatusRequest * @return Result of the GetInstancesHealthStatus operation returned by the service. * @throws InstanceNotFoundException * No instance exists with the specified ID, or the instance was recently registered, and information about * the instance hasn't propagated yet. * @throws 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. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.GetInstancesHealthStatus * @see AWS API Documentation */ @Override public GetInstancesHealthStatusResponse getInstancesHealthStatus( GetInstancesHealthStatusRequest getInstancesHealthStatusRequest) throws InstanceNotFoundException, InvalidInputException, ServiceNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetInstancesHealthStatusResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler .execute(new ClientExecutionParams() .withOperationName("GetInstancesHealthStatus").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(getInstancesHealthStatusRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new GetInstancesHealthStatusRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

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

* *

* There is 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 iterable that can be used to iterate through all the pages. SDK will * internally handle making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.GetInstancesHealthStatusIterable responses = client.getInstancesHealthStatusPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.servicediscovery.paginators.GetInstancesHealthStatusIterable responses = client
     *             .getInstancesHealthStatusPaginator(request);
     *     for (software.amazon.awssdk.services.servicediscovery.model.GetInstancesHealthStatusResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.GetInstancesHealthStatusIterable responses = client.getInstancesHealthStatusPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* 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 iterable that can be used to iterate through all the response pages. * @throws InstanceNotFoundException * No instance exists with the specified ID, or the instance was recently registered, and information about * the instance hasn't propagated yet. * @throws 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. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.GetInstancesHealthStatus * @see AWS API Documentation */ @Override public GetInstancesHealthStatusIterable getInstancesHealthStatusPaginator( GetInstancesHealthStatusRequest getInstancesHealthStatusRequest) throws InstanceNotFoundException, InvalidInputException, ServiceNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { return new GetInstancesHealthStatusIterable(this, applyPaginatorUserAgent(getInstancesHealthStatusRequest)); } /** *

* Gets information about a namespace. *

* * @param getNamespaceRequest * @return Result of the GetNamespace operation returned by the service. * @throws 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. * @throws NamespaceNotFoundException * No namespace exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.GetNamespace * @see AWS * API Documentation */ @Override public GetNamespaceResponse getNamespace(GetNamespaceRequest getNamespaceRequest) throws InvalidInputException, NamespaceNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, GetNamespaceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("GetNamespace").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(getNamespaceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new GetNamespaceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* 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 Result of the GetOperation operation returned by the service. * @throws 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. * @throws OperationNotFoundException * No operation exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.GetOperation * @see AWS * API Documentation */ @Override public GetOperationResponse getOperation(GetOperationRequest getOperationRequest) throws InvalidInputException, OperationNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, GetOperationResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("GetOperation").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(getOperationRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new GetOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Gets the settings for a specified service. *

* * @param getServiceRequest * @return Result of the GetService operation returned by the service. * @throws 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. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.GetService * @see AWS * API Documentation */ @Override public GetServiceResponse getService(GetServiceRequest getServiceRequest) throws InvalidInputException, ServiceNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, GetServiceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler .execute(new ClientExecutionParams().withOperationName("GetService") .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withInput(getServiceRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new GetServiceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

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

* * @param listInstancesRequest * @return Result of the ListInstances operation returned by the service. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListInstances * @see AWS * API Documentation */ @Override public ListInstancesResponse listInstances(ListInstancesRequest listInstancesRequest) throws ServiceNotFoundException, InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListInstancesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListInstances").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listInstancesRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new ListInstancesRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* 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 iterable that can be used to iterate through all the pages. SDK will internally * handle making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.ListInstancesIterable responses = client.listInstancesPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.servicediscovery.paginators.ListInstancesIterable responses = client
     *             .listInstancesPaginator(request);
     *     for (software.amazon.awssdk.services.servicediscovery.model.ListInstancesResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.ListInstancesIterable responses = client.listInstancesPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* 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 iterable that can be used to iterate through all the response pages. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListInstances * @see AWS * API Documentation */ @Override public ListInstancesIterable listInstancesPaginator(ListInstancesRequest listInstancesRequest) throws ServiceNotFoundException, InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { return new ListInstancesIterable(this, applyPaginatorUserAgent(listInstancesRequest)); } /** *

* Lists summary information about the namespaces that were created by the current AWS account. *

* * @param listNamespacesRequest * @return Result of the ListNamespaces operation returned by the service. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListNamespaces * @see AWS API Documentation */ @Override public ListNamespacesResponse listNamespaces(ListNamespacesRequest listNamespacesRequest) throws InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListNamespacesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListNamespaces").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listNamespacesRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new ListNamespacesRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Lists summary information about the namespaces that were created by the current AWS account. *

*
*

* This is a variant of * {@link #listNamespaces(software.amazon.awssdk.services.servicediscovery.model.ListNamespacesRequest)} operation. * The return type is a custom iterable that can be used to iterate through all the pages. SDK will internally * handle making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.ListNamespacesIterable responses = client.listNamespacesPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.servicediscovery.paginators.ListNamespacesIterable responses = client
     *             .listNamespacesPaginator(request);
     *     for (software.amazon.awssdk.services.servicediscovery.model.ListNamespacesResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.ListNamespacesIterable responses = client.listNamespacesPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* 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 iterable that can be used to iterate through all the response pages. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListNamespaces * @see AWS API Documentation */ @Override public ListNamespacesIterable listNamespacesPaginator(ListNamespacesRequest listNamespacesRequest) throws InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { return new ListNamespacesIterable(this, applyPaginatorUserAgent(listNamespacesRequest)); } /** *

* Lists operations that match the criteria that you specify. *

* * @param listOperationsRequest * @return Result of the ListOperations operation returned by the service. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListOperations * @see AWS API Documentation */ @Override public ListOperationsResponse listOperations(ListOperationsRequest listOperationsRequest) throws InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListOperationsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListOperations").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listOperationsRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new ListOperationsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* 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 iterable that can be used to iterate through all the pages. SDK will internally * handle making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.ListOperationsIterable responses = client.listOperationsPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.servicediscovery.paginators.ListOperationsIterable responses = client
     *             .listOperationsPaginator(request);
     *     for (software.amazon.awssdk.services.servicediscovery.model.ListOperationsResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.ListOperationsIterable responses = client.listOperationsPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* 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 iterable that can be used to iterate through all the response pages. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListOperations * @see AWS API Documentation */ @Override public ListOperationsIterable listOperationsPaginator(ListOperationsRequest listOperationsRequest) throws InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { return new ListOperationsIterable(this, applyPaginatorUserAgent(listOperationsRequest)); } /** *

* Lists summary information for all the services that are associated with one or more specified namespaces. *

* * @param listServicesRequest * @return Result of the ListServices operation returned by the service. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListServices * @see AWS * API Documentation */ @Override public ListServicesResponse listServices(ListServicesRequest listServicesRequest) throws InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListServicesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListServices").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listServicesRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new ListServicesRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* 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 iterable that can be used to iterate through all the pages. SDK will internally handle * making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.ListServicesIterable responses = client.listServicesPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.servicediscovery.paginators.ListServicesIterable responses = client
     *             .listServicesPaginator(request);
     *     for (software.amazon.awssdk.services.servicediscovery.model.ListServicesResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.servicediscovery.paginators.ListServicesIterable responses = client.listServicesPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* 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 iterable that can be used to iterate through all the response pages. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListServices * @see AWS * API Documentation */ @Override public ListServicesIterable listServicesPaginator(ListServicesRequest listServicesRequest) throws InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { return new ListServicesIterable(this, applyPaginatorUserAgent(listServicesRequest)); } /** *

* Lists tags for the specified resource. *

* * @param listTagsForResourceRequest * @return Result of the ListTagsForResource operation returned by the service. * @throws ResourceNotFoundException * The operation can't be completed because the resource was not found. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.ListTagsForResource * @see AWS API Documentation */ @Override public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest) throws ResourceNotFoundException, InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListTagsForResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListTagsForResource").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listTagsForResourceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* 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 is specified by ServiceId, a record is * created or updated in the hosted zone that is 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 AWS 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 AWS Cloud Map * Limits in the AWS Cloud Map Developer Guide. *

* * @param registerInstanceRequest * @return Result of the RegisterInstance operation returned by the service. * @throws DuplicateRequestException * The operation is already in progress. * @throws 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. * @throws 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. * @throws ResourceLimitExceededException * The resource can't be created because you've reached the quota on the number of resources. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.RegisterInstance * @see AWS API Documentation */ @Override public RegisterInstanceResponse registerInstance(RegisterInstanceRequest registerInstanceRequest) throws DuplicateRequestException, InvalidInputException, ResourceInUseException, ResourceLimitExceededException, ServiceNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, RegisterInstanceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("RegisterInstance").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(registerInstanceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new RegisterInstanceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Adds one or more tags to the specified resource. *

* * @param tagResourceRequest * @return Result of the TagResource operation returned by the service. * @throws ResourceNotFoundException * The operation can't be completed because the resource was not found. * @throws 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. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.TagResource * @see AWS * API Documentation */ @Override public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws ResourceNotFoundException, TooManyTagsException, InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, TagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("TagResource").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(tagResourceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new TagResourceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Removes one or more tags from the specified resource. *

* * @param untagResourceRequest * @return Result of the UntagResource operation returned by the service. * @throws ResourceNotFoundException * The operation can't be completed because the resource was not found. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.UntagResource * @see AWS * API Documentation */ @Override public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws ResourceNotFoundException, InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UntagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("UntagResource").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(untagResourceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new UntagResourceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* 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 Result of the UpdateInstanceCustomHealthStatus operation returned by the service. * @throws InstanceNotFoundException * No instance exists with the specified ID, or the instance was recently registered, and information about * the instance hasn't propagated yet. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws CustomHealthNotFoundException * The health check for the instance that is specified by ServiceId and InstanceId * is not a custom health check. * @throws 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. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.UpdateInstanceCustomHealthStatus * @see AWS API Documentation */ @Override public UpdateInstanceCustomHealthStatusResponse updateInstanceCustomHealthStatus( UpdateInstanceCustomHealthStatusRequest updateInstanceCustomHealthStatusRequest) throws InstanceNotFoundException, ServiceNotFoundException, CustomHealthNotFoundException, InvalidInputException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, UpdateInstanceCustomHealthStatusResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler .execute(new ClientExecutionParams() .withOperationName("UpdateInstanceCustomHealthStatus").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(updateInstanceCustomHealthStatusRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new UpdateInstanceCustomHealthStatusRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* 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 is not deleted from the service. *

    *
  • *
*

* When you update settings for a service, AWS 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 Result of the UpdateService operation returned by the service. * @throws DuplicateRequestException * The operation is already in progress. * @throws 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. * @throws ServiceNotFoundException * No service exists with the specified ID. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ServiceDiscoveryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ServiceDiscoveryClient.UpdateService * @see AWS * API Documentation */ @Override public UpdateServiceResponse updateService(UpdateServiceRequest updateServiceRequest) throws DuplicateRequestException, InvalidInputException, ServiceNotFoundException, AwsServiceException, SdkClientException, ServiceDiscoveryException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UpdateServiceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("UpdateService").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(updateServiceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new UpdateServiceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } 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 HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } private > T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(ServiceDiscoveryException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("OperationNotFound") .exceptionBuilderSupplier(OperationNotFoundException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("TooManyTagsException") .exceptionBuilderSupplier(TooManyTagsException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("RequestLimitExceeded") .exceptionBuilderSupplier(RequestLimitExceededException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceInUse") .exceptionBuilderSupplier(ResourceInUseException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceNotFoundException") .exceptionBuilderSupplier(ResourceNotFoundException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("DuplicateRequest") .exceptionBuilderSupplier(DuplicateRequestException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ServiceAlreadyExists") .exceptionBuilderSupplier(ServiceAlreadyExistsException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ServiceNotFound") .exceptionBuilderSupplier(ServiceNotFoundException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("NamespaceAlreadyExists") .exceptionBuilderSupplier(NamespaceAlreadyExistsException::builder).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InstanceNotFound") .exceptionBuilderSupplier(InstanceNotFoundException::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()); } @Override public void close() { clientHandler.close(); } 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(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy