aws_sdk_dynamodb/operation/batch_write_item/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::batch_write_item::_batch_write_item_output::BatchWriteItemOutputBuilder;
3
4pub use crate::operation::batch_write_item::_batch_write_item_input::BatchWriteItemInputBuilder;
5
6impl crate::operation::batch_write_item::builders::BatchWriteItemInputBuilder {
7                    /// Sends a request with this input using the given client.
8                    pub async fn send_with(self, client: &crate::Client) -> ::std::result::Result<
9                        crate::operation::batch_write_item::BatchWriteItemOutput,
10                        ::aws_smithy_runtime_api::client::result::SdkError<
11                            crate::operation::batch_write_item::BatchWriteItemError,
12                            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse
13                        >
14                    > {
15                        let mut fluent_builder = client.batch_write_item();
16                        fluent_builder.inner = self;
17                        fluent_builder.send().await
18                    }
19                }
20/// Fluent builder constructing a request to `BatchWriteItem`.
21/// 
22/// <p>The <code>BatchWriteItem</code> operation puts or deletes multiple items in one or more tables. A single call to <code>BatchWriteItem</code> can transmit up to 16MB of data over the network, consisting of up to 25 item put or delete operations. While individual items can be up to 400 KB once stored, it's important to note that an item's representation might be greater than 400KB while being sent in DynamoDB's JSON format for the API call. For more details on this distinction, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html">Naming Rules and Data Types</a>.</p><note>
23/// <p><code>BatchWriteItem</code> cannot update items. If you perform a <code>BatchWriteItem</code> operation on an existing item, that item's values will be overwritten by the operation and it will appear like it was updated. To update items, we recommend you use the <code>UpdateItem</code> action.</p>
24/// </note>
25/// <p>The individual <code>PutItem</code> and <code>DeleteItem</code> operations specified in <code>BatchWriteItem</code> are atomic; however <code>BatchWriteItem</code> as a whole is not. If any requested operations fail because the table's provisioned throughput is exceeded or an internal processing failure occurs, the failed operations are returned in the <code>UnprocessedItems</code> response parameter. You can investigate and optionally resend the requests. Typically, you would call <code>BatchWriteItem</code> in a loop. Each iteration would check for unprocessed items and submit a new <code>BatchWriteItem</code> request with those unprocessed items until all items have been processed.</p>
26/// <p>For tables and indexes with provisioned capacity, if none of the items can be processed due to insufficient provisioned throughput on all of the tables in the request, then <code>BatchWriteItem</code> returns a <code>ProvisionedThroughputExceededException</code>. For all tables and indexes, if none of the items can be processed due to other throttling scenarios (such as exceeding partition level limits), then <code>BatchWriteItem</code> returns a <code>ThrottlingException</code>.</p><important>
27/// <p>If DynamoDB returns any unprocessed items, you should retry the batch operation on those items. However, <i>we strongly recommend that you use an exponential backoff algorithm</i>. If you retry the batch operation immediately, the underlying read or write requests can still fail due to throttling on the individual tables. If you delay the batch operation using exponential backoff, the individual requests in the batch are much more likely to succeed.</p>
28/// <p>For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ErrorHandling.html#Programming.Errors.BatchOperations">Batch Operations and Error Handling</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
29/// </important>
30/// <p>With <code>BatchWriteItem</code>, you can efficiently write or delete large amounts of data, such as from Amazon EMR, or copy data from another database into DynamoDB. In order to improve performance with these large-scale operations, <code>BatchWriteItem</code> does not behave in the same way as individual <code>PutItem</code> and <code>DeleteItem</code> calls would. For example, you cannot specify conditions on individual put and delete requests, and <code>BatchWriteItem</code> does not return deleted items in the response.</p>
31/// <p>If you use a programming language that supports concurrency, you can use threads to write items in parallel. Your application must include the necessary logic to manage the threads. With languages that don't support threading, you must update or delete the specified items one at a time. In both situations, <code>BatchWriteItem</code> performs the specified put and delete operations in parallel, giving you the power of the thread pool approach without having to introduce complexity into your application.</p>
32/// <p>Parallel processing reduces latency, but each specified put and delete request consumes the same number of write capacity units whether it is processed in parallel or not. Delete operations on nonexistent items consume one write capacity unit.</p>
33/// <p>If one or more of the following is true, DynamoDB rejects the entire batch write operation:</p>
34/// <ul>
35/// <li>
36/// <p>One or more tables specified in the <code>BatchWriteItem</code> request does not exist.</p></li>
37/// <li>
38/// <p>Primary key attributes specified on an item in the request do not match those in the corresponding table's primary key schema.</p></li>
39/// <li>
40/// <p>You try to perform multiple operations on the same item in the same <code>BatchWriteItem</code> request. For example, you cannot put and delete the same item in the same <code>BatchWriteItem</code> request.</p></li>
41/// <li>
42/// <p>Your request contains at least two items with identical hash and range keys (which essentially is two put operations).</p></li>
43/// <li>
44/// <p>There are more than 25 requests in the batch.</p></li>
45/// <li>
46/// <p>Any individual item in a batch exceeds 400 KB.</p></li>
47/// <li>
48/// <p>The total request size exceeds 16 MB.</p></li>
49/// <li>
50/// <p>Any individual items with keys exceeding the key length limits. For a partition key, the limit is 2048 bytes and for a sort key, the limit is 1024 bytes.</p></li>
51/// </ul>
52#[derive(::std::clone::Clone, ::std::fmt::Debug)]
53pub struct BatchWriteItemFluentBuilder {
54                handle: ::std::sync::Arc<crate::client::Handle>,
55                inner: crate::operation::batch_write_item::builders::BatchWriteItemInputBuilder,
56config_override: ::std::option::Option<crate::config::Builder>,
57            }
58impl
59                crate::client::customize::internal::CustomizableSend<
60                    crate::operation::batch_write_item::BatchWriteItemOutput,
61                    crate::operation::batch_write_item::BatchWriteItemError,
62                > for BatchWriteItemFluentBuilder
63            {
64                fn send(
65                    self,
66                    config_override: crate::config::Builder,
67                ) -> crate::client::customize::internal::BoxFuture<
68                    crate::client::customize::internal::SendResult<
69                        crate::operation::batch_write_item::BatchWriteItemOutput,
70                        crate::operation::batch_write_item::BatchWriteItemError,
71                    >,
72                > {
73                    ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
74                }
75            }
76impl BatchWriteItemFluentBuilder {
77    /// Creates a new `BatchWriteItemFluentBuilder`.
78                    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
79                        Self {
80                            handle,
81                            inner: ::std::default::Default::default(),
82    config_override: ::std::option::Option::None,
83                        }
84                    }
85    /// Access the BatchWriteItem as a reference.
86                    pub fn as_input(&self) -> &crate::operation::batch_write_item::builders::BatchWriteItemInputBuilder {
87                        &self.inner
88                    }
89    /// Sends the request and returns the response.
90                    ///
91                    /// If an error occurs, an `SdkError` will be returned with additional details that
92                    /// can be matched against.
93                    ///
94                    /// By default, any retryable failures will be retried twice. Retry behavior
95                    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
96                    /// set when configuring the client.
97                    pub async fn send(self) -> ::std::result::Result<crate::operation::batch_write_item::BatchWriteItemOutput, ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::batch_write_item::BatchWriteItemError, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>> {
98                        let input = self.inner.build().map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
99                        let runtime_plugins = crate::operation::batch_write_item::BatchWriteItem::operation_runtime_plugins(
100                            self.handle.runtime_plugins.clone(),
101                            &self.handle.conf,
102                            self.config_override,
103                        );
104                        crate::operation::batch_write_item::BatchWriteItem::orchestrate(&runtime_plugins, input).await
105                    }
106    
107                    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
108                    pub fn customize(
109                        self,
110                    ) -> crate::client::customize::CustomizableOperation<crate::operation::batch_write_item::BatchWriteItemOutput, crate::operation::batch_write_item::BatchWriteItemError, Self> {
111                        crate::client::customize::CustomizableOperation::new(self)
112                    }
113    pub(crate) fn config_override(
114                            mut self,
115                            config_override: impl ::std::convert::Into<crate::config::Builder>,
116                        ) -> Self {
117                            self.set_config_override(::std::option::Option::Some(config_override.into()));
118                            self
119                        }
120    
121                        pub(crate) fn set_config_override(
122                            &mut self,
123                            config_override: ::std::option::Option<crate::config::Builder>,
124                        ) -> &mut Self {
125                            self.config_override = config_override;
126                            self
127                        }
128    /// 
129    /// Adds a key-value pair to `RequestItems`.
130    /// 
131    /// To override the contents of this collection use [`set_request_items`](Self::set_request_items).
132    /// 
133    /// <p>A map of one or more table names or table ARNs and, for each table, a list of operations to be performed (<code>DeleteRequest</code> or <code>PutRequest</code>). Each element in the map consists of the following:</p>
134    /// <ul>
135    /// <li>
136    /// <p><code>DeleteRequest</code> - Perform a <code>DeleteItem</code> operation on the specified item. The item to be deleted is identified by a <code>Key</code> subelement:</p>
137    /// <ul>
138    /// <li>
139    /// <p><code>Key</code> - A map of primary key attribute values that uniquely identify the item. Each entry in this map consists of an attribute name and an attribute value. For each primary key, you must provide <i>all</i> of the key attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for <i>both</i> the partition key and the sort key.</p></li>
140    /// </ul></li>
141    /// <li>
142    /// <p><code>PutRequest</code> - Perform a <code>PutItem</code> operation on the specified item. The item to be put is identified by an <code>Item</code> subelement:</p>
143    /// <ul>
144    /// <li>
145    /// <p><code>Item</code> - A map of attributes and their values. Each entry in this map consists of an attribute name and an attribute value. Attribute values must not be null; string and binary type attributes must have lengths greater than zero; and set type attributes must not be empty. Requests that contain empty values are rejected with a <code>ValidationException</code> exception.</p>
146    /// <p>If you specify any attributes that are part of an index key, then the data types for those attributes must match those of the schema in the table's attribute definition.</p></li>
147    /// </ul></li>
148    /// </ul>
149    pub fn request_items(mut self, k: impl ::std::convert::Into<::std::string::String>, v: ::std::vec::Vec::<crate::types::WriteRequest>) -> Self {
150                    self.inner = self.inner.request_items(k.into(), v);
151                    self
152                }
153    /// <p>A map of one or more table names or table ARNs and, for each table, a list of operations to be performed (<code>DeleteRequest</code> or <code>PutRequest</code>). Each element in the map consists of the following:</p>
154    /// <ul>
155    /// <li>
156    /// <p><code>DeleteRequest</code> - Perform a <code>DeleteItem</code> operation on the specified item. The item to be deleted is identified by a <code>Key</code> subelement:</p>
157    /// <ul>
158    /// <li>
159    /// <p><code>Key</code> - A map of primary key attribute values that uniquely identify the item. Each entry in this map consists of an attribute name and an attribute value. For each primary key, you must provide <i>all</i> of the key attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for <i>both</i> the partition key and the sort key.</p></li>
160    /// </ul></li>
161    /// <li>
162    /// <p><code>PutRequest</code> - Perform a <code>PutItem</code> operation on the specified item. The item to be put is identified by an <code>Item</code> subelement:</p>
163    /// <ul>
164    /// <li>
165    /// <p><code>Item</code> - A map of attributes and their values. Each entry in this map consists of an attribute name and an attribute value. Attribute values must not be null; string and binary type attributes must have lengths greater than zero; and set type attributes must not be empty. Requests that contain empty values are rejected with a <code>ValidationException</code> exception.</p>
166    /// <p>If you specify any attributes that are part of an index key, then the data types for those attributes must match those of the schema in the table's attribute definition.</p></li>
167    /// </ul></li>
168    /// </ul>
169    pub fn set_request_items(mut self, input: ::std::option::Option<::std::collections::HashMap::<::std::string::String, ::std::vec::Vec::<crate::types::WriteRequest>>>) -> Self {
170                    self.inner = self.inner.set_request_items(input);
171                    self
172                }
173    /// <p>A map of one or more table names or table ARNs and, for each table, a list of operations to be performed (<code>DeleteRequest</code> or <code>PutRequest</code>). Each element in the map consists of the following:</p>
174    /// <ul>
175    /// <li>
176    /// <p><code>DeleteRequest</code> - Perform a <code>DeleteItem</code> operation on the specified item. The item to be deleted is identified by a <code>Key</code> subelement:</p>
177    /// <ul>
178    /// <li>
179    /// <p><code>Key</code> - A map of primary key attribute values that uniquely identify the item. Each entry in this map consists of an attribute name and an attribute value. For each primary key, you must provide <i>all</i> of the key attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for <i>both</i> the partition key and the sort key.</p></li>
180    /// </ul></li>
181    /// <li>
182    /// <p><code>PutRequest</code> - Perform a <code>PutItem</code> operation on the specified item. The item to be put is identified by an <code>Item</code> subelement:</p>
183    /// <ul>
184    /// <li>
185    /// <p><code>Item</code> - A map of attributes and their values. Each entry in this map consists of an attribute name and an attribute value. Attribute values must not be null; string and binary type attributes must have lengths greater than zero; and set type attributes must not be empty. Requests that contain empty values are rejected with a <code>ValidationException</code> exception.</p>
186    /// <p>If you specify any attributes that are part of an index key, then the data types for those attributes must match those of the schema in the table's attribute definition.</p></li>
187    /// </ul></li>
188    /// </ul>
189    pub fn get_request_items(&self) -> &::std::option::Option<::std::collections::HashMap::<::std::string::String, ::std::vec::Vec::<crate::types::WriteRequest>>> {
190                    self.inner.get_request_items()
191                }
192    /// <p>Determines the level of detail about either provisioned or on-demand throughput consumption that is returned in the response:</p>
193    /// <ul>
194    /// <li>
195    /// <p><code>INDEXES</code> - The response includes the aggregate <code>ConsumedCapacity</code> for the operation, together with <code>ConsumedCapacity</code> for each table and secondary index that was accessed.</p>
196    /// <p>Note that some operations, such as <code>GetItem</code> and <code>BatchGetItem</code>, do not access any indexes at all. In these cases, specifying <code>INDEXES</code> will only return <code>ConsumedCapacity</code> information for table(s).</p></li>
197    /// <li>
198    /// <p><code>TOTAL</code> - The response includes only the aggregate <code>ConsumedCapacity</code> for the operation.</p></li>
199    /// <li>
200    /// <p><code>NONE</code> - No <code>ConsumedCapacity</code> details are included in the response.</p></li>
201    /// </ul>
202    pub fn return_consumed_capacity(mut self, input: crate::types::ReturnConsumedCapacity) -> Self {
203                    self.inner = self.inner.return_consumed_capacity(input);
204                    self
205                }
206    /// <p>Determines the level of detail about either provisioned or on-demand throughput consumption that is returned in the response:</p>
207    /// <ul>
208    /// <li>
209    /// <p><code>INDEXES</code> - The response includes the aggregate <code>ConsumedCapacity</code> for the operation, together with <code>ConsumedCapacity</code> for each table and secondary index that was accessed.</p>
210    /// <p>Note that some operations, such as <code>GetItem</code> and <code>BatchGetItem</code>, do not access any indexes at all. In these cases, specifying <code>INDEXES</code> will only return <code>ConsumedCapacity</code> information for table(s).</p></li>
211    /// <li>
212    /// <p><code>TOTAL</code> - The response includes only the aggregate <code>ConsumedCapacity</code> for the operation.</p></li>
213    /// <li>
214    /// <p><code>NONE</code> - No <code>ConsumedCapacity</code> details are included in the response.</p></li>
215    /// </ul>
216    pub fn set_return_consumed_capacity(mut self, input: ::std::option::Option<crate::types::ReturnConsumedCapacity>) -> Self {
217                    self.inner = self.inner.set_return_consumed_capacity(input);
218                    self
219                }
220    /// <p>Determines the level of detail about either provisioned or on-demand throughput consumption that is returned in the response:</p>
221    /// <ul>
222    /// <li>
223    /// <p><code>INDEXES</code> - The response includes the aggregate <code>ConsumedCapacity</code> for the operation, together with <code>ConsumedCapacity</code> for each table and secondary index that was accessed.</p>
224    /// <p>Note that some operations, such as <code>GetItem</code> and <code>BatchGetItem</code>, do not access any indexes at all. In these cases, specifying <code>INDEXES</code> will only return <code>ConsumedCapacity</code> information for table(s).</p></li>
225    /// <li>
226    /// <p><code>TOTAL</code> - The response includes only the aggregate <code>ConsumedCapacity</code> for the operation.</p></li>
227    /// <li>
228    /// <p><code>NONE</code> - No <code>ConsumedCapacity</code> details are included in the response.</p></li>
229    /// </ul>
230    pub fn get_return_consumed_capacity(&self) -> &::std::option::Option<crate::types::ReturnConsumedCapacity> {
231                    self.inner.get_return_consumed_capacity()
232                }
233    /// <p>Determines whether item collection metrics are returned. If set to <code>SIZE</code>, the response includes statistics about item collections, if any, that were modified during the operation are returned in the response. If set to <code>NONE</code> (the default), no statistics are returned.</p>
234    pub fn return_item_collection_metrics(mut self, input: crate::types::ReturnItemCollectionMetrics) -> Self {
235                    self.inner = self.inner.return_item_collection_metrics(input);
236                    self
237                }
238    /// <p>Determines whether item collection metrics are returned. If set to <code>SIZE</code>, the response includes statistics about item collections, if any, that were modified during the operation are returned in the response. If set to <code>NONE</code> (the default), no statistics are returned.</p>
239    pub fn set_return_item_collection_metrics(mut self, input: ::std::option::Option<crate::types::ReturnItemCollectionMetrics>) -> Self {
240                    self.inner = self.inner.set_return_item_collection_metrics(input);
241                    self
242                }
243    /// <p>Determines whether item collection metrics are returned. If set to <code>SIZE</code>, the response includes statistics about item collections, if any, that were modified during the operation are returned in the response. If set to <code>NONE</code> (the default), no statistics are returned.</p>
244    pub fn get_return_item_collection_metrics(&self) -> &::std::option::Option<crate::types::ReturnItemCollectionMetrics> {
245                    self.inner.get_return_item_collection_metrics()
246                }
247}
248