/* * 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.recyclebin; 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.recyclebin.AmazonRecycleBinClientBuilder; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.recyclebin.model.*; import com.amazonaws.services.recyclebin.model.transform.*; /** * Client for accessing Amazon Recycle Bin. All service calls made using this client are blocking, and will not return * until the service call completes. *
*
* This is the Recycle Bin API Reference. This documentation provides descriptions and syntax for each of the * actions and data types in Recycle Bin. *
** Recycle Bin is a resource recovery feature that enables you to restore accidentally deleted snapshots and EBS-backed * AMIs. When using Recycle Bin, if your resources are deleted, they are retained in the Recycle Bin for a time period * that you specify. *
** You can restore a resource from the Recycle Bin at any time before its retention period expires. After you restore a * resource from the Recycle Bin, the resource is removed from the Recycle Bin, and you can then use it in the same way * you use any other resource of that type in your account. If the retention period expires and the resource is not * restored, the resource is permanently deleted from the Recycle Bin and is no longer available for recovery. For more * information about Recycle Bin, see Recycle Bin in the * Amazon Elastic Compute Cloud User Guide. *
*/ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AmazonRecycleBinClient extends AmazonWebServiceClient implements AmazonRecycleBin { /** Provider for AWS credentials. */ private final AWSCredentialsProvider awsCredentialsProvider; private static final Log log = LogFactory.getLog(AmazonRecycleBin.class); /** Default signing name for the service. */ private static final String DEFAULT_SIGNING_NAME = "rbin"; /** 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("ValidationException").withExceptionUnmarshaller( com.amazonaws.services.recyclebin.model.transform.ValidationExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ConflictException").withExceptionUnmarshaller( com.amazonaws.services.recyclebin.model.transform.ConflictExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ServiceQuotaExceededException").withExceptionUnmarshaller( com.amazonaws.services.recyclebin.model.transform.ServiceQuotaExceededExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ResourceNotFoundException").withExceptionUnmarshaller( com.amazonaws.services.recyclebin.model.transform.ResourceNotFoundExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("InternalServerException").withExceptionUnmarshaller( com.amazonaws.services.recyclebin.model.transform.InternalServerExceptionUnmarshaller.getInstance())) .withBaseServiceExceptionClass(com.amazonaws.services.recyclebin.model.AmazonRecycleBinException.class)); public static AmazonRecycleBinClientBuilder builder() { return AmazonRecycleBinClientBuilder.standard(); } /** * Constructs a new client to invoke service methods on Amazon Recycle Bin 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. */ AmazonRecycleBinClient(AwsSyncClientParams clientParams) { this(clientParams, false); } /** * Constructs a new client to invoke service methods on Amazon Recycle Bin 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. */ AmazonRecycleBinClient(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("rbin.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/recyclebin/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/recyclebin/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); } /** *
* Creates a Recycle Bin retention rule. For more information, see Create Recycle Bin retention rules in the Amazon Elastic Compute Cloud User Guide. *
* * @param createRuleRequest * @return Result of the CreateRule operation returned by the service. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws ServiceQuotaExceededException * The request would cause a service quota for the number of tags per resource to be exceeded. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @sample AmazonRecycleBin.CreateRule * @see AWS API * Documentation */ @Override public CreateRuleResult createRule(CreateRuleRequest request) { request = beforeClientExecution(request); return executeCreateRule(request); } @SdkInternalApi final CreateRuleResult executeCreateRule(CreateRuleRequest createRuleRequest) { ExecutionContext executionContext = createExecutionContext(createRuleRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Deletes a Recycle Bin retention rule. For more information, see Delete Recycle Bin retention rules in the Amazon Elastic Compute Cloud User Guide. *
* * @param deleteRuleRequest * @return Result of the DeleteRule operation returned by the service. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @throws ResourceNotFoundException * The specified resource was not found. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws ConflictException * The specified retention rule lock request can't be completed. * @sample AmazonRecycleBin.DeleteRule * @see AWS API * Documentation */ @Override public DeleteRuleResult deleteRule(DeleteRuleRequest request) { request = beforeClientExecution(request); return executeDeleteRule(request); } @SdkInternalApi final DeleteRuleResult executeDeleteRule(DeleteRuleRequest deleteRuleRequest) { ExecutionContext executionContext = createExecutionContext(deleteRuleRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Gets information about a Recycle Bin retention rule. *
* * @param getRuleRequest * @return Result of the GetRule operation returned by the service. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @throws ResourceNotFoundException * The specified resource was not found. * @sample AmazonRecycleBin.GetRule * @see AWS API * Documentation */ @Override public GetRuleResult getRule(GetRuleRequest request) { request = beforeClientExecution(request); return executeGetRule(request); } @SdkInternalApi final GetRuleResult executeGetRule(GetRuleRequest getRuleRequest) { ExecutionContext executionContext = createExecutionContext(getRuleRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Lists the Recycle Bin retention rules in the Region. *
* * @param listRulesRequest * @return Result of the ListRules operation returned by the service. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @sample AmazonRecycleBin.ListRules * @see AWS API * Documentation */ @Override public ListRulesResult listRules(ListRulesRequest request) { request = beforeClientExecution(request); return executeListRules(request); } @SdkInternalApi final ListRulesResult executeListRules(ListRulesRequest listRulesRequest) { ExecutionContext executionContext = createExecutionContext(listRulesRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Lists the tags assigned to a retention rule. *
* * @param listTagsForResourceRequest * @return Result of the ListTagsForResource operation returned by the service. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @throws ResourceNotFoundException * The specified resource was not found. * @sample AmazonRecycleBin.ListTagsForResource * @see AWS API * Documentation */ @Override public ListTagsForResourceResult listTagsForResource(ListTagsForResourceRequest request) { request = beforeClientExecution(request); return executeListTagsForResource(request); } @SdkInternalApi final ListTagsForResourceResult executeListTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest) { ExecutionContext executionContext = createExecutionContext(listTagsForResourceRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Locks a retention rule. A locked retention rule can't be modified or deleted. *
* * @param lockRuleRequest * @return Result of the LockRule operation returned by the service. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @throws ResourceNotFoundException * The specified resource was not found. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws ConflictException * The specified retention rule lock request can't be completed. * @sample AmazonRecycleBin.LockRule * @see AWS API * Documentation */ @Override public LockRuleResult lockRule(LockRuleRequest request) { request = beforeClientExecution(request); return executeLockRule(request); } @SdkInternalApi final LockRuleResult executeLockRule(LockRuleRequest lockRuleRequest) { ExecutionContext executionContext = createExecutionContext(lockRuleRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Assigns tags to the specified retention rule. *
* * @param tagResourceRequest * @return Result of the TagResource operation returned by the service. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @throws ResourceNotFoundException * The specified resource was not found. * @throws ServiceQuotaExceededException * The request would cause a service quota for the number of tags per resource to be exceeded. * @sample AmazonRecycleBin.TagResource * @see AWS API * Documentation */ @Override public TagResourceResult tagResource(TagResourceRequest request) { request = beforeClientExecution(request); return executeTagResource(request); } @SdkInternalApi final TagResourceResult executeTagResource(TagResourceRequest tagResourceRequest) { ExecutionContext executionContext = createExecutionContext(tagResourceRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Unlocks a retention rule. After a retention rule is unlocked, it can be modified or deleted only after the unlock * delay period expires. *
* * @param unlockRuleRequest * @return Result of the UnlockRule operation returned by the service. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @throws ResourceNotFoundException * The specified resource was not found. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws ConflictException * The specified retention rule lock request can't be completed. * @sample AmazonRecycleBin.UnlockRule * @see AWS API * Documentation */ @Override public UnlockRuleResult unlockRule(UnlockRuleRequest request) { request = beforeClientExecution(request); return executeUnlockRule(request); } @SdkInternalApi final UnlockRuleResult executeUnlockRule(UnlockRuleRequest unlockRuleRequest) { ExecutionContext executionContext = createExecutionContext(unlockRuleRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Unassigns a tag from a retention rule. *
* * @param untagResourceRequest * @return Result of the UntagResource operation returned by the service. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @throws ResourceNotFoundException * The specified resource was not found. * @sample AmazonRecycleBin.UntagResource * @see AWS API * Documentation */ @Override public UntagResourceResult untagResource(UntagResourceRequest request) { request = beforeClientExecution(request); return executeUntagResource(request); } @SdkInternalApi final UntagResourceResult executeUntagResource(UntagResourceRequest untagResourceRequest) { ExecutionContext executionContext = createExecutionContext(untagResourceRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Updates an existing Recycle Bin retention rule. You can update a retention rule's description, resource tags, and * retention period at any time after creation. You can't update a retention rule's resource type after creation. * For more information, see Update Recycle Bin retention rules in the Amazon Elastic Compute Cloud User Guide. *
* * @param updateRuleRequest * @return Result of the UpdateRule operation returned by the service. * @throws ValidationException * One or more of the parameters in the request is not valid. * @throws InternalServerException * The service could not respond to the request due to an internal problem. * @throws ResourceNotFoundException * The specified resource was not found. * @throws ConflictException * The specified retention rule lock request can't be completed. * @sample AmazonRecycleBin.UpdateRule * @see AWS API * Documentation */ @Override public UpdateRuleResult updateRule(UpdateRuleRequest request) { request = beforeClientExecution(request); return executeUpdateRule(request); } @SdkInternalApi final UpdateRuleResult executeUpdateRule(UpdateRuleRequest updateRuleRequest) { ExecutionContext executionContext = createExecutionContext(updateRuleRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request
* 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