aws_sdk_dynamodb/operation/put_item/
_put_item_output.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Represents the output of a <code>PutItem</code> operation.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct PutItemOutput  {
7    /// <p>The attribute values as they appeared before the <code>PutItem</code> operation, but only if <code>ReturnValues</code> is specified as <code>ALL_OLD</code> in the request. Each element consists of an attribute name and an attribute value.</p>
8    pub attributes: ::std::option::Option<::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>>,
9    /// <p>The capacity units consumed by the <code>PutItem</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#write-operation-consumption">Capacity unity consumption for write operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
10    pub consumed_capacity: ::std::option::Option<crate::types::ConsumedCapacity>,
11    /// <p>Information about item collections, if any, that were affected by the <code>PutItem</code> operation. <code>ItemCollectionMetrics</code> is only returned if the <code>ReturnItemCollectionMetrics</code> parameter was specified. If the table does not have any local secondary indexes, this information is not returned in the response.</p>
12    /// <p>Each <code>ItemCollectionMetrics</code> element consists of:</p>
13    /// <ul>
14    /// <li>
15    /// <p><code>ItemCollectionKey</code> - The partition key value of the item collection. This is the same as the partition key value of the item itself.</p></li>
16    /// <li>
17    /// <p><code>SizeEstimateRangeGB</code> - An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the size of all the items in the table, plus the size of all attributes projected into all of the local secondary indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size limit.</p>
18    /// <p>The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the estimate.</p></li>
19    /// </ul>
20    pub item_collection_metrics: ::std::option::Option<crate::types::ItemCollectionMetrics>,
21    _request_id: Option<String>,
22}
23impl  PutItemOutput  {
24    /// <p>The attribute values as they appeared before the <code>PutItem</code> operation, but only if <code>ReturnValues</code> is specified as <code>ALL_OLD</code> in the request. Each element consists of an attribute name and an attribute value.</p>
25    pub fn attributes(&self) -> ::std::option::Option<&::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>> {
26        self.attributes.as_ref()
27    }
28    /// <p>The capacity units consumed by the <code>PutItem</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#write-operation-consumption">Capacity unity consumption for write operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
29    pub fn consumed_capacity(&self) -> ::std::option::Option<&crate::types::ConsumedCapacity> {
30        self.consumed_capacity.as_ref()
31    }
32    /// <p>Information about item collections, if any, that were affected by the <code>PutItem</code> operation. <code>ItemCollectionMetrics</code> is only returned if the <code>ReturnItemCollectionMetrics</code> parameter was specified. If the table does not have any local secondary indexes, this information is not returned in the response.</p>
33    /// <p>Each <code>ItemCollectionMetrics</code> element consists of:</p>
34    /// <ul>
35    /// <li>
36    /// <p><code>ItemCollectionKey</code> - The partition key value of the item collection. This is the same as the partition key value of the item itself.</p></li>
37    /// <li>
38    /// <p><code>SizeEstimateRangeGB</code> - An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the size of all the items in the table, plus the size of all attributes projected into all of the local secondary indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size limit.</p>
39    /// <p>The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the estimate.</p></li>
40    /// </ul>
41    pub fn item_collection_metrics(&self) -> ::std::option::Option<&crate::types::ItemCollectionMetrics> {
42        self.item_collection_metrics.as_ref()
43    }
44}
45static PUTITEMOUTPUT_SCHEMA_ID: ::aws_smithy_schema::ShapeId = ::aws_smithy_schema::ShapeId::from_static("com.amazonaws.dynamodb.synthetic#PutItemOutput", "com.amazonaws.dynamodb.synthetic", "PutItemOutput");
46static PUTITEMOUTPUT_MEMBER_ATTRIBUTES: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
47                            ::aws_smithy_schema::ShapeId::from_static(
48                                "com.amazonaws.dynamodb.synthetic#PutItemOutput$Attributes",
49                                "com.amazonaws.dynamodb.synthetic",
50                                "PutItemOutput",
51                            ),
52                            ::aws_smithy_schema::ShapeType::Map,
53                            "Attributes",
54                            0,
55                        );
56static PUTITEMOUTPUT_MEMBER_CONSUMED_CAPACITY: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
57                            ::aws_smithy_schema::ShapeId::from_static(
58                                "com.amazonaws.dynamodb.synthetic#PutItemOutput$ConsumedCapacity",
59                                "com.amazonaws.dynamodb.synthetic",
60                                "PutItemOutput",
61                            ),
62                            ::aws_smithy_schema::ShapeType::Structure,
63                            "ConsumedCapacity",
64                            1,
65                        );
66static PUTITEMOUTPUT_MEMBER_ITEM_COLLECTION_METRICS: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
67                            ::aws_smithy_schema::ShapeId::from_static(
68                                "com.amazonaws.dynamodb.synthetic#PutItemOutput$ItemCollectionMetrics",
69                                "com.amazonaws.dynamodb.synthetic",
70                                "PutItemOutput",
71                            ),
72                            ::aws_smithy_schema::ShapeType::Structure,
73                            "ItemCollectionMetrics",
74                            2,
75                        );
76static PUTITEMOUTPUT_MEMBER__REQUEST_ID: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
77                            ::aws_smithy_schema::ShapeId::from_static(
78                                "synthetic#request_id",
79                                "synthetic",
80                                "request_id",
81                            ),
82                            ::aws_smithy_schema::ShapeType::String,
83                            "request_id",
84                            3,
85                        ).with_http_header("x-amzn-requestid");
86static PUTITEMOUTPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
87                            PUTITEMOUTPUT_SCHEMA_ID,
88                            ::aws_smithy_schema::ShapeType::Structure,
89                            &[&PUTITEMOUTPUT_MEMBER_ATTRIBUTES, &PUTITEMOUTPUT_MEMBER_CONSUMED_CAPACITY, &PUTITEMOUTPUT_MEMBER_ITEM_COLLECTION_METRICS, &PUTITEMOUTPUT_MEMBER__REQUEST_ID],
90                        );
91impl PutItemOutput {
92                /// The schema for this shape.
93                pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &PUTITEMOUTPUT_SCHEMA;
94            }
95impl ::aws_smithy_schema::serde::SerializableStruct for PutItemOutput {
96                #[allow(unused_variables, clippy::diverging_sub_expression)]
97                fn serialize_members(&self, ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
98                    if let Some(ref val) = self.attributes {
99                                
100                    ser.write_map(&PUTITEMOUTPUT_MEMBER_ATTRIBUTES, &|ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer| {
101                        for (key, value) in val {
102                            ser.write_string(&::aws_smithy_schema::prelude::STRING, key)?;
103                            ser.write_struct(crate::types::AttributeValue::SCHEMA, value)?;
104                        }
105                        Ok(())
106                    })?;
107                    
108                            }
109if let Some(ref val) = self.consumed_capacity {
110                                ser.write_struct(&PUTITEMOUTPUT_MEMBER_CONSUMED_CAPACITY, val)?;
111                            }
112if let Some(ref val) = self.item_collection_metrics {
113                                ser.write_struct(&PUTITEMOUTPUT_MEMBER_ITEM_COLLECTION_METRICS, val)?;
114                            }
115                    Ok(())
116                }
117            }
118impl PutItemOutput {
119                /// Deserializes this structure from a [`ShapeDeserializer`].
120                pub fn deserialize(deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
121                    #[allow(unused_variables, unused_mut)]
122                    let mut builder = Self::builder();
123                    #[allow(unused_variables, unreachable_code, clippy::single_match, clippy::match_single_binding, clippy::diverging_sub_expression)]
124                    deserializer.read_struct(&PUTITEMOUTPUT_SCHEMA, &mut |member, deser| {
125                        match member.member_index() {
126                            Some(0) => {
127                                    builder.attributes = Some({ let mut container = std::collections::HashMap::new(); deser.read_map(member, &mut |key, deser| { container.insert(key, crate::types::AttributeValue::deserialize(deser)?); Ok(()) })?; container });
128                                }
129Some(1) => {
130                                    builder.consumed_capacity = Some(crate::types::ConsumedCapacity::deserialize(deser)?);
131                                }
132Some(2) => {
133                                    builder.item_collection_metrics = Some(crate::types::ItemCollectionMetrics::deserialize(deser)?);
134                                }
135Some(3) => {
136                                builder._request_id = Some(deser.read_string(member)?);
137                            }
138                            _ => {}
139                        }
140                        Ok(())
141                    })?;
142                    Ok(builder.build())
143                }
144            }
145impl PutItemOutput {
146                /// Deserializes this structure from a body deserializer and HTTP response headers.
147                /// Header-bound members are read directly from headers, avoiding runtime
148                /// member iteration overhead. Body members are read via the deserializer.
149                pub fn deserialize_with_response(
150                    deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
151                    headers: &::aws_smithy_runtime_api::http::Headers,
152                    _status: u16,
153                    _body: &[u8],
154                ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
155                    #[allow(unused_variables, unused_mut)]
156                    let mut builder = Self::builder();
157if let Some(val) = headers.get("x-amzn-requestid") {
158                    builder._request_id = Some(val.to_string());
159                }
160#[allow(unused_variables, unreachable_code, clippy::single_match, clippy::match_single_binding, clippy::diverging_sub_expression)]
161                    deserializer.read_struct(&PUTITEMOUTPUT_SCHEMA, &mut |member, deser| {
162                        match member.member_index() {
163                            Some(0) => { builder.attributes = Some({ let mut container = std::collections::HashMap::new(); deser.read_map(member, &mut |key, deser| { container.insert(key, crate::types::AttributeValue::deserialize(deser)?); Ok(()) })?; container }); }
164Some(1) => { builder.consumed_capacity = Some(crate::types::ConsumedCapacity::deserialize(deser)?); }
165Some(2) => { builder.item_collection_metrics = Some(crate::types::ItemCollectionMetrics::deserialize(deser)?); }
166                            _ => {}
167                        }
168                        Ok(())
169                    })?;
170                    Ok(builder.build())
171                    }
172                    }
173impl ::aws_types::request_id::RequestId for PutItemOutput {
174                                    fn request_id(&self) -> Option<&str> {
175                                        self._request_id.as_deref()
176                                    }
177                                }
178impl PutItemOutput {
179    /// Creates a new builder-style object to manufacture [`PutItemOutput`](crate::operation::put_item::PutItemOutput).
180    pub fn builder() -> crate::operation::put_item::builders::PutItemOutputBuilder {
181        crate::operation::put_item::builders::PutItemOutputBuilder::default()
182    }
183}
184
185/// A builder for [`PutItemOutput`](crate::operation::put_item::PutItemOutput).
186#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
187#[non_exhaustive]
188pub struct PutItemOutputBuilder {
189    pub(crate) attributes: ::std::option::Option<::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>>,
190    pub(crate) consumed_capacity: ::std::option::Option<crate::types::ConsumedCapacity>,
191    pub(crate) item_collection_metrics: ::std::option::Option<crate::types::ItemCollectionMetrics>,
192    _request_id: Option<String>,
193}
194impl PutItemOutputBuilder {
195    /// Adds a key-value pair to `attributes`.
196    ///
197    /// To override the contents of this collection use [`set_attributes`](Self::set_attributes).
198    ///
199    /// <p>The attribute values as they appeared before the <code>PutItem</code> operation, but only if <code>ReturnValues</code> is specified as <code>ALL_OLD</code> in the request. Each element consists of an attribute name and an attribute value.</p>
200    pub fn attributes(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
201        let mut hash_map = self.attributes.unwrap_or_default();
202                        hash_map.insert(k.into(), v);
203                        self.attributes = ::std::option::Option::Some(hash_map);
204                        self
205    }
206    /// <p>The attribute values as they appeared before the <code>PutItem</code> operation, but only if <code>ReturnValues</code> is specified as <code>ALL_OLD</code> in the request. Each element consists of an attribute name and an attribute value.</p>
207    pub fn set_attributes(mut self, input: ::std::option::Option<::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>>) -> Self {
208        self.attributes = input; self
209    }
210    /// <p>The attribute values as they appeared before the <code>PutItem</code> operation, but only if <code>ReturnValues</code> is specified as <code>ALL_OLD</code> in the request. Each element consists of an attribute name and an attribute value.</p>
211    pub fn get_attributes(&self) -> &::std::option::Option<::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>> {
212        &self.attributes
213    }
214    /// <p>The capacity units consumed by the <code>PutItem</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#write-operation-consumption">Capacity unity consumption for write operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
215    pub fn consumed_capacity(mut self, input: crate::types::ConsumedCapacity) -> Self {
216        self.consumed_capacity = ::std::option::Option::Some(input);
217        self
218    }
219    /// <p>The capacity units consumed by the <code>PutItem</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#write-operation-consumption">Capacity unity consumption for write operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
220    pub fn set_consumed_capacity(mut self, input: ::std::option::Option<crate::types::ConsumedCapacity>) -> Self {
221        self.consumed_capacity = input; self
222    }
223    /// <p>The capacity units consumed by the <code>PutItem</code> operation. The data returned includes the total provisioned throughput consumed, along with statistics for the table and any indexes involved in the operation. <code>ConsumedCapacity</code> is only returned if the <code>ReturnConsumedCapacity</code> parameter was specified. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/read-write-operations.html#write-operation-consumption">Capacity unity consumption for write operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
224    pub fn get_consumed_capacity(&self) -> &::std::option::Option<crate::types::ConsumedCapacity> {
225        &self.consumed_capacity
226    }
227    /// <p>Information about item collections, if any, that were affected by the <code>PutItem</code> operation. <code>ItemCollectionMetrics</code> is only returned if the <code>ReturnItemCollectionMetrics</code> parameter was specified. If the table does not have any local secondary indexes, this information is not returned in the response.</p>
228    /// <p>Each <code>ItemCollectionMetrics</code> element consists of:</p>
229    /// <ul>
230    /// <li>
231    /// <p><code>ItemCollectionKey</code> - The partition key value of the item collection. This is the same as the partition key value of the item itself.</p></li>
232    /// <li>
233    /// <p><code>SizeEstimateRangeGB</code> - An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the size of all the items in the table, plus the size of all attributes projected into all of the local secondary indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size limit.</p>
234    /// <p>The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the estimate.</p></li>
235    /// </ul>
236    pub fn item_collection_metrics(mut self, input: crate::types::ItemCollectionMetrics) -> Self {
237        self.item_collection_metrics = ::std::option::Option::Some(input);
238        self
239    }
240    /// <p>Information about item collections, if any, that were affected by the <code>PutItem</code> operation. <code>ItemCollectionMetrics</code> is only returned if the <code>ReturnItemCollectionMetrics</code> parameter was specified. If the table does not have any local secondary indexes, this information is not returned in the response.</p>
241    /// <p>Each <code>ItemCollectionMetrics</code> element consists of:</p>
242    /// <ul>
243    /// <li>
244    /// <p><code>ItemCollectionKey</code> - The partition key value of the item collection. This is the same as the partition key value of the item itself.</p></li>
245    /// <li>
246    /// <p><code>SizeEstimateRangeGB</code> - An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the size of all the items in the table, plus the size of all attributes projected into all of the local secondary indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size limit.</p>
247    /// <p>The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the estimate.</p></li>
248    /// </ul>
249    pub fn set_item_collection_metrics(mut self, input: ::std::option::Option<crate::types::ItemCollectionMetrics>) -> Self {
250        self.item_collection_metrics = input; self
251    }
252    /// <p>Information about item collections, if any, that were affected by the <code>PutItem</code> operation. <code>ItemCollectionMetrics</code> is only returned if the <code>ReturnItemCollectionMetrics</code> parameter was specified. If the table does not have any local secondary indexes, this information is not returned in the response.</p>
253    /// <p>Each <code>ItemCollectionMetrics</code> element consists of:</p>
254    /// <ul>
255    /// <li>
256    /// <p><code>ItemCollectionKey</code> - The partition key value of the item collection. This is the same as the partition key value of the item itself.</p></li>
257    /// <li>
258    /// <p><code>SizeEstimateRangeGB</code> - An estimate of item collection size, in gigabytes. This value is a two-element array containing a lower bound and an upper bound for the estimate. The estimate includes the size of all the items in the table, plus the size of all attributes projected into all of the local secondary indexes on that table. Use this estimate to measure whether a local secondary index is approaching its size limit.</p>
259    /// <p>The estimate is subject to change over time; therefore, do not rely on the precision or accuracy of the estimate.</p></li>
260    /// </ul>
261    pub fn get_item_collection_metrics(&self) -> &::std::option::Option<crate::types::ItemCollectionMetrics> {
262        &self.item_collection_metrics
263    }
264    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
265                                        self._request_id = Some(request_id.into());
266                                        self
267                                    }
268    
269                                    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
270                                        self._request_id = request_id;
271                                        self
272                                    }
273    /// Consumes the builder and constructs a [`PutItemOutput`](crate::operation::put_item::PutItemOutput).
274    pub fn build(self) -> crate::operation::put_item::PutItemOutput {
275        crate::operation::put_item::PutItemOutput {
276            attributes: self.attributes
277            ,
278            consumed_capacity: self.consumed_capacity
279            ,
280            item_collection_metrics: self.item_collection_metrics
281            ,
282            _request_id: self._request_id,
283        }
284    }
285}
286