software.amazon.awssdk.services.globalaccelerator.DefaultGlobalAcceleratorAsyncClient Maven / Gradle / Ivy
/*
* Copyright 2014-2019 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.globalaccelerator;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.handler.AsyncClientHandler;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.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.globalaccelerator.model.AcceleratorNotDisabledException;
import software.amazon.awssdk.services.globalaccelerator.model.AcceleratorNotFoundException;
import software.amazon.awssdk.services.globalaccelerator.model.AccessDeniedException;
import software.amazon.awssdk.services.globalaccelerator.model.AssociatedEndpointGroupFoundException;
import software.amazon.awssdk.services.globalaccelerator.model.AssociatedListenerFoundException;
import software.amazon.awssdk.services.globalaccelerator.model.CreateAcceleratorRequest;
import software.amazon.awssdk.services.globalaccelerator.model.CreateAcceleratorResponse;
import software.amazon.awssdk.services.globalaccelerator.model.CreateEndpointGroupRequest;
import software.amazon.awssdk.services.globalaccelerator.model.CreateEndpointGroupResponse;
import software.amazon.awssdk.services.globalaccelerator.model.CreateListenerRequest;
import software.amazon.awssdk.services.globalaccelerator.model.CreateListenerResponse;
import software.amazon.awssdk.services.globalaccelerator.model.DeleteAcceleratorRequest;
import software.amazon.awssdk.services.globalaccelerator.model.DeleteAcceleratorResponse;
import software.amazon.awssdk.services.globalaccelerator.model.DeleteEndpointGroupRequest;
import software.amazon.awssdk.services.globalaccelerator.model.DeleteEndpointGroupResponse;
import software.amazon.awssdk.services.globalaccelerator.model.DeleteListenerRequest;
import software.amazon.awssdk.services.globalaccelerator.model.DeleteListenerResponse;
import software.amazon.awssdk.services.globalaccelerator.model.DescribeAcceleratorAttributesRequest;
import software.amazon.awssdk.services.globalaccelerator.model.DescribeAcceleratorAttributesResponse;
import software.amazon.awssdk.services.globalaccelerator.model.DescribeAcceleratorRequest;
import software.amazon.awssdk.services.globalaccelerator.model.DescribeAcceleratorResponse;
import software.amazon.awssdk.services.globalaccelerator.model.DescribeEndpointGroupRequest;
import software.amazon.awssdk.services.globalaccelerator.model.DescribeEndpointGroupResponse;
import software.amazon.awssdk.services.globalaccelerator.model.DescribeListenerRequest;
import software.amazon.awssdk.services.globalaccelerator.model.DescribeListenerResponse;
import software.amazon.awssdk.services.globalaccelerator.model.EndpointGroupAlreadyExistsException;
import software.amazon.awssdk.services.globalaccelerator.model.EndpointGroupNotFoundException;
import software.amazon.awssdk.services.globalaccelerator.model.GlobalAcceleratorException;
import software.amazon.awssdk.services.globalaccelerator.model.InternalServiceErrorException;
import software.amazon.awssdk.services.globalaccelerator.model.InvalidArgumentException;
import software.amazon.awssdk.services.globalaccelerator.model.InvalidNextTokenException;
import software.amazon.awssdk.services.globalaccelerator.model.InvalidPortRangeException;
import software.amazon.awssdk.services.globalaccelerator.model.LimitExceededException;
import software.amazon.awssdk.services.globalaccelerator.model.ListAcceleratorsRequest;
import software.amazon.awssdk.services.globalaccelerator.model.ListAcceleratorsResponse;
import software.amazon.awssdk.services.globalaccelerator.model.ListEndpointGroupsRequest;
import software.amazon.awssdk.services.globalaccelerator.model.ListEndpointGroupsResponse;
import software.amazon.awssdk.services.globalaccelerator.model.ListListenersRequest;
import software.amazon.awssdk.services.globalaccelerator.model.ListListenersResponse;
import software.amazon.awssdk.services.globalaccelerator.model.ListenerNotFoundException;
import software.amazon.awssdk.services.globalaccelerator.model.UpdateAcceleratorAttributesRequest;
import software.amazon.awssdk.services.globalaccelerator.model.UpdateAcceleratorAttributesResponse;
import software.amazon.awssdk.services.globalaccelerator.model.UpdateAcceleratorRequest;
import software.amazon.awssdk.services.globalaccelerator.model.UpdateAcceleratorResponse;
import software.amazon.awssdk.services.globalaccelerator.model.UpdateEndpointGroupRequest;
import software.amazon.awssdk.services.globalaccelerator.model.UpdateEndpointGroupResponse;
import software.amazon.awssdk.services.globalaccelerator.model.UpdateListenerRequest;
import software.amazon.awssdk.services.globalaccelerator.model.UpdateListenerResponse;
import software.amazon.awssdk.services.globalaccelerator.transform.CreateAcceleratorRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.CreateEndpointGroupRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.CreateListenerRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.DeleteAcceleratorRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.DeleteEndpointGroupRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.DeleteListenerRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.DescribeAcceleratorAttributesRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.DescribeAcceleratorRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.DescribeEndpointGroupRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.DescribeListenerRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.ListAcceleratorsRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.ListEndpointGroupsRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.ListListenersRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.UpdateAcceleratorAttributesRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.UpdateAcceleratorRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.UpdateEndpointGroupRequestMarshaller;
import software.amazon.awssdk.services.globalaccelerator.transform.UpdateListenerRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link GlobalAcceleratorAsyncClient}.
*
* @see GlobalAcceleratorAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultGlobalAcceleratorAsyncClient implements GlobalAcceleratorAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultGlobalAcceleratorAsyncClient.class);
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultGlobalAcceleratorAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Create an accelerator. An accelerator includes one or more listeners that process inbound connections and direct
* traffic to one or more endpoint groups, each of which includes endpoints, such as Network Load Balancers. To see
* an AWS CLI example of creating an accelerator, scroll down to Example.
*
*
*
* You must specify the US-West-2 (Oregon) Region to create or update accelerators.
*
*
*
* @param createAcceleratorRequest
* @return A Java Future containing the result of the CreateAccelerator operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - InvalidArgumentException An argument that you specified is invalid.
* - LimitExceededException Processing your request would cause you to exceed an AWS Global Accelerator
* limit.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.CreateAccelerator
* @see AWS API Documentation
*/
@Override
public CompletableFuture createAccelerator(CreateAcceleratorRequest createAcceleratorRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateAcceleratorResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateAccelerator")
.withMarshaller(new CreateAcceleratorRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(createAcceleratorRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Create an endpoint group for the specified listener. An endpoint group is a collection of endpoints in one AWS
* Region. To see an AWS CLI example of creating an endpoint group, scroll down to Example.
*
*
* @param createEndpointGroupRequest
* @return A Java Future containing the result of the CreateEndpointGroup operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - AcceleratorNotFoundException The accelerator that you specified doesn't exist.
* - EndpointGroupAlreadyExistsException The endpoint group that you specified already exists.
* - ListenerNotFoundException The listener that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - InvalidArgumentException An argument that you specified is invalid.
* - LimitExceededException Processing your request would cause you to exceed an AWS Global Accelerator
* limit.
* - AccessDeniedException You don't have access permission.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.CreateEndpointGroup
* @see AWS API Documentation
*/
@Override
public CompletableFuture createEndpointGroup(
CreateEndpointGroupRequest createEndpointGroupRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateEndpointGroupResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateEndpointGroup")
.withMarshaller(new CreateEndpointGroupRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(createEndpointGroupRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Create a listener to process inbound connections from clients to an accelerator. Connections arrive to assigned
* static IP addresses on a port, port range, or list of port ranges that you specify. To see an AWS CLI example of
* creating a listener, scroll down to Example.
*
*
* @param createListenerRequest
* @return A Java Future containing the result of the CreateListener operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - AcceleratorNotFoundException The accelerator that you specified doesn't exist.
* - InvalidPortRangeException The port numbers that you specified are not valid numbers or are not unique
* for this accelerator.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - LimitExceededException Processing your request would cause you to exceed an AWS Global Accelerator
* limit.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.CreateListener
* @see AWS API Documentation
*/
@Override
public CompletableFuture createListener(CreateListenerRequest createListenerRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateListenerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateListener")
.withMarshaller(new CreateListenerRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(createListenerRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Delete an accelerator. Note: before you can delete an accelerator, you must disable it and remove all dependent
* resources (listeners and endpoint groups).
*
*
* @param deleteAcceleratorRequest
* @return A Java Future containing the result of the DeleteAccelerator operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - AcceleratorNotFoundException The accelerator that you specified doesn't exist.
* - AcceleratorNotDisabledException The accelerator that you specified could not be disabled.
* - AssociatedListenerFoundException The accelerator that you specified has a listener associated with
* it. You must remove all dependent resources from an accelerator before you can delete it.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - InvalidArgumentException An argument that you specified is invalid.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.DeleteAccelerator
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteAccelerator(DeleteAcceleratorRequest deleteAcceleratorRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteAcceleratorResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteAccelerator")
.withMarshaller(new DeleteAcceleratorRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(deleteAcceleratorRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Delete an endpoint group from a listener.
*
*
* @param deleteEndpointGroupRequest
* @return A Java Future containing the result of the DeleteEndpointGroup operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - EndpointGroupNotFoundException The endpoint group that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.DeleteEndpointGroup
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteEndpointGroup(
DeleteEndpointGroupRequest deleteEndpointGroupRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteEndpointGroupResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteEndpointGroup")
.withMarshaller(new DeleteEndpointGroupRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(deleteEndpointGroupRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Delete a listener from an accelerator.
*
*
* @param deleteListenerRequest
* @return A Java Future containing the result of the DeleteListener operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - ListenerNotFoundException The listener that you specified doesn't exist.
* - AssociatedEndpointGroupFoundException The listener that you specified has an endpoint group
* associated with it. You must remove all dependent resources from a listener before you can delete it.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.DeleteListener
* @see AWS API Documentation
*/
@Override
public CompletableFuture deleteListener(DeleteListenerRequest deleteListenerRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteListenerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteListener")
.withMarshaller(new DeleteListenerRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(deleteListenerRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Describe an accelerator. To see an AWS CLI example of describing an accelerator, scroll down to Example.
*
*
* @param describeAcceleratorRequest
* @return A Java Future containing the result of the DescribeAccelerator operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - AcceleratorNotFoundException The accelerator that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - InvalidArgumentException An argument that you specified is invalid.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.DescribeAccelerator
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeAccelerator(
DescribeAcceleratorRequest describeAcceleratorRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeAcceleratorResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeAccelerator")
.withMarshaller(new DescribeAcceleratorRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeAcceleratorRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Describe the attributes of an accelerator.
*
*
* @param describeAcceleratorAttributesRequest
* @return A Java Future containing the result of the DescribeAcceleratorAttributes operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - AcceleratorNotFoundException The accelerator that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - InvalidArgumentException An argument that you specified is invalid.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.DescribeAcceleratorAttributes
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeAcceleratorAttributes(
DescribeAcceleratorAttributesRequest describeAcceleratorAttributesRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeAcceleratorAttributesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeAcceleratorAttributes")
.withMarshaller(new DescribeAcceleratorAttributesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeAcceleratorAttributesRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Describe an endpoint group.
*
*
* @param describeEndpointGroupRequest
* @return A Java Future containing the result of the DescribeEndpointGroup operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - EndpointGroupNotFoundException The endpoint group that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.DescribeEndpointGroup
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeEndpointGroup(
DescribeEndpointGroupRequest describeEndpointGroupRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeEndpointGroupResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeEndpointGroup")
.withMarshaller(new DescribeEndpointGroupRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeEndpointGroupRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Describe a listener.
*
*
* @param describeListenerRequest
* @return A Java Future containing the result of the DescribeListener operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - ListenerNotFoundException The listener that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.DescribeListener
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeListener(DescribeListenerRequest describeListenerRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeListenerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeListener")
.withMarshaller(new DescribeListenerRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeListenerRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* List the accelerators for an AWS account.
*
*
* @param listAcceleratorsRequest
* @return A Java Future containing the result of the ListAccelerators operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - InvalidNextTokenException There isn't another item to return.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.ListAccelerators
* @see AWS API Documentation
*/
@Override
public CompletableFuture listAccelerators(ListAcceleratorsRequest listAcceleratorsRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListAcceleratorsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListAccelerators")
.withMarshaller(new ListAcceleratorsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(listAcceleratorsRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* List the endpoint groups that are associated with a listener.
*
*
* @param listEndpointGroupsRequest
* @return A Java Future containing the result of the ListEndpointGroups operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - ListenerNotFoundException The listener that you specified doesn't exist.
* - InvalidNextTokenException There isn't another item to return.
* - InvalidArgumentException An argument that you specified is invalid.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.ListEndpointGroups
* @see AWS API Documentation
*/
@Override
public CompletableFuture listEndpointGroups(ListEndpointGroupsRequest listEndpointGroupsRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListEndpointGroupsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListEndpointGroups")
.withMarshaller(new ListEndpointGroupsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(listEndpointGroupsRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* List the listeners for an accelerator.
*
*
* @param listListenersRequest
* @return A Java Future containing the result of the ListListeners operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - AcceleratorNotFoundException The accelerator that you specified doesn't exist.
* - InvalidNextTokenException There isn't another item to return.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.ListListeners
* @see AWS API Documentation
*/
@Override
public CompletableFuture listListeners(ListListenersRequest listListenersRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListListenersResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListListeners")
.withMarshaller(new ListListenersRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(listListenersRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Update an accelerator. To see an AWS CLI example of updating an accelerator, scroll down to Example.
*
*
*
* You must specify the US-West-2 (Oregon) Region to create or update accelerators.
*
*
*
* @param updateAcceleratorRequest
* @return A Java Future containing the result of the UpdateAccelerator operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - AcceleratorNotFoundException The accelerator that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - InvalidArgumentException An argument that you specified is invalid.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.UpdateAccelerator
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateAccelerator(UpdateAcceleratorRequest updateAcceleratorRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateAcceleratorResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateAccelerator")
.withMarshaller(new UpdateAcceleratorRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(updateAcceleratorRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Update the attributes for an accelerator. To see an AWS CLI example of updating an accelerator to enable flow
* logs, scroll down to Example.
*
*
* @param updateAcceleratorAttributesRequest
* @return A Java Future containing the result of the UpdateAcceleratorAttributes operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - AcceleratorNotFoundException The accelerator that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - InvalidArgumentException An argument that you specified is invalid.
* - AccessDeniedException You don't have access permission.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.UpdateAcceleratorAttributes
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateAcceleratorAttributes(
UpdateAcceleratorAttributesRequest updateAcceleratorAttributesRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateAcceleratorAttributesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateAcceleratorAttributes")
.withMarshaller(new UpdateAcceleratorAttributesRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(updateAcceleratorAttributesRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Update an endpoint group. To see an AWS CLI example of updating an endpoint group, scroll down to Example.
*
*
* @param updateEndpointGroupRequest
* @return A Java Future containing the result of the UpdateEndpointGroup operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - EndpointGroupNotFoundException The endpoint group that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - LimitExceededException Processing your request would cause you to exceed an AWS Global Accelerator
* limit.
* - AccessDeniedException You don't have access permission.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.UpdateEndpointGroup
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateEndpointGroup(
UpdateEndpointGroupRequest updateEndpointGroupRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateEndpointGroupResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateEndpointGroup")
.withMarshaller(new UpdateEndpointGroupRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(updateEndpointGroupRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Update a listener.
*
*
* @param updateListenerRequest
* @return A Java Future containing the result of the UpdateListener operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InvalidArgumentException An argument that you specified is invalid.
* - InvalidPortRangeException The port numbers that you specified are not valid numbers or are not unique
* for this accelerator.
* - ListenerNotFoundException The listener that you specified doesn't exist.
* - InternalServiceErrorException There was an internal error for AWS Global Accelerator.
* - LimitExceededException Processing your request would cause you to exceed an AWS Global Accelerator
* limit.
* - SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
* Can be used for catch all scenarios.
* - SdkClientException If any client side error occurs such as an IO related failure, failure to get
* credentials, etc.
* - GlobalAcceleratorException Base class for all service exceptions. Unknown exceptions will be thrown
* as an instance of this type.
*
* @sample GlobalAcceleratorAsyncClient.UpdateListener
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateListener(UpdateListenerRequest updateListenerRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateListenerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateListener")
.withMarshaller(new UpdateListenerRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(updateListenerRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
@Override
public void close() {
clientHandler.close();
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(GlobalAcceleratorException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidArgumentException")
.exceptionBuilderSupplier(InvalidArgumentException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ListenerNotFoundException")
.exceptionBuilderSupplier(ListenerNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AcceleratorNotFoundException")
.exceptionBuilderSupplier(AcceleratorNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AssociatedListenerFoundException")
.exceptionBuilderSupplier(AssociatedListenerFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServiceErrorException")
.exceptionBuilderSupplier(InternalServiceErrorException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AssociatedEndpointGroupFoundException")
.exceptionBuilderSupplier(AssociatedEndpointGroupFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("EndpointGroupNotFoundException")
.exceptionBuilderSupplier(EndpointGroupNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AcceleratorNotDisabledException")
.exceptionBuilderSupplier(AcceleratorNotDisabledException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidNextTokenException")
.exceptionBuilderSupplier(InvalidNextTokenException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("EndpointGroupAlreadyExistsException")
.exceptionBuilderSupplier(EndpointGroupAlreadyExistsException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidPortRangeException")
.exceptionBuilderSupplier(InvalidPortRangeException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitExceededException")
.exceptionBuilderSupplier(LimitExceededException::builder).build());
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
}