
software.amazon.awssdk.services.timestreamwrite.DefaultTimestreamWriteClient Maven / Gradle / Ivy
/*
* 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.timestreamwrite;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
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.endpointdiscovery.EndpointDiscoveryRefreshCache;
import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRequest;
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.core.util.VersionInfo;
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.timestreamwrite.model.AccessDeniedException;
import software.amazon.awssdk.services.timestreamwrite.model.ConflictException;
import software.amazon.awssdk.services.timestreamwrite.model.CreateDatabaseRequest;
import software.amazon.awssdk.services.timestreamwrite.model.CreateDatabaseResponse;
import software.amazon.awssdk.services.timestreamwrite.model.CreateTableRequest;
import software.amazon.awssdk.services.timestreamwrite.model.CreateTableResponse;
import software.amazon.awssdk.services.timestreamwrite.model.DeleteDatabaseRequest;
import software.amazon.awssdk.services.timestreamwrite.model.DeleteDatabaseResponse;
import software.amazon.awssdk.services.timestreamwrite.model.DeleteTableRequest;
import software.amazon.awssdk.services.timestreamwrite.model.DeleteTableResponse;
import software.amazon.awssdk.services.timestreamwrite.model.DescribeDatabaseRequest;
import software.amazon.awssdk.services.timestreamwrite.model.DescribeDatabaseResponse;
import software.amazon.awssdk.services.timestreamwrite.model.DescribeEndpointsRequest;
import software.amazon.awssdk.services.timestreamwrite.model.DescribeEndpointsResponse;
import software.amazon.awssdk.services.timestreamwrite.model.DescribeTableRequest;
import software.amazon.awssdk.services.timestreamwrite.model.DescribeTableResponse;
import software.amazon.awssdk.services.timestreamwrite.model.InternalServerException;
import software.amazon.awssdk.services.timestreamwrite.model.InvalidEndpointException;
import software.amazon.awssdk.services.timestreamwrite.model.ListDatabasesRequest;
import software.amazon.awssdk.services.timestreamwrite.model.ListDatabasesResponse;
import software.amazon.awssdk.services.timestreamwrite.model.ListTablesRequest;
import software.amazon.awssdk.services.timestreamwrite.model.ListTablesResponse;
import software.amazon.awssdk.services.timestreamwrite.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.timestreamwrite.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.timestreamwrite.model.RejectedRecordsException;
import software.amazon.awssdk.services.timestreamwrite.model.ResourceNotFoundException;
import software.amazon.awssdk.services.timestreamwrite.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.timestreamwrite.model.TagResourceRequest;
import software.amazon.awssdk.services.timestreamwrite.model.TagResourceResponse;
import software.amazon.awssdk.services.timestreamwrite.model.ThrottlingException;
import software.amazon.awssdk.services.timestreamwrite.model.TimestreamWriteException;
import software.amazon.awssdk.services.timestreamwrite.model.TimestreamWriteRequest;
import software.amazon.awssdk.services.timestreamwrite.model.UntagResourceRequest;
import software.amazon.awssdk.services.timestreamwrite.model.UntagResourceResponse;
import software.amazon.awssdk.services.timestreamwrite.model.UpdateDatabaseRequest;
import software.amazon.awssdk.services.timestreamwrite.model.UpdateDatabaseResponse;
import software.amazon.awssdk.services.timestreamwrite.model.UpdateTableRequest;
import software.amazon.awssdk.services.timestreamwrite.model.UpdateTableResponse;
import software.amazon.awssdk.services.timestreamwrite.model.ValidationException;
import software.amazon.awssdk.services.timestreamwrite.model.WriteRecordsRequest;
import software.amazon.awssdk.services.timestreamwrite.model.WriteRecordsResponse;
import software.amazon.awssdk.services.timestreamwrite.paginators.ListDatabasesIterable;
import software.amazon.awssdk.services.timestreamwrite.paginators.ListTablesIterable;
import software.amazon.awssdk.services.timestreamwrite.transform.CreateDatabaseRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.CreateTableRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.DeleteDatabaseRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.DeleteTableRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.DescribeDatabaseRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.DescribeEndpointsRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.DescribeTableRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.ListDatabasesRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.ListTablesRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.UpdateDatabaseRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.UpdateTableRequestMarshaller;
import software.amazon.awssdk.services.timestreamwrite.transform.WriteRecordsRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link TimestreamWriteClient}.
*
* @see TimestreamWriteClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultTimestreamWriteClient implements TimestreamWriteClient {
private static final Logger log = Logger.loggerFor(DefaultTimestreamWriteClient.class);
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private EndpointDiscoveryRefreshCache endpointDiscoveryCache;
protected DefaultTimestreamWriteClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) {
this.endpointDiscoveryCache = EndpointDiscoveryRefreshCache.create(TimestreamWriteEndpointDiscoveryCacheLoader
.create(this));
if (clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE) {
log.warn(() -> "Endpoint discovery is enabled for this client, and an endpoint override was also specified. This will disable endpoint discovery for methods that require it, instead using the specified endpoint override. This may or may not be what you intended.");
}
}
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Creates a new Timestream database. If the KMS key is not specified, the database will be encrypted with a
* Timestream managed KMS key located in your account. Refer to AWS managed KMS
* keys for more info. Service quotas apply. For more information, see Access Management in the
* Timestream Developer Guide.
*
*
* @param createDatabaseRequest
* @return Result of the CreateDatabase operation returned by the service.
* @throws ConflictException
* Timestream was unable to process this request because it contains resource that already exists.
* @throws ValidationException
* Invalid or malformed request.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws ServiceQuotaExceededException
* Instance quota of resource exceeded for this account.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.CreateDatabase
* @see AWS API Documentation
*/
@Override
public CreateDatabaseResponse createDatabase(CreateDatabaseRequest createDatabaseRequest) throws ConflictException,
ValidationException, AccessDeniedException, ServiceQuotaExceededException, ThrottlingException,
InvalidEndpointException, InternalServerException, AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateDatabaseResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, createDatabaseRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateDatabase");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateDatabase").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(createDatabaseRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateDatabaseRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* The CreateTable operation adds a new table to an existing database in your account. In an AWS account, table
* names must be at least unique within each Region if they are in the same database. You may have identical table
* names in the same Region if the tables are in seperate databases. While creating the table, you must specify the
* table name, database name, and the retention properties. Service quotas apply. For more information, see Access Management in the
* Timestream Developer Guide.
*
*
* @param createTableRequest
* @return Result of the CreateTable operation returned by the service.
* @throws ConflictException
* Timestream was unable to process this request because it contains resource that already exists.
* @throws ValidationException
* Invalid or malformed request.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws ServiceQuotaExceededException
* Instance quota of resource exceeded for this account.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.CreateTable
* @see AWS
* API Documentation
*/
@Override
public CreateTableResponse createTable(CreateTableRequest createTableRequest) throws ConflictException, ValidationException,
AccessDeniedException, ResourceNotFoundException, ServiceQuotaExceededException, ThrottlingException,
InternalServerException, InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateTableResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, createTableRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateTable");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateTable").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(createTableRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateTableRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a given Timestream database. This is an irreversible operation. After a database is deleted, the time
* series data from its tables cannot be recovered.
*
*
* All tables in the database must be deleted first, or a ValidationException error will be thrown.
*
*
* Due to the nature of distributed retries, the operation can return either success or a ResourceNotFoundException.
* Clients should consider them equivalent.
*
*
* @param deleteDatabaseRequest
* @return Result of the DeleteDatabase operation returned by the service.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws ValidationException
* Invalid or malformed request.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.DeleteDatabase
* @see AWS API Documentation
*/
@Override
public DeleteDatabaseResponse deleteDatabase(DeleteDatabaseRequest deleteDatabaseRequest) throws InternalServerException,
ThrottlingException, ResourceNotFoundException, ValidationException, AccessDeniedException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteDatabaseResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteDatabaseRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteDatabase");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteDatabase").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(deleteDatabaseRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteDatabaseRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a given Timestream table. This is an irreversible operation. After a Timestream database table is
* deleted, the time series data stored in the table cannot be recovered.
*
*
* Due to the nature of distributed retries, the operation can return either success or a ResourceNotFoundException.
* Clients should consider them equivalent.
*
*
* @param deleteTableRequest
* @return Result of the DeleteTable operation returned by the service.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.DeleteTable
* @see AWS
* API Documentation
*/
@Override
public DeleteTableResponse deleteTable(DeleteTableRequest deleteTableRequest) throws InternalServerException,
ThrottlingException, ValidationException, ResourceNotFoundException, AccessDeniedException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteTableResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteTableRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteTable");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteTable").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(deleteTableRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteTableRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns information about the database, including the database name, time that the database was created, and the
* total number of tables found within the database. Service quotas apply. For more information, see Access Management in the
* Timestream Developer Guide.
*
*
* @param describeDatabaseRequest
* @return Result of the DescribeDatabase operation returned by the service.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws ValidationException
* Invalid or malformed request.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.DescribeDatabase
* @see AWS API Documentation
*/
@Override
public DescribeDatabaseResponse describeDatabase(DescribeDatabaseRequest describeDatabaseRequest)
throws ResourceNotFoundException, ValidationException, AccessDeniedException, ThrottlingException,
InternalServerException, InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DescribeDatabaseResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeDatabaseRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeDatabase");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DescribeDatabase").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(describeDatabaseRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeDatabaseRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* DescribeEndpoints returns a list of available endpoints to make Timestream API calls against. This API is
* available through both Write and Query.
*
*
* Because Timestream’s SDKs are designed to transparently work with the service’s architecture, including the
* management and mapping of the service endpoints, it is not recommended that you use this API unless:
*
*
* -
*
* Your application uses a programming language that does not yet have SDK support
*
*
* -
*
* You require better control over the client-side implementation
*
*
*
*
* For detailed information on how to use DescribeEndpoints, see The
* Endpoint Discovery Pattern and REST APIs.
*
*
* @param describeEndpointsRequest
* @return Result of the DescribeEndpoints operation returned by the service.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ValidationException
* Invalid or malformed request.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.DescribeEndpoints
* @see AWS API Documentation
*/
@Override
public DescribeEndpointsResponse describeEndpoints(DescribeEndpointsRequest describeEndpointsRequest)
throws InternalServerException, ValidationException, ThrottlingException, AwsServiceException, SdkClientException,
TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DescribeEndpointsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeEndpointsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeEndpoints");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DescribeEndpoints").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(describeEndpointsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeEndpointsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns information about the table, including the table name, database name, retention duration of the memory
* store and the magnetic store. Service quotas apply. For more information, see Access Management in the
* Timestream Developer Guide.
*
*
* @param describeTableRequest
* @return Result of the DescribeTable operation returned by the service.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws ValidationException
* Invalid or malformed request.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.DescribeTable
* @see AWS API Documentation
*/
@Override
public DescribeTableResponse describeTable(DescribeTableRequest describeTableRequest) throws ResourceNotFoundException,
ValidationException, AccessDeniedException, ThrottlingException, InternalServerException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DescribeTableResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeTableRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeTable");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DescribeTable").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(describeTableRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeTableRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a list of your Timestream databases. Service quotas apply. For more information, see Access Management in the
* Timestream Developer Guide.
*
*
* @param listDatabasesRequest
* @return Result of the ListDatabases operation returned by the service.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.ListDatabases
* @see AWS API Documentation
*/
@Override
public ListDatabasesResponse listDatabases(ListDatabasesRequest listDatabasesRequest) throws InternalServerException,
ThrottlingException, ValidationException, AccessDeniedException, InvalidEndpointException, AwsServiceException,
SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListDatabasesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, listDatabasesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListDatabases");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListDatabases").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(listDatabasesRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListDatabasesRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Returns a list of your Timestream databases. Service quotas apply. For more information, see Access Management in the
* Timestream Developer Guide.
*
*
*
* This is a variant of
* {@link #listDatabases(software.amazon.awssdk.services.timestreamwrite.model.ListDatabasesRequest)} operation. The
* return type is a custom iterable that can be used to iterate through all the pages. SDK will internally handle
* making service calls for you.
*
*
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
*
*
*
* The following are few ways to iterate through the response pages:
*
* 1) Using a Stream
*
*
* {@code
* software.amazon.awssdk.services.timestreamwrite.paginators.ListDatabasesIterable responses = client.listDatabasesPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.timestreamwrite.paginators.ListDatabasesIterable responses = client
* .listDatabasesPaginator(request);
* for (software.amazon.awssdk.services.timestreamwrite.model.ListDatabasesResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.timestreamwrite.paginators.ListDatabasesIterable responses = client.listDatabasesPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listDatabases(software.amazon.awssdk.services.timestreamwrite.model.ListDatabasesRequest)} operation.
*
*
* @param listDatabasesRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.ListDatabases
* @see AWS API Documentation
*/
@Override
public ListDatabasesIterable listDatabasesPaginator(ListDatabasesRequest listDatabasesRequest)
throws InternalServerException, ThrottlingException, ValidationException, AccessDeniedException,
InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamWriteException {
return new ListDatabasesIterable(this, applyPaginatorUserAgent(listDatabasesRequest));
}
/**
*
* A list of tables, along with the name, status and retention properties of each table.
*
*
* @param listTablesRequest
* @return Result of the ListTables operation returned by the service.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.ListTables
* @see AWS
* API Documentation
*/
@Override
public ListTablesResponse listTables(ListTablesRequest listTablesRequest) throws InternalServerException,
ThrottlingException, ValidationException, ResourceNotFoundException, AccessDeniedException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListTablesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTablesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTables");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListTables").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(listTablesRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListTablesRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* A list of tables, along with the name, status and retention properties of each table.
*
*
*
* This is a variant of {@link #listTables(software.amazon.awssdk.services.timestreamwrite.model.ListTablesRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
*
*
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
*
*
*
* The following are few ways to iterate through the response pages:
*
* 1) Using a Stream
*
*
* {@code
* software.amazon.awssdk.services.timestreamwrite.paginators.ListTablesIterable responses = client.listTablesPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.timestreamwrite.paginators.ListTablesIterable responses = client.listTablesPaginator(request);
* for (software.amazon.awssdk.services.timestreamwrite.model.ListTablesResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.timestreamwrite.paginators.ListTablesIterable responses = client.listTablesPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Please notice that the configuration of MaxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listTables(software.amazon.awssdk.services.timestreamwrite.model.ListTablesRequest)} operation.
*
*
* @param listTablesRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.ListTables
* @see AWS
* API Documentation
*/
@Override
public ListTablesIterable listTablesPaginator(ListTablesRequest listTablesRequest) throws InternalServerException,
ThrottlingException, ValidationException, ResourceNotFoundException, AccessDeniedException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
return new ListTablesIterable(this, applyPaginatorUserAgent(listTablesRequest));
}
/**
*
* List all tags on a Timestream resource.
*
*
* @param listTagsForResourceRequest
* @return Result of the ListTagsForResource operation returned by the service.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest)
throws ResourceNotFoundException, ThrottlingException, ValidationException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(listTagsForResourceRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Associate a set of tags with a Timestream resource. You can then activate these user-defined tags so that they
* appear on the Billing and Cost Management console for cost allocation tracking.
*
*
* @param tagResourceRequest
* @return Result of the TagResource operation returned by the service.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws ServiceQuotaExceededException
* Instance quota of resource exceeded for this account.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.TagResource
* @see AWS
* API Documentation
*/
@Override
public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws ResourceNotFoundException,
ServiceQuotaExceededException, ThrottlingException, ValidationException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("TagResource").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(tagResourceRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Removes the association of tags from a Timestream resource.
*
*
* @param untagResourceRequest
* @return Result of the UntagResource operation returned by the service.
* @throws ValidationException
* Invalid or malformed request.
* @throws ServiceQuotaExceededException
* Instance quota of resource exceeded for this account.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.UntagResource
* @see AWS API Documentation
*/
@Override
public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws ValidationException,
ServiceQuotaExceededException, ThrottlingException, ResourceNotFoundException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UntagResource").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(untagResourceRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Modifies the KMS key for an existing database. While updating the database, you must specify the database name
* and the identifier of the new KMS key to be used (KmsKeyId
). If there are any concurrent
* UpdateDatabase
requests, first writer wins.
*
*
* @param updateDatabaseRequest
* @return Result of the UpdateDatabase operation returned by the service.
* @throws ValidationException
* Invalid or malformed request.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws ServiceQuotaExceededException
* Instance quota of resource exceeded for this account.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.UpdateDatabase
* @see AWS API Documentation
*/
@Override
public UpdateDatabaseResponse updateDatabase(UpdateDatabaseRequest updateDatabaseRequest) throws ValidationException,
AccessDeniedException, ResourceNotFoundException, ServiceQuotaExceededException, ThrottlingException,
InternalServerException, InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateDatabaseResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateDatabaseRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateDatabase");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UpdateDatabase").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(updateDatabaseRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateDatabaseRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Modifies the retention duration of the memory store and magnetic store for your Timestream table. Note that the
* change in retention duration takes effect immediately. For example, if the retention period of the memory store
* was initially set to 2 hours and then changed to 24 hours, the memory store will be capable of holding 24 hours
* of data, but will be populated with 24 hours of data 22 hours after this change was made. Timestream does not
* retrieve data from the magnetic store to populate the memory store.
*
*
* Service quotas apply. For more information, see Access Management in the
* Timestream Developer Guide.
*
*
* @param updateTableRequest
* @return Result of the UpdateTable operation returned by the service.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.UpdateTable
* @see AWS
* API Documentation
*/
@Override
public UpdateTableResponse updateTable(UpdateTableRequest updateTableRequest) throws InternalServerException,
ThrottlingException, ValidationException, ResourceNotFoundException, AccessDeniedException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UpdateTableResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateTableRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateTable");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UpdateTable").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(updateTableRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateTableRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* The WriteRecords operation enables you to write your time series data into Timestream. You can specify a single
* data point or a batch of data points to be inserted into the system. Timestream offers you with a flexible schema
* that auto detects the column names and data types for your Timestream tables based on the dimension names and
* data types of the data points you specify when invoking writes into the database. Timestream support eventual
* consistency read semantics. This means that when you query data immediately after writing a batch of data into
* Timestream, the query results might not reflect the results of a recently completed write operation. The results
* may also include some stale data. If you repeat the query request after a short time, the results should return
* the latest data. Service quotas apply. For more information, see Access Management in the
* Timestream Developer Guide.
*
*
* @param writeRecordsRequest
* @return Result of the WriteRecords operation returned by the service.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* Too many requests were made by a user exceeding service quotas. The request was throttled.
* @throws ValidationException
* Invalid or malformed request.
* @throws ResourceNotFoundException
* The operation tried to access a nonexistent resource. The resource might not be specified correctly, or
* its status might not be ACTIVE.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws RejectedRecordsException
* WriteRecords would throw this exception in the following cases:
*
* -
*
* Records with duplicate data where there are multiple records with the same dimensions, timestamps, and
* measure names but different measure values.
*
*
* -
*
* Records with timestamps that lie outside the retention duration of the memory store
*
*
* -
*
* Records with dimensions or measures that exceed the Timestream defined limits.
*
*
*
*
* For more information, see Access Management
* in the Timestream Developer Guide.
* @throws InvalidEndpointException
* The requested endpoint was invalid.
* @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 TimestreamWriteException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamWriteClient.WriteRecords
* @see AWS
* API Documentation
*/
@Override
public WriteRecordsResponse writeRecords(WriteRecordsRequest writeRecordsRequest) throws InternalServerException,
ThrottlingException, ValidationException, ResourceNotFoundException, AccessDeniedException, RejectedRecordsException,
InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamWriteException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
WriteRecordsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED);
boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE;
if (endpointOverridden) {
endpointDiscoveryEnabled = false;
} else if (!endpointDiscoveryEnabled) {
throw new IllegalStateException(
"This operation requires endpoint discovery to be enabled, or for you to specify an endpoint override when the client is created.");
}
URI cachedEndpoint = null;
if (endpointDiscoveryEnabled) {
String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, writeRecordsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Write");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "WriteRecords");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("WriteRecords").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(writeRecordsRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new WriteRecordsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
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 > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(TimestreamWriteException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.0")
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConflictException")
.exceptionBuilderSupplier(ConflictException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidEndpointException")
.exceptionBuilderSupplier(InvalidEndpointException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ValidationException")
.exceptionBuilderSupplier(ValidationException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException")
.exceptionBuilderSupplier(ServiceQuotaExceededException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("RejectedRecordsException")
.exceptionBuilderSupplier(RejectedRecordsException::builder).build());
}
@Override
public void close() {
clientHandler.close();
}
private T applyPaginatorUserAgent(T request) {
Consumer userAgentApplier = b -> b.addApiName(ApiName.builder()
.version(VersionInfo.SDK_VERSION).name("PAGINATED").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(userAgentApplier).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
}