aws_sdk_ec2/operation/create_image/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_image::_create_image_output::CreateImageOutputBuilder;
3
4pub use crate::operation::create_image::_create_image_input::CreateImageInputBuilder;
5
6impl crate::operation::create_image::builders::CreateImageInputBuilder {
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_image::CreateImageOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::create_image::CreateImageError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.create_image();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `CreateImage`.
24///
25/// <p>Creates an Amazon EBS-backed AMI from an Amazon EBS-backed instance that is either running or stopped.</p>
26/// <p>If you customized your instance with instance store volumes or Amazon EBS volumes in addition to the root device volume, the new AMI contains block device mapping information for those volumes. When you launch an instance from this new AMI, the instance automatically launches with those additional volumes.</p>
27/// <p>The location of the source instance determines where you can create the snapshots of the AMI:</p>
28/// <ul>
29/// <li>
30/// <p>If the source instance is in a Region, you must create the snapshots in the same Region as the instance.</p></li>
31/// <li>
32/// <p>If the source instance is in a Local Zone, you can create the snapshots in the same Local Zone or in its parent Region.</p></li>
33/// </ul>
34/// <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html">Create an Amazon EBS-backed AMI</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
35#[derive(::std::clone::Clone, ::std::fmt::Debug)]
36pub struct CreateImageFluentBuilder {
37 handle: ::std::sync::Arc<crate::client::Handle>,
38 inner: crate::operation::create_image::builders::CreateImageInputBuilder,
39 config_override: ::std::option::Option<crate::config::Builder>,
40}
41impl
42 crate::client::customize::internal::CustomizableSend<
43 crate::operation::create_image::CreateImageOutput,
44 crate::operation::create_image::CreateImageError,
45 > for CreateImageFluentBuilder
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::create_image::CreateImageOutput,
53 crate::operation::create_image::CreateImageError,
54 >,
55 > {
56 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
57 }
58}
59impl CreateImageFluentBuilder {
60 /// Creates a new `CreateImageFluentBuilder`.
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 CreateImage as a reference.
69 pub fn as_input(&self) -> &crate::operation::create_image::builders::CreateImageInputBuilder {
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::create_image::CreateImageOutput,
84 ::aws_smithy_runtime_api::client::result::SdkError<
85 crate::operation::create_image::CreateImageError,
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::create_image::CreateImage::operation_runtime_plugins(
94 self.handle.runtime_plugins.clone(),
95 &self.handle.conf,
96 self.config_override,
97 );
98 crate::operation::create_image::CreateImage::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::create_image::CreateImageOutput,
106 crate::operation::create_image::CreateImageError,
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 ///
121 /// Appends an item to `TagSpecifications`.
122 ///
123 /// To override the contents of this collection use [`set_tag_specifications`](Self::set_tag_specifications).
124 ///
125 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
126 /// <ul>
127 /// <li>
128 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
129 /// <li>
130 /// <p>To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the instance, the value for <code>ResourceType</code> must be <code>snapshot</code>. The same tag is applied to all of the snapshots that are created.</p></li>
131 /// </ul>
132 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
133 /// <p>To tag an AMI or snapshot after it has been created, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html">CreateTags</a>.</p>
134 pub fn tag_specifications(mut self, input: crate::types::TagSpecification) -> Self {
135 self.inner = self.inner.tag_specifications(input);
136 self
137 }
138 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
139 /// <ul>
140 /// <li>
141 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
142 /// <li>
143 /// <p>To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the instance, the value for <code>ResourceType</code> must be <code>snapshot</code>. The same tag is applied to all of the snapshots that are created.</p></li>
144 /// </ul>
145 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
146 /// <p>To tag an AMI or snapshot after it has been created, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html">CreateTags</a>.</p>
147 pub fn set_tag_specifications(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>>) -> Self {
148 self.inner = self.inner.set_tag_specifications(input);
149 self
150 }
151 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
152 /// <ul>
153 /// <li>
154 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
155 /// <li>
156 /// <p>To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the instance, the value for <code>ResourceType</code> must be <code>snapshot</code>. The same tag is applied to all of the snapshots that are created.</p></li>
157 /// </ul>
158 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
159 /// <p>To tag an AMI or snapshot after it has been created, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html">CreateTags</a>.</p>
160 pub fn get_tag_specifications(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>> {
161 self.inner.get_tag_specifications()
162 }
163 /// <note>
164 /// <p>Only supported for instances in Local Zones. If the source instance is not in a Local Zone, omit this parameter.</p>
165 /// </note>
166 /// <p>The Amazon S3 location where the snapshots will be stored.</p>
167 /// <ul>
168 /// <li>
169 /// <p>To create local snapshots in the same Local Zone as the source instance, specify <code>local</code>.</p></li>
170 /// <li>
171 /// <p>To create regional snapshots in the parent Region of the Local Zone, specify <code>regional</code> or omit this parameter.</p></li>
172 /// </ul>
173 /// <p>Default: <code>regional</code></p>
174 pub fn snapshot_location(mut self, input: crate::types::SnapshotLocationEnum) -> Self {
175 self.inner = self.inner.snapshot_location(input);
176 self
177 }
178 /// <note>
179 /// <p>Only supported for instances in Local Zones. If the source instance is not in a Local Zone, omit this parameter.</p>
180 /// </note>
181 /// <p>The Amazon S3 location where the snapshots will be stored.</p>
182 /// <ul>
183 /// <li>
184 /// <p>To create local snapshots in the same Local Zone as the source instance, specify <code>local</code>.</p></li>
185 /// <li>
186 /// <p>To create regional snapshots in the parent Region of the Local Zone, specify <code>regional</code> or omit this parameter.</p></li>
187 /// </ul>
188 /// <p>Default: <code>regional</code></p>
189 pub fn set_snapshot_location(mut self, input: ::std::option::Option<crate::types::SnapshotLocationEnum>) -> Self {
190 self.inner = self.inner.set_snapshot_location(input);
191 self
192 }
193 /// <note>
194 /// <p>Only supported for instances in Local Zones. If the source instance is not in a Local Zone, omit this parameter.</p>
195 /// </note>
196 /// <p>The Amazon S3 location where the snapshots will be stored.</p>
197 /// <ul>
198 /// <li>
199 /// <p>To create local snapshots in the same Local Zone as the source instance, specify <code>local</code>.</p></li>
200 /// <li>
201 /// <p>To create regional snapshots in the parent Region of the Local Zone, specify <code>regional</code> or omit this parameter.</p></li>
202 /// </ul>
203 /// <p>Default: <code>regional</code></p>
204 pub fn get_snapshot_location(&self) -> &::std::option::Option<crate::types::SnapshotLocationEnum> {
205 self.inner.get_snapshot_location()
206 }
207 /// <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>
208 pub fn dry_run(mut self, input: bool) -> Self {
209 self.inner = self.inner.dry_run(input);
210 self
211 }
212 /// <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>
213 pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
214 self.inner = self.inner.set_dry_run(input);
215 self
216 }
217 /// <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>
218 pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
219 self.inner.get_dry_run()
220 }
221 /// <p>The ID of the instance.</p>
222 pub fn instance_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
223 self.inner = self.inner.instance_id(input.into());
224 self
225 }
226 /// <p>The ID of the instance.</p>
227 pub fn set_instance_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
228 self.inner = self.inner.set_instance_id(input);
229 self
230 }
231 /// <p>The ID of the instance.</p>
232 pub fn get_instance_id(&self) -> &::std::option::Option<::std::string::String> {
233 self.inner.get_instance_id()
234 }
235 /// <p>A name for the new image.</p>
236 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
237 pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
238 self.inner = self.inner.name(input.into());
239 self
240 }
241 /// <p>A name for the new image.</p>
242 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
243 pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
244 self.inner = self.inner.set_name(input);
245 self
246 }
247 /// <p>A name for the new image.</p>
248 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
249 pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
250 self.inner.get_name()
251 }
252 /// <p>A description for the new image.</p>
253 pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
254 self.inner = self.inner.description(input.into());
255 self
256 }
257 /// <p>A description for the new image.</p>
258 pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
259 self.inner = self.inner.set_description(input);
260 self
261 }
262 /// <p>A description for the new image.</p>
263 pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
264 self.inner.get_description()
265 }
266 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
267 /// <ul>
268 /// <li>
269 /// <p><code>true</code> - The instance is not rebooted before creating the image. This creates crash-consistent snapshots that include only the data that has been written to the volumes at the time the snapshots are created. Buffered data and data in memory that has not yet been written to the volumes is not included in the snapshots.</p></li>
270 /// <li>
271 /// <p><code>false</code> - The instance is rebooted before creating the image. This ensures that all buffered data and data in memory is written to the volumes before the snapshots are created.</p></li>
272 /// </ul>
273 /// <p>Default: <code>false</code></p>
274 pub fn no_reboot(mut self, input: bool) -> Self {
275 self.inner = self.inner.no_reboot(input);
276 self
277 }
278 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
279 /// <ul>
280 /// <li>
281 /// <p><code>true</code> - The instance is not rebooted before creating the image. This creates crash-consistent snapshots that include only the data that has been written to the volumes at the time the snapshots are created. Buffered data and data in memory that has not yet been written to the volumes is not included in the snapshots.</p></li>
282 /// <li>
283 /// <p><code>false</code> - The instance is rebooted before creating the image. This ensures that all buffered data and data in memory is written to the volumes before the snapshots are created.</p></li>
284 /// </ul>
285 /// <p>Default: <code>false</code></p>
286 pub fn set_no_reboot(mut self, input: ::std::option::Option<bool>) -> Self {
287 self.inner = self.inner.set_no_reboot(input);
288 self
289 }
290 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
291 /// <ul>
292 /// <li>
293 /// <p><code>true</code> - The instance is not rebooted before creating the image. This creates crash-consistent snapshots that include only the data that has been written to the volumes at the time the snapshots are created. Buffered data and data in memory that has not yet been written to the volumes is not included in the snapshots.</p></li>
294 /// <li>
295 /// <p><code>false</code> - The instance is rebooted before creating the image. This ensures that all buffered data and data in memory is written to the volumes before the snapshots are created.</p></li>
296 /// </ul>
297 /// <p>Default: <code>false</code></p>
298 pub fn get_no_reboot(&self) -> &::std::option::Option<bool> {
299 self.inner.get_no_reboot()
300 }
301 ///
302 /// Appends an item to `BlockDeviceMappings`.
303 ///
304 /// To override the contents of this collection use [`set_block_device_mappings`](Self::set_block_device_mappings).
305 ///
306 /// <p>The block device mappings.</p>
307 /// <p>When using the CreateImage action:</p>
308 /// <ul>
309 /// <li>
310 /// <p>You can't change the volume size using the VolumeSize parameter. If you want a different volume size, you must first change the volume size of the source instance.</p></li>
311 /// <li>
312 /// <p>You can't modify the encryption status of existing volumes or snapshots. To create an AMI with volumes or snapshots that have a different encryption status (for example, where the source volume and snapshots are unencrypted, and you want to create an AMI with encrypted volumes or snapshots), copy the image instead.</p></li>
313 /// <li>
314 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
315 /// </ul>
316 pub fn block_device_mappings(mut self, input: crate::types::BlockDeviceMapping) -> Self {
317 self.inner = self.inner.block_device_mappings(input);
318 self
319 }
320 /// <p>The block device mappings.</p>
321 /// <p>When using the CreateImage action:</p>
322 /// <ul>
323 /// <li>
324 /// <p>You can't change the volume size using the VolumeSize parameter. If you want a different volume size, you must first change the volume size of the source instance.</p></li>
325 /// <li>
326 /// <p>You can't modify the encryption status of existing volumes or snapshots. To create an AMI with volumes or snapshots that have a different encryption status (for example, where the source volume and snapshots are unencrypted, and you want to create an AMI with encrypted volumes or snapshots), copy the image instead.</p></li>
327 /// <li>
328 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
329 /// </ul>
330 pub fn set_block_device_mappings(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::BlockDeviceMapping>>) -> Self {
331 self.inner = self.inner.set_block_device_mappings(input);
332 self
333 }
334 /// <p>The block device mappings.</p>
335 /// <p>When using the CreateImage action:</p>
336 /// <ul>
337 /// <li>
338 /// <p>You can't change the volume size using the VolumeSize parameter. If you want a different volume size, you must first change the volume size of the source instance.</p></li>
339 /// <li>
340 /// <p>You can't modify the encryption status of existing volumes or snapshots. To create an AMI with volumes or snapshots that have a different encryption status (for example, where the source volume and snapshots are unencrypted, and you want to create an AMI with encrypted volumes or snapshots), copy the image instead.</p></li>
341 /// <li>
342 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
343 /// </ul>
344 pub fn get_block_device_mappings(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::BlockDeviceMapping>> {
345 self.inner.get_block_device_mappings()
346 }
347}