aws_sdk_timestreamwrite/operation/write_records/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::write_records::_write_records_output::WriteRecordsOutputBuilder;
3
4pub use crate::operation::write_records::_write_records_input::WriteRecordsInputBuilder;
5
6impl crate::operation::write_records::builders::WriteRecordsInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(
9 self,
10 client: &crate::Client,
11 ) -> ::std::result::Result<
12 crate::operation::write_records::WriteRecordsOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::write_records::WriteRecordsError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.write_records();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `WriteRecords`.
24///
25/// <p>Enables you to write your time-series data into Timestream. You can specify a single data point or a batch of data points to be inserted into the system. Timestream offers you a flexible schema that auto detects the column names and data types for your Timestream tables based on the dimension names and data types of the data points you specify when invoking writes into the database.</p>
26/// <p>Timestream supports eventual consistency read semantics. This means that when you query data immediately after writing a batch of data into Timestream, the query results might not reflect the results of a recently completed write operation. The results may also include some stale data. If you repeat the query request after a short time, the results should return the latest data. <a href="https://docs.aws.amazon.com/timestream/latest/developerguide/ts-limits.html">Service quotas apply</a>.</p>
27/// <p>See <a href="https://docs.aws.amazon.com/timestream/latest/developerguide/code-samples.write.html">code sample</a> for details.</p>
28/// <p><b>Upserts</b></p>
29/// <p>You can use the <code>Version</code> parameter in a <code>WriteRecords</code> request to update data points. Timestream tracks a version number with each record. <code>Version</code> defaults to <code>1</code> when it's not specified for the record in the request. Timestream updates an existing record’s measure value along with its <code>Version</code> when it receives a write request with a higher <code>Version</code> number for that record. When it receives an update request where the measure value is the same as that of the existing record, Timestream still updates <code>Version</code>, if it is greater than the existing value of <code>Version</code>. You can update a data point as many times as desired, as long as the value of <code>Version</code> continuously increases.</p>
30/// <p>For example, suppose you write a new record without indicating <code>Version</code> in the request. Timestream stores this record, and set <code>Version</code> to <code>1</code>. Now, suppose you try to update this record with a <code>WriteRecords</code> request of the same record with a different measure value but, like before, do not provide <code>Version</code>. In this case, Timestream will reject this update with a <code>RejectedRecordsException</code> since the updated record’s version is not greater than the existing value of Version.</p>
31/// <p>However, if you were to resend the update request with <code>Version</code> set to <code>2</code>, Timestream would then succeed in updating the record’s value, and the <code>Version</code> would be set to <code>2</code>. Next, suppose you sent a <code>WriteRecords</code> request with this same record and an identical measure value, but with <code>Version</code> set to <code>3</code>. In this case, Timestream would only update <code>Version</code> to <code>3</code>. Any further updates would need to send a version number greater than <code>3</code>, or the update requests would receive a <code>RejectedRecordsException</code>.</p>
32#[derive(::std::clone::Clone, ::std::fmt::Debug)]
33pub struct WriteRecordsFluentBuilder {
34 handle: ::std::sync::Arc<crate::client::Handle>,
35 inner: crate::operation::write_records::builders::WriteRecordsInputBuilder,
36 config_override: ::std::option::Option<crate::config::Builder>,
37}
38impl
39 crate::client::customize::internal::CustomizableSend<
40 crate::operation::write_records::WriteRecordsOutput,
41 crate::operation::write_records::WriteRecordsError,
42 > for WriteRecordsFluentBuilder
43{
44 fn send(
45 self,
46 config_override: crate::config::Builder,
47 ) -> crate::client::customize::internal::BoxFuture<
48 crate::client::customize::internal::SendResult<
49 crate::operation::write_records::WriteRecordsOutput,
50 crate::operation::write_records::WriteRecordsError,
51 >,
52 > {
53 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
54 }
55}
56impl WriteRecordsFluentBuilder {
57 /// Creates a new `WriteRecordsFluentBuilder`.
58 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
59 Self {
60 handle,
61 inner: ::std::default::Default::default(),
62 config_override: ::std::option::Option::None,
63 }
64 }
65 /// Access the WriteRecords as a reference.
66 pub fn as_input(&self) -> &crate::operation::write_records::builders::WriteRecordsInputBuilder {
67 &self.inner
68 }
69 /// Sends the request and returns the response.
70 ///
71 /// If an error occurs, an `SdkError` will be returned with additional details that
72 /// can be matched against.
73 ///
74 /// By default, any retryable failures will be retried twice. Retry behavior
75 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
76 /// set when configuring the client.
77 pub async fn send(
78 self,
79 ) -> ::std::result::Result<
80 crate::operation::write_records::WriteRecordsOutput,
81 ::aws_smithy_runtime_api::client::result::SdkError<
82 crate::operation::write_records::WriteRecordsError,
83 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
84 >,
85 > {
86 let input = self
87 .inner
88 .build()
89 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
90 let runtime_plugins = crate::operation::write_records::WriteRecords::operation_runtime_plugins(
91 self.handle.runtime_plugins.clone(),
92 &self.handle.conf,
93 self.config_override,
94 );
95 crate::operation::write_records::WriteRecords::orchestrate(&runtime_plugins, input).await
96 }
97
98 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
99 pub fn customize(
100 self,
101 ) -> crate::client::customize::CustomizableOperation<
102 crate::operation::write_records::WriteRecordsOutput,
103 crate::operation::write_records::WriteRecordsError,
104 Self,
105 > {
106 crate::client::customize::CustomizableOperation::new(self)
107 }
108 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
109 self.set_config_override(::std::option::Option::Some(config_override.into()));
110 self
111 }
112
113 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
114 self.config_override = config_override;
115 self
116 }
117 /// <p>The name of the Timestream database.</p>
118 pub fn database_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
119 self.inner = self.inner.database_name(input.into());
120 self
121 }
122 /// <p>The name of the Timestream database.</p>
123 pub fn set_database_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
124 self.inner = self.inner.set_database_name(input);
125 self
126 }
127 /// <p>The name of the Timestream database.</p>
128 pub fn get_database_name(&self) -> &::std::option::Option<::std::string::String> {
129 self.inner.get_database_name()
130 }
131 /// <p>The name of the Timestream table.</p>
132 pub fn table_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
133 self.inner = self.inner.table_name(input.into());
134 self
135 }
136 /// <p>The name of the Timestream table.</p>
137 pub fn set_table_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
138 self.inner = self.inner.set_table_name(input);
139 self
140 }
141 /// <p>The name of the Timestream table.</p>
142 pub fn get_table_name(&self) -> &::std::option::Option<::std::string::String> {
143 self.inner.get_table_name()
144 }
145 /// <p>A record that contains the common measure, dimension, time, and version attributes shared across all the records in the request. The measure and dimension attributes specified will be merged with the measure and dimension attributes in the records object when the data is written into Timestream. Dimensions may not overlap, or a <code>ValidationException</code> will be thrown. In other words, a record must contain dimensions with unique names.</p>
146 pub fn common_attributes(mut self, input: crate::types::Record) -> Self {
147 self.inner = self.inner.common_attributes(input);
148 self
149 }
150 /// <p>A record that contains the common measure, dimension, time, and version attributes shared across all the records in the request. The measure and dimension attributes specified will be merged with the measure and dimension attributes in the records object when the data is written into Timestream. Dimensions may not overlap, or a <code>ValidationException</code> will be thrown. In other words, a record must contain dimensions with unique names.</p>
151 pub fn set_common_attributes(mut self, input: ::std::option::Option<crate::types::Record>) -> Self {
152 self.inner = self.inner.set_common_attributes(input);
153 self
154 }
155 /// <p>A record that contains the common measure, dimension, time, and version attributes shared across all the records in the request. The measure and dimension attributes specified will be merged with the measure and dimension attributes in the records object when the data is written into Timestream. Dimensions may not overlap, or a <code>ValidationException</code> will be thrown. In other words, a record must contain dimensions with unique names.</p>
156 pub fn get_common_attributes(&self) -> &::std::option::Option<crate::types::Record> {
157 self.inner.get_common_attributes()
158 }
159 ///
160 /// Appends an item to `Records`.
161 ///
162 /// To override the contents of this collection use [`set_records`](Self::set_records).
163 ///
164 /// <p>An array of records that contain the unique measure, dimension, time, and version attributes for each time-series data point.</p>
165 pub fn records(mut self, input: crate::types::Record) -> Self {
166 self.inner = self.inner.records(input);
167 self
168 }
169 /// <p>An array of records that contain the unique measure, dimension, time, and version attributes for each time-series data point.</p>
170 pub fn set_records(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Record>>) -> Self {
171 self.inner = self.inner.set_records(input);
172 self
173 }
174 /// <p>An array of records that contain the unique measure, dimension, time, and version attributes for each time-series data point.</p>
175 pub fn get_records(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Record>> {
176 self.inner.get_records()
177 }
178}