aws_sdk_dynamodb/types/
_delete.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Represents a request to perform a <code>DeleteItem</code> operation.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct Delete {
7    /// <p>The primary key of the item to be deleted. Each element consists of an attribute name and a value for that attribute.</p>
8    pub key: ::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>,
9    /// <p>Name of the table in which the item to be deleted resides. 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 condition that must be satisfied in order for a conditional delete to succeed.</p>
12    pub condition_expression: ::std::option::Option<::std::string::String>,
13    /// <p>One or more substitution tokens for attribute names in an expression.</p>
14    pub expression_attribute_names: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
15    /// <p>One or more values that can be substituted in an expression.</p>
16    pub expression_attribute_values: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
17    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Delete</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
18    pub return_values_on_condition_check_failure: ::std::option::Option<crate::types::ReturnValuesOnConditionCheckFailure>,
19}
20impl Delete {
21    /// <p>The primary key of the item to be deleted. Each element consists of an attribute name and a value for that attribute.</p>
22    pub fn key(&self) -> &::std::collections::HashMap<::std::string::String, crate::types::AttributeValue> {
23        &self.key
24    }
25    /// <p>Name of the table in which the item to be deleted resides. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
26    pub fn table_name(&self) -> &str {
27        use std::ops::Deref;
28        self.table_name.deref()
29    }
30    /// <p>A condition that must be satisfied in order for a conditional delete to succeed.</p>
31    pub fn condition_expression(&self) -> ::std::option::Option<&str> {
32        self.condition_expression.as_deref()
33    }
34    /// <p>One or more substitution tokens for attribute names in an expression.</p>
35    pub fn expression_attribute_names(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
36        self.expression_attribute_names.as_ref()
37    }
38    /// <p>One or more values that can be substituted in an expression.</p>
39    pub fn expression_attribute_values(
40        &self,
41    ) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
42        self.expression_attribute_values.as_ref()
43    }
44    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Delete</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
45    pub fn return_values_on_condition_check_failure(&self) -> ::std::option::Option<&crate::types::ReturnValuesOnConditionCheckFailure> {
46        self.return_values_on_condition_check_failure.as_ref()
47    }
48}
49impl Delete {
50    /// Creates a new builder-style object to manufacture [`Delete`](crate::types::Delete).
51    pub fn builder() -> crate::types::builders::DeleteBuilder {
52        crate::types::builders::DeleteBuilder::default()
53    }
54}
55
56/// A builder for [`Delete`](crate::types::Delete).
57#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
58#[non_exhaustive]
59pub struct DeleteBuilder {
60    pub(crate) key: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
61    pub(crate) table_name: ::std::option::Option<::std::string::String>,
62    pub(crate) condition_expression: ::std::option::Option<::std::string::String>,
63    pub(crate) expression_attribute_names: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
64    pub(crate) expression_attribute_values: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
65    pub(crate) return_values_on_condition_check_failure: ::std::option::Option<crate::types::ReturnValuesOnConditionCheckFailure>,
66}
67impl DeleteBuilder {
68    /// Adds a key-value pair to `key`.
69    ///
70    /// To override the contents of this collection use [`set_key`](Self::set_key).
71    ///
72    /// <p>The primary key of the item to be deleted. Each element consists of an attribute name and a value for that attribute.</p>
73    pub fn key(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
74        let mut hash_map = self.key.unwrap_or_default();
75        hash_map.insert(k.into(), v);
76        self.key = ::std::option::Option::Some(hash_map);
77        self
78    }
79    /// <p>The primary key of the item to be deleted. Each element consists of an attribute name and a value for that attribute.</p>
80    pub fn set_key(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>) -> Self {
81        self.key = input;
82        self
83    }
84    /// <p>The primary key of the item to be deleted. Each element consists of an attribute name and a value for that attribute.</p>
85    pub fn get_key(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
86        &self.key
87    }
88    /// <p>Name of the table in which the item to be deleted resides. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
89    /// This field is required.
90    pub fn table_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
91        self.table_name = ::std::option::Option::Some(input.into());
92        self
93    }
94    /// <p>Name of the table in which the item to be deleted resides. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
95    pub fn set_table_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
96        self.table_name = input;
97        self
98    }
99    /// <p>Name of the table in which the item to be deleted resides. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
100    pub fn get_table_name(&self) -> &::std::option::Option<::std::string::String> {
101        &self.table_name
102    }
103    /// <p>A condition that must be satisfied in order for a conditional delete to succeed.</p>
104    pub fn condition_expression(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
105        self.condition_expression = ::std::option::Option::Some(input.into());
106        self
107    }
108    /// <p>A condition that must be satisfied in order for a conditional delete to succeed.</p>
109    pub fn set_condition_expression(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
110        self.condition_expression = input;
111        self
112    }
113    /// <p>A condition that must be satisfied in order for a conditional delete to succeed.</p>
114    pub fn get_condition_expression(&self) -> &::std::option::Option<::std::string::String> {
115        &self.condition_expression
116    }
117    /// Adds a key-value pair to `expression_attribute_names`.
118    ///
119    /// To override the contents of this collection use [`set_expression_attribute_names`](Self::set_expression_attribute_names).
120    ///
121    /// <p>One or more substitution tokens for attribute names in an expression.</p>
122    pub fn expression_attribute_names(
123        mut self,
124        k: impl ::std::convert::Into<::std::string::String>,
125        v: impl ::std::convert::Into<::std::string::String>,
126    ) -> Self {
127        let mut hash_map = self.expression_attribute_names.unwrap_or_default();
128        hash_map.insert(k.into(), v.into());
129        self.expression_attribute_names = ::std::option::Option::Some(hash_map);
130        self
131    }
132    /// <p>One or more substitution tokens for attribute names in an expression.</p>
133    pub fn set_expression_attribute_names(
134        mut self,
135        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
136    ) -> Self {
137        self.expression_attribute_names = input;
138        self
139    }
140    /// <p>One or more substitution tokens for attribute names in an expression.</p>
141    pub fn get_expression_attribute_names(
142        &self,
143    ) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
144        &self.expression_attribute_names
145    }
146    /// Adds a key-value pair to `expression_attribute_values`.
147    ///
148    /// To override the contents of this collection use [`set_expression_attribute_values`](Self::set_expression_attribute_values).
149    ///
150    /// <p>One or more values that can be substituted in an expression.</p>
151    pub fn expression_attribute_values(mut self, k: impl ::std::convert::Into<::std::string::String>, v: crate::types::AttributeValue) -> Self {
152        let mut hash_map = self.expression_attribute_values.unwrap_or_default();
153        hash_map.insert(k.into(), v);
154        self.expression_attribute_values = ::std::option::Option::Some(hash_map);
155        self
156    }
157    /// <p>One or more values that can be substituted in an expression.</p>
158    pub fn set_expression_attribute_values(
159        mut self,
160        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>>,
161    ) -> Self {
162        self.expression_attribute_values = input;
163        self
164    }
165    /// <p>One or more values that can be substituted in an expression.</p>
166    pub fn get_expression_attribute_values(
167        &self,
168    ) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, crate::types::AttributeValue>> {
169        &self.expression_attribute_values
170    }
171    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Delete</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
172    pub fn return_values_on_condition_check_failure(mut self, input: crate::types::ReturnValuesOnConditionCheckFailure) -> Self {
173        self.return_values_on_condition_check_failure = ::std::option::Option::Some(input);
174        self
175    }
176    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Delete</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
177    pub fn set_return_values_on_condition_check_failure(
178        mut self,
179        input: ::std::option::Option<crate::types::ReturnValuesOnConditionCheckFailure>,
180    ) -> Self {
181        self.return_values_on_condition_check_failure = input;
182        self
183    }
184    /// <p>Use <code>ReturnValuesOnConditionCheckFailure</code> to get the item attributes if the <code>Delete</code> condition fails. For <code>ReturnValuesOnConditionCheckFailure</code>, the valid values are: NONE and ALL_OLD.</p>
185    pub fn get_return_values_on_condition_check_failure(&self) -> &::std::option::Option<crate::types::ReturnValuesOnConditionCheckFailure> {
186        &self.return_values_on_condition_check_failure
187    }
188    /// Consumes the builder and constructs a [`Delete`](crate::types::Delete).
189    /// This method will fail if any of the following fields are not set:
190    /// - [`key`](crate::types::builders::DeleteBuilder::key)
191    /// - [`table_name`](crate::types::builders::DeleteBuilder::table_name)
192    pub fn build(self) -> ::std::result::Result<crate::types::Delete, ::aws_smithy_types::error::operation::BuildError> {
193        ::std::result::Result::Ok(crate::types::Delete {
194            key: self.key.ok_or_else(|| {
195                ::aws_smithy_types::error::operation::BuildError::missing_field(
196                    "key",
197                    "key was not specified but it is required when building Delete",
198                )
199            })?,
200            table_name: self.table_name.ok_or_else(|| {
201                ::aws_smithy_types::error::operation::BuildError::missing_field(
202                    "table_name",
203                    "table_name was not specified but it is required when building Delete",
204                )
205            })?,
206            condition_expression: self.condition_expression,
207            expression_attribute_names: self.expression_attribute_names,
208            expression_attribute_values: self.expression_attribute_values,
209            return_values_on_condition_check_failure: self.return_values_on_condition_check_failure,
210        })
211    }
212}