1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>Represents a request to perform an <code>UpdateItem</code> operation.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Update {
    /// <p>The primary key of the item to be updated. Each element consists of an attribute name and a value for that attribute.</p>
    pub key: ::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>,
    /// <p>An expression that defines one or more attributes to be updated, the action to be performed on them, and new value(s) for them.</p>
    pub update_expression: ::std::string::String,
    /// <p>Name of the table for the <code>UpdateItem</code> request. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
    pub table_name: ::std::string::String,
    /// <p>A condition that must be satisfied in order for a conditional update to succeed.</p>
    pub condition_expression: ::std::option::Option<::std::string::String>,
    /// <p>One or more substitution tokens for attribute names in an expression.</p>
    pub expression_attribute_names: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    /// <p>One or more values that can be substituted in an expression.</p>
    pub expression_attribute_values: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Update</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
    pub return_values_on_condition_check_failure: ::std::option::Option<crate::types::ReturnValuesOnConditionCheckFailure>,
}
impl Update {
    /// <p>The primary key of the item to be updated. Each element consists of an attribute name and a value for that attribute.</p>
    pub fn key(&self) -> &::std::collections::HashMap<::std::string::String, crate::types::AttributeValue> {
        &self.key
    }
    /// <p>An expression that defines one or more attributes to be updated, the action to be performed on them, and new value(s) for them.</p>
    pub fn update_expression(&self) -> &str {
        use std::ops::Deref;
        self.update_expression.deref()
    }
    /// <p>Name of the table for the <code>UpdateItem</code> request. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
    pub fn table_name(&self) -> &str {
        use std::ops::Deref;
        self.table_name.deref()
    }
    /// <p>A condition that must be satisfied in order for a conditional update to succeed.</p>
    pub fn condition_expression(&self) -> ::std::option::Option<&str> {
        self.condition_expression.as_deref()
    }
    /// <p>One or more substitution tokens for attribute names in an expression.</p>
    pub fn expression_attribute_names(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        self.expression_attribute_names.as_ref()
    }
    /// <p>One or more values that can be substituted in an expression.</p>
    pub fn expression_attribute_values(
        &self,
    ) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
        self.expression_attribute_values.as_ref()
    }
    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Update</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
    pub fn return_values_on_condition_check_failure(&self) -> ::std::option::Option<&crate::types::ReturnValuesOnConditionCheckFailure> {
        self.return_values_on_condition_check_failure.as_ref()
    }
}
impl Update {
    /// Creates a new builder-style object to manufacture [`Update`](crate::types::Update).
    pub fn builder() -> crate::types::builders::UpdateBuilder {
        crate::types::builders::UpdateBuilder::default()
    }
}

/// A builder for [`Update`](crate::types::Update).
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
pub struct UpdateBuilder {
    pub(crate) key: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
    pub(crate) update_expression: ::std::option::Option<::std::string::String>,
    pub(crate) table_name: ::std::option::Option<::std::string::String>,
    pub(crate) condition_expression: ::std::option::Option<::std::string::String>,
    pub(crate) expression_attribute_names: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    pub(crate) expression_attribute_values: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
    pub(crate) return_values_on_condition_check_failure: ::std::option::Option<crate::types::ReturnValuesOnConditionCheckFailure>,
}
impl UpdateBuilder {
    /// Adds a key-value pair to `key`.
    ///
    /// To override the contents of this collection use [`set_key`](Self::set_key).
    ///
    /// <p>The primary key of the item to be updated. Each element consists of an attribute name and a value for that attribute.</p>
    pub fn key(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
        let mut hash_map = self.key.unwrap_or_default();
        hash_map.insert(k.into(), v);
        self.key = ::std::option::Option::Some(hash_map);
        self
    }
    /// <p>The primary key of the item to be updated. Each element consists of an attribute name and a value for that attribute.</p>
    pub fn set_key(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>) -> Self {
        self.key = input;
        self
    }
    /// <p>The primary key of the item to be updated. Each element consists of an attribute name and a value for that attribute.</p>
    pub fn get_key(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
        &self.key
    }
    /// <p>An expression that defines one or more attributes to be updated, the action to be performed on them, and new value(s) for them.</p>
    /// This field is required.
    pub fn update_expression(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.update_expression = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>An expression that defines one or more attributes to be updated, the action to be performed on them, and new value(s) for them.</p>
    pub fn set_update_expression(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.update_expression = input;
        self
    }
    /// <p>An expression that defines one or more attributes to be updated, the action to be performed on them, and new value(s) for them.</p>
    pub fn get_update_expression(&self) -> &::std::option::Option<::std::string::String> {
        &self.update_expression
    }
    /// <p>Name of the table for the <code>UpdateItem</code> request. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
    /// This field is required.
    pub fn table_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.table_name = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>Name of the table for the <code>UpdateItem</code> request. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
    pub fn set_table_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.table_name = input;
        self
    }
    /// <p>Name of the table for the <code>UpdateItem</code> request. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
    pub fn get_table_name(&self) -> &::std::option::Option<::std::string::String> {
        &self.table_name
    }
    /// <p>A condition that must be satisfied in order for a conditional update to succeed.</p>
    pub fn condition_expression(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.condition_expression = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>A condition that must be satisfied in order for a conditional update to succeed.</p>
    pub fn set_condition_expression(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.condition_expression = input;
        self
    }
    /// <p>A condition that must be satisfied in order for a conditional update to succeed.</p>
    pub fn get_condition_expression(&self) -> &::std::option::Option<::std::string::String> {
        &self.condition_expression
    }
    /// Adds a key-value pair to `expression_attribute_names`.
    ///
    /// To override the contents of this collection use [`set_expression_attribute_names`](Self::set_expression_attribute_names).
    ///
    /// <p>One or more substitution tokens for attribute names in an expression.</p>
    pub fn expression_attribute_names(
        mut self,
        k: impl ::std::convert::Into<::std::string::String>,
        v: impl ::std::convert::Into<::std::string::String>,
    ) -> Self {
        let mut hash_map = self.expression_attribute_names.unwrap_or_default();
        hash_map.insert(k.into(), v.into());
        self.expression_attribute_names = ::std::option::Option::Some(hash_map);
        self
    }
    /// <p>One or more substitution tokens for attribute names in an expression.</p>
    pub fn set_expression_attribute_names(
        mut self,
        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    ) -> Self {
        self.expression_attribute_names = input;
        self
    }
    /// <p>One or more substitution tokens for attribute names in an expression.</p>
    pub fn get_expression_attribute_names(
        &self,
    ) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        &self.expression_attribute_names
    }
    /// Adds a key-value pair to `expression_attribute_values`.
    ///
    /// To override the contents of this collection use [`set_expression_attribute_values`](Self::set_expression_attribute_values).
    ///
    /// <p>One or more values that can be substituted in an expression.</p>
    pub fn expression_attribute_values(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
        let mut hash_map = self.expression_attribute_values.unwrap_or_default();
        hash_map.insert(k.into(), v);
        self.expression_attribute_values = ::std::option::Option::Some(hash_map);
        self
    }
    /// <p>One or more values that can be substituted in an expression.</p>
    pub fn set_expression_attribute_values(
        mut self,
        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
    ) -> Self {
        self.expression_attribute_values = input;
        self
    }
    /// <p>One or more values that can be substituted in an expression.</p>
    pub fn get_expression_attribute_values(
        &self,
    ) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
        &self.expression_attribute_values
    }
    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Update</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
    pub fn return_values_on_condition_check_failure(mut self, input: crate::types::ReturnValuesOnConditionCheckFailure) -> Self {
        self.return_values_on_condition_check_failure = ::std::option::Option::Some(input);
        self
    }
    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Update</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
    pub fn set_return_values_on_condition_check_failure(
        mut self,
        input: ::std::option::Option<crate::types::ReturnValuesOnConditionCheckFailure>,
    ) -> Self {
        self.return_values_on_condition_check_failure = input;
        self
    }
    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Update</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
    pub fn get_return_values_on_condition_check_failure(&self) -> &::std::option::Option<crate::types::ReturnValuesOnConditionCheckFailure> {
        &self.return_values_on_condition_check_failure
    }
    /// Consumes the builder and constructs a [`Update`](crate::types::Update).
    /// This method will fail if any of the following fields are not set:
    /// - [`key`](crate::types::builders::UpdateBuilder::key)
    /// - [`update_expression`](crate::types::builders::UpdateBuilder::update_expression)
    /// - [`table_name`](crate::types::builders::UpdateBuilder::table_name)
    pub fn build(self) -> ::std::result::Result<crate::types::Update, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Update {
            key: self.key.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "key",
                    "key was not specified but it is required when building Update",
                )
            })?,
            update_expression: self.update_expression.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "update_expression",
                    "update_expression was not specified but it is required when building Update",
                )
            })?,
            table_name: self.table_name.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "table_name",
                    "table_name was not specified but it is required when building Update",
                )
            })?,
            condition_expression: self.condition_expression,
            expression_attribute_names: self.expression_attribute_names,
            expression_attribute_values: self.expression_attribute_values,
            return_values_on_condition_check_failure: self.return_values_on_condition_check_failure,
        })
    }
}