Struct aws_sdk_timestreamquery::client::Client
source · pub struct Client { /* private fields */ }Expand description
Client for Amazon Timestream Query
Client for invoking operations on Amazon Timestream Query. Each operation on Amazon Timestream Query is a method on this
this struct. .send() MUST be invoked on the generated operations to dispatch the request to the service.
Constructing a Client
A Config is required to construct a client. For most use cases, the aws-config
crate should be used to automatically resolve this config using
aws_config::load_from_env(), since this will resolve an SdkConfig which can be shared
across multiple different AWS SDK clients. This config resolution process can be customized
by calling aws_config::from_env() instead, which returns a ConfigLoader that uses
the builder pattern to customize the default config.
In the simplest case, creating a client looks as follows:
let config = aws_config::load_from_env().await;
// You MUST call `with_endpoint_discovery_enabled` to produce a working client for this service.
let client = aws_sdk_timestreamquery::Client::new(&config).with_endpoint_discovery_enabled().await;Occasionally, SDKs may have additional service-specific that can be set on the Config that
is absent from SdkConfig, or slightly different settings for a specific client may be desired.
The Config struct implements From<&SdkConfig>, so setting these specific settings can be
done as follows:
let sdk_config = ::aws_config::load_from_env().await;
let config = aws_sdk_timestreamquery::config::Builder::from(&sdk_config)
.some_service_specific_setting("value")
.build();See the aws-config docs and Config for more information on customizing configuration.
Note: Client construction is expensive due to connection thread pool initialization, and should be done once at application start-up.
Using the Client
A client has a function for every operation that can be performed by the service.
For example, the CancelQuery operation has
a Client::cancel_query, function which returns a builder for that operation.
The fluent builder ultimately has a send() function that returns an async future that
returns a result, as illustrated below:
let result = client.cancel_query()
.query_id("example")
.send()
.await;The underlying HTTP requests that get made by this can be modified with the customize_operation
function on the fluent builder. See the customize module for more
information.
Implementations§
source§impl Client
impl Client
sourcepub fn cancel_query(&self) -> CancelQueryFluentBuilder
pub fn cancel_query(&self) -> CancelQueryFluentBuilder
Constructs a fluent builder for the CancelQuery operation.
- The fluent builder is configurable:
query_id(impl Into<String>)/set_query_id(Option<String>):
required: trueThe ID of the query that needs to be cancelled.
QueryIDis returned as part of the query result.
- On success, responds with
CancelQueryOutputwith field(s):cancellation_message(Option<String>):A
CancellationMessageis returned when aCancelQueryrequest for the query specified byQueryIdhas already been issued.
- On failure, responds with
SdkError<CancelQueryError>
source§impl Client
impl Client
sourcepub fn create_scheduled_query(&self) -> CreateScheduledQueryFluentBuilder
pub fn create_scheduled_query(&self) -> CreateScheduledQueryFluentBuilder
Constructs a fluent builder for the CreateScheduledQuery operation.
- The fluent builder is configurable:
name(impl Into<String>)/set_name(Option<String>):
required: trueName of the scheduled query.
query_string(impl Into<String>)/set_query_string(Option<String>):
required: trueThe query string to run. Parameter names can be specified in the query string
@character followed by an identifier. The named Parameter@scheduled_runtimeis reserved and can be used in the query to get the time at which the query is scheduled to run.The timestamp calculated according to the ScheduleConfiguration parameter, will be the value of
@scheduled_runtimeparamater for each query run. For example, consider an instance of a scheduled query executing on 2021-12-01 00:00:00. For this instance, the@scheduled_runtimeparameter is initialized to the timestamp 2021-12-01 00:00:00 when invoking the query.schedule_configuration(ScheduleConfiguration)/set_schedule_configuration(Option<ScheduleConfiguration>):
required: trueThe schedule configuration for the query.
notification_configuration(NotificationConfiguration)/set_notification_configuration(Option<NotificationConfiguration>):
required: trueNotification configuration for the scheduled query. A notification is sent by Timestream when a query run finishes, when the state is updated or when you delete it.
target_configuration(TargetConfiguration)/set_target_configuration(Option<TargetConfiguration>):
required: falseConfiguration used for writing the result of a query.
client_token(impl Into<String>)/set_client_token(Option<String>):
required: falseUsing a ClientToken makes the call to CreateScheduledQuery idempotent, in other words, making the same request repeatedly will produce the same result. Making multiple identical CreateScheduledQuery requests has the same effect as making a single request.
-
If CreateScheduledQuery is called without a
ClientToken, the Query SDK generates aClientTokenon your behalf. -
After 8 hours, any request with the same
ClientTokenis treated as a new request.
-
scheduled_query_execution_role_arn(impl Into<String>)/set_scheduled_query_execution_role_arn(Option<String>):
required: trueThe ARN for the IAM role that Timestream will assume when running the scheduled query.
tags(Tag)/set_tags(Option<Vec::<Tag>>):
required: falseA list of key-value pairs to label the scheduled query.
kms_key_id(impl Into<String>)/set_kms_key_id(Option<String>):
required: falseThe Amazon KMS key used to encrypt the scheduled query resource, at-rest. If the Amazon KMS key is not specified, the scheduled query resource will be encrypted with a Timestream owned Amazon KMS key. To specify a KMS key, use the key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix the name with alias/
If ErrorReportConfiguration uses
SSE_KMSas encryption type, the same KmsKeyId is used to encrypt the error report at rest.error_report_configuration(ErrorReportConfiguration)/set_error_report_configuration(Option<ErrorReportConfiguration>):
required: trueConfiguration for error reporting. Error reports will be generated when a problem is encountered when writing the query results.
- On success, responds with
CreateScheduledQueryOutputwith field(s):arn(String):ARN for the created scheduled query.
- On failure, responds with
SdkError<CreateScheduledQueryError>
source§impl Client
impl Client
sourcepub fn delete_scheduled_query(&self) -> DeleteScheduledQueryFluentBuilder
pub fn delete_scheduled_query(&self) -> DeleteScheduledQueryFluentBuilder
Constructs a fluent builder for the DeleteScheduledQuery operation.
- The fluent builder is configurable:
scheduled_query_arn(impl Into<String>)/set_scheduled_query_arn(Option<String>):
required: trueThe ARN of the scheduled query.
- On success, responds with
DeleteScheduledQueryOutput - On failure, responds with
SdkError<DeleteScheduledQueryError>
source§impl Client
impl Client
sourcepub fn describe_endpoints(&self) -> DescribeEndpointsFluentBuilder
pub fn describe_endpoints(&self) -> DescribeEndpointsFluentBuilder
Constructs a fluent builder for the DescribeEndpoints operation.
- The fluent builder takes no input, just
sendit. - On success, responds with
DescribeEndpointsOutputwith field(s):endpoints(Vec::<Endpoint>):An
Endpointsobject is returned when aDescribeEndpointsrequest is made.
- On failure, responds with
SdkError<DescribeEndpointsError>
source§impl Client
impl Client
sourcepub fn describe_scheduled_query(&self) -> DescribeScheduledQueryFluentBuilder
pub fn describe_scheduled_query(&self) -> DescribeScheduledQueryFluentBuilder
Constructs a fluent builder for the DescribeScheduledQuery operation.
- The fluent builder is configurable:
scheduled_query_arn(impl Into<String>)/set_scheduled_query_arn(Option<String>):
required: trueThe ARN of the scheduled query.
- On success, responds with
DescribeScheduledQueryOutputwith field(s):scheduled_query(Option<ScheduledQueryDescription>):The scheduled query.
- On failure, responds with
SdkError<DescribeScheduledQueryError>
source§impl Client
impl Client
sourcepub fn execute_scheduled_query(&self) -> ExecuteScheduledQueryFluentBuilder
pub fn execute_scheduled_query(&self) -> ExecuteScheduledQueryFluentBuilder
Constructs a fluent builder for the ExecuteScheduledQuery operation.
- The fluent builder is configurable:
scheduled_query_arn(impl Into<String>)/set_scheduled_query_arn(Option<String>):
required: trueARN of the scheduled query.
invocation_time(DateTime)/set_invocation_time(Option<DateTime>):
required: trueThe timestamp in UTC. Query will be run as if it was invoked at this timestamp.
client_token(impl Into<String>)/set_client_token(Option<String>):
required: falseNot used.
- On success, responds with
ExecuteScheduledQueryOutput - On failure, responds with
SdkError<ExecuteScheduledQueryError>
source§impl Client
impl Client
sourcepub fn list_scheduled_queries(&self) -> ListScheduledQueriesFluentBuilder
pub fn list_scheduled_queries(&self) -> ListScheduledQueriesFluentBuilder
Constructs a fluent builder for the ListScheduledQueries operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
max_results(i32)/set_max_results(Option<i32>):
required: falseThe maximum number of items to return in the output. If the total number of items available is more than the value specified, a
NextTokenis provided in the output. To resume pagination, provide theNextTokenvalue as the argument to the subsequent call toListScheduledQueriesRequest.next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseA pagination token to resume pagination.
- On success, responds with
ListScheduledQueriesOutputwith field(s):scheduled_queries(Vec::<ScheduledQuery>):A list of scheduled queries.
next_token(Option<String>):A token to specify where to start paginating. This is the NextToken from a previously truncated response.
- On failure, responds with
SdkError<ListScheduledQueriesError>
source§impl Client
impl Client
Constructs a fluent builder for the ListTagsForResource operation.
This operation supports pagination; See into_paginator().
- The fluent builder is configurable:
resource_arn(impl Into<String>)/set_resource_arn(Option<String>):
required: trueThe Timestream resource with tags to be listed. This value is an Amazon Resource Name (ARN).
max_results(i32)/set_max_results(Option<i32>):
required: falseThe maximum number of tags to return.
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseA pagination token to resume pagination.
- On success, responds with
ListTagsForResourceOutputwith field(s):tags(Vec::<Tag>):The tags currently associated with the Timestream resource.
next_token(Option<String>):A pagination token to resume pagination with a subsequent call to
ListTagsForResourceResponse.
- On failure, responds with
SdkError<ListTagsForResourceError>
source§impl Client
impl Client
sourcepub fn prepare_query(&self) -> PrepareQueryFluentBuilder
pub fn prepare_query(&self) -> PrepareQueryFluentBuilder
Constructs a fluent builder for the PrepareQuery operation.
- The fluent builder is configurable:
query_string(impl Into<String>)/set_query_string(Option<String>):
required: trueThe Timestream query string that you want to use as a prepared statement. Parameter names can be specified in the query string
@character followed by an identifier.validate_only(bool)/set_validate_only(Option<bool>):
required: falseBy setting this value to
true, Timestream will only validate that the query string is a valid Timestream query, and not store the prepared query for later use.
- On success, responds with
PrepareQueryOutputwith field(s):query_string(String):The query string that you want prepare.
columns(Vec::<SelectColumn>):A list of SELECT clause columns of the submitted query string.
parameters(Vec::<ParameterMapping>):A list of parameters used in the submitted query string.
- On failure, responds with
SdkError<PrepareQueryError>
source§impl Client
impl Client
sourcepub fn query(&self) -> QueryFluentBuilder
pub fn query(&self) -> QueryFluentBuilder
Constructs a fluent builder for the Query operation.
- The fluent builder is configurable:
query_string(impl Into<String>)/set_query_string(Option<String>):
required: trueThe query to be run by Timestream.
client_token(impl Into<String>)/set_client_token(Option<String>):
required: falseUnique, case-sensitive string of up to 64 ASCII characters specified when a
Queryrequest is made. Providing aClientTokenmakes the call toQueryidempotent. This means that running the same query repeatedly will produce the same result. In other words, making multiple identicalQueryrequests has the same effect as making a single request. When usingClientTokenin a query, note the following:-
If the Query API is instantiated without a
ClientToken, the Query SDK generates aClientTokenon your behalf. -
If the
Queryinvocation only contains theClientTokenbut does not include aNextToken, that invocation ofQueryis assumed to be a new query run. -
If the invocation contains
NextToken, that particular invocation is assumed to be a subsequent invocation of a prior call to the Query API, and a result set is returned. -
After 4 hours, any request with the same
ClientTokenis treated as a new request.
-
next_token(impl Into<String>)/set_next_token(Option<String>):
required: falseA pagination token used to return a set of results. When the
QueryAPI is invoked usingNextToken, that particular invocation is assumed to be a subsequent invocation of a prior call toQuery, and a result set is returned. However, if theQueryinvocation only contains theClientToken, that invocation ofQueryis assumed to be a new query run.Note the following when using NextToken in a query:
-
A pagination token can be used for up to five
Queryinvocations, OR for a duration of up to 1 hour – whichever comes first. -
Using the same
NextTokenwill return the same set of records. To keep paginating through the result set, you must to use the most recentnextToken. -
Suppose a
Queryinvocation returns twoNextTokenvalues,TokenAandTokenB. IfTokenBis used in a subsequentQueryinvocation, thenTokenAis invalidated and cannot be reused. -
To request a previous result set from a query after pagination has begun, you must re-invoke the Query API.
-
The latest
NextTokenshould be used to paginate untilnullis returned, at which point a newNextTokenshould be used. -
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 tokenerror.
-
max_rows(i32)/set_max_rows(Option<i32>):
required: falseThe total number of rows to be returned in the
Queryoutput. The initial run ofQuerywith aMaxRowsvalue specified will return the result set of the query in two cases:-
The size of the result is less than
1MB. -
The number of rows in the result set is less than the value of
maxRows.
Otherwise, the initial invocation of
Queryonly returns aNextToken, which can then be used in subsequent calls to fetch the result set. To resume pagination, provide theNextTokenvalue in the subsequent command.If the row size is large (e.g. a row has many columns), Timestream may return fewer rows to keep the response size from exceeding the 1 MB limit. If
MaxRowsis not provided, Timestream will send the necessary number of rows to meet the 1 MB limit.-
- On success, responds with
QueryOutputwith field(s):query_id(String):A unique ID for the given query.
next_token(Option<String>):A pagination token that can be used again on a
Querycall to get the next set of results.rows(Vec::<Row>):The result set rows returned by the query.
column_info(Vec::<ColumnInfo>):The column data types of the returned result set.
query_status(Option<QueryStatus>):Information about the status of the query, including progress and bytes scanned.
- On failure, responds with
SdkError<QueryError>
source§impl Client
impl Client
sourcepub fn tag_resource(&self) -> TagResourceFluentBuilder
pub fn tag_resource(&self) -> TagResourceFluentBuilder
Constructs a fluent builder for the TagResource operation.
- The fluent builder is configurable:
resource_arn(impl Into<String>)/set_resource_arn(Option<String>):
required: trueIdentifies the Timestream resource to which tags should be added. This value is an Amazon Resource Name (ARN).
tags(Tag)/set_tags(Option<Vec::<Tag>>):
required: trueThe tags to be assigned to the Timestream resource.
- On success, responds with
TagResourceOutput - On failure, responds with
SdkError<TagResourceError>
source§impl Client
impl Client
sourcepub fn untag_resource(&self) -> UntagResourceFluentBuilder
pub fn untag_resource(&self) -> UntagResourceFluentBuilder
Constructs a fluent builder for the UntagResource operation.
- The fluent builder is configurable:
resource_arn(impl Into<String>)/set_resource_arn(Option<String>):
required: trueThe Timestream resource that the tags will be removed from. This value is an Amazon Resource Name (ARN).
tag_keys(impl Into<String>)/set_tag_keys(Option<Vec::<String>>):
required: trueA list of tags keys. Existing tags of the resource whose keys are members of this list will be removed from the Timestream resource.
- On success, responds with
UntagResourceOutput - On failure, responds with
SdkError<UntagResourceError>
source§impl Client
impl Client
sourcepub fn update_scheduled_query(&self) -> UpdateScheduledQueryFluentBuilder
pub fn update_scheduled_query(&self) -> UpdateScheduledQueryFluentBuilder
Constructs a fluent builder for the UpdateScheduledQuery operation.
- The fluent builder is configurable:
scheduled_query_arn(impl Into<String>)/set_scheduled_query_arn(Option<String>):
required: trueARN of the scheuled query.
state(ScheduledQueryState)/set_state(Option<ScheduledQueryState>):
required: trueState of the scheduled query.
- On success, responds with
UpdateScheduledQueryOutput - On failure, responds with
SdkError<UpdateScheduledQueryError>
source§impl Client
impl Client
sourcepub async fn with_endpoint_discovery_enabled(
self
) -> Result<(Self, ReloadEndpoint), BoxError>
pub async fn with_endpoint_discovery_enabled( self ) -> Result<(Self, ReloadEndpoint), BoxError>
Enable endpoint discovery for this client
This method MUST be called to construct a working client.
source§impl Client
impl Client
sourcepub fn from_conf(conf: Config) -> Self
pub fn from_conf(conf: Config) -> Self
Creates a new client from the service Config.
Panics
This method will panic in the following cases:
- Retries or timeouts are enabled without a
sleep_implconfigured. - Identity caching is enabled without a
sleep_implandtime_sourceconfigured. - No
behavior_versionis provided.
The panic message for each of these will have instructions on how to resolve them.
source§impl Client
impl Client
sourcepub fn new(sdk_config: &SdkConfig) -> Self
pub fn new(sdk_config: &SdkConfig) -> Self
Creates a new client from an SDK Config.
Panics
- This method will panic if the
sdk_configis missing an async sleep implementation. If you experience this panic, set thesleep_implon the Config passed into this function to fix it. - This method will panic if the
sdk_configis missing an HTTP connector. If you experience this panic, set thehttp_connectoron the Config passed into this function to fix it. - This method will panic if no
BehaviorVersionis provided. If you experience this panic, setbehavior_versionon the Config or enable thebehavior-version-latestCargo feature.