aws_sdk_ec2/operation/request_spot_instances/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::request_spot_instances::_request_spot_instances_output::RequestSpotInstancesOutputBuilder;
3
4pub use crate::operation::request_spot_instances::_request_spot_instances_input::RequestSpotInstancesInputBuilder;
5
6impl crate::operation::request_spot_instances::builders::RequestSpotInstancesInputBuilder {
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::request_spot_instances::RequestSpotInstancesOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::request_spot_instances::RequestSpotInstancesError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.request_spot_instances();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `RequestSpotInstances`.
24///
25/// <p>Creates a Spot Instance request.</p>
26/// <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html">Work with Spot Instance</a> in the <i>Amazon EC2 User Guide</i>.</p><important>
27/// <p>We strongly discourage using the RequestSpotInstances API because it is a legacy API with no planned investment. For options for requesting Spot Instances, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-best-practices.html#which-spot-request-method-to-use">Which is the best Spot request method to use?</a> in the <i>Amazon EC2 User Guide</i>.</p>
28/// </important>
29#[derive(::std::clone::Clone, ::std::fmt::Debug)]
30pub struct RequestSpotInstancesFluentBuilder {
31    handle: ::std::sync::Arc<crate::client::Handle>,
32    inner: crate::operation::request_spot_instances::builders::RequestSpotInstancesInputBuilder,
33    config_override: ::std::option::Option<crate::config::Builder>,
34}
35impl
36    crate::client::customize::internal::CustomizableSend<
37        crate::operation::request_spot_instances::RequestSpotInstancesOutput,
38        crate::operation::request_spot_instances::RequestSpotInstancesError,
39    > for RequestSpotInstancesFluentBuilder
40{
41    fn send(
42        self,
43        config_override: crate::config::Builder,
44    ) -> crate::client::customize::internal::BoxFuture<
45        crate::client::customize::internal::SendResult<
46            crate::operation::request_spot_instances::RequestSpotInstancesOutput,
47            crate::operation::request_spot_instances::RequestSpotInstancesError,
48        >,
49    > {
50        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
51    }
52}
53impl RequestSpotInstancesFluentBuilder {
54    /// Creates a new `RequestSpotInstancesFluentBuilder`.
55    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
56        Self {
57            handle,
58            inner: ::std::default::Default::default(),
59            config_override: ::std::option::Option::None,
60        }
61    }
62    /// Access the RequestSpotInstances as a reference.
63    pub fn as_input(&self) -> &crate::operation::request_spot_instances::builders::RequestSpotInstancesInputBuilder {
64        &self.inner
65    }
66    /// Sends the request and returns the response.
67    ///
68    /// If an error occurs, an `SdkError` will be returned with additional details that
69    /// can be matched against.
70    ///
71    /// By default, any retryable failures will be retried twice. Retry behavior
72    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
73    /// set when configuring the client.
74    pub async fn send(
75        self,
76    ) -> ::std::result::Result<
77        crate::operation::request_spot_instances::RequestSpotInstancesOutput,
78        ::aws_smithy_runtime_api::client::result::SdkError<
79            crate::operation::request_spot_instances::RequestSpotInstancesError,
80            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
81        >,
82    > {
83        let input = self
84            .inner
85            .build()
86            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
87        let runtime_plugins = crate::operation::request_spot_instances::RequestSpotInstances::operation_runtime_plugins(
88            self.handle.runtime_plugins.clone(),
89            &self.handle.conf,
90            self.config_override,
91        );
92        crate::operation::request_spot_instances::RequestSpotInstances::orchestrate(&runtime_plugins, input).await
93    }
94
95    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
96    pub fn customize(
97        self,
98    ) -> crate::client::customize::CustomizableOperation<
99        crate::operation::request_spot_instances::RequestSpotInstancesOutput,
100        crate::operation::request_spot_instances::RequestSpotInstancesError,
101        Self,
102    > {
103        crate::client::customize::CustomizableOperation::new(self)
104    }
105    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
106        self.set_config_override(::std::option::Option::Some(config_override.into()));
107        self
108    }
109
110    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
111        self.config_override = config_override;
112        self
113    }
114    /// <p>The launch specification.</p>
115    pub fn launch_specification(mut self, input: crate::types::RequestSpotLaunchSpecification) -> Self {
116        self.inner = self.inner.launch_specification(input);
117        self
118    }
119    /// <p>The launch specification.</p>
120    pub fn set_launch_specification(mut self, input: ::std::option::Option<crate::types::RequestSpotLaunchSpecification>) -> Self {
121        self.inner = self.inner.set_launch_specification(input);
122        self
123    }
124    /// <p>The launch specification.</p>
125    pub fn get_launch_specification(&self) -> &::std::option::Option<crate::types::RequestSpotLaunchSpecification> {
126        self.inner.get_launch_specification()
127    }
128    ///
129    /// Appends an item to `TagSpecifications`.
130    ///
131    /// To override the contents of this collection use [`set_tag_specifications`](Self::set_tag_specifications).
132    ///
133    /// <p>The key-value pair for tagging the Spot Instance request on creation. The value for <code>ResourceType</code> must be <code>spot-instances-request</code>, otherwise the Spot Instance request fails. To tag the Spot Instance request 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 key-value pair for tagging the Spot Instance request on creation. The value for <code>ResourceType</code> must be <code>spot-instances-request</code>, otherwise the Spot Instance request fails. To tag the Spot Instance request after it has been created, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html">CreateTags</a>.</p>
139    pub fn set_tag_specifications(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>>) -> Self {
140        self.inner = self.inner.set_tag_specifications(input);
141        self
142    }
143    /// <p>The key-value pair for tagging the Spot Instance request on creation. The value for <code>ResourceType</code> must be <code>spot-instances-request</code>, otherwise the Spot Instance request fails. To tag the Spot Instance request after it has been created, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html">CreateTags</a>.</p>
144    pub fn get_tag_specifications(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>> {
145        self.inner.get_tag_specifications()
146    }
147    /// <p>The behavior when a Spot Instance is interrupted. The default is <code>terminate</code>.</p>
148    pub fn instance_interruption_behavior(mut self, input: crate::types::InstanceInterruptionBehavior) -> Self {
149        self.inner = self.inner.instance_interruption_behavior(input);
150        self
151    }
152    /// <p>The behavior when a Spot Instance is interrupted. The default is <code>terminate</code>.</p>
153    pub fn set_instance_interruption_behavior(mut self, input: ::std::option::Option<crate::types::InstanceInterruptionBehavior>) -> Self {
154        self.inner = self.inner.set_instance_interruption_behavior(input);
155        self
156    }
157    /// <p>The behavior when a Spot Instance is interrupted. The default is <code>terminate</code>.</p>
158    pub fn get_instance_interruption_behavior(&self) -> &::std::option::Option<crate::types::InstanceInterruptionBehavior> {
159        self.inner.get_instance_interruption_behavior()
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 dry_run(mut self, input: bool) -> Self {
163        self.inner = self.inner.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 set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
168        self.inner = self.inner.set_dry_run(input);
169        self
170    }
171    /// <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>
172    pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
173        self.inner.get_dry_run()
174    }
175    /// <p>The maximum price per unit hour that you are willing to pay for a Spot Instance. We do not recommend using this parameter because it can lead to increased interruptions. If you do not specify this parameter, you will pay the current Spot price.</p><important>
176    /// <p>If you specify a maximum price, your instances will be interrupted more frequently than if you do not specify this parameter.</p>
177    /// </important>
178    pub fn spot_price(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
179        self.inner = self.inner.spot_price(input.into());
180        self
181    }
182    /// <p>The maximum price per unit hour that you are willing to pay for a Spot Instance. We do not recommend using this parameter because it can lead to increased interruptions. If you do not specify this parameter, you will pay the current Spot price.</p><important>
183    /// <p>If you specify a maximum price, your instances will be interrupted more frequently than if you do not specify this parameter.</p>
184    /// </important>
185    pub fn set_spot_price(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
186        self.inner = self.inner.set_spot_price(input);
187        self
188    }
189    /// <p>The maximum price per unit hour that you are willing to pay for a Spot Instance. We do not recommend using this parameter because it can lead to increased interruptions. If you do not specify this parameter, you will pay the current Spot price.</p><important>
190    /// <p>If you specify a maximum price, your instances will be interrupted more frequently than if you do not specify this parameter.</p>
191    /// </important>
192    pub fn get_spot_price(&self) -> &::std::option::Option<::std::string::String> {
193        self.inner.get_spot_price()
194    }
195    /// <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html">Ensuring idempotency in Amazon EC2 API requests</a> in the <i>Amazon EC2 User Guide</i>.</p>
196    pub fn client_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
197        self.inner = self.inner.client_token(input.into());
198        self
199    }
200    /// <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html">Ensuring idempotency in Amazon EC2 API requests</a> in the <i>Amazon EC2 User Guide</i>.</p>
201    pub fn set_client_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
202        self.inner = self.inner.set_client_token(input);
203        self
204    }
205    /// <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html">Ensuring idempotency in Amazon EC2 API requests</a> in the <i>Amazon EC2 User Guide</i>.</p>
206    pub fn get_client_token(&self) -> &::std::option::Option<::std::string::String> {
207        self.inner.get_client_token()
208    }
209    /// <p>The maximum number of Spot Instances to launch.</p>
210    /// <p>Default: 1</p>
211    pub fn instance_count(mut self, input: i32) -> Self {
212        self.inner = self.inner.instance_count(input);
213        self
214    }
215    /// <p>The maximum number of Spot Instances to launch.</p>
216    /// <p>Default: 1</p>
217    pub fn set_instance_count(mut self, input: ::std::option::Option<i32>) -> Self {
218        self.inner = self.inner.set_instance_count(input);
219        self
220    }
221    /// <p>The maximum number of Spot Instances to launch.</p>
222    /// <p>Default: 1</p>
223    pub fn get_instance_count(&self) -> &::std::option::Option<i32> {
224        self.inner.get_instance_count()
225    }
226    /// <p>The Spot Instance request type.</p>
227    /// <p>Default: <code>one-time</code></p>
228    pub fn r#type(mut self, input: crate::types::SpotInstanceType) -> Self {
229        self.inner = self.inner.r#type(input);
230        self
231    }
232    /// <p>The Spot Instance request type.</p>
233    /// <p>Default: <code>one-time</code></p>
234    pub fn set_type(mut self, input: ::std::option::Option<crate::types::SpotInstanceType>) -> Self {
235        self.inner = self.inner.set_type(input);
236        self
237    }
238    /// <p>The Spot Instance request type.</p>
239    /// <p>Default: <code>one-time</code></p>
240    pub fn get_type(&self) -> &::std::option::Option<crate::types::SpotInstanceType> {
241        self.inner.get_type()
242    }
243    /// <p>The start date of the request. If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled. If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled.</p>
244    /// <p>The specified start date and time cannot be equal to the current date and time. You must specify a start date and time that occurs after the current date and time.</p>
245    pub fn valid_from(mut self, input: ::aws_smithy_types::DateTime) -> Self {
246        self.inner = self.inner.valid_from(input);
247        self
248    }
249    /// <p>The start date of the request. If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled. If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled.</p>
250    /// <p>The specified start date and time cannot be equal to the current date and time. You must specify a start date and time that occurs after the current date and time.</p>
251    pub fn set_valid_from(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
252        self.inner = self.inner.set_valid_from(input);
253        self
254    }
255    /// <p>The start date of the request. If this is a one-time request, the request becomes active at this date and time and remains active until all instances launch, the request expires, or the request is canceled. If the request is persistent, the request becomes active at this date and time and remains active until it expires or is canceled.</p>
256    /// <p>The specified start date and time cannot be equal to the current date and time. You must specify a start date and time that occurs after the current date and time.</p>
257    pub fn get_valid_from(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
258        self.inner.get_valid_from()
259    }
260    /// <p>The end date of the request, in UTC format (<i>YYYY</i>-<i>MM</i>-<i>DD</i>T<i>HH</i>:<i>MM</i>:<i>SS</i>Z).</p>
261    /// <ul>
262    /// <li>
263    /// <p>For a persistent request, the request remains active until the <code>ValidUntil</code> date and time is reached. Otherwise, the request remains active until you cancel it.</p></li>
264    /// <li>
265    /// <p>For a one-time request, the request remains active until all instances launch, the request is canceled, or the <code>ValidUntil</code> date and time is reached. By default, the request is valid for 7 days from the date the request was created.</p></li>
266    /// </ul>
267    pub fn valid_until(mut self, input: ::aws_smithy_types::DateTime) -> Self {
268        self.inner = self.inner.valid_until(input);
269        self
270    }
271    /// <p>The end date of the request, in UTC format (<i>YYYY</i>-<i>MM</i>-<i>DD</i>T<i>HH</i>:<i>MM</i>:<i>SS</i>Z).</p>
272    /// <ul>
273    /// <li>
274    /// <p>For a persistent request, the request remains active until the <code>ValidUntil</code> date and time is reached. Otherwise, the request remains active until you cancel it.</p></li>
275    /// <li>
276    /// <p>For a one-time request, the request remains active until all instances launch, the request is canceled, or the <code>ValidUntil</code> date and time is reached. By default, the request is valid for 7 days from the date the request was created.</p></li>
277    /// </ul>
278    pub fn set_valid_until(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
279        self.inner = self.inner.set_valid_until(input);
280        self
281    }
282    /// <p>The end date of the request, in UTC format (<i>YYYY</i>-<i>MM</i>-<i>DD</i>T<i>HH</i>:<i>MM</i>:<i>SS</i>Z).</p>
283    /// <ul>
284    /// <li>
285    /// <p>For a persistent request, the request remains active until the <code>ValidUntil</code> date and time is reached. Otherwise, the request remains active until you cancel it.</p></li>
286    /// <li>
287    /// <p>For a one-time request, the request remains active until all instances launch, the request is canceled, or the <code>ValidUntil</code> date and time is reached. By default, the request is valid for 7 days from the date the request was created.</p></li>
288    /// </ul>
289    pub fn get_valid_until(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
290        self.inner.get_valid_until()
291    }
292    /// <p>The instance launch group. Launch groups are Spot Instances that launch together and terminate together.</p>
293    /// <p>Default: Instances are launched and terminated individually</p>
294    pub fn launch_group(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
295        self.inner = self.inner.launch_group(input.into());
296        self
297    }
298    /// <p>The instance launch group. Launch groups are Spot Instances that launch together and terminate together.</p>
299    /// <p>Default: Instances are launched and terminated individually</p>
300    pub fn set_launch_group(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
301        self.inner = self.inner.set_launch_group(input);
302        self
303    }
304    /// <p>The instance launch group. Launch groups are Spot Instances that launch together and terminate together.</p>
305    /// <p>Default: Instances are launched and terminated individually</p>
306    pub fn get_launch_group(&self) -> &::std::option::Option<::std::string::String> {
307        self.inner.get_launch_group()
308    }
309    /// <p>The user-specified name for a logical grouping of requests.</p>
310    /// <p>When you specify an Availability Zone group in a Spot Instance request, all Spot Instances in the request are launched in the same Availability Zone. Instance proximity is maintained with this parameter, but the choice of Availability Zone is not. The group applies only to requests for Spot Instances of the same instance type. Any additional Spot Instance requests that are specified with the same Availability Zone group name are launched in that same Availability Zone, as long as at least one instance from the group is still active.</p>
311    /// <p>If there is no active instance running in the Availability Zone group that you specify for a new Spot Instance request (all instances are terminated, the request is expired, or the maximum price you specified falls below current Spot price), then Amazon EC2 launches the instance in any Availability Zone where the constraint can be met. Consequently, the subsequent set of Spot Instances could be placed in a different zone from the original request, even if you specified the same Availability Zone group.</p>
312    /// <p>Default: Instances are launched in any available Availability Zone.</p>
313    pub fn availability_zone_group(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
314        self.inner = self.inner.availability_zone_group(input.into());
315        self
316    }
317    /// <p>The user-specified name for a logical grouping of requests.</p>
318    /// <p>When you specify an Availability Zone group in a Spot Instance request, all Spot Instances in the request are launched in the same Availability Zone. Instance proximity is maintained with this parameter, but the choice of Availability Zone is not. The group applies only to requests for Spot Instances of the same instance type. Any additional Spot Instance requests that are specified with the same Availability Zone group name are launched in that same Availability Zone, as long as at least one instance from the group is still active.</p>
319    /// <p>If there is no active instance running in the Availability Zone group that you specify for a new Spot Instance request (all instances are terminated, the request is expired, or the maximum price you specified falls below current Spot price), then Amazon EC2 launches the instance in any Availability Zone where the constraint can be met. Consequently, the subsequent set of Spot Instances could be placed in a different zone from the original request, even if you specified the same Availability Zone group.</p>
320    /// <p>Default: Instances are launched in any available Availability Zone.</p>
321    pub fn set_availability_zone_group(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
322        self.inner = self.inner.set_availability_zone_group(input);
323        self
324    }
325    /// <p>The user-specified name for a logical grouping of requests.</p>
326    /// <p>When you specify an Availability Zone group in a Spot Instance request, all Spot Instances in the request are launched in the same Availability Zone. Instance proximity is maintained with this parameter, but the choice of Availability Zone is not. The group applies only to requests for Spot Instances of the same instance type. Any additional Spot Instance requests that are specified with the same Availability Zone group name are launched in that same Availability Zone, as long as at least one instance from the group is still active.</p>
327    /// <p>If there is no active instance running in the Availability Zone group that you specify for a new Spot Instance request (all instances are terminated, the request is expired, or the maximum price you specified falls below current Spot price), then Amazon EC2 launches the instance in any Availability Zone where the constraint can be met. Consequently, the subsequent set of Spot Instances could be placed in a different zone from the original request, even if you specified the same Availability Zone group.</p>
328    /// <p>Default: Instances are launched in any available Availability Zone.</p>
329    pub fn get_availability_zone_group(&self) -> &::std::option::Option<::std::string::String> {
330        self.inner.get_availability_zone_group()
331    }
332    /// <p>Deprecated.</p>
333    pub fn block_duration_minutes(mut self, input: i32) -> Self {
334        self.inner = self.inner.block_duration_minutes(input);
335        self
336    }
337    /// <p>Deprecated.</p>
338    pub fn set_block_duration_minutes(mut self, input: ::std::option::Option<i32>) -> Self {
339        self.inner = self.inner.set_block_duration_minutes(input);
340        self
341    }
342    /// <p>Deprecated.</p>
343    pub fn get_block_duration_minutes(&self) -> &::std::option::Option<i32> {
344        self.inner.get_block_duration_minutes()
345    }
346}