/* * 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.cloudhsmv2; 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.cloudhsmv2.AWSCloudHSMV2ClientBuilder; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.cloudhsmv2.model.*; import com.amazonaws.services.cloudhsmv2.model.transform.*; /** * Client for accessing CloudHSM V2. All service calls made using this client are blocking, and will not return until * the service call completes. *
*
* For more information about AWS CloudHSM, see AWS CloudHSM and the AWS CloudHSM User Guide. *
*/ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AWSCloudHSMV2Client extends AmazonWebServiceClient implements AWSCloudHSMV2 { /** Provider for AWS credentials. */ private final AWSCredentialsProvider awsCredentialsProvider; private static final Log log = LogFactory.getLog(AWSCloudHSMV2.class); /** Default signing name for the service. */ private static final String DEFAULT_SIGNING_NAME = "cloudhsm"; /** 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) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("CloudHsmInternalFailureException").withExceptionUnmarshaller( com.amazonaws.services.cloudhsmv2.model.transform.CloudHsmInternalFailureExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("CloudHsmTagException").withExceptionUnmarshaller( com.amazonaws.services.cloudhsmv2.model.transform.CloudHsmTagExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("CloudHsmServiceException").withExceptionUnmarshaller( com.amazonaws.services.cloudhsmv2.model.transform.CloudHsmServiceExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("CloudHsmAccessDeniedException").withExceptionUnmarshaller( com.amazonaws.services.cloudhsmv2.model.transform.CloudHsmAccessDeniedExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("CloudHsmResourceNotFoundException").withExceptionUnmarshaller( com.amazonaws.services.cloudhsmv2.model.transform.CloudHsmResourceNotFoundExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("CloudHsmInvalidRequestException").withExceptionUnmarshaller( com.amazonaws.services.cloudhsmv2.model.transform.CloudHsmInvalidRequestExceptionUnmarshaller.getInstance())) .withBaseServiceExceptionClass(com.amazonaws.services.cloudhsmv2.model.AWSCloudHSMV2Exception.class)); public static AWSCloudHSMV2ClientBuilder builder() { return AWSCloudHSMV2ClientBuilder.standard(); } /** * Constructs a new client to invoke service methods on CloudHSM V2 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. */ AWSCloudHSMV2Client(AwsSyncClientParams clientParams) { this(clientParams, false); } /** * Constructs a new client to invoke service methods on CloudHSM V2 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. */ AWSCloudHSMV2Client(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("cloudhsmv2.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/cloudhsmv2/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/cloudhsmv2/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); } /** *
* Copy an AWS CloudHSM cluster backup to a different region. *
* * @param copyBackupToRegionRequest * @return Result of the CopyBackupToRegion operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @throws CloudHsmTagException * The request was rejected because of a tagging failure. Verify the tag conditions in all applicable * policies, and then retry the request. * @sample AWSCloudHSMV2.CopyBackupToRegion * @see AWS * API Documentation */ @Override public CopyBackupToRegionResult copyBackupToRegion(CopyBackupToRegionRequest request) { request = beforeClientExecution(request); return executeCopyBackupToRegion(request); } @SdkInternalApi final CopyBackupToRegionResult executeCopyBackupToRegion(CopyBackupToRegionRequest copyBackupToRegionRequest) { ExecutionContext executionContext = createExecutionContext(copyBackupToRegionRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Creates a new AWS CloudHSM cluster. *
* * @param createClusterRequest * @return Result of the CreateCluster operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @throws CloudHsmTagException * The request was rejected because of a tagging failure. Verify the tag conditions in all applicable * policies, and then retry the request. * @sample AWSCloudHSMV2.CreateCluster * @see AWS API * Documentation */ @Override public CreateClusterResult createCluster(CreateClusterRequest request) { request = beforeClientExecution(request); return executeCreateCluster(request); } @SdkInternalApi final CreateClusterResult executeCreateCluster(CreateClusterRequest createClusterRequest) { ExecutionContext executionContext = createExecutionContext(createClusterRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Creates a new hardware security module (HSM) in the specified AWS CloudHSM cluster. *
* * @param createHsmRequest * @return Result of the CreateHsm operation returned by the service. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @sample AWSCloudHSMV2.CreateHsm * @see AWS API * Documentation */ @Override public CreateHsmResult createHsm(CreateHsmRequest request) { request = beforeClientExecution(request); return executeCreateHsm(request); } @SdkInternalApi final CreateHsmResult executeCreateHsm(CreateHsmRequest createHsmRequest) { ExecutionContext executionContext = createExecutionContext(createHsmRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Deletes a specified AWS CloudHSM backup. A backup can be restored up to 7 days after the DeleteBackup request is * made. For more information on restoring a backup, see RestoreBackup. *
* * @param deleteBackupRequest * @return Result of the DeleteBackup operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @sample AWSCloudHSMV2.DeleteBackup * @see AWS API * Documentation */ @Override public DeleteBackupResult deleteBackup(DeleteBackupRequest request) { request = beforeClientExecution(request); return executeDeleteBackup(request); } @SdkInternalApi final DeleteBackupResult executeDeleteBackup(DeleteBackupRequest deleteBackupRequest) { ExecutionContext executionContext = createExecutionContext(deleteBackupRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Deletes the specified AWS CloudHSM cluster. Before you can delete a cluster, you must delete all HSMs in the * cluster. To see if the cluster contains any HSMs, use DescribeClusters. To delete an HSM, use * DeleteHsm. *
* * @param deleteClusterRequest * @return Result of the DeleteCluster operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @throws CloudHsmTagException * The request was rejected because of a tagging failure. Verify the tag conditions in all applicable * policies, and then retry the request. * @sample AWSCloudHSMV2.DeleteCluster * @see AWS API * Documentation */ @Override public DeleteClusterResult deleteCluster(DeleteClusterRequest request) { request = beforeClientExecution(request); return executeDeleteCluster(request); } @SdkInternalApi final DeleteClusterResult executeDeleteCluster(DeleteClusterRequest deleteClusterRequest) { ExecutionContext executionContext = createExecutionContext(deleteClusterRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Deletes the specified HSM. To specify an HSM, you can use its identifier (ID), the IP address of the HSM's * elastic network interface (ENI), or the ID of the HSM's ENI. You need to specify only one of these values. To * find these values, use DescribeClusters. *
* * @param deleteHsmRequest * @return Result of the DeleteHsm operation returned by the service. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @sample AWSCloudHSMV2.DeleteHsm * @see AWS API * Documentation */ @Override public DeleteHsmResult deleteHsm(DeleteHsmRequest request) { request = beforeClientExecution(request); return executeDeleteHsm(request); } @SdkInternalApi final DeleteHsmResult executeDeleteHsm(DeleteHsmRequest deleteHsmRequest) { ExecutionContext executionContext = createExecutionContext(deleteHsmRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Gets information about backups of AWS CloudHSM clusters. *
*
* This is a paginated operation, which means that each response might contain only a subset of all the backups.
* When the response contains only a subset of backups, it includes a NextToken
value. Use this value
* in a subsequent DescribeBackups
request to get more backups. When you receive a response with no
* NextToken
(or an empty or null value), that means there are no more backups to get.
*
* Gets information about AWS CloudHSM clusters. *
*
* This is a paginated operation, which means that each response might contain only a subset of all the clusters.
* When the response contains only a subset of clusters, it includes a NextToken
value. Use this value
* in a subsequent DescribeClusters
request to get more clusters. When you receive a response with no
* NextToken
(or an empty or null value), that means there are no more clusters to get.
*
* Claims an AWS CloudHSM cluster by submitting the cluster certificate issued by your issuing certificate authority * (CA) and the CA's root certificate. Before you can claim a cluster, you must sign the cluster's certificate * signing request (CSR) with your issuing CA. To get the cluster's CSR, use DescribeClusters. *
* * @param initializeClusterRequest * @return Result of the InitializeCluster operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @sample AWSCloudHSMV2.InitializeCluster * @see AWS * API Documentation */ @Override public InitializeClusterResult initializeCluster(InitializeClusterRequest request) { request = beforeClientExecution(request); return executeInitializeCluster(request); } @SdkInternalApi final InitializeClusterResult executeInitializeCluster(InitializeClusterRequest initializeClusterRequest) { ExecutionContext executionContext = createExecutionContext(initializeClusterRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Gets a list of tags for the specified AWS CloudHSM cluster. *
*
* This is a paginated operation, which means that each response might contain only a subset of all the tags. When
* the response contains only a subset of tags, it includes a NextToken
value. Use this value in a
* subsequent ListTags
request to get more tags. When you receive a response with no
* NextToken
(or an empty or null value), that means there are no more tags to get.
*
* Modifies attributes for AWS CloudHSM backup. *
* * @param modifyBackupAttributesRequest * @return Result of the ModifyBackupAttributes operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @sample AWSCloudHSMV2.ModifyBackupAttributes * @see AWS API Documentation */ @Override public ModifyBackupAttributesResult modifyBackupAttributes(ModifyBackupAttributesRequest request) { request = beforeClientExecution(request); return executeModifyBackupAttributes(request); } @SdkInternalApi final ModifyBackupAttributesResult executeModifyBackupAttributes(ModifyBackupAttributesRequest modifyBackupAttributesRequest) { ExecutionContext executionContext = createExecutionContext(modifyBackupAttributesRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request* Modifies AWS CloudHSM cluster. *
* * @param modifyClusterRequest * @return Result of the ModifyCluster operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @sample AWSCloudHSMV2.ModifyCluster * @see AWS API * Documentation */ @Override public ModifyClusterResult modifyCluster(ModifyClusterRequest request) { request = beforeClientExecution(request); return executeModifyCluster(request); } @SdkInternalApi final ModifyClusterResult executeModifyCluster(ModifyClusterRequest modifyClusterRequest) { ExecutionContext executionContext = createExecutionContext(modifyClusterRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request
* Restores a specified AWS CloudHSM backup that is in the PENDING_DELETION
state. For mor information
* on deleting a backup, see DeleteBackup.
*
* Adds or overwrites one or more tags for the specified AWS CloudHSM cluster. *
* * @param tagResourceRequest * @return Result of the TagResource operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @throws CloudHsmTagException * The request was rejected because of a tagging failure. Verify the tag conditions in all applicable * policies, and then retry the request. * @sample AWSCloudHSMV2.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* Removes the specified tag or tags from the specified AWS CloudHSM cluster. *
* * @param untagResourceRequest * @return Result of the UntagResource operation returned by the service. * @throws CloudHsmAccessDeniedException * The request was rejected because the requester does not have permission to perform the requested * operation. * @throws CloudHsmInternalFailureException * The request was rejected because of an AWS CloudHSM internal failure. The request can be retried. * @throws CloudHsmInvalidRequestException * The request was rejected because it is not a valid request. * @throws CloudHsmResourceNotFoundException * The request was rejected because it refers to a resource that cannot be found. * @throws CloudHsmServiceException * The request was rejected because an error occurred. * @throws CloudHsmTagException * The request was rejected because of a tagging failure. Verify the tag conditions in all applicable * policies, and then retry the request. * @sample AWSCloudHSMV2.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
* 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