/* * 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.rdsdata; 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.rdsdata.AWSRDSDataClientBuilder; import com.amazonaws.AmazonServiceException; import com.amazonaws.services.rdsdata.model.*; import com.amazonaws.services.rdsdata.model.transform.*; /** * Client for accessing AWS RDS DataService. All service calls made using this client are blocking, and will not return * until the service call completes. *
*
*
* Amazon RDS provides an HTTP endpoint to run SQL statements on an Amazon Aurora Serverless v1 DB cluster. To run these * statements, you work with the Data Service API. *
** The Data Service API isn't supported on Amazon Aurora Serverless v2 DB clusters. *
** For more information about the Data Service API, see Using the Data API in the * Amazon Aurora User Guide. *
* */ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AWSRDSDataClient extends AmazonWebServiceClient implements AWSRDSData { /** Provider for AWS credentials. */ private final AWSCredentialsProvider awsCredentialsProvider; private static final Log log = LogFactory.getLog(AWSRDSData.class); /** Default signing name for the service. */ private static final String DEFAULT_SIGNING_NAME = "rds-data"; /** 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.rdsdata.model.transform.AccessDeniedExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("NotFoundException").withExceptionUnmarshaller( com.amazonaws.services.rdsdata.model.transform.NotFoundExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ForbiddenException").withExceptionUnmarshaller( com.amazonaws.services.rdsdata.model.transform.ForbiddenExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("ServiceUnavailableError").withExceptionUnmarshaller( com.amazonaws.services.rdsdata.model.transform.ServiceUnavailableErrorExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("StatementTimeoutException").withExceptionUnmarshaller( com.amazonaws.services.rdsdata.model.transform.StatementTimeoutExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("BadRequestException").withExceptionUnmarshaller( com.amazonaws.services.rdsdata.model.transform.BadRequestExceptionUnmarshaller.getInstance())) .addErrorMetadata( new JsonErrorShapeMetadata().withErrorCode("InternalServerErrorException").withExceptionUnmarshaller( com.amazonaws.services.rdsdata.model.transform.InternalServerErrorExceptionUnmarshaller.getInstance())) .withBaseServiceExceptionClass(com.amazonaws.services.rdsdata.model.AWSRDSDataException.class)); public static AWSRDSDataClientBuilder builder() { return AWSRDSDataClientBuilder.standard(); } /** * Constructs a new client to invoke service methods on AWS RDS DataService 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. */ AWSRDSDataClient(AwsSyncClientParams clientParams) { this(clientParams, false); } /** * Constructs a new client to invoke service methods on AWS RDS DataService 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. */ AWSRDSDataClient(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("rds-data.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/rdsdata/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/rdsdata/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); } /** *
* Runs a batch SQL statement over an array of data. *
** You can run bulk update and insert operations for multiple records using a DML statement with different parameter * sets. Bulk operations can provide a significant performance improvement over individual insert and update * operations. *
*
* If a call isn't part of a transaction because it doesn't include the transactionID
parameter,
* changes that result from the call are committed automatically.
*
* There isn't a fixed upper limit on the number of parameter sets. However, the maximum size of the HTTP request * submitted through the Data API is 4 MiB. If the request exceeds this limit, the Data API returns an error and * doesn't process the request. This 4-MiB limit includes the size of the HTTP headers and the JSON notation in the * request. Thus, the number of parameter sets that you can include depends on a combination of factors, such as the * size of the SQL statement and the size of each parameter set. *
** The response size limit is 1 MiB. If the call returns more than 1 MiB of response data, the call is terminated. *
*resourceArn
parameter is not available.
* @sample AWSRDSData.BatchExecuteStatement
* @see AWS
* API Documentation
*/
@Override
public BatchExecuteStatementResult batchExecuteStatement(BatchExecuteStatementRequest request) {
request = beforeClientExecution(request);
return executeBatchExecuteStatement(request);
}
@SdkInternalApi
final BatchExecuteStatementResult executeBatchExecuteStatement(BatchExecuteStatementRequest batchExecuteStatementRequest) {
ExecutionContext executionContext = createExecutionContext(batchExecuteStatementRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request* Starts a SQL transaction. *
** A transaction can run for a maximum of 24 hours. A transaction is terminated and rolled back automatically after * 24 hours. *
** A transaction times out if no calls use its transaction ID in three minutes. If a transaction times out before * it's committed, it's rolled back automatically. *
*
* DDL statements inside a transaction cause an implicit commit. We recommend that you run each DDL statement in a
* separate ExecuteStatement
call with continueAfterTimeout
enabled.
*
resourceArn
parameter is not available.
* @sample AWSRDSData.BeginTransaction
* @see AWS API
* Documentation
*/
@Override
public BeginTransactionResult beginTransaction(BeginTransactionRequest request) {
request = beforeClientExecution(request);
return executeBeginTransaction(request);
}
@SdkInternalApi
final BeginTransactionResult executeBeginTransaction(BeginTransactionRequest beginTransactionRequest) {
ExecutionContext executionContext = createExecutionContext(beginTransactionRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request
* Ends a SQL transaction started with the BeginTransaction
operation and commits the changes.
*
resourceArn
parameter is not available.
* @throws NotFoundException
* The resourceArn
, secretArn
, or transactionId
value can't be found.
* @sample AWSRDSData.CommitTransaction
* @see AWS API
* Documentation
*/
@Override
public CommitTransactionResult commitTransaction(CommitTransactionRequest request) {
request = beforeClientExecution(request);
return executeCommitTransaction(request);
}
@SdkInternalApi
final CommitTransactionResult executeCommitTransaction(CommitTransactionRequest commitTransactionRequest) {
ExecutionContext executionContext = createExecutionContext(commitTransactionRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request* Runs one or more SQL statements. *
*
* This operation is deprecated. Use the BatchExecuteStatement
or ExecuteStatement
* operation.
*
resourceArn
parameter is not available.
* @sample AWSRDSData.ExecuteSql
* @see AWS API
* Documentation
*/
@Override
@Deprecated
public ExecuteSqlResult executeSql(ExecuteSqlRequest request) {
request = beforeClientExecution(request);
return executeExecuteSql(request);
}
@SdkInternalApi
final ExecuteSqlResult executeExecuteSql(ExecuteSqlRequest executeSqlRequest) {
ExecutionContext executionContext = createExecutionContext(executeSqlRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request* Runs a SQL statement against a database. *
*
* If a call isn't part of a transaction because it doesn't include the transactionID
parameter,
* changes that result from the call are committed automatically.
*
* If the binary response data from the database is more than 1 MB, the call is terminated. *
*resourceArn
parameter is not available.
* @sample AWSRDSData.ExecuteStatement
* @see AWS API
* Documentation
*/
@Override
public ExecuteStatementResult executeStatement(ExecuteStatementRequest request) {
request = beforeClientExecution(request);
return executeExecuteStatement(request);
}
@SdkInternalApi
final ExecuteStatementResult executeExecuteStatement(ExecuteStatementRequest executeStatementRequest) {
ExecutionContext executionContext = createExecutionContext(executeStatementRequest);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
awsRequestMetrics.startEvent(Field.ClientExecuteTime);
Request* Performs a rollback of a transaction. Rolling back a transaction cancels its changes. *
* * @param rollbackTransactionRequest * The request parameters represent the input of a request to perform a rollback of a transaction. * @return Result of the RollbackTransaction operation returned by the service. * @throws AccessDeniedException * You do not have sufficient access to perform this action. * @throws BadRequestException * There is an error in the call or in a SQL statement. * @throws StatementTimeoutException * The execution of the SQL statement timed out. * @throws InternalServerErrorException * An internal error occurred. * @throws ForbiddenException * There are insufficient privileges to make the call. * @throws ServiceUnavailableErrorException * The service specified by theresourceArn
parameter is not available.
* @throws NotFoundException
* The resourceArn
, secretArn
, or transactionId
value can't be found.
* @sample AWSRDSData.RollbackTransaction
* @see AWS
* API Documentation
*/
@Override
public RollbackTransactionResult rollbackTransaction(RollbackTransactionRequest request) {
request = beforeClientExecution(request);
return executeRollbackTransaction(request);
}
@SdkInternalApi
final RollbackTransactionResult executeRollbackTransaction(RollbackTransactionRequest rollbackTransactionRequest) {
ExecutionContext executionContext = createExecutionContext(rollbackTransactionRequest);
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