aws_sdk_ec2/operation/terminate_instances/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::terminate_instances::_terminate_instances_output::TerminateInstancesOutputBuilder;
3
4pub use crate::operation::terminate_instances::_terminate_instances_input::TerminateInstancesInputBuilder;
5
6impl crate::operation::terminate_instances::builders::TerminateInstancesInputBuilder {
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::terminate_instances::TerminateInstancesOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::terminate_instances::TerminateInstancesError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.terminate_instances();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `TerminateInstances`.
24///
25/// <p>Shuts down the specified instances. This operation is <a href="https://docs.aws.amazon.com/ec2/latest/devguide/ec2-api-idempotency.html">idempotent</a>; if you terminate an instance more than once, each call succeeds.</p>
26/// <p>If you specify multiple instances and the request fails (for example, because of a single incorrect instance ID), none of the instances are terminated.</p>
27/// <p>If you terminate multiple instances across multiple Availability Zones, and one or more of the specified instances are enabled for termination protection, the request fails with the following results:</p>
28/// <ul>
29/// <li>
30/// <p>The specified instances that are in the same Availability Zone as the protected instance are not terminated.</p></li>
31/// <li>
32/// <p>The specified instances that are in different Availability Zones, where no other specified instances are protected, are successfully terminated.</p></li>
33/// </ul>
34/// <p>For example, say you have the following instances:</p>
35/// <ul>
36/// <li>
37/// <p>Instance A: <code>us-east-1a</code>; Not protected</p></li>
38/// <li>
39/// <p>Instance B: <code>us-east-1a</code>; Not protected</p></li>
40/// <li>
41/// <p>Instance C: <code>us-east-1b</code>; Protected</p></li>
42/// <li>
43/// <p>Instance D: <code>us-east-1b</code>; not protected</p></li>
44/// </ul>
45/// <p>If you attempt to terminate all of these instances in the same request, the request reports failure with the following results:</p>
46/// <ul>
47/// <li>
48/// <p>Instance A and Instance B are successfully terminated because none of the specified instances in <code>us-east-1a</code> are enabled for termination protection.</p></li>
49/// <li>
50/// <p>Instance C and Instance D fail to terminate because at least one of the specified instances in <code>us-east-1b</code> (Instance C) is enabled for termination protection.</p></li>
51/// </ul>
52/// <p>Terminated instances remain visible after termination (for approximately one hour).</p>
53/// <p>By default, Amazon EC2 deletes all EBS volumes that were attached when the instance launched. Volumes attached after instance launch continue running.</p>
54/// <p>You can stop, start, and terminate EBS-backed instances. You can only terminate instance store-backed instances. What happens to an instance differs if you stop or terminate it. For example, when you stop an instance, the root device and any other devices attached to the instance persist. When you terminate an instance, any attached EBS volumes with the <code>DeleteOnTermination</code> block device mapping parameter set to <code>true</code> are automatically deleted. For more information about the differences between stopping and terminating instances, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-lifecycle.html">Instance lifecycle</a> in the <i>Amazon EC2 User Guide</i>.</p>
55/// <p>For more information about troubleshooting, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesShuttingDown.html">Troubleshooting terminating your instance</a> in the <i>Amazon EC2 User Guide</i>.</p>
56#[derive(::std::clone::Clone, ::std::fmt::Debug)]
57pub struct TerminateInstancesFluentBuilder {
58 handle: ::std::sync::Arc<crate::client::Handle>,
59 inner: crate::operation::terminate_instances::builders::TerminateInstancesInputBuilder,
60 config_override: ::std::option::Option<crate::config::Builder>,
61}
62impl
63 crate::client::customize::internal::CustomizableSend<
64 crate::operation::terminate_instances::TerminateInstancesOutput,
65 crate::operation::terminate_instances::TerminateInstancesError,
66 > for TerminateInstancesFluentBuilder
67{
68 fn send(
69 self,
70 config_override: crate::config::Builder,
71 ) -> crate::client::customize::internal::BoxFuture<
72 crate::client::customize::internal::SendResult<
73 crate::operation::terminate_instances::TerminateInstancesOutput,
74 crate::operation::terminate_instances::TerminateInstancesError,
75 >,
76 > {
77 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
78 }
79}
80impl TerminateInstancesFluentBuilder {
81 /// Creates a new `TerminateInstancesFluentBuilder`.
82 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
83 Self {
84 handle,
85 inner: ::std::default::Default::default(),
86 config_override: ::std::option::Option::None,
87 }
88 }
89 /// Access the TerminateInstances as a reference.
90 pub fn as_input(&self) -> &crate::operation::terminate_instances::builders::TerminateInstancesInputBuilder {
91 &self.inner
92 }
93 /// Sends the request and returns the response.
94 ///
95 /// If an error occurs, an `SdkError` will be returned with additional details that
96 /// can be matched against.
97 ///
98 /// By default, any retryable failures will be retried twice. Retry behavior
99 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
100 /// set when configuring the client.
101 pub async fn send(
102 self,
103 ) -> ::std::result::Result<
104 crate::operation::terminate_instances::TerminateInstancesOutput,
105 ::aws_smithy_runtime_api::client::result::SdkError<
106 crate::operation::terminate_instances::TerminateInstancesError,
107 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
108 >,
109 > {
110 let input = self
111 .inner
112 .build()
113 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
114 let runtime_plugins = crate::operation::terminate_instances::TerminateInstances::operation_runtime_plugins(
115 self.handle.runtime_plugins.clone(),
116 &self.handle.conf,
117 self.config_override,
118 );
119 crate::operation::terminate_instances::TerminateInstances::orchestrate(&runtime_plugins, input).await
120 }
121
122 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
123 pub fn customize(
124 self,
125 ) -> crate::client::customize::CustomizableOperation<
126 crate::operation::terminate_instances::TerminateInstancesOutput,
127 crate::operation::terminate_instances::TerminateInstancesError,
128 Self,
129 > {
130 crate::client::customize::CustomizableOperation::new(self)
131 }
132 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
133 self.set_config_override(::std::option::Option::Some(config_override.into()));
134 self
135 }
136
137 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
138 self.config_override = config_override;
139 self
140 }
141 ///
142 /// Appends an item to `InstanceIds`.
143 ///
144 /// To override the contents of this collection use [`set_instance_ids`](Self::set_instance_ids).
145 ///
146 /// <p>The IDs of the instances.</p>
147 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
148 pub fn instance_ids(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
149 self.inner = self.inner.instance_ids(input.into());
150 self
151 }
152 /// <p>The IDs of the instances.</p>
153 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
154 pub fn set_instance_ids(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
155 self.inner = self.inner.set_instance_ids(input);
156 self
157 }
158 /// <p>The IDs of the instances.</p>
159 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
160 pub fn get_instance_ids(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
161 self.inner.get_instance_ids()
162 }
163 /// <p>Checks whether you have the required permissions for the operation, 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>
164 pub fn dry_run(mut self, input: bool) -> Self {
165 self.inner = self.inner.dry_run(input);
166 self
167 }
168 /// <p>Checks whether you have the required permissions for the operation, 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>
169 pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
170 self.inner = self.inner.set_dry_run(input);
171 self
172 }
173 /// <p>Checks whether you have the required permissions for the operation, 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>
174 pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
175 self.inner.get_dry_run()
176 }
177}