/*
* Copyright 2018-2023 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 com.amazonaws.services.ebs;
import org.w3c.dom.*;
import java.net.*;
import java.util.*;
import javax.annotation.Generated;
import org.apache.commons.logging.*;
import com.amazonaws.*;
import com.amazonaws.annotation.SdkInternalApi;
import com.amazonaws.auth.*;
import com.amazonaws.handlers.*;
import com.amazonaws.http.*;
import com.amazonaws.internal.*;
import com.amazonaws.internal.auth.*;
import com.amazonaws.metrics.*;
import com.amazonaws.regions.*;
import com.amazonaws.transform.*;
import com.amazonaws.util.*;
import com.amazonaws.protocol.json.*;
import com.amazonaws.util.AWSRequestMetrics.Field;
import com.amazonaws.annotation.ThreadSafe;
import com.amazonaws.client.AwsSyncClientParams;
import com.amazonaws.client.builder.AdvancedConfig;
import com.amazonaws.services.ebs.AmazonEBSClientBuilder;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.ebs.model.*;
import com.amazonaws.services.ebs.model.transform.*;
/**
* Client for accessing Amazon EBS. All service calls made using this client are blocking, and will not return until the
* service call completes.
*
*
* You can use the Amazon Elastic Block Store (Amazon EBS) direct APIs to create Amazon EBS snapshots, write data
* directly to your snapshots, read data on your snapshots, and identify the differences or changes between two
* snapshots. If you’re an independent software vendor (ISV) who offers backup services for Amazon EBS, the EBS direct
* APIs make it more efficient and cost-effective to track incremental changes on your Amazon EBS volumes through
* snapshots. This can be done without having to create new volumes from snapshots, and then use Amazon Elastic Compute
* Cloud (Amazon EC2) instances to compare the differences.
*
*
* You can create incremental snapshots directly from data on-premises into volumes and the cloud to use for quick
* disaster recovery. With the ability to write and read snapshots, you can write your on-premises data to an snapshot
* during a disaster. Then after recovery, you can restore it back to Amazon Web Services or on-premises from the
* snapshot. You no longer need to build and maintain complex mechanisms to copy data to and from Amazon EBS.
*
*
* This API reference provides detailed information about the actions, data types, parameters, and errors of the EBS
* direct APIs. For more information about the elements that make up the EBS direct APIs, and examples of how to use
* them effectively, see Accessing the Contents of an
* Amazon EBS Snapshot in the Amazon Elastic Compute Cloud User Guide. For more information about the
* supported Amazon Web Services Regions, endpoints, and service quotas for the EBS direct APIs, see Amazon Elastic Block Store Endpoints and
* Quotas in the Amazon Web Services General Reference.
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AmazonEBSClient extends AmazonWebServiceClient implements AmazonEBS {
/** Provider for AWS credentials. */
private final AWSCredentialsProvider awsCredentialsProvider;
private static final Log log = LogFactory.getLog(AmazonEBS.class);
/** Default signing name for the service. */
private static final String DEFAULT_SIGNING_NAME = "ebs";
/** Client configuration factory providing ClientConfigurations tailored to this client */
protected static final ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
private final AdvancedConfig advancedConfig;
private static final com.amazonaws.protocol.json.SdkJsonProtocolFactory protocolFactory = new com.amazonaws.protocol.json.SdkJsonProtocolFactory(
new JsonClientMetadata()
.withProtocolVersion("1.1")
.withSupportsCbor(false)
.withSupportsIon(false)
.withContentTypeOverride("application/json")
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("AccessDeniedException").withExceptionUnmarshaller(
com.amazonaws.services.ebs.model.transform.AccessDeniedExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ValidationException").withExceptionUnmarshaller(
com.amazonaws.services.ebs.model.transform.ValidationExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ConflictException").withExceptionUnmarshaller(
com.amazonaws.services.ebs.model.transform.ConflictExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("RequestThrottledException").withExceptionUnmarshaller(
com.amazonaws.services.ebs.model.transform.RequestThrottledExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ResourceNotFoundException").withExceptionUnmarshaller(
com.amazonaws.services.ebs.model.transform.ResourceNotFoundExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ServiceQuotaExceededException").withExceptionUnmarshaller(
com.amazonaws.services.ebs.model.transform.ServiceQuotaExceededExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("ConcurrentLimitExceededException").withExceptionUnmarshaller(
com.amazonaws.services.ebs.model.transform.ConcurrentLimitExceededExceptionUnmarshaller.getInstance()))
.addErrorMetadata(
new JsonErrorShapeMetadata().withErrorCode("InternalServerException").withExceptionUnmarshaller(
com.amazonaws.services.ebs.model.transform.InternalServerExceptionUnmarshaller.getInstance()))
.withBaseServiceExceptionClass(com.amazonaws.services.ebs.model.AmazonEBSException.class));
public static AmazonEBSClientBuilder builder() {
return AmazonEBSClientBuilder.standard();
}
/**
* Constructs a new client to invoke service methods on Amazon EBS using the specified parameters.
*
*
* All service calls made using this new client object are blocking, and will not return until the service call
* completes.
*
* @param clientParams
* Object providing client parameters.
*/
AmazonEBSClient(AwsSyncClientParams clientParams) {
this(clientParams, false);
}
/**
* Constructs a new client to invoke service methods on Amazon EBS using the specified parameters.
*
*
* All service calls made using this new client object are blocking, and will not return until the service call
* completes.
*
* @param clientParams
* Object providing client parameters.
*/
AmazonEBSClient(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled) {
super(clientParams);
this.awsCredentialsProvider = clientParams.getCredentialsProvider();
this.advancedConfig = clientParams.getAdvancedConfig();
init();
}
private void init() {
setServiceNameIntern(DEFAULT_SIGNING_NAME);
setEndpointPrefix(ENDPOINT_PREFIX);
// calling this.setEndPoint(...) will also modify the signer accordingly
setEndpoint("ebs.us-east-1.amazonaws.com");
HandlerChainFactory chainFactory = new HandlerChainFactory();
requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/ebs/request.handlers"));
requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/ebs/request.handler2s"));
requestHandler2s.addAll(chainFactory.getGlobalHandlers());
}
/**
*
* Seals and completes the snapshot after all of the required blocks of data have been written to it. Completing the
* snapshot changes the status to completed
. You cannot write new blocks to a snapshot after it has
* been completed.
*
*
*
* You should always retry requests that receive server (5xx
) error responses, and
* ThrottlingException
and RequestThrottledException
client error responses. For more
* information see Error
* retries in the Amazon Elastic Compute Cloud User Guide.
*
*
*
* @param completeSnapshotRequest
* @return Result of the CompleteSnapshot operation returned by the service.
* @throws AccessDeniedException
* You do not have sufficient access to perform this action.
* @throws ValidationException
* The input fails to satisfy the constraints of the EBS direct APIs.
* @throws ResourceNotFoundException
* The specified resource does not exist.
* @throws RequestThrottledException
* The number of API requests has exceeded the maximum allowed API request throttling limit for the
* snapshot. For more information see Error retries.
* @throws ServiceQuotaExceededException
* Your current service quotas do not allow you to perform this action.
* @throws InternalServerException
* An internal error has occurred. For more information see Error retries.
* @sample AmazonEBS.CompleteSnapshot
* @see AWS API
* Documentation
*/
@Override
public CompleteSnapshotResult completeSnapshot(CompleteSnapshotRequest request) {
request = beforeClientExecution(request);
return executeCompleteSnapshot(request);
}
@SdkInternalApi
final CompleteSnapshotResult executeCompleteSnapshot(CompleteSnapshotRequest completeSnapshotRequest) {
ExecutionContext executionContext = createExecutionContext(completeSnapshotRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new CompleteSnapshotRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(completeSnapshotRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EBS");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "CompleteSnapshot");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new CompleteSnapshotResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* Returns the data in a block in an Amazon Elastic Block Store snapshot.
*
*
*
* You should always retry requests that receive server (5xx
) error responses, and
* ThrottlingException
and RequestThrottledException
client error responses. For more
* information see Error
* retries in the Amazon Elastic Compute Cloud User Guide.
*
*
*
* @param getSnapshotBlockRequest
* @return Result of the GetSnapshotBlock operation returned by the service.
* @throws AccessDeniedException
* You do not have sufficient access to perform this action.
* @throws ValidationException
* The input fails to satisfy the constraints of the EBS direct APIs.
* @throws ResourceNotFoundException
* The specified resource does not exist.
* @throws RequestThrottledException
* The number of API requests has exceeded the maximum allowed API request throttling limit for the
* snapshot. For more information see Error retries.
* @throws ServiceQuotaExceededException
* Your current service quotas do not allow you to perform this action.
* @throws InternalServerException
* An internal error has occurred. For more information see Error retries.
* @sample AmazonEBS.GetSnapshotBlock
* @see AWS API
* Documentation
*/
@Override
public GetSnapshotBlockResult getSnapshotBlock(GetSnapshotBlockRequest request) {
request = beforeClientExecution(request);
return executeGetSnapshotBlock(request);
}
@SdkInternalApi
final GetSnapshotBlockResult executeGetSnapshotBlock(GetSnapshotBlockRequest getSnapshotBlockRequest) {
ExecutionContext executionContext = createExecutionContext(getSnapshotBlockRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new GetSnapshotBlockRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(getSnapshotBlockRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EBS");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetSnapshotBlock");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(false).withHasStreamingSuccessResponse(true), new GetSnapshotBlockResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
request.addHandlerContext(HandlerContextKey.HAS_STREAMING_OUTPUT, Boolean.TRUE);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* Returns information about the blocks that are different between two Amazon Elastic Block Store snapshots of the
* same volume/snapshot lineage.
*
*
*
* You should always retry requests that receive server (5xx
) error responses, and
* ThrottlingException
and RequestThrottledException
client error responses. For more
* information see Error
* retries in the Amazon Elastic Compute Cloud User Guide.
*
*
*
* @param listChangedBlocksRequest
* @return Result of the ListChangedBlocks operation returned by the service.
* @throws AccessDeniedException
* You do not have sufficient access to perform this action.
* @throws ValidationException
* The input fails to satisfy the constraints of the EBS direct APIs.
* @throws ResourceNotFoundException
* The specified resource does not exist.
* @throws RequestThrottledException
* The number of API requests has exceeded the maximum allowed API request throttling limit for the
* snapshot. For more information see Error retries.
* @throws ServiceQuotaExceededException
* Your current service quotas do not allow you to perform this action.
* @throws InternalServerException
* An internal error has occurred. For more information see Error retries.
* @sample AmazonEBS.ListChangedBlocks
* @see AWS API
* Documentation
*/
@Override
public ListChangedBlocksResult listChangedBlocks(ListChangedBlocksRequest request) {
request = beforeClientExecution(request);
return executeListChangedBlocks(request);
}
@SdkInternalApi
final ListChangedBlocksResult executeListChangedBlocks(ListChangedBlocksRequest listChangedBlocksRequest) {
ExecutionContext executionContext = createExecutionContext(listChangedBlocksRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListChangedBlocksRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(listChangedBlocksRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EBS");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListChangedBlocks");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListChangedBlocksResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* Returns information about the blocks in an Amazon Elastic Block Store snapshot.
*
*
*
* You should always retry requests that receive server (5xx
) error responses, and
* ThrottlingException
and RequestThrottledException
client error responses. For more
* information see Error
* retries in the Amazon Elastic Compute Cloud User Guide.
*
*
*
* @param listSnapshotBlocksRequest
* @return Result of the ListSnapshotBlocks operation returned by the service.
* @throws AccessDeniedException
* You do not have sufficient access to perform this action.
* @throws ValidationException
* The input fails to satisfy the constraints of the EBS direct APIs.
* @throws ResourceNotFoundException
* The specified resource does not exist.
* @throws RequestThrottledException
* The number of API requests has exceeded the maximum allowed API request throttling limit for the
* snapshot. For more information see Error retries.
* @throws ServiceQuotaExceededException
* Your current service quotas do not allow you to perform this action.
* @throws InternalServerException
* An internal error has occurred. For more information see Error retries.
* @sample AmazonEBS.ListSnapshotBlocks
* @see AWS API
* Documentation
*/
@Override
public ListSnapshotBlocksResult listSnapshotBlocks(ListSnapshotBlocksRequest request) {
request = beforeClientExecution(request);
return executeListSnapshotBlocks(request);
}
@SdkInternalApi
final ListSnapshotBlocksResult executeListSnapshotBlocks(ListSnapshotBlocksRequest listSnapshotBlocksRequest) {
ExecutionContext executionContext = createExecutionContext(listSnapshotBlocksRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new ListSnapshotBlocksRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(listSnapshotBlocksRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EBS");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListSnapshotBlocks");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListSnapshotBlocksResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* Writes a block of data to a snapshot. If the specified block contains data, the existing data is overwritten. The
* target snapshot must be in the pending
state.
*
*
* Data written to a snapshot must be aligned with 512-KiB sectors.
*
*
*
* You should always retry requests that receive server (5xx
) error responses, and
* ThrottlingException
and RequestThrottledException
client error responses. For more
* information see Error
* retries in the Amazon Elastic Compute Cloud User Guide.
*
*
*
* @param putSnapshotBlockRequest
* @return Result of the PutSnapshotBlock operation returned by the service.
* @throws AccessDeniedException
* You do not have sufficient access to perform this action.
* @throws ValidationException
* The input fails to satisfy the constraints of the EBS direct APIs.
* @throws ResourceNotFoundException
* The specified resource does not exist.
* @throws RequestThrottledException
* The number of API requests has exceeded the maximum allowed API request throttling limit for the
* snapshot. For more information see Error retries.
* @throws ServiceQuotaExceededException
* Your current service quotas do not allow you to perform this action.
* @throws InternalServerException
* An internal error has occurred. For more information see Error retries.
* @sample AmazonEBS.PutSnapshotBlock
* @see AWS API
* Documentation
*/
@Override
public PutSnapshotBlockResult putSnapshotBlock(PutSnapshotBlockRequest request) {
request = beforeClientExecution(request);
return executePutSnapshotBlock(request);
}
@SdkInternalApi
final PutSnapshotBlockResult executePutSnapshotBlock(PutSnapshotBlockRequest putSnapshotBlockRequest) {
ExecutionContext executionContext = createExecutionContext(putSnapshotBlockRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new PutSnapshotBlockRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(putSnapshotBlockRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EBS");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "PutSnapshotBlock");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
request.addHandlerContext(HandlerContextKey.HAS_STREAMING_INPUT, Boolean.TRUE);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new PutSnapshotBlockResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
*
* Creates a new Amazon EBS snapshot. The new snapshot enters the pending
state after the request
* completes.
*
*
* After creating the snapshot, use PutSnapshotBlock to
* write blocks of data to the snapshot.
*
*
*
* You should always retry requests that receive server (5xx
) error responses, and
* ThrottlingException
and RequestThrottledException
client error responses. For more
* information see Error
* retries in the Amazon Elastic Compute Cloud User Guide.
*
*
*
* @param startSnapshotRequest
* @return Result of the StartSnapshot operation returned by the service.
* @throws AccessDeniedException
* You do not have sufficient access to perform this action.
* @throws ValidationException
* The input fails to satisfy the constraints of the EBS direct APIs.
* @throws RequestThrottledException
* The number of API requests has exceeded the maximum allowed API request throttling limit for the
* snapshot. For more information see Error retries.
* @throws ResourceNotFoundException
* The specified resource does not exist.
* @throws ServiceQuotaExceededException
* Your current service quotas do not allow you to perform this action.
* @throws InternalServerException
* An internal error has occurred. For more information see Error retries.
* @throws ConcurrentLimitExceededException
* You have reached the limit for concurrent API requests. For more information, see Optimizing performance of the EBS direct APIs in the Amazon Elastic Compute Cloud User Guide.
* @throws ConflictException
* The request uses the same client token as a previous, but non-identical request.
* @sample AmazonEBS.StartSnapshot
* @see AWS API
* Documentation
*/
@Override
public StartSnapshotResult startSnapshot(StartSnapshotRequest request) {
request = beforeClientExecution(request);
return executeStartSnapshot(request);
}
@SdkInternalApi
final StartSnapshotResult executeStartSnapshot(StartSnapshotRequest startSnapshotRequest) {
ExecutionContext executionContext = createExecutionContext(startSnapshotRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request request = null;
Response response = null;
try {
awsRequestMetrics.startEvent(Field.RequestMarshallTime);
try {
request = new StartSnapshotRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(startSnapshotRequest));
// Binds the request metrics to the current request.
request.setAWSRequestMetrics(awsRequestMetrics);
request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EBS");
request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "StartSnapshot");
request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
} finally {
awsRequestMetrics.endEvent(Field.RequestMarshallTime);
}
HttpResponseHandler> responseHandler = protocolFactory.createResponseHandler(
new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new StartSnapshotResultJsonUnmarshaller());
response = invoke(request, responseHandler, executionContext);
return response.getAwsResponse();
} finally {
endClientExecution(awsRequestMetrics, request, response);
}
}
/**
* Returns additional metadata for a previously executed successful, request, typically used for debugging issues
* where a service isn't acting as expected. This data isn't considered part of the result data returned by an
* operation, so it's available through this separate, diagnostic interface.
*
* Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic
* information for an executed request, you should use this method to retrieve it as soon as possible after
* executing the request.
*
* @param request
* The originally executed request
*
* @return The response metadata for the specified request, or null if none is available.
*/
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
return client.getResponseMetadataForRequest(request);
}
/**
* Normal invoke with authentication. Credentials are required and may be overriden at the request level.
**/
private Response invoke(Request request, HttpResponseHandler> responseHandler,
ExecutionContext executionContext) {
return invoke(request, responseHandler, executionContext, null, null);
}
/**
* Normal invoke with authentication. Credentials are required and may be overriden at the request level.
**/
private Response invoke(Request request, HttpResponseHandler> responseHandler,
ExecutionContext executionContext, URI cachedEndpoint, URI uriFromEndpointTrait) {
executionContext.setCredentialsProvider(CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider));
return doInvoke(request, responseHandler, executionContext, cachedEndpoint, uriFromEndpointTrait);
}
/**
* Invoke with no authentication. Credentials are not required and any credentials set on the client or request will
* be ignored for this operation.
**/
private Response anonymousInvoke(Request request,
HttpResponseHandler> responseHandler, ExecutionContext executionContext) {
return doInvoke(request, responseHandler, executionContext, null, null);
}
/**
* Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
* ExecutionContext beforehand.
**/
private Response doInvoke(Request request, HttpResponseHandler> responseHandler,
ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
if (discoveredEndpoint != null) {
request.setEndpoint(discoveredEndpoint);
request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
} else if (uriFromEndpointTrait != null) {
request.setEndpoint(uriFromEndpointTrait);
} else {
request.setEndpoint(endpoint);
}
request.setTimeOffset(timeOffset);
HttpResponseHandler errorResponseHandler = protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata());
return client.execute(request, responseHandler, errorResponseHandler, executionContext);
}
@com.amazonaws.annotation.SdkInternalApi
static com.amazonaws.protocol.json.SdkJsonProtocolFactory getProtocolFactory() {
return protocolFactory;
}
@Override
public void shutdown() {
super.shutdown();
}
}