aws_sdk_dlm/operation/create_lifecycle_policy/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_lifecycle_policy::_create_lifecycle_policy_output::CreateLifecyclePolicyOutputBuilder;
3
4pub use crate::operation::create_lifecycle_policy::_create_lifecycle_policy_input::CreateLifecyclePolicyInputBuilder;
5
6impl crate::operation::create_lifecycle_policy::builders::CreateLifecyclePolicyInputBuilder {
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_lifecycle_policy::CreateLifecyclePolicyOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_lifecycle_policy::CreateLifecyclePolicyError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_lifecycle_policy();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateLifecyclePolicy`.
24///
25/// <p>Creates an Amazon Data Lifecycle Manager lifecycle policy. Amazon Data Lifecycle Manager supports the following policy types:</p>
26/// <ul>
27/// <li>
28/// <p>Custom EBS snapshot policy</p></li>
29/// <li>
30/// <p>Custom EBS-backed AMI policy</p></li>
31/// <li>
32/// <p>Cross-account copy event policy</p></li>
33/// <li>
34/// <p>Default policy for EBS snapshots</p></li>
35/// <li>
36/// <p>Default policy for EBS-backed AMIs</p></li>
37/// </ul>
38/// <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/policy-differences.html"> Default policies vs custom policies</a>.</p><important>
39/// <p>If you create a default policy, you can specify the request parameters either in the request body, or in the PolicyDetails request structure, but not both.</p>
40/// </important>
41#[derive(::std::clone::Clone, ::std::fmt::Debug)]
42pub struct CreateLifecyclePolicyFluentBuilder {
43    handle: ::std::sync::Arc<crate::client::Handle>,
44    inner: crate::operation::create_lifecycle_policy::builders::CreateLifecyclePolicyInputBuilder,
45    config_override: ::std::option::Option<crate::config::Builder>,
46}
47impl
48    crate::client::customize::internal::CustomizableSend<
49        crate::operation::create_lifecycle_policy::CreateLifecyclePolicyOutput,
50        crate::operation::create_lifecycle_policy::CreateLifecyclePolicyError,
51    > for CreateLifecyclePolicyFluentBuilder
52{
53    fn send(
54        self,
55        config_override: crate::config::Builder,
56    ) -> crate::client::customize::internal::BoxFuture<
57        crate::client::customize::internal::SendResult<
58            crate::operation::create_lifecycle_policy::CreateLifecyclePolicyOutput,
59            crate::operation::create_lifecycle_policy::CreateLifecyclePolicyError,
60        >,
61    > {
62        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
63    }
64}
65impl CreateLifecyclePolicyFluentBuilder {
66    /// Creates a new `CreateLifecyclePolicyFluentBuilder`.
67    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
68        Self {
69            handle,
70            inner: ::std::default::Default::default(),
71            config_override: ::std::option::Option::None,
72        }
73    }
74    /// Access the CreateLifecyclePolicy as a reference.
75    pub fn as_input(&self) -> &crate::operation::create_lifecycle_policy::builders::CreateLifecyclePolicyInputBuilder {
76        &self.inner
77    }
78    /// Sends the request and returns the response.
79    ///
80    /// If an error occurs, an `SdkError` will be returned with additional details that
81    /// can be matched against.
82    ///
83    /// By default, any retryable failures will be retried twice. Retry behavior
84    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
85    /// set when configuring the client.
86    pub async fn send(
87        self,
88    ) -> ::std::result::Result<
89        crate::operation::create_lifecycle_policy::CreateLifecyclePolicyOutput,
90        ::aws_smithy_runtime_api::client::result::SdkError<
91            crate::operation::create_lifecycle_policy::CreateLifecyclePolicyError,
92            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
93        >,
94    > {
95        let input = self
96            .inner
97            .build()
98            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
99        let runtime_plugins = crate::operation::create_lifecycle_policy::CreateLifecyclePolicy::operation_runtime_plugins(
100            self.handle.runtime_plugins.clone(),
101            &self.handle.conf,
102            self.config_override,
103        );
104        crate::operation::create_lifecycle_policy::CreateLifecyclePolicy::orchestrate(&runtime_plugins, input).await
105    }
106
107    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
108    pub fn customize(
109        self,
110    ) -> crate::client::customize::CustomizableOperation<
111        crate::operation::create_lifecycle_policy::CreateLifecyclePolicyOutput,
112        crate::operation::create_lifecycle_policy::CreateLifecyclePolicyError,
113        Self,
114    > {
115        crate::client::customize::CustomizableOperation::new(self)
116    }
117    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
118        self.set_config_override(::std::option::Option::Some(config_override.into()));
119        self
120    }
121
122    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
123        self.config_override = config_override;
124        self
125    }
126    /// <p>The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by the lifecycle policy.</p>
127    pub fn execution_role_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
128        self.inner = self.inner.execution_role_arn(input.into());
129        self
130    }
131    /// <p>The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by the lifecycle policy.</p>
132    pub fn set_execution_role_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
133        self.inner = self.inner.set_execution_role_arn(input);
134        self
135    }
136    /// <p>The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by the lifecycle policy.</p>
137    pub fn get_execution_role_arn(&self) -> &::std::option::Option<::std::string::String> {
138        self.inner.get_execution_role_arn()
139    }
140    /// <p>A description of the lifecycle policy. The characters ^\[0-9A-Za-z _-\]+$ are supported.</p>
141    pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
142        self.inner = self.inner.description(input.into());
143        self
144    }
145    /// <p>A description of the lifecycle policy. The characters ^\[0-9A-Za-z _-\]+$ are supported.</p>
146    pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
147        self.inner = self.inner.set_description(input);
148        self
149    }
150    /// <p>A description of the lifecycle policy. The characters ^\[0-9A-Za-z _-\]+$ are supported.</p>
151    pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
152        self.inner.get_description()
153    }
154    /// <p>The activation state of the lifecycle policy after creation.</p>
155    pub fn state(mut self, input: crate::types::SettablePolicyStateValues) -> Self {
156        self.inner = self.inner.state(input);
157        self
158    }
159    /// <p>The activation state of the lifecycle policy after creation.</p>
160    pub fn set_state(mut self, input: ::std::option::Option<crate::types::SettablePolicyStateValues>) -> Self {
161        self.inner = self.inner.set_state(input);
162        self
163    }
164    /// <p>The activation state of the lifecycle policy after creation.</p>
165    pub fn get_state(&self) -> &::std::option::Option<crate::types::SettablePolicyStateValues> {
166        self.inner.get_state()
167    }
168    /// <p>The configuration details of the lifecycle policy.</p><important>
169    /// <p>If you create a default policy, you can specify the request parameters either in the request body, or in the PolicyDetails request structure, but not both.</p>
170    /// </important>
171    pub fn policy_details(mut self, input: crate::types::PolicyDetails) -> Self {
172        self.inner = self.inner.policy_details(input);
173        self
174    }
175    /// <p>The configuration details of the lifecycle policy.</p><important>
176    /// <p>If you create a default policy, you can specify the request parameters either in the request body, or in the PolicyDetails request structure, but not both.</p>
177    /// </important>
178    pub fn set_policy_details(mut self, input: ::std::option::Option<crate::types::PolicyDetails>) -> Self {
179        self.inner = self.inner.set_policy_details(input);
180        self
181    }
182    /// <p>The configuration details of the lifecycle policy.</p><important>
183    /// <p>If you create a default policy, you can specify the request parameters either in the request body, or in the PolicyDetails request structure, but not both.</p>
184    /// </important>
185    pub fn get_policy_details(&self) -> &::std::option::Option<crate::types::PolicyDetails> {
186        self.inner.get_policy_details()
187    }
188    ///
189    /// Adds a key-value pair to `Tags`.
190    ///
191    /// To override the contents of this collection use [`set_tags`](Self::set_tags).
192    ///
193    /// <p>The tags to apply to the lifecycle policy during creation.</p>
194    pub fn tags(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
195        self.inner = self.inner.tags(k.into(), v.into());
196        self
197    }
198    /// <p>The tags to apply to the lifecycle policy during creation.</p>
199    pub fn set_tags(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
200        self.inner = self.inner.set_tags(input);
201        self
202    }
203    /// <p>The tags to apply to the lifecycle policy during creation.</p>
204    pub fn get_tags(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
205        self.inner.get_tags()
206    }
207    /// <p><b>\[Default policies only\]</b> Specify the type of default policy to create.</p>
208    /// <ul>
209    /// <li>
210    /// <p>To create a default policy for EBS snapshots, that creates snapshots of all volumes in the Region that do not have recent backups, specify <code>VOLUME</code>.</p></li>
211    /// <li>
212    /// <p>To create a default policy for EBS-backed AMIs, that creates EBS-backed AMIs from all instances in the Region that do not have recent backups, specify <code>INSTANCE</code>.</p></li>
213    /// </ul>
214    pub fn default_policy(mut self, input: crate::types::DefaultPolicyTypeValues) -> Self {
215        self.inner = self.inner.default_policy(input);
216        self
217    }
218    /// <p><b>\[Default policies only\]</b> Specify the type of default policy to create.</p>
219    /// <ul>
220    /// <li>
221    /// <p>To create a default policy for EBS snapshots, that creates snapshots of all volumes in the Region that do not have recent backups, specify <code>VOLUME</code>.</p></li>
222    /// <li>
223    /// <p>To create a default policy for EBS-backed AMIs, that creates EBS-backed AMIs from all instances in the Region that do not have recent backups, specify <code>INSTANCE</code>.</p></li>
224    /// </ul>
225    pub fn set_default_policy(mut self, input: ::std::option::Option<crate::types::DefaultPolicyTypeValues>) -> Self {
226        self.inner = self.inner.set_default_policy(input);
227        self
228    }
229    /// <p><b>\[Default policies only\]</b> Specify the type of default policy to create.</p>
230    /// <ul>
231    /// <li>
232    /// <p>To create a default policy for EBS snapshots, that creates snapshots of all volumes in the Region that do not have recent backups, specify <code>VOLUME</code>.</p></li>
233    /// <li>
234    /// <p>To create a default policy for EBS-backed AMIs, that creates EBS-backed AMIs from all instances in the Region that do not have recent backups, specify <code>INSTANCE</code>.</p></li>
235    /// </ul>
236    pub fn get_default_policy(&self) -> &::std::option::Option<crate::types::DefaultPolicyTypeValues> {
237        self.inner.get_default_policy()
238    }
239    /// <p><b>\[Default policies only\]</b> Specifies how often the policy should run and create snapshots or AMIs. The creation frequency can range from 1 to 7 days. If you do not specify a value, the default is 1.</p>
240    /// <p>Default: 1</p>
241    pub fn create_interval(mut self, input: i32) -> Self {
242        self.inner = self.inner.create_interval(input);
243        self
244    }
245    /// <p><b>\[Default policies only\]</b> Specifies how often the policy should run and create snapshots or AMIs. The creation frequency can range from 1 to 7 days. If you do not specify a value, the default is 1.</p>
246    /// <p>Default: 1</p>
247    pub fn set_create_interval(mut self, input: ::std::option::Option<i32>) -> Self {
248        self.inner = self.inner.set_create_interval(input);
249        self
250    }
251    /// <p><b>\[Default policies only\]</b> Specifies how often the policy should run and create snapshots or AMIs. The creation frequency can range from 1 to 7 days. If you do not specify a value, the default is 1.</p>
252    /// <p>Default: 1</p>
253    pub fn get_create_interval(&self) -> &::std::option::Option<i32> {
254        self.inner.get_create_interval()
255    }
256    /// <p><b>\[Default policies only\]</b> Specifies how long the policy should retain snapshots or AMIs before deleting them. The retention period can range from 2 to 14 days, but it must be greater than the creation frequency to ensure that the policy retains at least 1 snapshot or AMI at any given time. If you do not specify a value, the default is 7.</p>
257    /// <p>Default: 7</p>
258    pub fn retain_interval(mut self, input: i32) -> Self {
259        self.inner = self.inner.retain_interval(input);
260        self
261    }
262    /// <p><b>\[Default policies only\]</b> Specifies how long the policy should retain snapshots or AMIs before deleting them. The retention period can range from 2 to 14 days, but it must be greater than the creation frequency to ensure that the policy retains at least 1 snapshot or AMI at any given time. If you do not specify a value, the default is 7.</p>
263    /// <p>Default: 7</p>
264    pub fn set_retain_interval(mut self, input: ::std::option::Option<i32>) -> Self {
265        self.inner = self.inner.set_retain_interval(input);
266        self
267    }
268    /// <p><b>\[Default policies only\]</b> Specifies how long the policy should retain snapshots or AMIs before deleting them. The retention period can range from 2 to 14 days, but it must be greater than the creation frequency to ensure that the policy retains at least 1 snapshot or AMI at any given time. If you do not specify a value, the default is 7.</p>
269    /// <p>Default: 7</p>
270    pub fn get_retain_interval(&self) -> &::std::option::Option<i32> {
271        self.inner.get_retain_interval()
272    }
273    /// <p><b>\[Default policies only\]</b> Indicates whether the policy should copy tags from the source resource to the snapshot or AMI. If you do not specify a value, the default is <code>false</code>.</p>
274    /// <p>Default: false</p>
275    pub fn copy_tags(mut self, input: bool) -> Self {
276        self.inner = self.inner.copy_tags(input);
277        self
278    }
279    /// <p><b>\[Default policies only\]</b> Indicates whether the policy should copy tags from the source resource to the snapshot or AMI. If you do not specify a value, the default is <code>false</code>.</p>
280    /// <p>Default: false</p>
281    pub fn set_copy_tags(mut self, input: ::std::option::Option<bool>) -> Self {
282        self.inner = self.inner.set_copy_tags(input);
283        self
284    }
285    /// <p><b>\[Default policies only\]</b> Indicates whether the policy should copy tags from the source resource to the snapshot or AMI. If you do not specify a value, the default is <code>false</code>.</p>
286    /// <p>Default: false</p>
287    pub fn get_copy_tags(&self) -> &::std::option::Option<bool> {
288        self.inner.get_copy_tags()
289    }
290    /// <p><b>\[Default policies only\]</b> Defines the snapshot or AMI retention behavior for the policy if the source volume or instance is deleted, or if the policy enters the error, disabled, or deleted state.</p>
291    /// <p>By default (<b>ExtendDeletion=false</b>):</p>
292    /// <ul>
293    /// <li>
294    /// <p>If a source resource is deleted, Amazon Data Lifecycle Manager will continue to delete previously created snapshots or AMIs, up to but not including the last one, based on the specified retention period. If you want Amazon Data Lifecycle Manager to delete all snapshots or AMIs, including the last one, specify <code>true</code>.</p></li>
295    /// <li>
296    /// <p>If a policy enters the error, disabled, or deleted state, Amazon Data Lifecycle Manager stops deleting snapshots and AMIs. If you want Amazon Data Lifecycle Manager to continue deleting snapshots or AMIs, including the last one, if the policy enters one of these states, specify <code>true</code>.</p></li>
297    /// </ul>
298    /// <p>If you enable extended deletion (<b>ExtendDeletion=true</b>), you override both default behaviors simultaneously.</p>
299    /// <p>If you do not specify a value, the default is <code>false</code>.</p>
300    /// <p>Default: false</p>
301    pub fn extend_deletion(mut self, input: bool) -> Self {
302        self.inner = self.inner.extend_deletion(input);
303        self
304    }
305    /// <p><b>\[Default policies only\]</b> Defines the snapshot or AMI retention behavior for the policy if the source volume or instance is deleted, or if the policy enters the error, disabled, or deleted state.</p>
306    /// <p>By default (<b>ExtendDeletion=false</b>):</p>
307    /// <ul>
308    /// <li>
309    /// <p>If a source resource is deleted, Amazon Data Lifecycle Manager will continue to delete previously created snapshots or AMIs, up to but not including the last one, based on the specified retention period. If you want Amazon Data Lifecycle Manager to delete all snapshots or AMIs, including the last one, specify <code>true</code>.</p></li>
310    /// <li>
311    /// <p>If a policy enters the error, disabled, or deleted state, Amazon Data Lifecycle Manager stops deleting snapshots and AMIs. If you want Amazon Data Lifecycle Manager to continue deleting snapshots or AMIs, including the last one, if the policy enters one of these states, specify <code>true</code>.</p></li>
312    /// </ul>
313    /// <p>If you enable extended deletion (<b>ExtendDeletion=true</b>), you override both default behaviors simultaneously.</p>
314    /// <p>If you do not specify a value, the default is <code>false</code>.</p>
315    /// <p>Default: false</p>
316    pub fn set_extend_deletion(mut self, input: ::std::option::Option<bool>) -> Self {
317        self.inner = self.inner.set_extend_deletion(input);
318        self
319    }
320    /// <p><b>\[Default policies only\]</b> Defines the snapshot or AMI retention behavior for the policy if the source volume or instance is deleted, or if the policy enters the error, disabled, or deleted state.</p>
321    /// <p>By default (<b>ExtendDeletion=false</b>):</p>
322    /// <ul>
323    /// <li>
324    /// <p>If a source resource is deleted, Amazon Data Lifecycle Manager will continue to delete previously created snapshots or AMIs, up to but not including the last one, based on the specified retention period. If you want Amazon Data Lifecycle Manager to delete all snapshots or AMIs, including the last one, specify <code>true</code>.</p></li>
325    /// <li>
326    /// <p>If a policy enters the error, disabled, or deleted state, Amazon Data Lifecycle Manager stops deleting snapshots and AMIs. If you want Amazon Data Lifecycle Manager to continue deleting snapshots or AMIs, including the last one, if the policy enters one of these states, specify <code>true</code>.</p></li>
327    /// </ul>
328    /// <p>If you enable extended deletion (<b>ExtendDeletion=true</b>), you override both default behaviors simultaneously.</p>
329    /// <p>If you do not specify a value, the default is <code>false</code>.</p>
330    /// <p>Default: false</p>
331    pub fn get_extend_deletion(&self) -> &::std::option::Option<bool> {
332        self.inner.get_extend_deletion()
333    }
334    ///
335    /// Appends an item to `CrossRegionCopyTargets`.
336    ///
337    /// To override the contents of this collection use [`set_cross_region_copy_targets`](Self::set_cross_region_copy_targets).
338    ///
339    /// <p><b>\[Default policies only\]</b> Specifies destination Regions for snapshot or AMI copies. You can specify up to 3 destination Regions. If you do not want to create cross-Region copies, omit this parameter.</p>
340    pub fn cross_region_copy_targets(mut self, input: crate::types::CrossRegionCopyTarget) -> Self {
341        self.inner = self.inner.cross_region_copy_targets(input);
342        self
343    }
344    /// <p><b>\[Default policies only\]</b> Specifies destination Regions for snapshot or AMI copies. You can specify up to 3 destination Regions. If you do not want to create cross-Region copies, omit this parameter.</p>
345    pub fn set_cross_region_copy_targets(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::CrossRegionCopyTarget>>) -> Self {
346        self.inner = self.inner.set_cross_region_copy_targets(input);
347        self
348    }
349    /// <p><b>\[Default policies only\]</b> Specifies destination Regions for snapshot or AMI copies. You can specify up to 3 destination Regions. If you do not want to create cross-Region copies, omit this parameter.</p>
350    pub fn get_cross_region_copy_targets(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::CrossRegionCopyTarget>> {
351        self.inner.get_cross_region_copy_targets()
352    }
353    /// <p><b>\[Default policies only\]</b> Specifies exclusion parameters for volumes or instances for which you do not want to create snapshots or AMIs. The policy will not create snapshots or AMIs for target resources that match any of the specified exclusion parameters.</p>
354    pub fn exclusions(mut self, input: crate::types::Exclusions) -> Self {
355        self.inner = self.inner.exclusions(input);
356        self
357    }
358    /// <p><b>\[Default policies only\]</b> Specifies exclusion parameters for volumes or instances for which you do not want to create snapshots or AMIs. The policy will not create snapshots or AMIs for target resources that match any of the specified exclusion parameters.</p>
359    pub fn set_exclusions(mut self, input: ::std::option::Option<crate::types::Exclusions>) -> Self {
360        self.inner = self.inner.set_exclusions(input);
361        self
362    }
363    /// <p><b>\[Default policies only\]</b> Specifies exclusion parameters for volumes or instances for which you do not want to create snapshots or AMIs. The policy will not create snapshots or AMIs for target resources that match any of the specified exclusion parameters.</p>
364    pub fn get_exclusions(&self) -> &::std::option::Option<crate::types::Exclusions> {
365        self.inner.get_exclusions()
366    }
367}