aws_sdk_ec2/operation/modify_capacity_reservation/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::modify_capacity_reservation::_modify_capacity_reservation_output::ModifyCapacityReservationOutputBuilder;
3
4pub use crate::operation::modify_capacity_reservation::_modify_capacity_reservation_input::ModifyCapacityReservationInputBuilder;
5
6impl crate::operation::modify_capacity_reservation::builders::ModifyCapacityReservationInputBuilder {
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_capacity_reservation::ModifyCapacityReservationOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::modify_capacity_reservation::ModifyCapacityReservationError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.modify_capacity_reservation();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `ModifyCapacityReservation`.
24///
25/// <p>Modifies a Capacity Reservation's capacity, instance eligibility, and the conditions under which it is to be released. You can't modify a Capacity Reservation's instance type, EBS optimization, platform, instance store settings, Availability Zone, or tenancy. If you need to modify any of these attributes, we recommend that you cancel the Capacity Reservation, and then create a new one with the required attributes. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/capacity-reservations-modify.html"> Modify an active Capacity Reservation</a>.</p>
26/// <p>The allowed modifications depend on the state of the Capacity Reservation:</p>
27/// <ul>
28/// <li>
29/// <p><code>assessing</code> or <code>scheduled</code> state - You can modify the tags only.</p></li>
30/// <li>
31/// <p><code>pending</code> state - You can't modify the Capacity Reservation in any way.</p></li>
32/// <li>
33/// <p><code>active</code> state but still within the commitment duration - You can't decrease the instance count or set an end date that is within the commitment duration. All other modifications are allowed.</p></li>
34/// <li>
35/// <p><code>active</code> state with no commitment duration or elapsed commitment duration - All modifications are allowed.</p></li>
36/// <li>
37/// <p><code>expired</code>, <code>cancelled</code>, <code>unsupported</code>, or <code>failed</code> state - You can't modify the Capacity Reservation in any way.</p></li>
38/// </ul>
39#[derive(::std::clone::Clone, ::std::fmt::Debug)]
40pub struct ModifyCapacityReservationFluentBuilder {
41    handle: ::std::sync::Arc<crate::client::Handle>,
42    inner: crate::operation::modify_capacity_reservation::builders::ModifyCapacityReservationInputBuilder,
43    config_override: ::std::option::Option<crate::config::Builder>,
44}
45impl
46    crate::client::customize::internal::CustomizableSend<
47        crate::operation::modify_capacity_reservation::ModifyCapacityReservationOutput,
48        crate::operation::modify_capacity_reservation::ModifyCapacityReservationError,
49    > for ModifyCapacityReservationFluentBuilder
50{
51    fn send(
52        self,
53        config_override: crate::config::Builder,
54    ) -> crate::client::customize::internal::BoxFuture<
55        crate::client::customize::internal::SendResult<
56            crate::operation::modify_capacity_reservation::ModifyCapacityReservationOutput,
57            crate::operation::modify_capacity_reservation::ModifyCapacityReservationError,
58        >,
59    > {
60        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
61    }
62}
63impl ModifyCapacityReservationFluentBuilder {
64    /// Creates a new `ModifyCapacityReservationFluentBuilder`.
65    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
66        Self {
67            handle,
68            inner: ::std::default::Default::default(),
69            config_override: ::std::option::Option::None,
70        }
71    }
72    /// Access the ModifyCapacityReservation as a reference.
73    pub fn as_input(&self) -> &crate::operation::modify_capacity_reservation::builders::ModifyCapacityReservationInputBuilder {
74        &self.inner
75    }
76    /// Sends the request and returns the response.
77    ///
78    /// If an error occurs, an `SdkError` will be returned with additional details that
79    /// can be matched against.
80    ///
81    /// By default, any retryable failures will be retried twice. Retry behavior
82    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
83    /// set when configuring the client.
84    pub async fn send(
85        self,
86    ) -> ::std::result::Result<
87        crate::operation::modify_capacity_reservation::ModifyCapacityReservationOutput,
88        ::aws_smithy_runtime_api::client::result::SdkError<
89            crate::operation::modify_capacity_reservation::ModifyCapacityReservationError,
90            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
91        >,
92    > {
93        let input = self
94            .inner
95            .build()
96            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
97        let runtime_plugins = crate::operation::modify_capacity_reservation::ModifyCapacityReservation::operation_runtime_plugins(
98            self.handle.runtime_plugins.clone(),
99            &self.handle.conf,
100            self.config_override,
101        );
102        crate::operation::modify_capacity_reservation::ModifyCapacityReservation::orchestrate(&runtime_plugins, input).await
103    }
104
105    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
106    pub fn customize(
107        self,
108    ) -> crate::client::customize::CustomizableOperation<
109        crate::operation::modify_capacity_reservation::ModifyCapacityReservationOutput,
110        crate::operation::modify_capacity_reservation::ModifyCapacityReservationError,
111        Self,
112    > {
113        crate::client::customize::CustomizableOperation::new(self)
114    }
115    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
116        self.set_config_override(::std::option::Option::Some(config_override.into()));
117        self
118    }
119
120    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
121        self.config_override = config_override;
122        self
123    }
124    /// <p>The ID of the Capacity Reservation.</p>
125    pub fn capacity_reservation_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
126        self.inner = self.inner.capacity_reservation_id(input.into());
127        self
128    }
129    /// <p>The ID of the Capacity Reservation.</p>
130    pub fn set_capacity_reservation_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
131        self.inner = self.inner.set_capacity_reservation_id(input);
132        self
133    }
134    /// <p>The ID of the Capacity Reservation.</p>
135    pub fn get_capacity_reservation_id(&self) -> &::std::option::Option<::std::string::String> {
136        self.inner.get_capacity_reservation_id()
137    }
138    /// <p>The number of instances for which to reserve capacity. The number of instances can't be increased or decreased by more than <code>1000</code> in a single request.</p>
139    pub fn instance_count(mut self, input: i32) -> Self {
140        self.inner = self.inner.instance_count(input);
141        self
142    }
143    /// <p>The number of instances for which to reserve capacity. The number of instances can't be increased or decreased by more than <code>1000</code> in a single request.</p>
144    pub fn set_instance_count(mut self, input: ::std::option::Option<i32>) -> Self {
145        self.inner = self.inner.set_instance_count(input);
146        self
147    }
148    /// <p>The number of instances for which to reserve capacity. The number of instances can't be increased or decreased by more than <code>1000</code> in a single request.</p>
149    pub fn get_instance_count(&self) -> &::std::option::Option<i32> {
150        self.inner.get_instance_count()
151    }
152    /// <p>The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. The Capacity Reservation's state changes to <code>expired</code> when it reaches its end date and time.</p>
153    /// <p>The Capacity Reservation is cancelled within an hour from the specified time. For example, if you specify 5/31/2019, 13:30:55, the Capacity Reservation is guaranteed to end between 13:30:55 and 14:30:55 on 5/31/2019.</p>
154    /// <p>You must provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>limited</code>. Omit <code>EndDate</code> if <code>EndDateType</code> is <code>unlimited</code>.</p>
155    pub fn end_date(mut self, input: ::aws_smithy_types::DateTime) -> Self {
156        self.inner = self.inner.end_date(input);
157        self
158    }
159    /// <p>The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. The Capacity Reservation's state changes to <code>expired</code> when it reaches its end date and time.</p>
160    /// <p>The Capacity Reservation is cancelled within an hour from the specified time. For example, if you specify 5/31/2019, 13:30:55, the Capacity Reservation is guaranteed to end between 13:30:55 and 14:30:55 on 5/31/2019.</p>
161    /// <p>You must provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>limited</code>. Omit <code>EndDate</code> if <code>EndDateType</code> is <code>unlimited</code>.</p>
162    pub fn set_end_date(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
163        self.inner = self.inner.set_end_date(input);
164        self
165    }
166    /// <p>The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. The Capacity Reservation's state changes to <code>expired</code> when it reaches its end date and time.</p>
167    /// <p>The Capacity Reservation is cancelled within an hour from the specified time. For example, if you specify 5/31/2019, 13:30:55, the Capacity Reservation is guaranteed to end between 13:30:55 and 14:30:55 on 5/31/2019.</p>
168    /// <p>You must provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>limited</code>. Omit <code>EndDate</code> if <code>EndDateType</code> is <code>unlimited</code>.</p>
169    pub fn get_end_date(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
170        self.inner.get_end_date()
171    }
172    /// <p>Indicates the way in which the Capacity Reservation ends. A Capacity Reservation can have one of the following end types:</p>
173    /// <ul>
174    /// <li>
175    /// <p><code>unlimited</code> - The Capacity Reservation remains active until you explicitly cancel it. Do not provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>unlimited</code>.</p></li>
176    /// <li>
177    /// <p><code>limited</code> - The Capacity Reservation expires automatically at a specified date and time. You must provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>limited</code>.</p></li>
178    /// </ul>
179    pub fn end_date_type(mut self, input: crate::types::EndDateType) -> Self {
180        self.inner = self.inner.end_date_type(input);
181        self
182    }
183    /// <p>Indicates the way in which the Capacity Reservation ends. A Capacity Reservation can have one of the following end types:</p>
184    /// <ul>
185    /// <li>
186    /// <p><code>unlimited</code> - The Capacity Reservation remains active until you explicitly cancel it. Do not provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>unlimited</code>.</p></li>
187    /// <li>
188    /// <p><code>limited</code> - The Capacity Reservation expires automatically at a specified date and time. You must provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>limited</code>.</p></li>
189    /// </ul>
190    pub fn set_end_date_type(mut self, input: ::std::option::Option<crate::types::EndDateType>) -> Self {
191        self.inner = self.inner.set_end_date_type(input);
192        self
193    }
194    /// <p>Indicates the way in which the Capacity Reservation ends. A Capacity Reservation can have one of the following end types:</p>
195    /// <ul>
196    /// <li>
197    /// <p><code>unlimited</code> - The Capacity Reservation remains active until you explicitly cancel it. Do not provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>unlimited</code>.</p></li>
198    /// <li>
199    /// <p><code>limited</code> - The Capacity Reservation expires automatically at a specified date and time. You must provide an <code>EndDate</code> value if <code>EndDateType</code> is <code>limited</code>.</p></li>
200    /// </ul>
201    pub fn get_end_date_type(&self) -> &::std::option::Option<crate::types::EndDateType> {
202        self.inner.get_end_date_type()
203    }
204    /// <p>Reserved. Capacity Reservations you have created are accepted by default.</p>
205    pub fn accept(mut self, input: bool) -> Self {
206        self.inner = self.inner.accept(input);
207        self
208    }
209    /// <p>Reserved. Capacity Reservations you have created are accepted by default.</p>
210    pub fn set_accept(mut self, input: ::std::option::Option<bool>) -> Self {
211        self.inner = self.inner.set_accept(input);
212        self
213    }
214    /// <p>Reserved. Capacity Reservations you have created are accepted by default.</p>
215    pub fn get_accept(&self) -> &::std::option::Option<bool> {
216        self.inner.get_accept()
217    }
218    /// <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>
219    pub fn dry_run(mut self, input: bool) -> Self {
220        self.inner = self.inner.dry_run(input);
221        self
222    }
223    /// <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>
224    pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
225        self.inner = self.inner.set_dry_run(input);
226        self
227    }
228    /// <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>
229    pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
230        self.inner.get_dry_run()
231    }
232    /// <p>Reserved for future use.</p>
233    pub fn additional_info(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
234        self.inner = self.inner.additional_info(input.into());
235        self
236    }
237    /// <p>Reserved for future use.</p>
238    pub fn set_additional_info(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
239        self.inner = self.inner.set_additional_info(input);
240        self
241    }
242    /// <p>Reserved for future use.</p>
243    pub fn get_additional_info(&self) -> &::std::option::Option<::std::string::String> {
244        self.inner.get_additional_info()
245    }
246    /// <p>The matching criteria (instance eligibility) that you want to use in the modified Capacity Reservation. If you change the instance eligibility of an existing Capacity Reservation from <code>targeted</code> to <code>open</code>, any running instances that match the attributes of the Capacity Reservation, have the <code>CapacityReservationPreference</code> set to <code>open</code>, and are not yet running in the Capacity Reservation, will automatically use the modified Capacity Reservation.</p>
247    /// <p>To modify the instance eligibility, the Capacity Reservation must be completely idle (zero usage).</p>
248    pub fn instance_match_criteria(mut self, input: crate::types::InstanceMatchCriteria) -> Self {
249        self.inner = self.inner.instance_match_criteria(input);
250        self
251    }
252    /// <p>The matching criteria (instance eligibility) that you want to use in the modified Capacity Reservation. If you change the instance eligibility of an existing Capacity Reservation from <code>targeted</code> to <code>open</code>, any running instances that match the attributes of the Capacity Reservation, have the <code>CapacityReservationPreference</code> set to <code>open</code>, and are not yet running in the Capacity Reservation, will automatically use the modified Capacity Reservation.</p>
253    /// <p>To modify the instance eligibility, the Capacity Reservation must be completely idle (zero usage).</p>
254    pub fn set_instance_match_criteria(mut self, input: ::std::option::Option<crate::types::InstanceMatchCriteria>) -> Self {
255        self.inner = self.inner.set_instance_match_criteria(input);
256        self
257    }
258    /// <p>The matching criteria (instance eligibility) that you want to use in the modified Capacity Reservation. If you change the instance eligibility of an existing Capacity Reservation from <code>targeted</code> to <code>open</code>, any running instances that match the attributes of the Capacity Reservation, have the <code>CapacityReservationPreference</code> set to <code>open</code>, and are not yet running in the Capacity Reservation, will automatically use the modified Capacity Reservation.</p>
259    /// <p>To modify the instance eligibility, the Capacity Reservation must be completely idle (zero usage).</p>
260    pub fn get_instance_match_criteria(&self) -> &::std::option::Option<crate::types::InstanceMatchCriteria> {
261        self.inner.get_instance_match_criteria()
262    }
263}