aws_sdk_dynamodb/operation/get_item/
_get_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>GetItem</code> operation.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct GetItemOutput  {
7    /// <p>A map of attribute names to <code>AttributeValue</code> objects, as specified by <code>ProjectionExpression</code>.</p>
8    pub item: ::std::option::Option<::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>>,
9    /// <p>The capacity units consumed by the <code>GetItem</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#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
10    pub consumed_capacity: ::std::option::Option<crate::types::ConsumedCapacity>,
11    _request_id: Option<String>,
12}
13impl  GetItemOutput  {
14    /// <p>A map of attribute names to <code>AttributeValue</code> objects, as specified by <code>ProjectionExpression</code>.</p>
15    pub fn item(&self) -> ::std::option::Option<&::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>> {
16        self.item.as_ref()
17    }
18    /// <p>The capacity units consumed by the <code>GetItem</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#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
19    pub fn consumed_capacity(&self) -> ::std::option::Option<&crate::types::ConsumedCapacity> {
20        self.consumed_capacity.as_ref()
21    }
22}
23static GETITEMOUTPUT_SCHEMA_ID: ::aws_smithy_schema::ShapeId = ::aws_smithy_schema::ShapeId::from_static("com.amazonaws.dynamodb.synthetic#GetItemOutput", "com.amazonaws.dynamodb.synthetic", "GetItemOutput");
24static GETITEMOUTPUT_MEMBER_ITEM: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
25                            ::aws_smithy_schema::ShapeId::from_static(
26                                "com.amazonaws.dynamodb.synthetic#GetItemOutput$Item",
27                                "com.amazonaws.dynamodb.synthetic",
28                                "GetItemOutput",
29                            ),
30                            ::aws_smithy_schema::ShapeType::Map,
31                            "Item",
32                            0,
33                        );
34static GETITEMOUTPUT_MEMBER_CONSUMED_CAPACITY: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
35                            ::aws_smithy_schema::ShapeId::from_static(
36                                "com.amazonaws.dynamodb.synthetic#GetItemOutput$ConsumedCapacity",
37                                "com.amazonaws.dynamodb.synthetic",
38                                "GetItemOutput",
39                            ),
40                            ::aws_smithy_schema::ShapeType::Structure,
41                            "ConsumedCapacity",
42                            1,
43                        );
44static GETITEMOUTPUT_MEMBER__REQUEST_ID: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_member(
45                            ::aws_smithy_schema::ShapeId::from_static(
46                                "synthetic#request_id",
47                                "synthetic",
48                                "request_id",
49                            ),
50                            ::aws_smithy_schema::ShapeType::String,
51                            "request_id",
52                            2,
53                        ).with_http_header("x-amzn-requestid");
54static GETITEMOUTPUT_SCHEMA: ::aws_smithy_schema::Schema = ::aws_smithy_schema::Schema::new_struct(
55                            GETITEMOUTPUT_SCHEMA_ID,
56                            ::aws_smithy_schema::ShapeType::Structure,
57                            &[&GETITEMOUTPUT_MEMBER_ITEM, &GETITEMOUTPUT_MEMBER_CONSUMED_CAPACITY, &GETITEMOUTPUT_MEMBER__REQUEST_ID],
58                        );
59impl GetItemOutput {
60                /// The schema for this shape.
61                pub const SCHEMA: &'static ::aws_smithy_schema::Schema = &GETITEMOUTPUT_SCHEMA;
62            }
63impl ::aws_smithy_schema::serde::SerializableStruct for GetItemOutput {
64                #[allow(unused_variables, clippy::diverging_sub_expression)]
65                fn serialize_members(&self, ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
66                    if let Some(ref val) = self.item {
67                                
68                    ser.write_map(&GETITEMOUTPUT_MEMBER_ITEM, &|ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer| {
69                        for (key, value) in val {
70                            ser.write_string(&::aws_smithy_schema::prelude::STRING, key)?;
71                            ser.write_struct(crate::types::AttributeValue::SCHEMA, value)?;
72                        }
73                        Ok(())
74                    })?;
75                    
76                            }
77if let Some(ref val) = self.consumed_capacity {
78                                ser.write_struct(&GETITEMOUTPUT_MEMBER_CONSUMED_CAPACITY, val)?;
79                            }
80                    Ok(())
81                }
82            }
83impl GetItemOutput {
84                /// Deserializes this structure from a [`ShapeDeserializer`].
85                pub fn deserialize(deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
86                    #[allow(unused_variables, unused_mut)]
87                    let mut builder = Self::builder();
88                    #[allow(unused_variables, unreachable_code, clippy::single_match, clippy::match_single_binding, clippy::diverging_sub_expression)]
89                    deserializer.read_struct(&GETITEMOUTPUT_SCHEMA, &mut |member, deser| {
90                        match member.member_index() {
91                            Some(0) => {
92                                    builder.item = 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 });
93                                }
94Some(1) => {
95                                    builder.consumed_capacity = Some(crate::types::ConsumedCapacity::deserialize(deser)?);
96                                }
97Some(2) => {
98                                builder._request_id = Some(deser.read_string(member)?);
99                            }
100                            _ => {}
101                        }
102                        Ok(())
103                    })?;
104                    Ok(builder.build())
105                }
106            }
107impl GetItemOutput {
108                /// Deserializes this structure from a body deserializer and HTTP response headers.
109                /// Header-bound members are read directly from headers, avoiding runtime
110                /// member iteration overhead. Body members are read via the deserializer.
111                pub fn deserialize_with_response(
112                    deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
113                    headers: &::aws_smithy_runtime_api::http::Headers,
114                    _status: u16,
115                    _body: &[u8],
116                ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
117                    #[allow(unused_variables, unused_mut)]
118                    let mut builder = Self::builder();
119if let Some(val) = headers.get("x-amzn-requestid") {
120                    builder._request_id = Some(val.to_string());
121                }
122#[allow(unused_variables, unreachable_code, clippy::single_match, clippy::match_single_binding, clippy::diverging_sub_expression)]
123                    deserializer.read_struct(&GETITEMOUTPUT_SCHEMA, &mut |member, deser| {
124                        match member.member_index() {
125                            Some(0) => { builder.item = 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 }); }
126Some(1) => { builder.consumed_capacity = Some(crate::types::ConsumedCapacity::deserialize(deser)?); }
127                            _ => {}
128                        }
129                        Ok(())
130                    })?;
131                    Ok(builder.build())
132                    }
133                    }
134impl ::aws_types::request_id::RequestId for GetItemOutput {
135                                    fn request_id(&self) -> Option<&str> {
136                                        self._request_id.as_deref()
137                                    }
138                                }
139impl GetItemOutput {
140    /// Creates a new builder-style object to manufacture [`GetItemOutput`](crate::operation::get_item::GetItemOutput).
141    pub fn builder() -> crate::operation::get_item::builders::GetItemOutputBuilder {
142        crate::operation::get_item::builders::GetItemOutputBuilder::default()
143    }
144}
145
146/// A builder for [`GetItemOutput`](crate::operation::get_item::GetItemOutput).
147#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
148#[non_exhaustive]
149pub struct GetItemOutputBuilder {
150    pub(crate) item: ::std::option::Option<::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>>,
151    pub(crate) consumed_capacity: ::std::option::Option<crate::types::ConsumedCapacity>,
152    _request_id: Option<String>,
153}
154impl GetItemOutputBuilder {
155    /// Adds a key-value pair to `item`.
156    ///
157    /// To override the contents of this collection use [`set_item`](Self::set_item).
158    ///
159    /// <p>A map of attribute names to <code>AttributeValue</code> objects, as specified by <code>ProjectionExpression</code>.</p>
160    pub fn item(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
161        let mut hash_map = self.item.unwrap_or_default();
162                        hash_map.insert(k.into(), v);
163                        self.item = ::std::option::Option::Some(hash_map);
164                        self
165    }
166    /// <p>A map of attribute names to <code>AttributeValue</code> objects, as specified by <code>ProjectionExpression</code>.</p>
167    pub fn set_item(mut self, input: ::std::option::Option<::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>>) -> Self {
168        self.item = input; self
169    }
170    /// <p>A map of attribute names to <code>AttributeValue</code> objects, as specified by <code>ProjectionExpression</code>.</p>
171    pub fn get_item(&self) -> &::std::option::Option<::std::collections::HashMap::<::std::string::String, crate::types::AttributeValue>> {
172        &self.item
173    }
174    /// <p>The capacity units consumed by the <code>GetItem</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#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
175    pub fn consumed_capacity(mut self, input: crate::types::ConsumedCapacity) -> Self {
176        self.consumed_capacity = ::std::option::Option::Some(input);
177        self
178    }
179    /// <p>The capacity units consumed by the <code>GetItem</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#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
180    pub fn set_consumed_capacity(mut self, input: ::std::option::Option<crate::types::ConsumedCapacity>) -> Self {
181        self.consumed_capacity = input; self
182    }
183    /// <p>The capacity units consumed by the <code>GetItem</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#read-operation-consumption">Capacity unit consumption for read operations</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
184    pub fn get_consumed_capacity(&self) -> &::std::option::Option<crate::types::ConsumedCapacity> {
185        &self.consumed_capacity
186    }
187    pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
188                                        self._request_id = Some(request_id.into());
189                                        self
190                                    }
191    
192                                    pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
193                                        self._request_id = request_id;
194                                        self
195                                    }
196    /// Consumes the builder and constructs a [`GetItemOutput`](crate::operation::get_item::GetItemOutput).
197    pub fn build(self) -> crate::operation::get_item::GetItemOutput {
198        crate::operation::get_item::GetItemOutput {
199            item: self.item
200            ,
201            consumed_capacity: self.consumed_capacity
202            ,
203            _request_id: self._request_id,
204        }
205    }
206}
207