software.amazon.awssdk.services.timestreamquery.DefaultTimestreamQueryClient Maven / Gradle / Ivy
Show all versions of timestreamquery 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.timestreamquery;
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.timestreamquery.model.AccessDeniedException;
import software.amazon.awssdk.services.timestreamquery.model.CancelQueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.CancelQueryResponse;
import software.amazon.awssdk.services.timestreamquery.model.ConflictException;
import software.amazon.awssdk.services.timestreamquery.model.CreateScheduledQueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.CreateScheduledQueryResponse;
import software.amazon.awssdk.services.timestreamquery.model.DeleteScheduledQueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.DeleteScheduledQueryResponse;
import software.amazon.awssdk.services.timestreamquery.model.DescribeEndpointsRequest;
import software.amazon.awssdk.services.timestreamquery.model.DescribeEndpointsResponse;
import software.amazon.awssdk.services.timestreamquery.model.DescribeScheduledQueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.DescribeScheduledQueryResponse;
import software.amazon.awssdk.services.timestreamquery.model.ExecuteScheduledQueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.ExecuteScheduledQueryResponse;
import software.amazon.awssdk.services.timestreamquery.model.InternalServerException;
import software.amazon.awssdk.services.timestreamquery.model.InvalidEndpointException;
import software.amazon.awssdk.services.timestreamquery.model.ListScheduledQueriesRequest;
import software.amazon.awssdk.services.timestreamquery.model.ListScheduledQueriesResponse;
import software.amazon.awssdk.services.timestreamquery.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.timestreamquery.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.timestreamquery.model.PrepareQueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.PrepareQueryResponse;
import software.amazon.awssdk.services.timestreamquery.model.QueryExecutionException;
import software.amazon.awssdk.services.timestreamquery.model.QueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.QueryResponse;
import software.amazon.awssdk.services.timestreamquery.model.ResourceNotFoundException;
import software.amazon.awssdk.services.timestreamquery.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.timestreamquery.model.TagResourceRequest;
import software.amazon.awssdk.services.timestreamquery.model.TagResourceResponse;
import software.amazon.awssdk.services.timestreamquery.model.ThrottlingException;
import software.amazon.awssdk.services.timestreamquery.model.TimestreamQueryException;
import software.amazon.awssdk.services.timestreamquery.model.TimestreamQueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.UntagResourceRequest;
import software.amazon.awssdk.services.timestreamquery.model.UntagResourceResponse;
import software.amazon.awssdk.services.timestreamquery.model.UpdateScheduledQueryRequest;
import software.amazon.awssdk.services.timestreamquery.model.UpdateScheduledQueryResponse;
import software.amazon.awssdk.services.timestreamquery.model.ValidationException;
import software.amazon.awssdk.services.timestreamquery.paginators.ListScheduledQueriesIterable;
import software.amazon.awssdk.services.timestreamquery.paginators.ListTagsForResourceIterable;
import software.amazon.awssdk.services.timestreamquery.paginators.QueryIterable;
import software.amazon.awssdk.services.timestreamquery.transform.CancelQueryRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.CreateScheduledQueryRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.DeleteScheduledQueryRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.DescribeEndpointsRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.DescribeScheduledQueryRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.ExecuteScheduledQueryRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.ListScheduledQueriesRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.PrepareQueryRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.QueryRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.timestreamquery.transform.UpdateScheduledQueryRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link TimestreamQueryClient}.
*
* @see TimestreamQueryClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultTimestreamQueryClient implements TimestreamQueryClient {
private static final Logger log = Logger.loggerFor(DefaultTimestreamQueryClient.class);
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private EndpointDiscoveryRefreshCache endpointDiscoveryCache;
protected DefaultTimestreamQueryClient(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(TimestreamQueryEndpointDiscoveryCacheLoader
.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;
}
/**
*
* Cancels a query that has been issued. Cancellation is provided only if the query has not completed running before
* the cancellation request was issued. Because cancellation is an idempotent operation, subsequent cancellation
* requests will return a CancellationMessage
, indicating that the query has already been canceled. See
* code
* sample for details.
*
*
* @param cancelQueryRequest
* @return Result of the CancelQuery operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.CancelQuery
* @see AWS
* API Documentation
*/
@Override
public CancelQueryResponse cancelQuery(CancelQueryRequest cancelQueryRequest) throws AccessDeniedException,
InternalServerException, ThrottlingException, ValidationException, InvalidEndpointException, AwsServiceException,
SdkClientException, TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CancelQueryResponse::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 = cancelQueryRequest.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(cancelQueryRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, cancelQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CancelQuery");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CancelQuery").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(cancelQueryRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CancelQueryRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Create a scheduled query that will be run on your behalf at the configured schedule. Timestream assumes the
* execution role provided as part of the ScheduledQueryExecutionRoleArn
parameter to run the query.
* You can use the NotificationConfiguration
parameter to configure notification for your scheduled
* query operations.
*
*
* @param createScheduledQueryRequest
* @return Result of the CreateScheduledQuery operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws ConflictException
* Unable to poll results for a cancelled query.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ServiceQuotaExceededException
* You have exceeded the service quota.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.CreateScheduledQuery
* @see AWS API Documentation
*/
@Override
public CreateScheduledQueryResponse createScheduledQuery(CreateScheduledQueryRequest createScheduledQueryRequest)
throws AccessDeniedException, ConflictException, InternalServerException, ServiceQuotaExceededException,
ThrottlingException, ValidationException, InvalidEndpointException, AwsServiceException, SdkClientException,
TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateScheduledQueryResponse::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 = createScheduledQueryRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(createScheduledQueryRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, createScheduledQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateScheduledQuery");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateScheduledQuery").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(createScheduledQueryRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateScheduledQueryRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a given scheduled query. This is an irreversible operation.
*
*
* @param deleteScheduledQueryRequest
* @return Result of the DeleteScheduledQuery operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ResourceNotFoundException
* The requested resource could not be found.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.DeleteScheduledQuery
* @see AWS API Documentation
*/
@Override
public DeleteScheduledQueryResponse deleteScheduledQuery(DeleteScheduledQueryRequest deleteScheduledQueryRequest)
throws AccessDeniedException, InternalServerException, ResourceNotFoundException, ThrottlingException,
ValidationException, InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteScheduledQueryResponse::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 = deleteScheduledQueryRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(deleteScheduledQueryRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteScheduledQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteScheduledQuery");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteScheduledQuery").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(deleteScheduledQueryRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteScheduledQueryRequestMarshaller(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 the Timestream 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:
*
*
* -
*
* You are using VPC endpoints
* (Amazon Web Services PrivateLink) with Timestream
*
*
* -
*
* 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 and when to use and implement DescribeEndpoints, see The Endpoint Discovery Pattern.
*
*
* @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
* The request was denied due to request throttling.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.DescribeEndpoints
* @see AWS API Documentation
*/
@Override
public DescribeEndpointsResponse describeEndpoints(DescribeEndpointsRequest describeEndpointsRequest)
throws InternalServerException, ValidationException, ThrottlingException, AwsServiceException, SdkClientException,
TimestreamQueryException {
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 Query");
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()));
}
}
/**
*
* Provides detailed information about a scheduled query.
*
*
* @param describeScheduledQueryRequest
* @return Result of the DescribeScheduledQuery operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ResourceNotFoundException
* The requested resource could not be found.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.DescribeScheduledQuery
* @see AWS API Documentation
*/
@Override
public DescribeScheduledQueryResponse describeScheduledQuery(DescribeScheduledQueryRequest describeScheduledQueryRequest)
throws AccessDeniedException, InternalServerException, ResourceNotFoundException, ThrottlingException,
ValidationException, InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeScheduledQueryResponse::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 = describeScheduledQueryRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(describeScheduledQueryRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeScheduledQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeScheduledQuery");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeScheduledQuery").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(describeScheduledQueryRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeScheduledQueryRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* You can use this API to run a scheduled query manually.
*
*
* @param executeScheduledQueryRequest
* @return Result of the ExecuteScheduledQuery operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ResourceNotFoundException
* The requested resource could not be found.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.ExecuteScheduledQuery
* @see AWS API Documentation
*/
@Override
public ExecuteScheduledQueryResponse executeScheduledQuery(ExecuteScheduledQueryRequest executeScheduledQueryRequest)
throws AccessDeniedException, InternalServerException, ResourceNotFoundException, ThrottlingException,
ValidationException, InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ExecuteScheduledQueryResponse::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 = executeScheduledQueryRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(executeScheduledQueryRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, executeScheduledQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ExecuteScheduledQuery");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ExecuteScheduledQuery").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(executeScheduledQueryRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ExecuteScheduledQueryRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets a list of all scheduled queries in the caller's Amazon account and Region. ListScheduledQueries
* is eventually consistent.
*
*
* @param listScheduledQueriesRequest
* @return Result of the ListScheduledQueries operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.ListScheduledQueries
* @see AWS API Documentation
*/
@Override
public ListScheduledQueriesResponse listScheduledQueries(ListScheduledQueriesRequest listScheduledQueriesRequest)
throws AccessDeniedException, InternalServerException, ThrottlingException, ValidationException,
InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListScheduledQueriesResponse::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 = listScheduledQueriesRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(listScheduledQueriesRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, listScheduledQueriesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListScheduledQueries");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListScheduledQueries").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(listScheduledQueriesRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListScheduledQueriesRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets a list of all scheduled queries in the caller's Amazon account and Region. ListScheduledQueries
* is eventually consistent.
*
*
*
* This is a variant of
* {@link #listScheduledQueries(software.amazon.awssdk.services.timestreamquery.model.ListScheduledQueriesRequest)}
* 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.timestreamquery.paginators.ListScheduledQueriesIterable responses = client.listScheduledQueriesPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.timestreamquery.paginators.ListScheduledQueriesIterable responses = client
* .listScheduledQueriesPaginator(request);
* for (software.amazon.awssdk.services.timestreamquery.model.ListScheduledQueriesResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.timestreamquery.paginators.ListScheduledQueriesIterable responses = client.listScheduledQueriesPaginator(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 #listScheduledQueries(software.amazon.awssdk.services.timestreamquery.model.ListScheduledQueriesRequest)}
* operation.
*
*
* @param listScheduledQueriesRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.ListScheduledQueries
* @see AWS API Documentation
*/
@Override
public ListScheduledQueriesIterable listScheduledQueriesPaginator(ListScheduledQueriesRequest listScheduledQueriesRequest)
throws AccessDeniedException, InternalServerException, ThrottlingException, ValidationException,
InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamQueryException {
return new ListScheduledQueriesIterable(this, applyPaginatorUserAgent(listScheduledQueriesRequest));
}
/**
*
* List all tags on a Timestream query resource.
*
*
* @param listTagsForResourceRequest
* @return Result of the ListTagsForResource operation returned by the service.
* @throws ResourceNotFoundException
* The requested resource could not be found.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest)
throws ResourceNotFoundException, ThrottlingException, ValidationException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamQueryException {
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 = listTagsForResourceRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(listTagsForResourceRequest.overrideConfiguration().orElse(null)).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 Query");
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()));
}
}
/**
*
* List all tags on a Timestream query resource.
*
*
*
* This is a variant of
* {@link #listTagsForResource(software.amazon.awssdk.services.timestreamquery.model.ListTagsForResourceRequest)}
* 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.timestreamquery.paginators.ListTagsForResourceIterable responses = client.listTagsForResourcePaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.timestreamquery.paginators.ListTagsForResourceIterable responses = client
* .listTagsForResourcePaginator(request);
* for (software.amazon.awssdk.services.timestreamquery.model.ListTagsForResourceResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.timestreamquery.paginators.ListTagsForResourceIterable responses = client.listTagsForResourcePaginator(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 #listTagsForResource(software.amazon.awssdk.services.timestreamquery.model.ListTagsForResourceRequest)}
* operation.
*
*
* @param listTagsForResourceRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws ResourceNotFoundException
* The requested resource could not be found.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public ListTagsForResourceIterable listTagsForResourcePaginator(ListTagsForResourceRequest listTagsForResourceRequest)
throws ResourceNotFoundException, ThrottlingException, ValidationException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamQueryException {
return new ListTagsForResourceIterable(this, applyPaginatorUserAgent(listTagsForResourceRequest));
}
/**
*
* A synchronous operation that allows you to submit a query with parameters to be stored by Timestream for later
* running. Timestream only supports using this operation with the PrepareQueryRequest$ValidateOnly
* set to true
.
*
*
* @param prepareQueryRequest
* @return Result of the PrepareQuery operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.PrepareQuery
* @see AWS
* API Documentation
*/
@Override
public PrepareQueryResponse prepareQuery(PrepareQueryRequest prepareQueryRequest) throws AccessDeniedException,
InternalServerException, ThrottlingException, ValidationException, InvalidEndpointException, AwsServiceException,
SdkClientException, TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
PrepareQueryResponse::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 = prepareQueryRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(prepareQueryRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, prepareQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PrepareQuery");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("PrepareQuery").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(prepareQueryRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new PrepareQueryRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Query
is a synchronous operation that enables you to run a query against your Amazon Timestream
* data. Query
will time out after 60 seconds. You must update the default timeout in the SDK to
* support a timeout of 60 seconds. See the code sample
* for details.
*
*
* Your query request will fail in the following cases:
*
*
* -
*
* If you submit a Query
request with the same client token outside of the 5-minute idempotency window.
*
*
* -
*
* If you submit a Query
request with the same client token, but change other parameters, within the
* 5-minute idempotency window.
*
*
* -
*
* If the size of the row (including the query metadata) exceeds 1 MB, then the query will fail with the following
* error message:
*
*
* Query aborted as max page response size has been exceeded by the output result row
*
*
* -
*
* If the IAM principal of the query initiator and the result reader are not the same and/or the query initiator and
* the result reader do not have the same query string in the query requests, the query will fail with an
* Invalid pagination token
error.
*
*
*
*
* @param queryRequest
* @return Result of the Query operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws ConflictException
* Unable to poll results for a cancelled query.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws QueryExecutionException
* Timestream was unable to run the query successfully.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.Query
* @see AWS API
* Documentation
*/
@Override
public QueryResponse query(QueryRequest queryRequest) throws AccessDeniedException, ConflictException,
InternalServerException, QueryExecutionException, ThrottlingException, ValidationException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
QueryResponse::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 = queryRequest.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(queryRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, queryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "Query");
return clientHandler.execute(new ClientExecutionParams().withOperationName("Query")
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.discoveredEndpoint(cachedEndpoint).withInput(queryRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new QueryRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Query
is a synchronous operation that enables you to run a query against your Amazon Timestream
* data. Query
will time out after 60 seconds. You must update the default timeout in the SDK to
* support a timeout of 60 seconds. See the code sample
* for details.
*
*
* Your query request will fail in the following cases:
*
*
* -
*
* If you submit a Query
request with the same client token outside of the 5-minute idempotency window.
*
*
* -
*
* If you submit a Query
request with the same client token, but change other parameters, within the
* 5-minute idempotency window.
*
*
* -
*
* If the size of the row (including the query metadata) exceeds 1 MB, then the query will fail with the following
* error message:
*
*
* Query aborted as max page response size has been exceeded by the output result row
*
*
* -
*
* If the IAM principal of the query initiator and the result reader are not the same and/or the query initiator and
* the result reader do not have the same query string in the query requests, the query will fail with an
* Invalid pagination token
error.
*
*
*
*
*
* This is a variant of {@link #query(software.amazon.awssdk.services.timestreamquery.model.QueryRequest)}
* 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.timestreamquery.paginators.QueryIterable responses = client.queryPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.timestreamquery.paginators.QueryIterable responses = client.queryPaginator(request);
* for (software.amazon.awssdk.services.timestreamquery.model.QueryResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.timestreamquery.paginators.QueryIterable responses = client.queryPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Please notice that the configuration of MaxRows 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 #query(software.amazon.awssdk.services.timestreamquery.model.QueryRequest)} operation.
*
*
* @param queryRequest
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws ConflictException
* Unable to poll results for a cancelled query.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws QueryExecutionException
* Timestream was unable to run the query successfully.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.Query
* @see AWS API
* Documentation
*/
@Override
public QueryIterable queryPaginator(QueryRequest queryRequest) throws AccessDeniedException, ConflictException,
InternalServerException, QueryExecutionException, ThrottlingException, ValidationException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamQueryException {
return new QueryIterable(this, applyPaginatorUserAgent(queryRequest));
}
/**
*
* 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 requested resource could not be found.
* @throws ServiceQuotaExceededException
* You have exceeded the service quota.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.TagResource
* @see AWS
* API Documentation
*/
@Override
public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws ResourceNotFoundException,
ServiceQuotaExceededException, ThrottlingException, ValidationException, InvalidEndpointException,
AwsServiceException, SdkClientException, TimestreamQueryException {
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 = tagResourceRequest.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(tagResourceRequest.overrideConfiguration().orElse(null)).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 Query");
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 query resource.
*
*
* @param untagResourceRequest
* @return Result of the UntagResource operation returned by the service.
* @throws ValidationException
* Invalid or malformed request.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ResourceNotFoundException
* The requested resource could not be found.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.UntagResource
* @see AWS API Documentation
*/
@Override
public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws ValidationException,
ThrottlingException, ResourceNotFoundException, InvalidEndpointException, AwsServiceException, SdkClientException,
TimestreamQueryException {
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 = untagResourceRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(untagResourceRequest.overrideConfiguration().orElse(null)).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 Query");
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()));
}
}
/**
*
* Update a scheduled query.
*
*
* @param updateScheduledQueryRequest
* @return Result of the UpdateScheduledQuery operation returned by the service.
* @throws AccessDeniedException
* You are not authorized to perform this action.
* @throws InternalServerException
* Timestream was unable to fully process this request because of an internal server error.
* @throws ResourceNotFoundException
* The requested resource could not be found.
* @throws ThrottlingException
* The request was denied due to request throttling.
* @throws ValidationException
* Invalid or malformed request.
* @throws InvalidEndpointException
* The requested endpoint was not valid.
* @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 TimestreamQueryException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample TimestreamQueryClient.UpdateScheduledQuery
* @see AWS API Documentation
*/
@Override
public UpdateScheduledQueryResponse updateScheduledQuery(UpdateScheduledQueryRequest updateScheduledQueryRequest)
throws AccessDeniedException, InternalServerException, ResourceNotFoundException, ThrottlingException,
ValidationException, InvalidEndpointException, AwsServiceException, SdkClientException, TimestreamQueryException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateScheduledQueryResponse::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 = updateScheduledQueryRequest.overrideConfiguration()
.flatMap(AwsRequestOverrideConfiguration::credentialsProvider)
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER)).resolveCredentials()
.accessKeyId();
EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true)
.defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT))
.overrideConfiguration(updateScheduledQueryRequest.overrideConfiguration().orElse(null)).build();
cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest);
}
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateScheduledQueryRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Timestream Query");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateScheduledQuery");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UpdateScheduledQuery").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).discoveredEndpoint(cachedEndpoint)
.withInput(updateScheduledQueryRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateScheduledQueryRequestMarshaller(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(TimestreamQueryException::builder)
.protocol(AwsJsonProtocol.AWS_JSON)
.protocolVersion("1.0")
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConflictException")
.exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InvalidEndpointException")
.exceptionBuilderSupplier(InvalidEndpointException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ValidationException")
.exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException")
.exceptionBuilderSupplier(ServiceQuotaExceededException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("QueryExecutionException")
.exceptionBuilderSupplier(QueryExecutionException::builder).httpStatusCode(400).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();
}
}