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>By default, the TerminateInstances operation includes a graceful operating system (OS) shutdown. To bypass the graceful shutdown, use the <code>skipOsShutdown</code> parameter; however, this might risk data integrity.</p>
55/// <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">Amazon EC2 instance state changes</a> in the <i>Amazon EC2 User Guide</i>.</p>
56/// <p>When you terminate an instance, we attempt to terminate it forcibly after a short while. If your instance appears stuck in the shutting-down state after a period of time, there might be an issue with the underlying host computer. For more information about terminating and troubleshooting terminating your instances, see <a href="https://docs.aws.amazon.com/">Terminate Amazon EC2 instances</a> and <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>
57#[derive(::std::clone::Clone, ::std::fmt::Debug)]
58pub struct TerminateInstancesFluentBuilder {
59 handle: ::std::sync::Arc<crate::client::Handle>,
60 inner: crate::operation::terminate_instances::builders::TerminateInstancesInputBuilder,
61 config_override: ::std::option::Option<crate::config::Builder>,
62}
63impl
64 crate::client::customize::internal::CustomizableSend<
65 crate::operation::terminate_instances::TerminateInstancesOutput,
66 crate::operation::terminate_instances::TerminateInstancesError,
67 > for TerminateInstancesFluentBuilder
68{
69 fn send(
70 self,
71 config_override: crate::config::Builder,
72 ) -> crate::client::customize::internal::BoxFuture<
73 crate::client::customize::internal::SendResult<
74 crate::operation::terminate_instances::TerminateInstancesOutput,
75 crate::operation::terminate_instances::TerminateInstancesError,
76 >,
77 > {
78 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
79 }
80}
81impl TerminateInstancesFluentBuilder {
82 /// Creates a new `TerminateInstancesFluentBuilder`.
83 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
84 Self {
85 handle,
86 inner: ::std::default::Default::default(),
87 config_override: ::std::option::Option::None,
88 }
89 }
90 /// Access the TerminateInstances as a reference.
91 pub fn as_input(&self) -> &crate::operation::terminate_instances::builders::TerminateInstancesInputBuilder {
92 &self.inner
93 }
94 /// Sends the request and returns the response.
95 ///
96 /// If an error occurs, an `SdkError` will be returned with additional details that
97 /// can be matched against.
98 ///
99 /// By default, any retryable failures will be retried twice. Retry behavior
100 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
101 /// set when configuring the client.
102 pub async fn send(
103 self,
104 ) -> ::std::result::Result<
105 crate::operation::terminate_instances::TerminateInstancesOutput,
106 ::aws_smithy_runtime_api::client::result::SdkError<
107 crate::operation::terminate_instances::TerminateInstancesError,
108 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
109 >,
110 > {
111 let input = self
112 .inner
113 .build()
114 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
115 let runtime_plugins = crate::operation::terminate_instances::TerminateInstances::operation_runtime_plugins(
116 self.handle.runtime_plugins.clone(),
117 &self.handle.conf,
118 self.config_override,
119 );
120 crate::operation::terminate_instances::TerminateInstances::orchestrate(&runtime_plugins, input).await
121 }
122
123 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
124 pub fn customize(
125 self,
126 ) -> crate::client::customize::CustomizableOperation<
127 crate::operation::terminate_instances::TerminateInstancesOutput,
128 crate::operation::terminate_instances::TerminateInstancesError,
129 Self,
130 > {
131 crate::client::customize::CustomizableOperation::new(self)
132 }
133 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
134 self.set_config_override(::std::option::Option::Some(config_override.into()));
135 self
136 }
137
138 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
139 self.config_override = config_override;
140 self
141 }
142 ///
143 /// Appends an item to `InstanceIds`.
144 ///
145 /// To override the contents of this collection use [`set_instance_ids`](Self::set_instance_ids).
146 ///
147 /// <p>The IDs of the instances.</p>
148 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
149 pub fn instance_ids(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
150 self.inner = self.inner.instance_ids(input.into());
151 self
152 }
153 /// <p>The IDs of the instances.</p>
154 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
155 pub fn set_instance_ids(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
156 self.inner = self.inner.set_instance_ids(input);
157 self
158 }
159 /// <p>The IDs of the instances.</p>
160 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
161 pub fn get_instance_ids(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
162 self.inner.get_instance_ids()
163 }
164 /// <p>Forces the instances to terminate. The instance will first attempt a graceful shutdown, which includes flushing file system caches and metadata. If the graceful shutdown fails to complete within the timeout period, the instance shuts down forcibly without flushing the file system caches and metadata.</p>
165 pub fn force(mut self, input: bool) -> Self {
166 self.inner = self.inner.force(input);
167 self
168 }
169 /// <p>Forces the instances to terminate. The instance will first attempt a graceful shutdown, which includes flushing file system caches and metadata. If the graceful shutdown fails to complete within the timeout period, the instance shuts down forcibly without flushing the file system caches and metadata.</p>
170 pub fn set_force(mut self, input: ::std::option::Option<bool>) -> Self {
171 self.inner = self.inner.set_force(input);
172 self
173 }
174 /// <p>Forces the instances to terminate. The instance will first attempt a graceful shutdown, which includes flushing file system caches and metadata. If the graceful shutdown fails to complete within the timeout period, the instance shuts down forcibly without flushing the file system caches and metadata.</p>
175 pub fn get_force(&self) -> &::std::option::Option<bool> {
176 self.inner.get_force()
177 }
178 /// <p>Specifies whether to bypass the graceful OS shutdown process when the instance is terminated.</p>
179 /// <p>Default: <code>false</code></p>
180 pub fn skip_os_shutdown(mut self, input: bool) -> Self {
181 self.inner = self.inner.skip_os_shutdown(input);
182 self
183 }
184 /// <p>Specifies whether to bypass the graceful OS shutdown process when the instance is terminated.</p>
185 /// <p>Default: <code>false</code></p>
186 pub fn set_skip_os_shutdown(mut self, input: ::std::option::Option<bool>) -> Self {
187 self.inner = self.inner.set_skip_os_shutdown(input);
188 self
189 }
190 /// <p>Specifies whether to bypass the graceful OS shutdown process when the instance is terminated.</p>
191 /// <p>Default: <code>false</code></p>
192 pub fn get_skip_os_shutdown(&self) -> &::std::option::Option<bool> {
193 self.inner.get_skip_os_shutdown()
194 }
195 /// <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>
196 pub fn dry_run(mut self, input: bool) -> Self {
197 self.inner = self.inner.dry_run(input);
198 self
199 }
200 /// <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>
201 pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
202 self.inner = self.inner.set_dry_run(input);
203 self
204 }
205 /// <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>
206 pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
207 self.inner.get_dry_run()
208 }
209}