aws_sdk_ec2/operation/create_image/_create_image_input.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[allow(missing_docs)] // documentation missing in model
3#[non_exhaustive]
4#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
5pub struct CreateImageInput {
6 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
7 /// <ul>
8 /// <li>
9 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
10 /// <li>
11 /// <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>
12 /// </ul>
13 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
14 /// <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>
15 pub tag_specifications: ::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>>,
16 /// <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>
17 pub dry_run: ::std::option::Option<bool>,
18 /// <p>The ID of the instance.</p>
19 pub instance_id: ::std::option::Option<::std::string::String>,
20 /// <p>A name for the new image.</p>
21 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
22 pub name: ::std::option::Option<::std::string::String>,
23 /// <p>A description for the new image.</p>
24 pub description: ::std::option::Option<::std::string::String>,
25 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
26 /// <ul>
27 /// <li>
28 /// <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>
29 /// <li>
30 /// <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>
31 /// </ul>
32 /// <p>Default: <code>false</code></p>
33 pub no_reboot: ::std::option::Option<bool>,
34 /// <p>The block device mappings.</p>
35 /// <p>When using the CreateImage action:</p>
36 /// <ul>
37 /// <li>
38 /// <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>
39 /// <li>
40 /// <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>
41 /// <li>
42 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
43 /// </ul>
44 pub block_device_mappings: ::std::option::Option<::std::vec::Vec<crate::types::BlockDeviceMapping>>,
45}
46impl CreateImageInput {
47 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
48 /// <ul>
49 /// <li>
50 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
51 /// <li>
52 /// <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>
53 /// </ul>
54 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
55 /// <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>
56 ///
57 /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.tag_specifications.is_none()`.
58 pub fn tag_specifications(&self) -> &[crate::types::TagSpecification] {
59 self.tag_specifications.as_deref().unwrap_or_default()
60 }
61 /// <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>
62 pub fn dry_run(&self) -> ::std::option::Option<bool> {
63 self.dry_run
64 }
65 /// <p>The ID of the instance.</p>
66 pub fn instance_id(&self) -> ::std::option::Option<&str> {
67 self.instance_id.as_deref()
68 }
69 /// <p>A name for the new image.</p>
70 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
71 pub fn name(&self) -> ::std::option::Option<&str> {
72 self.name.as_deref()
73 }
74 /// <p>A description for the new image.</p>
75 pub fn description(&self) -> ::std::option::Option<&str> {
76 self.description.as_deref()
77 }
78 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
79 /// <ul>
80 /// <li>
81 /// <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>
82 /// <li>
83 /// <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>
84 /// </ul>
85 /// <p>Default: <code>false</code></p>
86 pub fn no_reboot(&self) -> ::std::option::Option<bool> {
87 self.no_reboot
88 }
89 /// <p>The block device mappings.</p>
90 /// <p>When using the CreateImage action:</p>
91 /// <ul>
92 /// <li>
93 /// <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>
94 /// <li>
95 /// <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>
96 /// <li>
97 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
98 /// </ul>
99 ///
100 /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.block_device_mappings.is_none()`.
101 pub fn block_device_mappings(&self) -> &[crate::types::BlockDeviceMapping] {
102 self.block_device_mappings.as_deref().unwrap_or_default()
103 }
104}
105impl CreateImageInput {
106 /// Creates a new builder-style object to manufacture [`CreateImageInput`](crate::operation::create_image::CreateImageInput).
107 pub fn builder() -> crate::operation::create_image::builders::CreateImageInputBuilder {
108 crate::operation::create_image::builders::CreateImageInputBuilder::default()
109 }
110}
111
112/// A builder for [`CreateImageInput`](crate::operation::create_image::CreateImageInput).
113#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
114#[non_exhaustive]
115pub struct CreateImageInputBuilder {
116 pub(crate) tag_specifications: ::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>>,
117 pub(crate) dry_run: ::std::option::Option<bool>,
118 pub(crate) instance_id: ::std::option::Option<::std::string::String>,
119 pub(crate) name: ::std::option::Option<::std::string::String>,
120 pub(crate) description: ::std::option::Option<::std::string::String>,
121 pub(crate) no_reboot: ::std::option::Option<bool>,
122 pub(crate) block_device_mappings: ::std::option::Option<::std::vec::Vec<crate::types::BlockDeviceMapping>>,
123}
124impl CreateImageInputBuilder {
125 /// Appends an item to `tag_specifications`.
126 ///
127 /// To override the contents of this collection use [`set_tag_specifications`](Self::set_tag_specifications).
128 ///
129 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
130 /// <ul>
131 /// <li>
132 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
133 /// <li>
134 /// <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>
135 /// </ul>
136 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
137 /// <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>
138 pub fn tag_specifications(mut self, input: crate::types::TagSpecification) -> Self {
139 let mut v = self.tag_specifications.unwrap_or_default();
140 v.push(input);
141 self.tag_specifications = ::std::option::Option::Some(v);
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 set_tag_specifications(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>>) -> Self {
154 self.tag_specifications = input;
155 self
156 }
157 /// <p>The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.</p>
158 /// <ul>
159 /// <li>
160 /// <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>.</p></li>
161 /// <li>
162 /// <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>
163 /// </ul>
164 /// <p>If you specify other values for <code>ResourceType</code>, the request fails.</p>
165 /// <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>
166 pub fn get_tag_specifications(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>> {
167 &self.tag_specifications
168 }
169 /// <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>
170 pub fn dry_run(mut self, input: bool) -> Self {
171 self.dry_run = ::std::option::Option::Some(input);
172 self
173 }
174 /// <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>
175 pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
176 self.dry_run = input;
177 self
178 }
179 /// <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>
180 pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
181 &self.dry_run
182 }
183 /// <p>The ID of the instance.</p>
184 /// This field is required.
185 pub fn instance_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
186 self.instance_id = ::std::option::Option::Some(input.into());
187 self
188 }
189 /// <p>The ID of the instance.</p>
190 pub fn set_instance_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
191 self.instance_id = input;
192 self
193 }
194 /// <p>The ID of the instance.</p>
195 pub fn get_instance_id(&self) -> &::std::option::Option<::std::string::String> {
196 &self.instance_id
197 }
198 /// <p>A name for the new image.</p>
199 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
200 /// This field is required.
201 pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
202 self.name = ::std::option::Option::Some(input.into());
203 self
204 }
205 /// <p>A name for the new image.</p>
206 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
207 pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
208 self.name = input;
209 self
210 }
211 /// <p>A name for the new image.</p>
212 /// <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
213 pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
214 &self.name
215 }
216 /// <p>A description for the new image.</p>
217 pub fn description(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
218 self.description = ::std::option::Option::Some(input.into());
219 self
220 }
221 /// <p>A description for the new image.</p>
222 pub fn set_description(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
223 self.description = input;
224 self
225 }
226 /// <p>A description for the new image.</p>
227 pub fn get_description(&self) -> &::std::option::Option<::std::string::String> {
228 &self.description
229 }
230 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
231 /// <ul>
232 /// <li>
233 /// <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>
234 /// <li>
235 /// <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>
236 /// </ul>
237 /// <p>Default: <code>false</code></p>
238 pub fn no_reboot(mut self, input: bool) -> Self {
239 self.no_reboot = ::std::option::Option::Some(input);
240 self
241 }
242 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
243 /// <ul>
244 /// <li>
245 /// <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>
246 /// <li>
247 /// <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>
248 /// </ul>
249 /// <p>Default: <code>false</code></p>
250 pub fn set_no_reboot(mut self, input: ::std::option::Option<bool>) -> Self {
251 self.no_reboot = input;
252 self
253 }
254 /// <p>Indicates whether or not the instance should be automatically rebooted before creating the image. Specify one of the following values:</p>
255 /// <ul>
256 /// <li>
257 /// <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>
258 /// <li>
259 /// <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>
260 /// </ul>
261 /// <p>Default: <code>false</code></p>
262 pub fn get_no_reboot(&self) -> &::std::option::Option<bool> {
263 &self.no_reboot
264 }
265 /// Appends an item to `block_device_mappings`.
266 ///
267 /// To override the contents of this collection use [`set_block_device_mappings`](Self::set_block_device_mappings).
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 block_device_mappings(mut self, input: crate::types::BlockDeviceMapping) -> Self {
280 let mut v = self.block_device_mappings.unwrap_or_default();
281 v.push(input);
282 self.block_device_mappings = ::std::option::Option::Some(v);
283 self
284 }
285 /// <p>The block device mappings.</p>
286 /// <p>When using the CreateImage action:</p>
287 /// <ul>
288 /// <li>
289 /// <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>
290 /// <li>
291 /// <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>
292 /// <li>
293 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
294 /// </ul>
295 pub fn set_block_device_mappings(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::BlockDeviceMapping>>) -> Self {
296 self.block_device_mappings = input;
297 self
298 }
299 /// <p>The block device mappings.</p>
300 /// <p>When using the CreateImage action:</p>
301 /// <ul>
302 /// <li>
303 /// <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>
304 /// <li>
305 /// <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>
306 /// <li>
307 /// <p>The only option that can be changed for existing mappings or snapshots is <code>DeleteOnTermination</code>.</p></li>
308 /// </ul>
309 pub fn get_block_device_mappings(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::BlockDeviceMapping>> {
310 &self.block_device_mappings
311 }
312 /// Consumes the builder and constructs a [`CreateImageInput`](crate::operation::create_image::CreateImageInput).
313 pub fn build(self) -> ::std::result::Result<crate::operation::create_image::CreateImageInput, ::aws_smithy_types::error::operation::BuildError> {
314 ::std::result::Result::Ok(crate::operation::create_image::CreateImageInput {
315 tag_specifications: self.tag_specifications,
316 dry_run: self.dry_run,
317 instance_id: self.instance_id,
318 name: self.name,
319 description: self.description,
320 no_reboot: self.no_reboot,
321 block_device_mappings: self.block_device_mappings,
322 })
323 }
324}