software.amazon.awssdk.services.shield.DefaultShieldAsyncClient Maven / Gradle / Ivy
Show all versions of shield Show documentation
/*
* 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.shield;
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.shield.model.AccessDeniedException;
import software.amazon.awssdk.services.shield.model.AccessDeniedForDependencyException;
import software.amazon.awssdk.services.shield.model.AssociateDrtLogBucketRequest;
import software.amazon.awssdk.services.shield.model.AssociateDrtLogBucketResponse;
import software.amazon.awssdk.services.shield.model.AssociateDrtRoleRequest;
import software.amazon.awssdk.services.shield.model.AssociateDrtRoleResponse;
import software.amazon.awssdk.services.shield.model.CreateProtectionRequest;
import software.amazon.awssdk.services.shield.model.CreateProtectionResponse;
import software.amazon.awssdk.services.shield.model.CreateSubscriptionRequest;
import software.amazon.awssdk.services.shield.model.CreateSubscriptionResponse;
import software.amazon.awssdk.services.shield.model.DeleteProtectionRequest;
import software.amazon.awssdk.services.shield.model.DeleteProtectionResponse;
import software.amazon.awssdk.services.shield.model.DescribeAttackRequest;
import software.amazon.awssdk.services.shield.model.DescribeAttackResponse;
import software.amazon.awssdk.services.shield.model.DescribeDrtAccessRequest;
import software.amazon.awssdk.services.shield.model.DescribeDrtAccessResponse;
import software.amazon.awssdk.services.shield.model.DescribeEmergencyContactSettingsRequest;
import software.amazon.awssdk.services.shield.model.DescribeEmergencyContactSettingsResponse;
import software.amazon.awssdk.services.shield.model.DescribeProtectionRequest;
import software.amazon.awssdk.services.shield.model.DescribeProtectionResponse;
import software.amazon.awssdk.services.shield.model.DescribeSubscriptionRequest;
import software.amazon.awssdk.services.shield.model.DescribeSubscriptionResponse;
import software.amazon.awssdk.services.shield.model.DisassociateDrtLogBucketRequest;
import software.amazon.awssdk.services.shield.model.DisassociateDrtLogBucketResponse;
import software.amazon.awssdk.services.shield.model.DisassociateDrtRoleRequest;
import software.amazon.awssdk.services.shield.model.DisassociateDrtRoleResponse;
import software.amazon.awssdk.services.shield.model.GetSubscriptionStateRequest;
import software.amazon.awssdk.services.shield.model.GetSubscriptionStateResponse;
import software.amazon.awssdk.services.shield.model.InternalErrorException;
import software.amazon.awssdk.services.shield.model.InvalidOperationException;
import software.amazon.awssdk.services.shield.model.InvalidPaginationTokenException;
import software.amazon.awssdk.services.shield.model.InvalidParameterException;
import software.amazon.awssdk.services.shield.model.InvalidResourceException;
import software.amazon.awssdk.services.shield.model.LimitsExceededException;
import software.amazon.awssdk.services.shield.model.ListAttacksRequest;
import software.amazon.awssdk.services.shield.model.ListAttacksResponse;
import software.amazon.awssdk.services.shield.model.ListProtectionsRequest;
import software.amazon.awssdk.services.shield.model.ListProtectionsResponse;
import software.amazon.awssdk.services.shield.model.LockedSubscriptionException;
import software.amazon.awssdk.services.shield.model.NoAssociatedRoleException;
import software.amazon.awssdk.services.shield.model.OptimisticLockException;
import software.amazon.awssdk.services.shield.model.ResourceAlreadyExistsException;
import software.amazon.awssdk.services.shield.model.ResourceNotFoundException;
import software.amazon.awssdk.services.shield.model.ShieldException;
import software.amazon.awssdk.services.shield.model.UpdateEmergencyContactSettingsRequest;
import software.amazon.awssdk.services.shield.model.UpdateEmergencyContactSettingsResponse;
import software.amazon.awssdk.services.shield.model.UpdateSubscriptionRequest;
import software.amazon.awssdk.services.shield.model.UpdateSubscriptionResponse;
import software.amazon.awssdk.services.shield.transform.AssociateDrtLogBucketRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.AssociateDrtRoleRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.CreateProtectionRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.CreateSubscriptionRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.DeleteProtectionRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.DescribeAttackRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.DescribeDrtAccessRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.DescribeEmergencyContactSettingsRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.DescribeProtectionRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.DescribeSubscriptionRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.DisassociateDrtLogBucketRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.DisassociateDrtRoleRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.GetSubscriptionStateRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.ListAttacksRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.ListProtectionsRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.UpdateEmergencyContactSettingsRequestMarshaller;
import software.amazon.awssdk.services.shield.transform.UpdateSubscriptionRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;
/**
* Internal implementation of {@link ShieldAsyncClient}.
*
* @see ShieldAsyncClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultShieldAsyncClient implements ShieldAsyncClient {
private static final Logger log = LoggerFactory.getLogger(DefaultShieldAsyncClient.class);
private final AsyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultShieldAsyncClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Authorizes the DDoS Response team (DRT) to access the specified Amazon S3 bucket containing your flow logs. You
* can associate up to 10 Amazon S3 buckets with your subscription.
*
*
* To use the services of the DRT and make an AssociateDRTLogBucket
request, you must be subscribed to
* the Business Support plan or the Enterprise Support plan.
*
*
* @param associateDrtLogBucketRequest
* @return A Java Future containing the result of the AssociateDRTLogBucket operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - InvalidOperationException Exception that indicates that the operation would not cause any change to
* occur.
* - NoAssociatedRoleException The ARN of the role that you specifed does not exist.
* - LimitsExceededException Exception that indicates that the operation would exceed a limit.
*
* Type
is the type of limit that would be exceeded.
*
*
* Limit
is the threshold that would be exceeded.
* - InvalidParameterException Exception that indicates that the parameters passed to the API are invalid.
*
* - AccessDeniedForDependencyException In order to grant the necessary access to the DDoS Response Team,
* the user submitting
AssociateDRTRole
must have the iam:PassRole
permission.
* This error indicates the user did not have the appropriate permissions. For more information, see Granting a User
* Permissions to Pass a Role to an AWS Service.
* - OptimisticLockException Exception that indicates that the protection state has been modified by
* another client. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.AssociateDRTLogBucket
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture associateDRTLogBucket(
AssociateDrtLogBucketRequest associateDrtLogBucketRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, AssociateDrtLogBucketResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("AssociateDRTLogBucket")
.withMarshaller(new AssociateDrtLogBucketRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(associateDrtLogBucketRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Authorizes the DDoS Response team (DRT), using the specified role, to access your AWS account to assist with DDoS
* attack mitigation during potential attacks. This enables the DRT to inspect your AWS WAF configuration and create
* or update AWS WAF rules and web ACLs.
*
*
* You can associate only one RoleArn
with your subscription. If you submit an
* AssociateDRTRole
request for an account that already has an associated role, the new
* RoleArn
will replace the existing RoleArn
.
*
*
* Prior to making the AssociateDRTRole
request, you must attach the AWSShieldDRTAccessPolicy managed policy to the role you will specify in the request. For more information
* see Attaching and
* Detaching IAM Policies. The role must also trust the service principal drt.shield.amazonaws.com
* . For more information, see IAM JSON
* Policy Elements: Principal.
*
*
* The DRT will have access only to your AWS WAF and Shield resources. By submitting this request, you authorize the
* DRT to inspect your AWS WAF and Shield configuration and create and update AWS WAF rules and web ACLs on your
* behalf. The DRT takes these actions only if explicitly authorized by you.
*
*
* You must have the iam:PassRole
permission to make an AssociateDRTRole
request. For more
* information, see Granting a
* User Permissions to Pass a Role to an AWS Service.
*
*
* To use the services of the DRT and make an AssociateDRTRole
request, you must be subscribed to the
* Business Support plan or the Enterprise Support plan.
*
*
* @param associateDrtRoleRequest
* @return A Java Future containing the result of the AssociateDRTRole operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - InvalidOperationException Exception that indicates that the operation would not cause any change to
* occur.
* - InvalidParameterException Exception that indicates that the parameters passed to the API are invalid.
*
* - AccessDeniedForDependencyException In order to grant the necessary access to the DDoS Response Team,
* the user submitting
AssociateDRTRole
must have the iam:PassRole
permission.
* This error indicates the user did not have the appropriate permissions. For more information, see Granting a User
* Permissions to Pass a Role to an AWS Service.
* - OptimisticLockException Exception that indicates that the protection state has been modified by
* another client. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.AssociateDRTRole
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture associateDRTRole(AssociateDrtRoleRequest associateDrtRoleRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, AssociateDrtRoleResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("AssociateDRTRole")
.withMarshaller(new AssociateDrtRoleRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(associateDrtRoleRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Enables AWS Shield Advanced for a specific AWS resource. The resource can be an Amazon CloudFront distribution,
* Elastic Load Balancing load balancer, AWS Global Accelerator accelerator, Elastic IP Address, or an Amazon Route
* 53 hosted zone.
*
*
* You can add protection to only a single resource with each CreateProtection request. If you want to add
* protection to multiple resources at once, use the AWS WAF
* console. For more information see Getting Started with AWS
* Shield Advanced and Add AWS Shield
* Advanced Protection to more AWS Resources.
*
*
* @param createProtectionRequest
* @return A Java Future containing the result of the CreateProtection operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - InvalidResourceException Exception that indicates that the resource is invalid. You might not have
* access to the resource, or the resource might not exist.
* - InvalidOperationException Exception that indicates that the operation would not cause any change to
* occur.
* - LimitsExceededException Exception that indicates that the operation would exceed a limit.
*
* Type
is the type of limit that would be exceeded.
*
*
* Limit
is the threshold that would be exceeded.
* - ResourceAlreadyExistsException Exception indicating the specified resource already exists.
* - OptimisticLockException Exception that indicates that the protection state has been modified by
* another client. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.CreateProtection
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture createProtection(CreateProtectionRequest createProtectionRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateProtectionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateProtection")
.withMarshaller(new CreateProtectionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(createProtectionRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Activates AWS Shield Advanced for an account.
*
*
* As part of this request you can specify EmergencySettings
that automaticaly grant the DDoS response
* team (DRT) needed permissions to assist you during a suspected DDoS attack. For more information see Authorize the DDoS Response Team
* to Create Rules and Web ACLs on Your Behalf.
*
*
* When you initally create a subscription, your subscription is set to be automatically renewed at the end of the
* existing subscription period. You can change this by submitting an UpdateSubscription
request.
*
*
* @param createSubscriptionRequest
* @return A Java Future containing the result of the CreateSubscription operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - ResourceAlreadyExistsException Exception indicating the specified resource already exists.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.CreateSubscription
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture createSubscription(CreateSubscriptionRequest createSubscriptionRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateSubscriptionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateSubscription")
.withMarshaller(new CreateSubscriptionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(createSubscriptionRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Deletes an AWS Shield Advanced Protection.
*
*
* @param deleteProtectionRequest
* @return A Java Future containing the result of the DeleteProtection operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - OptimisticLockException Exception that indicates that the protection state has been modified by
* another client. You can retry the request.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.DeleteProtection
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture deleteProtection(DeleteProtectionRequest deleteProtectionRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteProtectionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteProtection")
.withMarshaller(new DeleteProtectionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(deleteProtectionRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Describes the details of a DDoS attack.
*
*
* @param describeAttackRequest
* @return A Java Future containing the result of the DescribeAttack operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - AccessDeniedException Exception that indicates the specified
AttackId
does not exist, or
* the requester does not have the appropriate permissions to access the AttackId
.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.DescribeAttack
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture describeAttack(DescribeAttackRequest describeAttackRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeAttackResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeAttack")
.withMarshaller(new DescribeAttackRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeAttackRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns the current role and list of Amazon S3 log buckets used by the DDoS Response team (DRT) to access your
* AWS account while assisting with attack mitigation.
*
*
* @param describeDrtAccessRequest
* @return A Java Future containing the result of the DescribeDRTAccess operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.DescribeDRTAccess
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture describeDRTAccess(DescribeDrtAccessRequest describeDrtAccessRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeDrtAccessResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeDRTAccess")
.withMarshaller(new DescribeDrtAccessRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeDrtAccessRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists the email addresses that the DRT can use to contact you during a suspected attack.
*
*
* @param describeEmergencyContactSettingsRequest
* @return A Java Future containing the result of the DescribeEmergencyContactSettings operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.DescribeEmergencyContactSettings
* @see AWS API Documentation
*/
@Override
public CompletableFuture describeEmergencyContactSettings(
DescribeEmergencyContactSettingsRequest describeEmergencyContactSettingsRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, DescribeEmergencyContactSettingsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeEmergencyContactSettings")
.withMarshaller(new DescribeEmergencyContactSettingsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeEmergencyContactSettingsRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists the details of a Protection object.
*
*
* @param describeProtectionRequest
* @return A Java Future containing the result of the DescribeProtection operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - InvalidParameterException Exception that indicates that the parameters passed to the API are invalid.
*
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.DescribeProtection
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture describeProtection(DescribeProtectionRequest describeProtectionRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeProtectionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeProtection")
.withMarshaller(new DescribeProtectionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeProtectionRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Provides details about the AWS Shield Advanced subscription for an account.
*
*
* @param describeSubscriptionRequest
* @return A Java Future containing the result of the DescribeSubscription operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.DescribeSubscription
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture describeSubscription(
DescribeSubscriptionRequest describeSubscriptionRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeSubscriptionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeSubscription")
.withMarshaller(new DescribeSubscriptionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(describeSubscriptionRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Removes the DDoS Response team's (DRT) access to the specified Amazon S3 bucket containing your flow logs.
*
*
* To make a DisassociateDRTLogBucket
request, you must be subscribed to the Business Support plan or the Enterprise Support plan. However, if you are
* not subscribed to one of these support plans, but had been previously and had granted the DRT access to your
* account, you can submit a DisassociateDRTLogBucket
request to remove this access.
*
*
* @param disassociateDrtLogBucketRequest
* @return A Java Future containing the result of the DisassociateDRTLogBucket operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - InvalidOperationException Exception that indicates that the operation would not cause any change to
* occur.
* - NoAssociatedRoleException The ARN of the role that you specifed does not exist.
* - AccessDeniedForDependencyException In order to grant the necessary access to the DDoS Response Team,
* the user submitting
AssociateDRTRole
must have the iam:PassRole
permission.
* This error indicates the user did not have the appropriate permissions. For more information, see Granting a User
* Permissions to Pass a Role to an AWS Service.
* - OptimisticLockException Exception that indicates that the protection state has been modified by
* another client. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.DisassociateDRTLogBucket
* @see AWS API Documentation
*/
@Override
public CompletableFuture disassociateDRTLogBucket(
DisassociateDrtLogBucketRequest disassociateDrtLogBucketRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DisassociateDrtLogBucketResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DisassociateDRTLogBucket")
.withMarshaller(new DisassociateDrtLogBucketRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(disassociateDrtLogBucketRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Removes the DDoS Response team's (DRT) access to your AWS account.
*
*
* To make a DisassociateDRTRole
request, you must be subscribed to the Business Support plan or the Enterprise Support plan. However, if you are
* not subscribed to one of these support plans, but had been previously and had granted the DRT access to your
* account, you can submit a DisassociateDRTRole
request to remove this access.
*
*
* @param disassociateDrtRoleRequest
* @return A Java Future containing the result of the DisassociateDRTRole operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - InvalidOperationException Exception that indicates that the operation would not cause any change to
* occur.
* - OptimisticLockException Exception that indicates that the protection state has been modified by
* another client. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.DisassociateDRTRole
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture disassociateDRTRole(
DisassociateDrtRoleRequest disassociateDrtRoleRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DisassociateDrtRoleResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DisassociateDRTRole")
.withMarshaller(new DisassociateDrtRoleRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(disassociateDrtRoleRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns the SubscriptionState
, either Active
or Inactive
.
*
*
* @param getSubscriptionStateRequest
* @return A Java Future containing the result of the GetSubscriptionState operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.GetSubscriptionState
* @see AWS
* API Documentation
*/
@Override
public CompletableFuture getSubscriptionState(
GetSubscriptionStateRequest getSubscriptionStateRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetSubscriptionStateResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetSubscriptionState")
.withMarshaller(new GetSubscriptionStateRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(getSubscriptionStateRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Returns all ongoing DDoS attacks or all DDoS attacks during a specified time period.
*
*
* @param listAttacksRequest
* @return A Java Future containing the result of the ListAttacks operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - InvalidParameterException Exception that indicates that the parameters passed to the API are invalid.
*
* - InvalidOperationException Exception that indicates that the operation would not cause any change to
* occur.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.ListAttacks
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listAttacks(ListAttacksRequest listAttacksRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListAttacksResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListAttacks").withMarshaller(new ListAttacksRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(listAttacksRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Lists all Protection objects for the account.
*
*
* @param listProtectionsRequest
* @return A Java Future containing the result of the ListProtections operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - InvalidPaginationTokenException Exception that indicates that the NextToken specified in the request
* is invalid. Submit the request using the NextToken value that was returned in the response.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.ListProtections
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture listProtections(ListProtectionsRequest listProtectionsRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListProtectionsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListProtections")
.withMarshaller(new ListProtectionsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(listProtectionsRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates the details of the list of email addresses that the DRT can use to contact you during a suspected attack.
*
*
* @param updateEmergencyContactSettingsRequest
* @return A Java Future containing the result of the UpdateEmergencyContactSettings operation returned by the
* service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - InvalidParameterException Exception that indicates that the parameters passed to the API are invalid.
*
* - OptimisticLockException Exception that indicates that the protection state has been modified by
* another client. You can retry the request.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.UpdateEmergencyContactSettings
* @see AWS API Documentation
*/
@Override
public CompletableFuture updateEmergencyContactSettings(
UpdateEmergencyContactSettingsRequest updateEmergencyContactSettingsRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateEmergencyContactSettingsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateEmergencyContactSettings")
.withMarshaller(new UpdateEmergencyContactSettingsRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(updateEmergencyContactSettingsRequest));
return executeFuture;
} catch (Throwable t) {
return CompletableFutureUtils.failedFuture(t);
}
}
/**
*
* Updates the details of an existing subscription. Only enter values for parameters you want to change. Empty
* parameters are not updated.
*
*
* @param updateSubscriptionRequest
* @return A Java Future containing the result of the UpdateSubscription operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following
* exceptions.
*
* - InternalErrorException Exception that indicates that a problem occurred with the service
* infrastructure. You can retry the request.
* - LockedSubscriptionException You are trying to update a subscription that has not yet completed the
* 1-year commitment. You can change the
AutoRenew
parameter during the last 30 days of your
* subscription. This exception indicates that you are attempting to change AutoRenew
prior to
* that period.
* - ResourceNotFoundException Exception indicating the specified resource does not exist.
* - InvalidParameterException Exception that indicates that the parameters passed to the API are invalid.
*
* - OptimisticLockException Exception that indicates that the protection state has been modified by
* another client. You can retry the request.
* - 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.
* - ShieldException Base class for all service exceptions. Unknown exceptions will be thrown as an
* instance of this type.
*
* @sample ShieldAsyncClient.UpdateSubscription
* @see AWS API
* Documentation
*/
@Override
public CompletableFuture updateSubscription(UpdateSubscriptionRequest updateSubscriptionRequest) {
try {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateSubscriptionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
CompletableFuture executeFuture = clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateSubscription")
.withMarshaller(new UpdateSubscriptionRequestMarshaller(protocolFactory))
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withInput(updateSubscriptionRequest));
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(ShieldException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("OptimisticLockException")
.exceptionBuilderSupplier(OptimisticLockException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LockedSubscriptionException")
.exceptionBuilderSupplier(LockedSubscriptionException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidResourceException")
.exceptionBuilderSupplier(InvalidResourceException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidParameterException")
.exceptionBuilderSupplier(InvalidParameterException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidOperationException")
.exceptionBuilderSupplier(InvalidOperationException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceAlreadyExistsException")
.exceptionBuilderSupplier(ResourceAlreadyExistsException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalErrorException")
.exceptionBuilderSupplier(InternalErrorException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidPaginationTokenException")
.exceptionBuilderSupplier(InvalidPaginationTokenException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitsExceededException")
.exceptionBuilderSupplier(LimitsExceededException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("NoAssociatedRoleException")
.exceptionBuilderSupplier(NoAssociatedRoleException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedForDependencyException")
.exceptionBuilderSupplier(AccessDeniedForDependencyException::builder).build());
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
}