aws_sdk_ec2/operation/modify_spot_fleet_request/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::modify_spot_fleet_request::_modify_spot_fleet_request_output::ModifySpotFleetRequestOutputBuilder;
3
4pub use crate::operation::modify_spot_fleet_request::_modify_spot_fleet_request_input::ModifySpotFleetRequestInputBuilder;
5
6impl crate::operation::modify_spot_fleet_request::builders::ModifySpotFleetRequestInputBuilder {
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::modify_spot_fleet_request::ModifySpotFleetRequestOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.modify_spot_fleet_request();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `ModifySpotFleetRequest`.
24///
25/// <p>Modifies the specified Spot Fleet request.</p>
26/// <p>You can only modify a Spot Fleet request of type <code>maintain</code>.</p>
27/// <p>While the Spot Fleet request is being modified, it is in the <code>modifying</code> state.</p>
28/// <p>To scale up your Spot Fleet, increase its target capacity. The Spot Fleet launches the additional Spot Instances according to the allocation strategy for the Spot Fleet request. If the allocation strategy is <code>lowestPrice</code>, the Spot Fleet launches instances using the Spot Instance pool with the lowest price. If the allocation strategy is <code>diversified</code>, the Spot Fleet distributes the instances across the Spot Instance pools. If the allocation strategy is <code>capacityOptimized</code>, Spot Fleet launches instances from Spot Instance pools with optimal capacity for the number of instances that are launching.</p>
29/// <p>To scale down your Spot Fleet, decrease its target capacity. First, the Spot Fleet cancels any open requests that exceed the new target capacity. You can request that the Spot Fleet terminate Spot Instances until the size of the fleet no longer exceeds the new target capacity. If the allocation strategy is <code>lowestPrice</code>, the Spot Fleet terminates the instances with the highest price per unit. If the allocation strategy is <code>capacityOptimized</code>, the Spot Fleet terminates the instances in the Spot Instance pools that have the least available Spot Instance capacity. If the allocation strategy is <code>diversified</code>, the Spot Fleet terminates instances across the Spot Instance pools. Alternatively, you can request that the Spot Fleet keep the fleet at its current size, but not replace any Spot Instances that are interrupted or that you terminate manually.</p>
30/// <p>If you are finished with your Spot Fleet for now, but will use it again later, you can set the target capacity to 0.</p>
31#[derive(::std::clone::Clone, ::std::fmt::Debug)]
32pub struct ModifySpotFleetRequestFluentBuilder {
33    handle: ::std::sync::Arc<crate::client::Handle>,
34    inner: crate::operation::modify_spot_fleet_request::builders::ModifySpotFleetRequestInputBuilder,
35    config_override: ::std::option::Option<crate::config::Builder>,
36}
37impl
38    crate::client::customize::internal::CustomizableSend<
39        crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestOutput,
40        crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestError,
41    > for ModifySpotFleetRequestFluentBuilder
42{
43    fn send(
44        self,
45        config_override: crate::config::Builder,
46    ) -> crate::client::customize::internal::BoxFuture<
47        crate::client::customize::internal::SendResult<
48            crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestOutput,
49            crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestError,
50        >,
51    > {
52        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
53    }
54}
55impl ModifySpotFleetRequestFluentBuilder {
56    /// Creates a new `ModifySpotFleetRequestFluentBuilder`.
57    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
58        Self {
59            handle,
60            inner: ::std::default::Default::default(),
61            config_override: ::std::option::Option::None,
62        }
63    }
64    /// Access the ModifySpotFleetRequest as a reference.
65    pub fn as_input(&self) -> &crate::operation::modify_spot_fleet_request::builders::ModifySpotFleetRequestInputBuilder {
66        &self.inner
67    }
68    /// Sends the request and returns the response.
69    ///
70    /// If an error occurs, an `SdkError` will be returned with additional details that
71    /// can be matched against.
72    ///
73    /// By default, any retryable failures will be retried twice. Retry behavior
74    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
75    /// set when configuring the client.
76    pub async fn send(
77        self,
78    ) -> ::std::result::Result<
79        crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestOutput,
80        ::aws_smithy_runtime_api::client::result::SdkError<
81            crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestError,
82            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
83        >,
84    > {
85        let input = self
86            .inner
87            .build()
88            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
89        let runtime_plugins = crate::operation::modify_spot_fleet_request::ModifySpotFleetRequest::operation_runtime_plugins(
90            self.handle.runtime_plugins.clone(),
91            &self.handle.conf,
92            self.config_override,
93        );
94        crate::operation::modify_spot_fleet_request::ModifySpotFleetRequest::orchestrate(&runtime_plugins, input).await
95    }
96
97    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
98    pub fn customize(
99        self,
100    ) -> crate::client::customize::CustomizableOperation<
101        crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestOutput,
102        crate::operation::modify_spot_fleet_request::ModifySpotFleetRequestError,
103        Self,
104    > {
105        crate::client::customize::CustomizableOperation::new(self)
106    }
107    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
108        self.set_config_override(::std::option::Option::Some(config_override.into()));
109        self
110    }
111
112    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
113        self.config_override = config_override;
114        self
115    }
116    ///
117    /// Appends an item to `LaunchTemplateConfigs`.
118    ///
119    /// To override the contents of this collection use [`set_launch_template_configs`](Self::set_launch_template_configs).
120    ///
121    /// <p>The launch template and overrides. You can only use this parameter if you specified a launch template (<code>LaunchTemplateConfigs</code>) in your Spot Fleet request. If you specified <code>LaunchSpecifications</code> in your Spot Fleet request, then omit this parameter.</p>
122    pub fn launch_template_configs(mut self, input: crate::types::LaunchTemplateConfig) -> Self {
123        self.inner = self.inner.launch_template_configs(input);
124        self
125    }
126    /// <p>The launch template and overrides. You can only use this parameter if you specified a launch template (<code>LaunchTemplateConfigs</code>) in your Spot Fleet request. If you specified <code>LaunchSpecifications</code> in your Spot Fleet request, then omit this parameter.</p>
127    pub fn set_launch_template_configs(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::LaunchTemplateConfig>>) -> Self {
128        self.inner = self.inner.set_launch_template_configs(input);
129        self
130    }
131    /// <p>The launch template and overrides. You can only use this parameter if you specified a launch template (<code>LaunchTemplateConfigs</code>) in your Spot Fleet request. If you specified <code>LaunchSpecifications</code> in your Spot Fleet request, then omit this parameter.</p>
132    pub fn get_launch_template_configs(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::LaunchTemplateConfig>> {
133        self.inner.get_launch_template_configs()
134    }
135    /// <p>The number of On-Demand Instances in the fleet.</p>
136    pub fn on_demand_target_capacity(mut self, input: i32) -> Self {
137        self.inner = self.inner.on_demand_target_capacity(input);
138        self
139    }
140    /// <p>The number of On-Demand Instances in the fleet.</p>
141    pub fn set_on_demand_target_capacity(mut self, input: ::std::option::Option<i32>) -> Self {
142        self.inner = self.inner.set_on_demand_target_capacity(input);
143        self
144    }
145    /// <p>The number of On-Demand Instances in the fleet.</p>
146    pub fn get_on_demand_target_capacity(&self) -> &::std::option::Option<i32> {
147        self.inner.get_on_demand_target_capacity()
148    }
149    /// <p>Reserved.</p>
150    pub fn context(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
151        self.inner = self.inner.context(input.into());
152        self
153    }
154    /// <p>Reserved.</p>
155    pub fn set_context(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
156        self.inner = self.inner.set_context(input);
157        self
158    }
159    /// <p>Reserved.</p>
160    pub fn get_context(&self) -> &::std::option::Option<::std::string::String> {
161        self.inner.get_context()
162    }
163    /// <p>The ID of the Spot Fleet request.</p>
164    pub fn spot_fleet_request_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
165        self.inner = self.inner.spot_fleet_request_id(input.into());
166        self
167    }
168    /// <p>The ID of the Spot Fleet request.</p>
169    pub fn set_spot_fleet_request_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
170        self.inner = self.inner.set_spot_fleet_request_id(input);
171        self
172    }
173    /// <p>The ID of the Spot Fleet request.</p>
174    pub fn get_spot_fleet_request_id(&self) -> &::std::option::Option<::std::string::String> {
175        self.inner.get_spot_fleet_request_id()
176    }
177    /// <p>The size of the fleet.</p>
178    pub fn target_capacity(mut self, input: i32) -> Self {
179        self.inner = self.inner.target_capacity(input);
180        self
181    }
182    /// <p>The size of the fleet.</p>
183    pub fn set_target_capacity(mut self, input: ::std::option::Option<i32>) -> Self {
184        self.inner = self.inner.set_target_capacity(input);
185        self
186    }
187    /// <p>The size of the fleet.</p>
188    pub fn get_target_capacity(&self) -> &::std::option::Option<i32> {
189        self.inner.get_target_capacity()
190    }
191    /// <p>Indicates whether running instances should be terminated if the target capacity of the Spot Fleet request is decreased below the current size of the Spot Fleet.</p>
192    /// <p>Supported only for fleets of type <code>maintain</code>.</p>
193    pub fn excess_capacity_termination_policy(mut self, input: crate::types::ExcessCapacityTerminationPolicy) -> Self {
194        self.inner = self.inner.excess_capacity_termination_policy(input);
195        self
196    }
197    /// <p>Indicates whether running instances should be terminated if the target capacity of the Spot Fleet request is decreased below the current size of the Spot Fleet.</p>
198    /// <p>Supported only for fleets of type <code>maintain</code>.</p>
199    pub fn set_excess_capacity_termination_policy(mut self, input: ::std::option::Option<crate::types::ExcessCapacityTerminationPolicy>) -> Self {
200        self.inner = self.inner.set_excess_capacity_termination_policy(input);
201        self
202    }
203    /// <p>Indicates whether running instances should be terminated if the target capacity of the Spot Fleet request is decreased below the current size of the Spot Fleet.</p>
204    /// <p>Supported only for fleets of type <code>maintain</code>.</p>
205    pub fn get_excess_capacity_termination_policy(&self) -> &::std::option::Option<crate::types::ExcessCapacityTerminationPolicy> {
206        self.inner.get_excess_capacity_termination_policy()
207    }
208}