aws_sdk_ec2/operation/request_spot_fleet/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::request_spot_fleet::_request_spot_fleet_output::RequestSpotFleetOutputBuilder;
3
4pub use crate::operation::request_spot_fleet::_request_spot_fleet_input::RequestSpotFleetInputBuilder;
5
6impl crate::operation::request_spot_fleet::builders::RequestSpotFleetInputBuilder {
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_fleet::RequestSpotFleetOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::request_spot_fleet::RequestSpotFleetError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.request_spot_fleet();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `RequestSpotFleet`.
24///
25/// <p>Creates a Spot Fleet request.</p>
26/// <p>The Spot Fleet request specifies the total target capacity and the On-Demand target capacity. Amazon EC2 calculates the difference between the total capacity and On-Demand capacity, and launches the difference as Spot capacity.</p>
27/// <p>You can submit a single request that includes multiple launch specifications that vary by instance type, AMI, Availability Zone, or subnet.</p>
28/// <p>By default, the Spot Fleet requests Spot Instances in the Spot Instance pool where the price per unit is the lowest. Each launch specification can include its own instance weighting that reflects the value of the instance type to your application workload.</p>
29/// <p>Alternatively, you can specify that the Spot Fleet distribute the target capacity across the Spot pools included in its launch specifications. By ensuring that the Spot Instances in your Spot Fleet are in different Spot pools, you can improve the availability of your fleet.</p>
30/// <p>You can specify tags for the Spot Fleet request and instances launched by the fleet. You cannot tag other resource types in a Spot Fleet request because only the <code>spot-fleet-request</code> and <code>instance</code> resource types are supported.</p>
31/// <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet-requests.html">Spot Fleet requests</a> in the <i>Amazon EC2 User Guide</i>.</p><important>
32/// <p>We strongly discourage using the RequestSpotFleet 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>
33/// </important>
34#[derive(::std::clone::Clone, ::std::fmt::Debug)]
35pub struct RequestSpotFleetFluentBuilder {
36    handle: ::std::sync::Arc<crate::client::Handle>,
37    inner: crate::operation::request_spot_fleet::builders::RequestSpotFleetInputBuilder,
38    config_override: ::std::option::Option<crate::config::Builder>,
39}
40impl
41    crate::client::customize::internal::CustomizableSend<
42        crate::operation::request_spot_fleet::RequestSpotFleetOutput,
43        crate::operation::request_spot_fleet::RequestSpotFleetError,
44    > for RequestSpotFleetFluentBuilder
45{
46    fn send(
47        self,
48        config_override: crate::config::Builder,
49    ) -> crate::client::customize::internal::BoxFuture<
50        crate::client::customize::internal::SendResult<
51            crate::operation::request_spot_fleet::RequestSpotFleetOutput,
52            crate::operation::request_spot_fleet::RequestSpotFleetError,
53        >,
54    > {
55        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
56    }
57}
58impl RequestSpotFleetFluentBuilder {
59    /// Creates a new `RequestSpotFleetFluentBuilder`.
60    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
61        Self {
62            handle,
63            inner: ::std::default::Default::default(),
64            config_override: ::std::option::Option::None,
65        }
66    }
67    /// Access the RequestSpotFleet as a reference.
68    pub fn as_input(&self) -> &crate::operation::request_spot_fleet::builders::RequestSpotFleetInputBuilder {
69        &self.inner
70    }
71    /// Sends the request and returns the response.
72    ///
73    /// If an error occurs, an `SdkError` will be returned with additional details that
74    /// can be matched against.
75    ///
76    /// By default, any retryable failures will be retried twice. Retry behavior
77    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
78    /// set when configuring the client.
79    pub async fn send(
80        self,
81    ) -> ::std::result::Result<
82        crate::operation::request_spot_fleet::RequestSpotFleetOutput,
83        ::aws_smithy_runtime_api::client::result::SdkError<
84            crate::operation::request_spot_fleet::RequestSpotFleetError,
85            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
86        >,
87    > {
88        let input = self
89            .inner
90            .build()
91            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
92        let runtime_plugins = crate::operation::request_spot_fleet::RequestSpotFleet::operation_runtime_plugins(
93            self.handle.runtime_plugins.clone(),
94            &self.handle.conf,
95            self.config_override,
96        );
97        crate::operation::request_spot_fleet::RequestSpotFleet::orchestrate(&runtime_plugins, input).await
98    }
99
100    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
101    pub fn customize(
102        self,
103    ) -> crate::client::customize::CustomizableOperation<
104        crate::operation::request_spot_fleet::RequestSpotFleetOutput,
105        crate::operation::request_spot_fleet::RequestSpotFleetError,
106        Self,
107    > {
108        crate::client::customize::CustomizableOperation::new(self)
109    }
110    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
111        self.set_config_override(::std::option::Option::Some(config_override.into()));
112        self
113    }
114
115    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
116        self.config_override = config_override;
117        self
118    }
119    /// <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>
120    pub fn dry_run(mut self, input: bool) -> Self {
121        self.inner = self.inner.dry_run(input);
122        self
123    }
124    /// <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>
125    pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
126        self.inner = self.inner.set_dry_run(input);
127        self
128    }
129    /// <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>
130    pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
131        self.inner.get_dry_run()
132    }
133    /// <p>The configuration for the Spot Fleet request.</p>
134    pub fn spot_fleet_request_config(mut self, input: crate::types::SpotFleetRequestConfigData) -> Self {
135        self.inner = self.inner.spot_fleet_request_config(input);
136        self
137    }
138    /// <p>The configuration for the Spot Fleet request.</p>
139    pub fn set_spot_fleet_request_config(mut self, input: ::std::option::Option<crate::types::SpotFleetRequestConfigData>) -> Self {
140        self.inner = self.inner.set_spot_fleet_request_config(input);
141        self
142    }
143    /// <p>The configuration for the Spot Fleet request.</p>
144    pub fn get_spot_fleet_request_config(&self) -> &::std::option::Option<crate::types::SpotFleetRequestConfigData> {
145        self.inner.get_spot_fleet_request_config()
146    }
147}