aws_sdk_ec2/operation/lock_snapshot/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::lock_snapshot::_lock_snapshot_output::LockSnapshotOutputBuilder;
3
4pub use crate::operation::lock_snapshot::_lock_snapshot_input::LockSnapshotInputBuilder;
5
6impl crate::operation::lock_snapshot::builders::LockSnapshotInputBuilder {
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::lock_snapshot::LockSnapshotOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::lock_snapshot::LockSnapshotError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.lock_snapshot();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `LockSnapshot`.
24///
25/// <p>Locks an Amazon EBS snapshot in either <i>governance</i> or <i>compliance</i> mode to protect it against accidental or malicious deletions for a specific duration. A locked snapshot can't be deleted.</p>
26/// <p>You can also use this action to modify the lock settings for a snapshot that is already locked. The allowed modifications depend on the lock mode and lock state:</p>
27/// <ul>
28/// <li>
29/// <p>If the snapshot is locked in governance mode, you can modify the lock mode and the lock duration or lock expiration date.</p></li>
30/// <li>
31/// <p>If the snapshot is locked in compliance mode and it is in the cooling-off period, you can modify the lock mode and the lock duration or lock expiration date.</p></li>
32/// <li>
33/// <p>If the snapshot is locked in compliance mode and the cooling-off period has lapsed, you can only increase the lock duration or extend the lock expiration date.</p></li>
34/// </ul>
35#[derive(::std::clone::Clone, ::std::fmt::Debug)]
36pub struct LockSnapshotFluentBuilder {
37    handle: ::std::sync::Arc<crate::client::Handle>,
38    inner: crate::operation::lock_snapshot::builders::LockSnapshotInputBuilder,
39    config_override: ::std::option::Option<crate::config::Builder>,
40}
41impl
42    crate::client::customize::internal::CustomizableSend<
43        crate::operation::lock_snapshot::LockSnapshotOutput,
44        crate::operation::lock_snapshot::LockSnapshotError,
45    > for LockSnapshotFluentBuilder
46{
47    fn send(
48        self,
49        config_override: crate::config::Builder,
50    ) -> crate::client::customize::internal::BoxFuture<
51        crate::client::customize::internal::SendResult<
52            crate::operation::lock_snapshot::LockSnapshotOutput,
53            crate::operation::lock_snapshot::LockSnapshotError,
54        >,
55    > {
56        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
57    }
58}
59impl LockSnapshotFluentBuilder {
60    /// Creates a new `LockSnapshotFluentBuilder`.
61    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
62        Self {
63            handle,
64            inner: ::std::default::Default::default(),
65            config_override: ::std::option::Option::None,
66        }
67    }
68    /// Access the LockSnapshot as a reference.
69    pub fn as_input(&self) -> &crate::operation::lock_snapshot::builders::LockSnapshotInputBuilder {
70        &self.inner
71    }
72    /// Sends the request and returns the response.
73    ///
74    /// If an error occurs, an `SdkError` will be returned with additional details that
75    /// can be matched against.
76    ///
77    /// By default, any retryable failures will be retried twice. Retry behavior
78    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
79    /// set when configuring the client.
80    pub async fn send(
81        self,
82    ) -> ::std::result::Result<
83        crate::operation::lock_snapshot::LockSnapshotOutput,
84        ::aws_smithy_runtime_api::client::result::SdkError<
85            crate::operation::lock_snapshot::LockSnapshotError,
86            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
87        >,
88    > {
89        let input = self
90            .inner
91            .build()
92            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
93        let runtime_plugins = crate::operation::lock_snapshot::LockSnapshot::operation_runtime_plugins(
94            self.handle.runtime_plugins.clone(),
95            &self.handle.conf,
96            self.config_override,
97        );
98        crate::operation::lock_snapshot::LockSnapshot::orchestrate(&runtime_plugins, input).await
99    }
100
101    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
102    pub fn customize(
103        self,
104    ) -> crate::client::customize::CustomizableOperation<
105        crate::operation::lock_snapshot::LockSnapshotOutput,
106        crate::operation::lock_snapshot::LockSnapshotError,
107        Self,
108    > {
109        crate::client::customize::CustomizableOperation::new(self)
110    }
111    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
112        self.set_config_override(::std::option::Option::Some(config_override.into()));
113        self
114    }
115
116    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
117        self.config_override = config_override;
118        self
119    }
120    /// <p>The ID of the snapshot to lock.</p>
121    pub fn snapshot_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
122        self.inner = self.inner.snapshot_id(input.into());
123        self
124    }
125    /// <p>The ID of the snapshot to lock.</p>
126    pub fn set_snapshot_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
127        self.inner = self.inner.set_snapshot_id(input);
128        self
129    }
130    /// <p>The ID of the snapshot to lock.</p>
131    pub fn get_snapshot_id(&self) -> &::std::option::Option<::std::string::String> {
132        self.inner.get_snapshot_id()
133    }
134    /// <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
135    pub fn dry_run(mut self, input: bool) -> Self {
136        self.inner = self.inner.dry_run(input);
137        self
138    }
139    /// <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
140    pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
141        self.inner = self.inner.set_dry_run(input);
142        self
143    }
144    /// <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
145    pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
146        self.inner.get_dry_run()
147    }
148    /// <p>The mode in which to lock the snapshot. Specify one of the following:</p>
149    /// <ul>
150    /// <li>
151    /// <p><code>governance</code> - Locks the snapshot in governance mode. Snapshots locked in governance mode can't be deleted until one of the following conditions are met:</p>
152    /// <ul>
153    /// <li>
154    /// <p>The lock duration expires.</p></li>
155    /// <li>
156    /// <p>The snapshot is unlocked by a user with the appropriate permissions.</p></li>
157    /// </ul>
158    /// <p>Users with the appropriate IAM permissions can unlock the snapshot, increase or decrease the lock duration, and change the lock mode to <code>compliance</code> at any time.</p>
159    /// <p>If you lock a snapshot in <code>governance</code> mode, omit <b> CoolOffPeriod</b>.</p></li>
160    /// <li>
161    /// <p><code>compliance</code> - Locks the snapshot in compliance mode. Snapshots locked in compliance mode can't be unlocked by any user. They can be deleted only after the lock duration expires. Users can't decrease the lock duration or change the lock mode to <code>governance</code>. However, users with appropriate IAM permissions can increase the lock duration at any time.</p>
162    /// <p>If you lock a snapshot in <code>compliance</code> mode, you can optionally specify <b>CoolOffPeriod</b>.</p></li>
163    /// </ul>
164    pub fn lock_mode(mut self, input: crate::types::LockMode) -> Self {
165        self.inner = self.inner.lock_mode(input);
166        self
167    }
168    /// <p>The mode in which to lock the snapshot. Specify one of the following:</p>
169    /// <ul>
170    /// <li>
171    /// <p><code>governance</code> - Locks the snapshot in governance mode. Snapshots locked in governance mode can't be deleted until one of the following conditions are met:</p>
172    /// <ul>
173    /// <li>
174    /// <p>The lock duration expires.</p></li>
175    /// <li>
176    /// <p>The snapshot is unlocked by a user with the appropriate permissions.</p></li>
177    /// </ul>
178    /// <p>Users with the appropriate IAM permissions can unlock the snapshot, increase or decrease the lock duration, and change the lock mode to <code>compliance</code> at any time.</p>
179    /// <p>If you lock a snapshot in <code>governance</code> mode, omit <b> CoolOffPeriod</b>.</p></li>
180    /// <li>
181    /// <p><code>compliance</code> - Locks the snapshot in compliance mode. Snapshots locked in compliance mode can't be unlocked by any user. They can be deleted only after the lock duration expires. Users can't decrease the lock duration or change the lock mode to <code>governance</code>. However, users with appropriate IAM permissions can increase the lock duration at any time.</p>
182    /// <p>If you lock a snapshot in <code>compliance</code> mode, you can optionally specify <b>CoolOffPeriod</b>.</p></li>
183    /// </ul>
184    pub fn set_lock_mode(mut self, input: ::std::option::Option<crate::types::LockMode>) -> Self {
185        self.inner = self.inner.set_lock_mode(input);
186        self
187    }
188    /// <p>The mode in which to lock the snapshot. Specify one of the following:</p>
189    /// <ul>
190    /// <li>
191    /// <p><code>governance</code> - Locks the snapshot in governance mode. Snapshots locked in governance mode can't be deleted until one of the following conditions are met:</p>
192    /// <ul>
193    /// <li>
194    /// <p>The lock duration expires.</p></li>
195    /// <li>
196    /// <p>The snapshot is unlocked by a user with the appropriate permissions.</p></li>
197    /// </ul>
198    /// <p>Users with the appropriate IAM permissions can unlock the snapshot, increase or decrease the lock duration, and change the lock mode to <code>compliance</code> at any time.</p>
199    /// <p>If you lock a snapshot in <code>governance</code> mode, omit <b> CoolOffPeriod</b>.</p></li>
200    /// <li>
201    /// <p><code>compliance</code> - Locks the snapshot in compliance mode. Snapshots locked in compliance mode can't be unlocked by any user. They can be deleted only after the lock duration expires. Users can't decrease the lock duration or change the lock mode to <code>governance</code>. However, users with appropriate IAM permissions can increase the lock duration at any time.</p>
202    /// <p>If you lock a snapshot in <code>compliance</code> mode, you can optionally specify <b>CoolOffPeriod</b>.</p></li>
203    /// </ul>
204    pub fn get_lock_mode(&self) -> &::std::option::Option<crate::types::LockMode> {
205        self.inner.get_lock_mode()
206    }
207    /// <p>The cooling-off period during which you can unlock the snapshot or modify the lock settings after locking the snapshot in compliance mode, in hours. After the cooling-off period expires, you can't unlock or delete the snapshot, decrease the lock duration, or change the lock mode. You can increase the lock duration after the cooling-off period expires.</p>
208    /// <p>The cooling-off period is optional when locking a snapshot in compliance mode. If you are locking the snapshot in governance mode, omit this parameter.</p>
209    /// <p>To lock the snapshot in compliance mode immediately without a cooling-off period, omit this parameter.</p>
210    /// <p>If you are extending the lock duration for a snapshot that is locked in compliance mode after the cooling-off period has expired, omit this parameter. If you specify a cooling-period in a such a request, the request fails.</p>
211    /// <p>Allowed values: Min 1, max 72.</p>
212    pub fn cool_off_period(mut self, input: i32) -> Self {
213        self.inner = self.inner.cool_off_period(input);
214        self
215    }
216    /// <p>The cooling-off period during which you can unlock the snapshot or modify the lock settings after locking the snapshot in compliance mode, in hours. After the cooling-off period expires, you can't unlock or delete the snapshot, decrease the lock duration, or change the lock mode. You can increase the lock duration after the cooling-off period expires.</p>
217    /// <p>The cooling-off period is optional when locking a snapshot in compliance mode. If you are locking the snapshot in governance mode, omit this parameter.</p>
218    /// <p>To lock the snapshot in compliance mode immediately without a cooling-off period, omit this parameter.</p>
219    /// <p>If you are extending the lock duration for a snapshot that is locked in compliance mode after the cooling-off period has expired, omit this parameter. If you specify a cooling-period in a such a request, the request fails.</p>
220    /// <p>Allowed values: Min 1, max 72.</p>
221    pub fn set_cool_off_period(mut self, input: ::std::option::Option<i32>) -> Self {
222        self.inner = self.inner.set_cool_off_period(input);
223        self
224    }
225    /// <p>The cooling-off period during which you can unlock the snapshot or modify the lock settings after locking the snapshot in compliance mode, in hours. After the cooling-off period expires, you can't unlock or delete the snapshot, decrease the lock duration, or change the lock mode. You can increase the lock duration after the cooling-off period expires.</p>
226    /// <p>The cooling-off period is optional when locking a snapshot in compliance mode. If you are locking the snapshot in governance mode, omit this parameter.</p>
227    /// <p>To lock the snapshot in compliance mode immediately without a cooling-off period, omit this parameter.</p>
228    /// <p>If you are extending the lock duration for a snapshot that is locked in compliance mode after the cooling-off period has expired, omit this parameter. If you specify a cooling-period in a such a request, the request fails.</p>
229    /// <p>Allowed values: Min 1, max 72.</p>
230    pub fn get_cool_off_period(&self) -> &::std::option::Option<i32> {
231        self.inner.get_cool_off_period()
232    }
233    /// <p>The period of time for which to lock the snapshot, in days. The snapshot lock will automatically expire after this period lapses.</p>
234    /// <p>You must specify either this parameter or <b>ExpirationDate</b>, but not both.</p>
235    /// <p>Allowed values: Min: 1, max 36500</p>
236    pub fn lock_duration(mut self, input: i32) -> Self {
237        self.inner = self.inner.lock_duration(input);
238        self
239    }
240    /// <p>The period of time for which to lock the snapshot, in days. The snapshot lock will automatically expire after this period lapses.</p>
241    /// <p>You must specify either this parameter or <b>ExpirationDate</b>, but not both.</p>
242    /// <p>Allowed values: Min: 1, max 36500</p>
243    pub fn set_lock_duration(mut self, input: ::std::option::Option<i32>) -> Self {
244        self.inner = self.inner.set_lock_duration(input);
245        self
246    }
247    /// <p>The period of time for which to lock the snapshot, in days. The snapshot lock will automatically expire after this period lapses.</p>
248    /// <p>You must specify either this parameter or <b>ExpirationDate</b>, but not both.</p>
249    /// <p>Allowed values: Min: 1, max 36500</p>
250    pub fn get_lock_duration(&self) -> &::std::option::Option<i32> {
251        self.inner.get_lock_duration()
252    }
253    /// <p>The date and time at which the snapshot lock is to automatically expire, in the UTC time zone (<code>YYYY-MM-DDThh:mm:ss.sssZ</code>).</p>
254    /// <p>You must specify either this parameter or <b>LockDuration</b>, but not both.</p>
255    pub fn expiration_date(mut self, input: ::aws_smithy_types::DateTime) -> Self {
256        self.inner = self.inner.expiration_date(input);
257        self
258    }
259    /// <p>The date and time at which the snapshot lock is to automatically expire, in the UTC time zone (<code>YYYY-MM-DDThh:mm:ss.sssZ</code>).</p>
260    /// <p>You must specify either this parameter or <b>LockDuration</b>, but not both.</p>
261    pub fn set_expiration_date(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
262        self.inner = self.inner.set_expiration_date(input);
263        self
264    }
265    /// <p>The date and time at which the snapshot lock is to automatically expire, in the UTC time zone (<code>YYYY-MM-DDThh:mm:ss.sssZ</code>).</p>
266    /// <p>You must specify either this parameter or <b>LockDuration</b>, but not both.</p>
267    pub fn get_expiration_date(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
268        self.inner.get_expiration_date()
269    }
270}