aws_sdk_dynamodb/types/_get.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Specifies an item and related attribute values to retrieve in a <code>TransactGetItem</code> object.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Get {
7 /// <p>A map of attribute names to <code>AttributeValue</code> objects that specifies the primary key of the item to retrieve.</p>
8 pub key: ::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>,
9 /// <p>The name of the table from which to retrieve the specified item. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
10 pub table_name: ::std::string::String,
11 /// <p>A string that identifies one or more attributes of the specified item to retrieve from the table. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes of the specified item are returned. If any of the requested attributes are not found, they do not appear in the result.</p>
12 pub projection_expression: ::std::option::Option<::std::string::String>,
13 /// <p>One or more substitution tokens for attribute names in the ProjectionExpression parameter.</p>
14 pub expression_attribute_names: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
15}
16impl Get {
17 /// <p>A map of attribute names to <code>AttributeValue</code> objects that specifies the primary key of the item to retrieve.</p>
18 pub fn key(&self) -> &::std::collections::HashMap<::std::string::String, crate::types::AttributeValue> {
19 &self.key
20 }
21 /// <p>The name of the table from which to retrieve the specified item. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
22 pub fn table_name(&self) -> &str {
23 use std::ops::Deref;
24 self.table_name.deref()
25 }
26 /// <p>A string that identifies one or more attributes of the specified item to retrieve from the table. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes of the specified item are returned. If any of the requested attributes are not found, they do not appear in the result.</p>
27 pub fn projection_expression(&self) -> ::std::option::Option<&str> {
28 self.projection_expression.as_deref()
29 }
30 /// <p>One or more substitution tokens for attribute names in the ProjectionExpression parameter.</p>
31 pub fn expression_attribute_names(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
32 self.expression_attribute_names.as_ref()
33 }
34}
35impl Get {
36 /// Creates a new builder-style object to manufacture [`Get`](crate::types::Get).
37 pub fn builder() -> crate::types::builders::GetBuilder {
38 crate::types::builders::GetBuilder::default()
39 }
40}
41
42/// A builder for [`Get`](crate::types::Get).
43#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
44#[non_exhaustive]
45pub struct GetBuilder {
46 pub(crate) key: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
47 pub(crate) table_name: ::std::option::Option<::std::string::String>,
48 pub(crate) projection_expression: ::std::option::Option<::std::string::String>,
49 pub(crate) expression_attribute_names: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
50}
51impl GetBuilder {
52 /// Adds a key-value pair to `key`.
53 ///
54 /// To override the contents of this collection use [`set_key`](Self::set_key).
55 ///
56 /// <p>A map of attribute names to <code>AttributeValue</code> objects that specifies the primary key of the item to retrieve.</p>
57 pub fn key(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
58 let mut hash_map = self.key.unwrap_or_default();
59 hash_map.insert(k.into(), v);
60 self.key = ::std::option::Option::Some(hash_map);
61 self
62 }
63 /// <p>A map of attribute names to <code>AttributeValue</code> objects that specifies the primary key of the item to retrieve.</p>
64 pub fn set_key(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>) -> Self {
65 self.key = input;
66 self
67 }
68 /// <p>A map of attribute names to <code>AttributeValue</code> objects that specifies the primary key of the item to retrieve.</p>
69 pub fn get_key(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
70 &self.key
71 }
72 /// <p>The name of the table from which to retrieve the specified item. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
73 /// This field is required.
74 pub fn table_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
75 self.table_name = ::std::option::Option::Some(input.into());
76 self
77 }
78 /// <p>The name of the table from which to retrieve the specified item. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
79 pub fn set_table_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
80 self.table_name = input;
81 self
82 }
83 /// <p>The name of the table from which to retrieve the specified item. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
84 pub fn get_table_name(&self) -> &::std::option::Option<::std::string::String> {
85 &self.table_name
86 }
87 /// <p>A string that identifies one or more attributes of the specified item to retrieve from the table. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes of the specified item are returned. If any of the requested attributes are not found, they do not appear in the result.</p>
88 pub fn projection_expression(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
89 self.projection_expression = ::std::option::Option::Some(input.into());
90 self
91 }
92 /// <p>A string that identifies one or more attributes of the specified item to retrieve from the table. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes of the specified item are returned. If any of the requested attributes are not found, they do not appear in the result.</p>
93 pub fn set_projection_expression(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
94 self.projection_expression = input;
95 self
96 }
97 /// <p>A string that identifies one or more attributes of the specified item to retrieve from the table. The attributes in the expression must be separated by commas. If no attribute names are specified, then all attributes of the specified item are returned. If any of the requested attributes are not found, they do not appear in the result.</p>
98 pub fn get_projection_expression(&self) -> &::std::option::Option<::std::string::String> {
99 &self.projection_expression
100 }
101 /// Adds a key-value pair to `expression_attribute_names`.
102 ///
103 /// To override the contents of this collection use [`set_expression_attribute_names`](Self::set_expression_attribute_names).
104 ///
105 /// <p>One or more substitution tokens for attribute names in the ProjectionExpression parameter.</p>
106 pub fn expression_attribute_names(
107 mut self,
108 k: impl ::std::convert::Into<::std::string::String>,
109 v: impl ::std::convert::Into<::std::string::String>,
110 ) -> Self {
111 let mut hash_map = self.expression_attribute_names.unwrap_or_default();
112 hash_map.insert(k.into(), v.into());
113 self.expression_attribute_names = ::std::option::Option::Some(hash_map);
114 self
115 }
116 /// <p>One or more substitution tokens for attribute names in the ProjectionExpression parameter.</p>
117 pub fn set_expression_attribute_names(
118 mut self,
119 input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
120 ) -> Self {
121 self.expression_attribute_names = input;
122 self
123 }
124 /// <p>One or more substitution tokens for attribute names in the ProjectionExpression parameter.</p>
125 pub fn get_expression_attribute_names(
126 &self,
127 ) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
128 &self.expression_attribute_names
129 }
130 /// Consumes the builder and constructs a [`Get`](crate::types::Get).
131 /// This method will fail if any of the following fields are not set:
132 /// - [`key`](crate::types::builders::GetBuilder::key)
133 /// - [`table_name`](crate::types::builders::GetBuilder::table_name)
134 pub fn build(self) -> ::std::result::Result<crate::types::Get, ::aws_smithy_types::error::operation::BuildError> {
135 ::std::result::Result::Ok(crate::types::Get {
136 key: self.key.ok_or_else(|| {
137 ::aws_smithy_types::error::operation::BuildError::missing_field("key", "key was not specified but it is required when building Get")
138 })?,
139 table_name: self.table_name.ok_or_else(|| {
140 ::aws_smithy_types::error::operation::BuildError::missing_field(
141 "table_name",
142 "table_name was not specified but it is required when building Get",
143 )
144 })?,
145 projection_expression: self.projection_expression,
146 expression_attribute_names: self.expression_attribute_names,
147 })
148 }
149}