software.amazon.awssdk.services.qldb.DefaultQldbClient Maven / Gradle / Ivy
Show all versions of qldb Show documentation
/*
* Copyright 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.qldb;
import java.util.Collections;
import java.util.List;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.client.handler.SyncClientHandler;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
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.qldb.internal.QldbServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.qldb.model.CancelJournalKinesisStreamRequest;
import software.amazon.awssdk.services.qldb.model.CancelJournalKinesisStreamResponse;
import software.amazon.awssdk.services.qldb.model.CreateLedgerRequest;
import software.amazon.awssdk.services.qldb.model.CreateLedgerResponse;
import software.amazon.awssdk.services.qldb.model.DeleteLedgerRequest;
import software.amazon.awssdk.services.qldb.model.DeleteLedgerResponse;
import software.amazon.awssdk.services.qldb.model.DescribeJournalKinesisStreamRequest;
import software.amazon.awssdk.services.qldb.model.DescribeJournalKinesisStreamResponse;
import software.amazon.awssdk.services.qldb.model.DescribeJournalS3ExportRequest;
import software.amazon.awssdk.services.qldb.model.DescribeJournalS3ExportResponse;
import software.amazon.awssdk.services.qldb.model.DescribeLedgerRequest;
import software.amazon.awssdk.services.qldb.model.DescribeLedgerResponse;
import software.amazon.awssdk.services.qldb.model.ExportJournalToS3Request;
import software.amazon.awssdk.services.qldb.model.ExportJournalToS3Response;
import software.amazon.awssdk.services.qldb.model.GetBlockRequest;
import software.amazon.awssdk.services.qldb.model.GetBlockResponse;
import software.amazon.awssdk.services.qldb.model.GetDigestRequest;
import software.amazon.awssdk.services.qldb.model.GetDigestResponse;
import software.amazon.awssdk.services.qldb.model.GetRevisionRequest;
import software.amazon.awssdk.services.qldb.model.GetRevisionResponse;
import software.amazon.awssdk.services.qldb.model.InvalidParameterException;
import software.amazon.awssdk.services.qldb.model.LimitExceededException;
import software.amazon.awssdk.services.qldb.model.ListJournalKinesisStreamsForLedgerRequest;
import software.amazon.awssdk.services.qldb.model.ListJournalKinesisStreamsForLedgerResponse;
import software.amazon.awssdk.services.qldb.model.ListJournalS3ExportsForLedgerRequest;
import software.amazon.awssdk.services.qldb.model.ListJournalS3ExportsForLedgerResponse;
import software.amazon.awssdk.services.qldb.model.ListJournalS3ExportsRequest;
import software.amazon.awssdk.services.qldb.model.ListJournalS3ExportsResponse;
import software.amazon.awssdk.services.qldb.model.ListLedgersRequest;
import software.amazon.awssdk.services.qldb.model.ListLedgersResponse;
import software.amazon.awssdk.services.qldb.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.qldb.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.qldb.model.QldbException;
import software.amazon.awssdk.services.qldb.model.ResourceAlreadyExistsException;
import software.amazon.awssdk.services.qldb.model.ResourceInUseException;
import software.amazon.awssdk.services.qldb.model.ResourceNotFoundException;
import software.amazon.awssdk.services.qldb.model.ResourcePreconditionNotMetException;
import software.amazon.awssdk.services.qldb.model.StreamJournalToKinesisRequest;
import software.amazon.awssdk.services.qldb.model.StreamJournalToKinesisResponse;
import software.amazon.awssdk.services.qldb.model.TagResourceRequest;
import software.amazon.awssdk.services.qldb.model.TagResourceResponse;
import software.amazon.awssdk.services.qldb.model.UntagResourceRequest;
import software.amazon.awssdk.services.qldb.model.UntagResourceResponse;
import software.amazon.awssdk.services.qldb.model.UpdateLedgerPermissionsModeRequest;
import software.amazon.awssdk.services.qldb.model.UpdateLedgerPermissionsModeResponse;
import software.amazon.awssdk.services.qldb.model.UpdateLedgerRequest;
import software.amazon.awssdk.services.qldb.model.UpdateLedgerResponse;
import software.amazon.awssdk.services.qldb.transform.CancelJournalKinesisStreamRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.CreateLedgerRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.DeleteLedgerRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.DescribeJournalKinesisStreamRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.DescribeJournalS3ExportRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.DescribeLedgerRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.ExportJournalToS3RequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.GetBlockRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.GetDigestRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.GetRevisionRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.ListJournalKinesisStreamsForLedgerRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.ListJournalS3ExportsForLedgerRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.ListJournalS3ExportsRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.ListLedgersRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.StreamJournalToKinesisRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.UpdateLedgerPermissionsModeRequestMarshaller;
import software.amazon.awssdk.services.qldb.transform.UpdateLedgerRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link QldbClient}.
*
* @see QldbClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultQldbClient implements QldbClient {
private static final Logger log = Logger.loggerFor(DefaultQldbClient.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultQldbClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
*
* Ends a given Amazon QLDB journal stream. Before a stream can be canceled, its current status must be
* ACTIVE
.
*
*
* You can't restart a stream after you cancel it. Canceled QLDB stream resources are subject to a 7-day retention
* period, so they are automatically deleted after this limit expires.
*
*
* @param cancelJournalKinesisStreamRequest
* @return Result of the CancelJournalKinesisStream operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.CancelJournalKinesisStream
* @see AWS API Documentation
*/
@Override
public CancelJournalKinesisStreamResponse cancelJournalKinesisStream(
CancelJournalKinesisStreamRequest cancelJournalKinesisStreamRequest) throws InvalidParameterException,
ResourceNotFoundException, ResourcePreconditionNotMetException, AwsServiceException, SdkClientException,
QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CancelJournalKinesisStreamResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(cancelJournalKinesisStreamRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, cancelJournalKinesisStreamRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CancelJournalKinesisStream");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CancelJournalKinesisStream").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(cancelJournalKinesisStreamRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CancelJournalKinesisStreamRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a new ledger in your Amazon Web Services account in the current Region.
*
*
* @param createLedgerRequest
* @return Result of the CreateLedger operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceAlreadyExistsException
* The specified resource already exists.
* @throws LimitExceededException
* You have reached the limit on the maximum number of resources allowed.
* @throws ResourceInUseException
* The specified resource can't be modified at this time.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.CreateLedger
* @see AWS API
* Documentation
*/
@Override
public CreateLedgerResponse createLedger(CreateLedgerRequest createLedgerRequest) throws InvalidParameterException,
ResourceAlreadyExistsException, LimitExceededException, ResourceInUseException, AwsServiceException,
SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateLedgerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createLedgerRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createLedgerRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateLedger");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateLedger").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createLedgerRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateLedgerRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a ledger and all of its contents. This action is irreversible.
*
*
* If deletion protection is enabled, you must first disable it before you can delete the ledger. You can disable it
* by calling the UpdateLedger
operation to set this parameter to false
.
*
*
* @param deleteLedgerRequest
* @return Result of the DeleteLedger operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourceInUseException
* The specified resource can't be modified at this time.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.DeleteLedger
* @see AWS API
* Documentation
*/
@Override
public DeleteLedgerResponse deleteLedger(DeleteLedgerRequest deleteLedgerRequest) throws InvalidParameterException,
ResourceNotFoundException, ResourceInUseException, ResourcePreconditionNotMetException, AwsServiceException,
SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteLedgerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteLedgerRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteLedgerRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteLedger");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteLedger").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteLedgerRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteLedgerRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns detailed information about a given Amazon QLDB journal stream. The output includes the Amazon Resource
* Name (ARN), stream name, current status, creation time, and the parameters of the original stream creation
* request.
*
*
* This action does not return any expired journal streams. For more information, see Expiration for terminal streams in the Amazon QLDB Developer Guide.
*
*
* @param describeJournalKinesisStreamRequest
* @return Result of the DescribeJournalKinesisStream operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.DescribeJournalKinesisStream
* @see AWS API Documentation
*/
@Override
public DescribeJournalKinesisStreamResponse describeJournalKinesisStream(
DescribeJournalKinesisStreamRequest describeJournalKinesisStreamRequest) throws InvalidParameterException,
ResourceNotFoundException, ResourcePreconditionNotMetException, AwsServiceException, SdkClientException,
QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeJournalKinesisStreamResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeJournalKinesisStreamRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeJournalKinesisStreamRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeJournalKinesisStream");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeJournalKinesisStream").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(describeJournalKinesisStreamRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeJournalKinesisStreamRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns information about a journal export job, including the ledger name, export ID, creation time, current
* status, and the parameters of the original export creation request.
*
*
* This action does not return any expired export jobs. For more information, see Export job expiration in the Amazon QLDB Developer Guide.
*
*
* If the export job with the given ExportId
doesn't exist, then throws
* ResourceNotFoundException
.
*
*
* If the ledger with the given Name
doesn't exist, then throws ResourceNotFoundException
.
*
*
* @param describeJournalS3ExportRequest
* @return Result of the DescribeJournalS3Export operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.DescribeJournalS3Export
* @see AWS
* API Documentation
*/
@Override
public DescribeJournalS3ExportResponse describeJournalS3Export(DescribeJournalS3ExportRequest describeJournalS3ExportRequest)
throws ResourceNotFoundException, AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeJournalS3ExportResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeJournalS3ExportRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeJournalS3ExportRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeJournalS3Export");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeJournalS3Export").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(describeJournalS3ExportRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeJournalS3ExportRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns information about a ledger, including its state, permissions mode, encryption at rest settings, and when
* it was created.
*
*
* @param describeLedgerRequest
* @return Result of the DescribeLedger operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.DescribeLedger
* @see AWS API
* Documentation
*/
@Override
public DescribeLedgerResponse describeLedger(DescribeLedgerRequest describeLedgerRequest) throws InvalidParameterException,
ResourceNotFoundException, AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DescribeLedgerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeLedgerRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeLedgerRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeLedger");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DescribeLedger").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(describeLedgerRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeLedgerRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Exports journal contents within a date and time range from a ledger into a specified Amazon Simple Storage
* Service (Amazon S3) bucket. A journal export job can write the data objects in either the text or binary
* representation of Amazon Ion format, or in JSON Lines text format.
*
*
* If the ledger with the given Name
doesn't exist, then throws ResourceNotFoundException
.
*
*
* If the ledger with the given Name
is in CREATING
status, then throws
* ResourcePreconditionNotMetException
.
*
*
* You can initiate up to two concurrent journal export requests for each ledger. Beyond this limit, journal export
* requests throw LimitExceededException
.
*
*
* @param exportJournalToS3Request
* @return Result of the ExportJournalToS3 operation returned by the service.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.ExportJournalToS3
* @see AWS API
* Documentation
*/
@Override
public ExportJournalToS3Response exportJournalToS3(ExportJournalToS3Request exportJournalToS3Request)
throws ResourceNotFoundException, ResourcePreconditionNotMetException, AwsServiceException, SdkClientException,
QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ExportJournalToS3Response::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(exportJournalToS3Request,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, exportJournalToS3Request
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExportJournalToS3");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ExportJournalToS3").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(exportJournalToS3Request)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ExportJournalToS3RequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a block object at a specified address in a journal. Also returns a proof of the specified block for
* verification if DigestTipAddress
is provided.
*
*
* For information about the data contents in a block, see Journal contents in the
* Amazon QLDB Developer Guide.
*
*
* If the specified ledger doesn't exist or is in DELETING
status, then throws
* ResourceNotFoundException
.
*
*
* If the specified ledger is in CREATING
status, then throws
* ResourcePreconditionNotMetException
.
*
*
* If no block exists with the specified address, then throws InvalidParameterException
.
*
*
* @param getBlockRequest
* @return Result of the GetBlock operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.GetBlock
* @see AWS API
* Documentation
*/
@Override
public GetBlockResponse getBlock(GetBlockRequest getBlockRequest) throws InvalidParameterException,
ResourceNotFoundException, ResourcePreconditionNotMetException, AwsServiceException, SdkClientException,
QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetBlockResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getBlockRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getBlockRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetBlock");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetBlock").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(getBlockRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetBlockRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns the digest of a ledger at the latest committed block in the journal. The response includes a 256-bit hash
* value and a block address.
*
*
* @param getDigestRequest
* @return Result of the GetDigest operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.GetDigest
* @see AWS API
* Documentation
*/
@Override
public GetDigestResponse getDigest(GetDigestRequest getDigestRequest) throws InvalidParameterException,
ResourceNotFoundException, ResourcePreconditionNotMetException, AwsServiceException, SdkClientException,
QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetDigestResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getDigestRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getDigestRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetDigest");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetDigest").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(getDigestRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetDigestRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a revision data object for a specified document ID and block address. Also returns a proof of the
* specified revision for verification if DigestTipAddress
is provided.
*
*
* @param getRevisionRequest
* @return Result of the GetRevision operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.GetRevision
* @see AWS API
* Documentation
*/
@Override
public GetRevisionResponse getRevision(GetRevisionRequest getRevisionRequest) throws InvalidParameterException,
ResourceNotFoundException, ResourcePreconditionNotMetException, AwsServiceException, SdkClientException,
QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetRevisionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getRevisionRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getRevisionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetRevision");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetRevision").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(getRevisionRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetRevisionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns all Amazon QLDB journal streams for a given ledger.
*
*
* This action does not return any expired journal streams. For more information, see Expiration for terminal streams in the Amazon QLDB Developer Guide.
*
*
* This action returns a maximum of MaxResults
items. It is paginated so that you can retrieve all the
* items by calling ListJournalKinesisStreamsForLedger
multiple times.
*
*
* @param listJournalKinesisStreamsForLedgerRequest
* @return Result of the ListJournalKinesisStreamsForLedger operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.ListJournalKinesisStreamsForLedger
* @see AWS API Documentation
*/
@Override
public ListJournalKinesisStreamsForLedgerResponse listJournalKinesisStreamsForLedger(
ListJournalKinesisStreamsForLedgerRequest listJournalKinesisStreamsForLedgerRequest)
throws InvalidParameterException, ResourceNotFoundException, ResourcePreconditionNotMetException,
AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListJournalKinesisStreamsForLedgerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listJournalKinesisStreamsForLedgerRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
listJournalKinesisStreamsForLedgerRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListJournalKinesisStreamsForLedger");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListJournalKinesisStreamsForLedger").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listJournalKinesisStreamsForLedgerRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListJournalKinesisStreamsForLedgerRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns all journal export jobs for all ledgers that are associated with the current Amazon Web Services account
* and Region.
*
*
* This action returns a maximum of MaxResults
items, and is paginated so that you can retrieve all the
* items by calling ListJournalS3Exports
multiple times.
*
*
* This action does not return any expired export jobs. For more information, see Export job expiration in the Amazon QLDB Developer Guide.
*
*
* @param listJournalS3ExportsRequest
* @return Result of the ListJournalS3Exports operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.ListJournalS3Exports
* @see AWS API
* Documentation
*/
@Override
public ListJournalS3ExportsResponse listJournalS3Exports(ListJournalS3ExportsRequest listJournalS3ExportsRequest)
throws AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListJournalS3ExportsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listJournalS3ExportsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listJournalS3ExportsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListJournalS3Exports");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListJournalS3Exports").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listJournalS3ExportsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListJournalS3ExportsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns all journal export jobs for a specified ledger.
*
*
* This action returns a maximum of MaxResults
items, and is paginated so that you can retrieve all the
* items by calling ListJournalS3ExportsForLedger
multiple times.
*
*
* This action does not return any expired export jobs. For more information, see Export job expiration in the Amazon QLDB Developer Guide.
*
*
* @param listJournalS3ExportsForLedgerRequest
* @return Result of the ListJournalS3ExportsForLedger operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.ListJournalS3ExportsForLedger
* @see AWS API Documentation
*/
@Override
public ListJournalS3ExportsForLedgerResponse listJournalS3ExportsForLedger(
ListJournalS3ExportsForLedgerRequest listJournalS3ExportsForLedgerRequest) throws AwsServiceException,
SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListJournalS3ExportsForLedgerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listJournalS3ExportsForLedgerRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
listJournalS3ExportsForLedgerRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListJournalS3ExportsForLedger");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListJournalS3ExportsForLedger").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listJournalS3ExportsForLedgerRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListJournalS3ExportsForLedgerRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns all ledgers that are associated with the current Amazon Web Services account and Region.
*
*
* This action returns a maximum of MaxResults
items and is paginated so that you can retrieve all the
* items by calling ListLedgers
multiple times.
*
*
* @param listLedgersRequest
* @return Result of the ListLedgers operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.ListLedgers
* @see AWS API
* Documentation
*/
@Override
public ListLedgersResponse listLedgers(ListLedgersRequest listLedgersRequest) throws AwsServiceException, SdkClientException,
QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListLedgersResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listLedgersRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listLedgersRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListLedgers");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListLedgers").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(listLedgersRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListLedgersRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns all tags for a specified Amazon QLDB resource.
*
*
* @param listTagsForResourceRequest
* @return Result of the ListTagsForResource operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.ListTagsForResource
* @see AWS API
* Documentation
*/
@Override
public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest)
throws InvalidParameterException, ResourceNotFoundException, AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTagsForResourceRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listTagsForResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a journal stream for a given Amazon QLDB ledger. The stream captures every document revision that is
* committed to the ledger's journal and delivers the data to a specified Amazon Kinesis Data Streams resource.
*
*
* @param streamJournalToKinesisRequest
* @return Result of the StreamJournalToKinesis operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws ResourcePreconditionNotMetException
* The operation failed because a condition wasn't satisfied in advance.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.StreamJournalToKinesis
* @see AWS
* API Documentation
*/
@Override
public StreamJournalToKinesisResponse streamJournalToKinesis(StreamJournalToKinesisRequest streamJournalToKinesisRequest)
throws InvalidParameterException, ResourceNotFoundException, ResourcePreconditionNotMetException,
AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, StreamJournalToKinesisResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamJournalToKinesisRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, streamJournalToKinesisRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamJournalToKinesis");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("StreamJournalToKinesis").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(streamJournalToKinesisRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new StreamJournalToKinesisRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Adds one or more tags to a specified Amazon QLDB resource.
*
*
* A resource can have up to 50 tags. If you try to create more than 50 tags for a resource, your request fails and
* returns an error.
*
*
* @param tagResourceRequest
* @return Result of the TagResource operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.TagResource
* @see AWS API
* Documentation
*/
@Override
public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws InvalidParameterException,
ResourceNotFoundException, AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(tagResourceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("TagResource").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(tagResourceRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Removes one or more tags from a specified Amazon QLDB resource. You can specify up to 50 tag keys to remove.
*
*
* @param untagResourceRequest
* @return Result of the UntagResource operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.UntagResource
* @see AWS API
* Documentation
*/
@Override
public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws InvalidParameterException,
ResourceNotFoundException, AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(untagResourceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UntagResource").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(untagResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Updates properties on a ledger.
*
*
* @param updateLedgerRequest
* @return Result of the UpdateLedger operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.UpdateLedger
* @see AWS API
* Documentation
*/
@Override
public UpdateLedgerResponse updateLedger(UpdateLedgerRequest updateLedgerRequest) throws InvalidParameterException,
ResourceNotFoundException, AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateLedgerResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateLedgerRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateLedgerRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateLedger");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UpdateLedger").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(updateLedgerRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateLedgerRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Updates the permissions mode of a ledger.
*
*
*
* Before you switch to the STANDARD
permissions mode, you must first create all required IAM policies
* and table tags to avoid disruption to your users. To learn more, see Migrating to the standard permissions mode in the Amazon QLDB Developer Guide.
*
*
*
* @param updateLedgerPermissionsModeRequest
* @return Result of the UpdateLedgerPermissionsMode operation returned by the service.
* @throws InvalidParameterException
* One or more parameters in the request aren't valid.
* @throws ResourceNotFoundException
* The specified resource doesn't exist.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws QldbException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample QldbClient.UpdateLedgerPermissionsMode
* @see AWS API Documentation
*/
@Override
public UpdateLedgerPermissionsModeResponse updateLedgerPermissionsMode(
UpdateLedgerPermissionsModeRequest updateLedgerPermissionsModeRequest) throws InvalidParameterException,
ResourceNotFoundException, AwsServiceException, SdkClientException, QldbException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateLedgerPermissionsModeResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateLedgerPermissionsModeRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateLedgerPermissionsModeRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QLDB");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateLedgerPermissionsMode");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateLedgerPermissionsMode").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(updateLedgerPermissionsModeRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateLedgerPermissionsModeRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) {
List plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList());
SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder();
if (plugins.isEmpty()) {
return configuration.build();
}
QldbServiceClientConfigurationBuilder serviceConfigBuilder = new QldbServiceClientConfigurationBuilder(configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
return configuration.build();
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(QldbException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.0")
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourcePreconditionNotMetException")
.exceptionBuilderSupplier(ResourcePreconditionNotMetException::builder).httpStatusCode(412)
.build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidParameterException")
.exceptionBuilderSupplier(InvalidParameterException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceInUseException")
.exceptionBuilderSupplier(ResourceInUseException::builder).httpStatusCode(409).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceAlreadyExistsException")
.exceptionBuilderSupplier(ResourceAlreadyExistsException::builder).httpStatusCode(409).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitExceededException")
.exceptionBuilderSupplier(LimitExceededException::builder).httpStatusCode(400).build());
}
@Override
public final QldbServiceClientConfiguration serviceClientConfiguration() {
return new QldbServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}