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>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html">Create an Amazon EBS-backed Linux AMI</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.</p>
28#[derive(::std::clone::Clone, ::std::fmt::Debug)]
29pub struct CreateImageFluentBuilder {
30 handle: ::std::sync::Arc<crate::client::Handle>,
31 inner: crate::operation::create_image::builders::CreateImageInputBuilder,
32 config_override: ::std::option::Option<crate::config::Builder>,
33}
34impl
35 crate::client::customize::internal::CustomizableSend<
36 crate::operation::create_image::CreateImageOutput,
37 crate::operation::create_image::CreateImageError,
38 > for CreateImageFluentBuilder
39{
40 fn send(
41 self,
42 config_override: crate::config::Builder,
43 ) -> crate::client::customize::internal::BoxFuture<
44 crate::client::customize::internal::SendResult<
45 crate::operation::create_image::CreateImageOutput,
46 crate::operation::create_image::CreateImageError,
47 >,
48 > {
49 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
50 }
51}
52impl CreateImageFluentBuilder {
53 /// Creates a new `CreateImageFluentBuilder`.
54 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
55 Self {
56 handle,
57 inner: ::std::default::Default::default(),
58 config_override: ::std::option::Option::None,
59 }
60 }
61 /// Access the CreateImage as a reference.
62 pub fn as_input(&self) -> &crate::operation::create_image::builders::CreateImageInputBuilder {
63 &self.inner
64 }
65 /// Sends the request and returns the response.
66 ///
67 /// If an error occurs, an `SdkError` will be returned with additional details that
68 /// can be matched against.
69 ///
70 /// By default, any retryable failures will be retried twice. Retry behavior
71 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
72 /// set when configuring the client.
73 pub async fn send(
74 self,
75 ) -> ::std::result::Result<
76 crate::operation::create_image::CreateImageOutput,
77 ::aws_smithy_runtime_api::client::result::SdkError<
78 crate::operation::create_image::CreateImageError,
79 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
80 >,
81 > {
82 let input = self
83 .inner
84 .build()
85 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
86 let runtime_plugins = crate::operation::create_image::CreateImage::operation_runtime_plugins(
87 self.handle.runtime_plugins.clone(),
88 &self.handle.conf,
89 self.config_override,
90 );
91 crate::operation::create_image::CreateImage::orchestrate(&runtime_plugins, input).await
92 }
93
94 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
95 pub fn customize(
96 self,
97 ) -> crate::client::customize::CustomizableOperation<
98 crate::operation::create_image::CreateImageOutput,
99 crate::operation::create_image::CreateImageError,
100 Self,
101 > {
102 crate::client::customize::CustomizableOperation::new(self)
103 }
104 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
105 self.set_config_override(::std::option::Option::Some(config_override.into()));
106 self
107 }
108
109 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
110 self.config_override = config_override;
111 self
112 }
113 ///
114 /// Appends an item to `TagSpecifications`.
115 ///
116 /// To override the contents of this collection use [`set_tag_specifications`](Self::set_tag_specifications).
117 ///
118 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
119 /// <ul>
120 /// <li>
121 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
122 /// <li>
123 /// <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>
124 /// </ul>
125 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
126 /// <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>
127 pub fn tag_specifications(mut self, input: crate::types::TagSpecification) -> Self {
128 self.inner = self.inner.tag_specifications(input);
129 self
130 }
131 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
132 /// <ul>
133 /// <li>
134 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
135 /// <li>
136 /// <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>
137 /// </ul>
138 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
139 /// <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>
140 pub fn set_tag_specifications(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>>) -> Self {
141 self.inner = self.inner.set_tag_specifications(input);
142 self
143 }
144 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
145 /// <ul>
146 /// <li>
147 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
148 /// <li>
149 /// <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>
150 /// </ul>
151 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
152 /// <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>
153 pub fn get_tag_specifications(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>> {
154 self.inner.get_tag_specifications()
155 }
156 /// <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>
157 pub fn dry_run(mut self, input: bool) -> Self {
158 self.inner = self.inner.dry_run(input);
159 self
160 }
161 /// <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>
162 pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
163 self.inner = self.inner.set_dry_run(input);
164 self
165 }
166 /// <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>
167 pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
168 self.inner.get_dry_run()
169 }
170 /// <p>The ID of the instance.</p>
171 pub fn instance_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
172 self.inner = self.inner.instance_id(input.into());
173 self
174 }
175 /// <p>The ID of the instance.</p>
176 pub fn set_instance_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
177 self.inner = self.inner.set_instance_id(input);
178 self
179 }
180 /// <p>The ID of the instance.</p>
181 pub fn get_instance_id(&self) -> &::std::option::Option<::std::string::String> {
182 self.inner.get_instance_id()
183 }
184 /// <p>A name for the new image.</p>
185 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
186 pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
187 self.inner = self.inner.name(input.into());
188 self
189 }
190 /// <p>A name for the new image.</p>
191 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
192 pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
193 self.inner = self.inner.set_name(input);
194 self
195 }
196 /// <p>A name for the new image.</p>
197 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
198 pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
199 self.inner.get_name()
200 }
201 /// <p>A description for the new image.</p>
202 pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
203 self.inner = self.inner.description(input.into());
204 self
205 }
206 /// <p>A description for the new image.</p>
207 pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
208 self.inner = self.inner.set_description(input);
209 self
210 }
211 /// <p>A description for the new image.</p>
212 pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
213 self.inner.get_description()
214 }
215 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
216 /// <ul>
217 /// <li>
218 /// <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>
219 /// <li>
220 /// <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>
221 /// </ul>
222 /// <p>Default: <code>false</code></p>
223 pub fn no_reboot(mut self, input: bool) -> Self {
224 self.inner = self.inner.no_reboot(input);
225 self
226 }
227 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
228 /// <ul>
229 /// <li>
230 /// <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>
231 /// <li>
232 /// <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>
233 /// </ul>
234 /// <p>Default: <code>false</code></p>
235 pub fn set_no_reboot(mut self, input: ::std::option::Option<bool>) -> Self {
236 self.inner = self.inner.set_no_reboot(input);
237 self
238 }
239 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
240 /// <ul>
241 /// <li>
242 /// <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>
243 /// <li>
244 /// <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>
245 /// </ul>
246 /// <p>Default: <code>false</code></p>
247 pub fn get_no_reboot(&self) -> &::std::option::Option<bool> {
248 self.inner.get_no_reboot()
249 }
250 ///
251 /// Appends an item to `BlockDeviceMappings`.
252 ///
253 /// To override the contents of this collection use [`set_block_device_mappings`](Self::set_block_device_mappings).
254 ///
255 /// <p>The block device mappings.</p>
256 /// <p>When using the CreateImage action:</p>
257 /// <ul>
258 /// <li>
259 /// <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>
260 /// <li>
261 /// <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), use the <code>CopyImage</code> action.</p></li>
262 /// <li>
263 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
264 /// </ul>
265 pub fn block_device_mappings(mut self, input: crate::types::BlockDeviceMapping) -> Self {
266 self.inner = self.inner.block_device_mappings(input);
267 self
268 }
269 /// <p>The block device mappings.</p>
270 /// <p>When using the CreateImage action:</p>
271 /// <ul>
272 /// <li>
273 /// <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>
274 /// <li>
275 /// <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), use the <code>CopyImage</code> action.</p></li>
276 /// <li>
277 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
278 /// </ul>
279 pub fn set_block_device_mappings(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::BlockDeviceMapping>>) -> Self {
280 self.inner = self.inner.set_block_device_mappings(input);
281 self
282 }
283 /// <p>The block device mappings.</p>
284 /// <p>When using the CreateImage action:</p>
285 /// <ul>
286 /// <li>
287 /// <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>
288 /// <li>
289 /// <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), use the <code>CopyImage</code> action.</p></li>
290 /// <li>
291 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
292 /// </ul>
293 pub fn get_block_device_mappings(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::BlockDeviceMapping>> {
294 self.inner.get_block_device_mappings()
295 }
296}