aws_sdk_ec2/operation/create_instance_event_window/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_instance_event_window::_create_instance_event_window_output::CreateInstanceEventWindowOutputBuilder;
3
4pub use crate::operation::create_instance_event_window::_create_instance_event_window_input::CreateInstanceEventWindowInputBuilder;
5
6impl crate::operation::create_instance_event_window::builders::CreateInstanceEventWindowInputBuilder {
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::create_instance_event_window::CreateInstanceEventWindowOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_instance_event_window::CreateInstanceEventWindowError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_instance_event_window();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateInstanceEventWindow`.
24///
25/// <p>Creates an event window in which scheduled events for the associated Amazon EC2 instances can run.</p>
26/// <p>You can define either a set of time ranges or a cron expression when creating the event window, but not both. All event window times are in UTC.</p>
27/// <p>You can create up to 200 event windows per Amazon Web Services Region.</p>
28/// <p>When you create the event window, targets (instance IDs, Dedicated Host IDs, or tags) are not yet associated with it. To ensure that the event window can be used, you must associate one or more targets with it by using the <code>AssociateInstanceEventWindow</code> API.</p><important>
29/// <p>Event windows are applicable only for scheduled events that stop, reboot, or terminate instances.</p>
30/// <p>Event windows are <i>not</i> applicable for:</p>
31/// <ul>
32/// <li>
33/// <p>Expedited scheduled events and network maintenance events.</p></li>
34/// <li>
35/// <p>Unscheduled maintenance such as AutoRecovery and unplanned reboots.</p></li>
36/// </ul>
37/// </important>
38/// <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/event-windows.html">Define event windows for scheduled events</a> in the <i>Amazon EC2 User Guide</i>.</p>
39#[derive(::std::clone::Clone, ::std::fmt::Debug)]
40pub struct CreateInstanceEventWindowFluentBuilder {
41    handle: ::std::sync::Arc<crate::client::Handle>,
42    inner: crate::operation::create_instance_event_window::builders::CreateInstanceEventWindowInputBuilder,
43    config_override: ::std::option::Option<crate::config::Builder>,
44}
45impl
46    crate::client::customize::internal::CustomizableSend<
47        crate::operation::create_instance_event_window::CreateInstanceEventWindowOutput,
48        crate::operation::create_instance_event_window::CreateInstanceEventWindowError,
49    > for CreateInstanceEventWindowFluentBuilder
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::create_instance_event_window::CreateInstanceEventWindowOutput,
57            crate::operation::create_instance_event_window::CreateInstanceEventWindowError,
58        >,
59    > {
60        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
61    }
62}
63impl CreateInstanceEventWindowFluentBuilder {
64    /// Creates a new `CreateInstanceEventWindowFluentBuilder`.
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 CreateInstanceEventWindow as a reference.
73    pub fn as_input(&self) -> &crate::operation::create_instance_event_window::builders::CreateInstanceEventWindowInputBuilder {
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::create_instance_event_window::CreateInstanceEventWindowOutput,
88        ::aws_smithy_runtime_api::client::result::SdkError<
89            crate::operation::create_instance_event_window::CreateInstanceEventWindowError,
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::create_instance_event_window::CreateInstanceEventWindow::operation_runtime_plugins(
98            self.handle.runtime_plugins.clone(),
99            &self.handle.conf,
100            self.config_override,
101        );
102        crate::operation::create_instance_event_window::CreateInstanceEventWindow::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::create_instance_event_window::CreateInstanceEventWindowOutput,
110        crate::operation::create_instance_event_window::CreateInstanceEventWindowError,
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>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 dry_run(mut self, input: bool) -> Self {
126        self.inner = self.inner.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 set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
131        self.inner = self.inner.set_dry_run(input);
132        self
133    }
134    /// <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>
135    pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
136        self.inner.get_dry_run()
137    }
138    /// <p>The name of the event window.</p>
139    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
140        self.inner = self.inner.name(input.into());
141        self
142    }
143    /// <p>The name of the event window.</p>
144    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
145        self.inner = self.inner.set_name(input);
146        self
147    }
148    /// <p>The name of the event window.</p>
149    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
150        self.inner.get_name()
151    }
152    ///
153    /// Appends an item to `TimeRanges`.
154    ///
155    /// To override the contents of this collection use [`set_time_ranges`](Self::set_time_ranges).
156    ///
157    /// <p>The time range for the event window. If you specify a time range, you can't specify a cron expression.</p>
158    pub fn time_ranges(mut self, input: crate::types::InstanceEventWindowTimeRangeRequest) -> Self {
159        self.inner = self.inner.time_ranges(input);
160        self
161    }
162    /// <p>The time range for the event window. If you specify a time range, you can't specify a cron expression.</p>
163    pub fn set_time_ranges(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::InstanceEventWindowTimeRangeRequest>>) -> Self {
164        self.inner = self.inner.set_time_ranges(input);
165        self
166    }
167    /// <p>The time range for the event window. If you specify a time range, you can't specify a cron expression.</p>
168    pub fn get_time_ranges(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::InstanceEventWindowTimeRangeRequest>> {
169        self.inner.get_time_ranges()
170    }
171    /// <p>The cron expression for the event window, for example, <code>* 0-4,20-23 * * 1,5</code>. If you specify a cron expression, you can't specify a time range.</p>
172    /// <p>Constraints:</p>
173    /// <ul>
174    /// <li>
175    /// <p>Only hour and day of the week values are supported.</p></li>
176    /// <li>
177    /// <p>For day of the week values, you can specify either integers <code>0</code> through <code>6</code>, or alternative single values <code>SUN</code> through <code>SAT</code>.</p></li>
178    /// <li>
179    /// <p>The minute, month, and year must be specified by <code>*</code>.</p></li>
180    /// <li>
181    /// <p>The hour value must be one or a multiple range, for example, <code>0-4</code> or <code>0-4,20-23</code>.</p></li>
182    /// <li>
183    /// <p>Each hour range must be &gt;= 2 hours, for example, <code>0-2</code> or <code>20-23</code>.</p></li>
184    /// <li>
185    /// <p>The event window must be &gt;= 4 hours. The combined total time ranges in the event window must be &gt;= 4 hours.</p></li>
186    /// </ul>
187    /// <p>For more information about cron expressions, see <a href="https://en.wikipedia.org/wiki/Cron">cron</a> on the <i>Wikipedia website</i>.</p>
188    pub fn cron_expression(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
189        self.inner = self.inner.cron_expression(input.into());
190        self
191    }
192    /// <p>The cron expression for the event window, for example, <code>* 0-4,20-23 * * 1,5</code>. If you specify a cron expression, you can't specify a time range.</p>
193    /// <p>Constraints:</p>
194    /// <ul>
195    /// <li>
196    /// <p>Only hour and day of the week values are supported.</p></li>
197    /// <li>
198    /// <p>For day of the week values, you can specify either integers <code>0</code> through <code>6</code>, or alternative single values <code>SUN</code> through <code>SAT</code>.</p></li>
199    /// <li>
200    /// <p>The minute, month, and year must be specified by <code>*</code>.</p></li>
201    /// <li>
202    /// <p>The hour value must be one or a multiple range, for example, <code>0-4</code> or <code>0-4,20-23</code>.</p></li>
203    /// <li>
204    /// <p>Each hour range must be &gt;= 2 hours, for example, <code>0-2</code> or <code>20-23</code>.</p></li>
205    /// <li>
206    /// <p>The event window must be &gt;= 4 hours. The combined total time ranges in the event window must be &gt;= 4 hours.</p></li>
207    /// </ul>
208    /// <p>For more information about cron expressions, see <a href="https://en.wikipedia.org/wiki/Cron">cron</a> on the <i>Wikipedia website</i>.</p>
209    pub fn set_cron_expression(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
210        self.inner = self.inner.set_cron_expression(input);
211        self
212    }
213    /// <p>The cron expression for the event window, for example, <code>* 0-4,20-23 * * 1,5</code>. If you specify a cron expression, you can't specify a time range.</p>
214    /// <p>Constraints:</p>
215    /// <ul>
216    /// <li>
217    /// <p>Only hour and day of the week values are supported.</p></li>
218    /// <li>
219    /// <p>For day of the week values, you can specify either integers <code>0</code> through <code>6</code>, or alternative single values <code>SUN</code> through <code>SAT</code>.</p></li>
220    /// <li>
221    /// <p>The minute, month, and year must be specified by <code>*</code>.</p></li>
222    /// <li>
223    /// <p>The hour value must be one or a multiple range, for example, <code>0-4</code> or <code>0-4,20-23</code>.</p></li>
224    /// <li>
225    /// <p>Each hour range must be &gt;= 2 hours, for example, <code>0-2</code> or <code>20-23</code>.</p></li>
226    /// <li>
227    /// <p>The event window must be &gt;= 4 hours. The combined total time ranges in the event window must be &gt;= 4 hours.</p></li>
228    /// </ul>
229    /// <p>For more information about cron expressions, see <a href="https://en.wikipedia.org/wiki/Cron">cron</a> on the <i>Wikipedia website</i>.</p>
230    pub fn get_cron_expression(&self) -> &::std::option::Option<::std::string::String> {
231        self.inner.get_cron_expression()
232    }
233    ///
234    /// Appends an item to `TagSpecifications`.
235    ///
236    /// To override the contents of this collection use [`set_tag_specifications`](Self::set_tag_specifications).
237    ///
238    /// <p>The tags to apply to the event window.</p>
239    pub fn tag_specifications(mut self, input: crate::types::TagSpecification) -> Self {
240        self.inner = self.inner.tag_specifications(input);
241        self
242    }
243    /// <p>The tags to apply to the event window.</p>
244    pub fn set_tag_specifications(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>>) -> Self {
245        self.inner = self.inner.set_tag_specifications(input);
246        self
247    }
248    /// <p>The tags to apply to the event window.</p>
249    pub fn get_tag_specifications(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::TagSpecification>> {
250        self.inner.get_tag_specifications()
251    }
252}