aws_sdk_rbin/operation/create_rule/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_rule::_create_rule_output::CreateRuleOutputBuilder;
3
4pub use crate::operation::create_rule::_create_rule_input::CreateRuleInputBuilder;
5
6impl crate::operation::create_rule::builders::CreateRuleInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::create_rule::CreateRuleOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_rule::CreateRuleError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_rule();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateRule`.
24///
25/// <p>Creates a Recycle Bin retention rule. You can create two types of retention rules:</p>
26/// <ul>
27/// <li>
28/// <p><b>Tag-level retention rules</b> - These retention rules use resource tags to identify the resources to protect. For each retention rule, you specify one or more tag key and value pairs. Resources (of the specified type) that have at least one of these tag key and value pairs are automatically retained in the Recycle Bin upon deletion. Use this type of retention rule to protect specific resources in your account based on their tags.</p></li>
29/// <li>
30/// <p><b>Region-level retention rules</b> - These retention rules, by default, apply to all of the resources (of the specified type) in the Region, even if the resources are not tagged. However, you can specify exclusion tags to exclude resources that have specific tags. Use this type of retention rule to protect all resources of a specific type in a Region.</p></li>
31/// </ul>
32/// <p>For more information, see <a href="https://docs.aws.amazon.com/ebs/latest/userguide/recycle-bin.html"> Create Recycle Bin retention rules</a> in the <i>Amazon EBS User Guide</i>.</p>
33#[derive(::std::clone::Clone, ::std::fmt::Debug)]
34pub struct CreateRuleFluentBuilder {
35    handle: ::std::sync::Arc<crate::client::Handle>,
36    inner: crate::operation::create_rule::builders::CreateRuleInputBuilder,
37    config_override: ::std::option::Option<crate::config::Builder>,
38}
39impl
40    crate::client::customize::internal::CustomizableSend<
41        crate::operation::create_rule::CreateRuleOutput,
42        crate::operation::create_rule::CreateRuleError,
43    > for CreateRuleFluentBuilder
44{
45    fn send(
46        self,
47        config_override: crate::config::Builder,
48    ) -> crate::client::customize::internal::BoxFuture<
49        crate::client::customize::internal::SendResult<
50            crate::operation::create_rule::CreateRuleOutput,
51            crate::operation::create_rule::CreateRuleError,
52        >,
53    > {
54        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
55    }
56}
57impl CreateRuleFluentBuilder {
58    /// Creates a new `CreateRuleFluentBuilder`.
59    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
60        Self {
61            handle,
62            inner: ::std::default::Default::default(),
63            config_override: ::std::option::Option::None,
64        }
65    }
66    /// Access the CreateRule as a reference.
67    pub fn as_input(&self) -> &crate::operation::create_rule::builders::CreateRuleInputBuilder {
68        &self.inner
69    }
70    /// Sends the request and returns the response.
71    ///
72    /// If an error occurs, an `SdkError` will be returned with additional details that
73    /// can be matched against.
74    ///
75    /// By default, any retryable failures will be retried twice. Retry behavior
76    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
77    /// set when configuring the client.
78    pub async fn send(
79        self,
80    ) -> ::std::result::Result<
81        crate::operation::create_rule::CreateRuleOutput,
82        ::aws_smithy_runtime_api::client::result::SdkError<
83            crate::operation::create_rule::CreateRuleError,
84            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
85        >,
86    > {
87        let input = self
88            .inner
89            .build()
90            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
91        let runtime_plugins = crate::operation::create_rule::CreateRule::operation_runtime_plugins(
92            self.handle.runtime_plugins.clone(),
93            &self.handle.conf,
94            self.config_override,
95        );
96        crate::operation::create_rule::CreateRule::orchestrate(&runtime_plugins, input).await
97    }
98
99    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
100    pub fn customize(
101        self,
102    ) -> crate::client::customize::CustomizableOperation<
103        crate::operation::create_rule::CreateRuleOutput,
104        crate::operation::create_rule::CreateRuleError,
105        Self,
106    > {
107        crate::client::customize::CustomizableOperation::new(self)
108    }
109    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
110        self.set_config_override(::std::option::Option::Some(config_override.into()));
111        self
112    }
113
114    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
115        self.config_override = config_override;
116        self
117    }
118    /// <p>Information about the retention period for which the retention rule is to retain resources.</p>
119    pub fn retention_period(mut self, input: crate::types::RetentionPeriod) -> Self {
120        self.inner = self.inner.retention_period(input);
121        self
122    }
123    /// <p>Information about the retention period for which the retention rule is to retain resources.</p>
124    pub fn set_retention_period(mut self, input: ::std::option::Option<crate::types::RetentionPeriod>) -> Self {
125        self.inner = self.inner.set_retention_period(input);
126        self
127    }
128    /// <p>Information about the retention period for which the retention rule is to retain resources.</p>
129    pub fn get_retention_period(&self) -> &::std::option::Option<crate::types::RetentionPeriod> {
130        self.inner.get_retention_period()
131    }
132    /// <p>The retention rule description.</p>
133    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
134        self.inner = self.inner.description(input.into());
135        self
136    }
137    /// <p>The retention rule description.</p>
138    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
139        self.inner = self.inner.set_description(input);
140        self
141    }
142    /// <p>The retention rule description.</p>
143    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
144        self.inner.get_description()
145    }
146    ///
147    /// Appends an item to `Tags`.
148    ///
149    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
150    ///
151    /// <p>Information about the tags to assign to the retention rule.</p>
152    pub fn tags(mut self, input: crate::types::Tag) -> Self {
153        self.inner = self.inner.tags(input);
154        self
155    }
156    /// <p>Information about the tags to assign to the retention rule.</p>
157    pub fn set_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Tag>>) -> Self {
158        self.inner = self.inner.set_tags(input);
159        self
160    }
161    /// <p>Information about the tags to assign to the retention rule.</p>
162    pub fn get_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Tag>> {
163        self.inner.get_tags()
164    }
165    /// <p>The resource type to be retained by the retention rule. Currently, only EBS volumes, EBS snapshots, and EBS-backed AMIs are supported.</p>
166    /// <ul>
167    /// <li>
168    /// <p>To retain EBS volumes, specify <code>EBS_VOLUME</code>.</p></li>
169    /// <li>
170    /// <p>To retain EBS snapshots, specify <code>EBS_SNAPSHOT</code></p></li>
171    /// <li>
172    /// <p>To retain EBS-backed AMIs, specify <code>EC2_IMAGE</code>.</p></li>
173    /// </ul>
174    pub fn resource_type(mut self, input: crate::types::ResourceType) -> Self {
175        self.inner = self.inner.resource_type(input);
176        self
177    }
178    /// <p>The resource type to be retained by the retention rule. Currently, only EBS volumes, EBS snapshots, and EBS-backed AMIs are supported.</p>
179    /// <ul>
180    /// <li>
181    /// <p>To retain EBS volumes, specify <code>EBS_VOLUME</code>.</p></li>
182    /// <li>
183    /// <p>To retain EBS snapshots, specify <code>EBS_SNAPSHOT</code></p></li>
184    /// <li>
185    /// <p>To retain EBS-backed AMIs, specify <code>EC2_IMAGE</code>.</p></li>
186    /// </ul>
187    pub fn set_resource_type(mut self, input: ::std::option::Option<crate::types::ResourceType>) -> Self {
188        self.inner = self.inner.set_resource_type(input);
189        self
190    }
191    /// <p>The resource type to be retained by the retention rule. Currently, only EBS volumes, EBS snapshots, and EBS-backed AMIs are supported.</p>
192    /// <ul>
193    /// <li>
194    /// <p>To retain EBS volumes, specify <code>EBS_VOLUME</code>.</p></li>
195    /// <li>
196    /// <p>To retain EBS snapshots, specify <code>EBS_SNAPSHOT</code></p></li>
197    /// <li>
198    /// <p>To retain EBS-backed AMIs, specify <code>EC2_IMAGE</code>.</p></li>
199    /// </ul>
200    pub fn get_resource_type(&self) -> &::std::option::Option<crate::types::ResourceType> {
201        self.inner.get_resource_type()
202    }
203    ///
204    /// Appends an item to `ResourceTags`.
205    ///
206    /// To override the contents of this collection use [`set_resource_tags`](Self::set_resource_tags).
207    ///
208    /// <p>\[Tag-level retention rules only\] Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.</p>
209    /// <p>You can add the same tag key and value pair to a maximum or five retention rules.</p>
210    /// <p>To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.</p>
211    pub fn resource_tags(mut self, input: crate::types::ResourceTag) -> Self {
212        self.inner = self.inner.resource_tags(input);
213        self
214    }
215    /// <p>\[Tag-level retention rules only\] Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.</p>
216    /// <p>You can add the same tag key and value pair to a maximum or five retention rules.</p>
217    /// <p>To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.</p>
218    pub fn set_resource_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ResourceTag>>) -> Self {
219        self.inner = self.inner.set_resource_tags(input);
220        self
221    }
222    /// <p>\[Tag-level retention rules only\] Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.</p>
223    /// <p>You can add the same tag key and value pair to a maximum or five retention rules.</p>
224    /// <p>To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.</p>
225    pub fn get_resource_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ResourceTag>> {
226        self.inner.get_resource_tags()
227    }
228    /// <p>Information about the retention rule lock configuration.</p>
229    pub fn lock_configuration(mut self, input: crate::types::LockConfiguration) -> Self {
230        self.inner = self.inner.lock_configuration(input);
231        self
232    }
233    /// <p>Information about the retention rule lock configuration.</p>
234    pub fn set_lock_configuration(mut self, input: ::std::option::Option<crate::types::LockConfiguration>) -> Self {
235        self.inner = self.inner.set_lock_configuration(input);
236        self
237    }
238    /// <p>Information about the retention rule lock configuration.</p>
239    pub fn get_lock_configuration(&self) -> &::std::option::Option<crate::types::LockConfiguration> {
240        self.inner.get_lock_configuration()
241    }
242    ///
243    /// Appends an item to `ExcludeResourceTags`.
244    ///
245    /// To override the contents of this collection use [`set_exclude_resource_tags`](Self::set_exclude_resource_tags).
246    ///
247    /// <p>\[Region-level retention rules only\] Specifies the exclusion tags to use to identify resources that are to be excluded, or ignored, by a Region-level retention rule. Resources that have any of these tags are not retained by the retention rule upon deletion.</p>
248    /// <p>You can't specify exclusion tags for tag-level retention rules.</p>
249    pub fn exclude_resource_tags(mut self, input: crate::types::ResourceTag) -> Self {
250        self.inner = self.inner.exclude_resource_tags(input);
251        self
252    }
253    /// <p>\[Region-level retention rules only\] Specifies the exclusion tags to use to identify resources that are to be excluded, or ignored, by a Region-level retention rule. Resources that have any of these tags are not retained by the retention rule upon deletion.</p>
254    /// <p>You can't specify exclusion tags for tag-level retention rules.</p>
255    pub fn set_exclude_resource_tags(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ResourceTag>>) -> Self {
256        self.inner = self.inner.set_exclude_resource_tags(input);
257        self
258    }
259    /// <p>\[Region-level retention rules only\] Specifies the exclusion tags to use to identify resources that are to be excluded, or ignored, by a Region-level retention rule. Resources that have any of these tags are not retained by the retention rule upon deletion.</p>
260    /// <p>You can't specify exclusion tags for tag-level retention rules.</p>
261    pub fn get_exclude_resource_tags(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ResourceTag>> {
262        self.inner.get_exclude_resource_tags()
263    }
264}