aws_sdk_ecs/operation/update_task_protection/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::update_task_protection::_update_task_protection_output::UpdateTaskProtectionOutputBuilder;
3
4pub use crate::operation::update_task_protection::_update_task_protection_input::UpdateTaskProtectionInputBuilder;
5
6impl crate::operation::update_task_protection::builders::UpdateTaskProtectionInputBuilder {
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::update_task_protection::UpdateTaskProtectionOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::update_task_protection::UpdateTaskProtectionError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.update_task_protection();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `UpdateTaskProtection`.
24///
25/// <p>Updates the protection status of a task. You can set <code>protectionEnabled</code> to <code>true</code> to protect your task from termination during scale-in events from <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html">Service Autoscaling</a> or <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html">deployments</a>.</p>
26/// <p>Task-protection, by default, expires after 2 hours at which point Amazon ECS clears the <code>protectionEnabled</code> property making the task eligible for termination by a subsequent scale-in event.</p>
27/// <p>You can specify a custom expiration period for task protection from 1 minute to up to 2,880 minutes (48 hours). To specify the custom expiration period, set the <code>expiresInMinutes</code> property. The <code>expiresInMinutes</code> property is always reset when you invoke this operation for a task that already has <code>protectionEnabled</code> set to <code>true</code>. You can keep extending the protection expiration period of a task by invoking this operation repeatedly.</p>
28/// <p>To learn more about Amazon ECS task protection, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-scale-in-protection.html">Task scale-in protection</a> in the <i> <i>Amazon Elastic Container Service Developer Guide</i> </i>.</p><note>
29/// <p>This operation is only supported for tasks belonging to an Amazon ECS service. Invoking this operation for a standalone task will result in an <code>TASK_NOT_VALID</code> failure. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/api_failures_messages.html">API failure reasons</a>.</p>
30/// </note> <important>
31/// <p>If you prefer to set task protection from within the container, we recommend using the <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-scale-in-protection-endpoint.html">Task scale-in protection endpoint</a>.</p>
32/// </important>
33#[derive(::std::clone::Clone, ::std::fmt::Debug)]
34pub struct UpdateTaskProtectionFluentBuilder {
35    handle: ::std::sync::Arc<crate::client::Handle>,
36    inner: crate::operation::update_task_protection::builders::UpdateTaskProtectionInputBuilder,
37    config_override: ::std::option::Option<crate::config::Builder>,
38}
39impl
40    crate::client::customize::internal::CustomizableSend<
41        crate::operation::update_task_protection::UpdateTaskProtectionOutput,
42        crate::operation::update_task_protection::UpdateTaskProtectionError,
43    > for UpdateTaskProtectionFluentBuilder
44{
45    fn send(
46        self,
47        config_override: crate::config::Builder,
48    ) -> crate::client::customize::internal::BoxFuture<
49        crate::client::customize::internal::SendResult<
50            crate::operation::update_task_protection::UpdateTaskProtectionOutput,
51            crate::operation::update_task_protection::UpdateTaskProtectionError,
52        >,
53    > {
54        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
55    }
56}
57impl UpdateTaskProtectionFluentBuilder {
58    /// Creates a new `UpdateTaskProtectionFluentBuilder`.
59    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
60        Self {
61            handle,
62            inner: ::std::default::Default::default(),
63            config_override: ::std::option::Option::None,
64        }
65    }
66    /// Access the UpdateTaskProtection as a reference.
67    pub fn as_input(&self) -> &crate::operation::update_task_protection::builders::UpdateTaskProtectionInputBuilder {
68        &self.inner
69    }
70    /// Sends the request and returns the response.
71    ///
72    /// If an error occurs, an `SdkError` will be returned with additional details that
73    /// can be matched against.
74    ///
75    /// By default, any retryable failures will be retried twice. Retry behavior
76    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
77    /// set when configuring the client.
78    pub async fn send(
79        self,
80    ) -> ::std::result::Result<
81        crate::operation::update_task_protection::UpdateTaskProtectionOutput,
82        ::aws_smithy_runtime_api::client::result::SdkError<
83            crate::operation::update_task_protection::UpdateTaskProtectionError,
84            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
85        >,
86    > {
87        let input = self
88            .inner
89            .build()
90            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
91        let runtime_plugins = crate::operation::update_task_protection::UpdateTaskProtection::operation_runtime_plugins(
92            self.handle.runtime_plugins.clone(),
93            &self.handle.conf,
94            self.config_override,
95        );
96        crate::operation::update_task_protection::UpdateTaskProtection::orchestrate(&runtime_plugins, input).await
97    }
98
99    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
100    pub fn customize(
101        self,
102    ) -> crate::client::customize::CustomizableOperation<
103        crate::operation::update_task_protection::UpdateTaskProtectionOutput,
104        crate::operation::update_task_protection::UpdateTaskProtectionError,
105        Self,
106    > {
107        crate::client::customize::CustomizableOperation::new(self)
108    }
109    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
110        self.set_config_override(::std::option::Option::Some(config_override.into()));
111        self
112    }
113
114    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
115        self.config_override = config_override;
116        self
117    }
118    /// <p>The short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.</p>
119    pub fn cluster(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
120        self.inner = self.inner.cluster(input.into());
121        self
122    }
123    /// <p>The short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.</p>
124    pub fn set_cluster(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
125        self.inner = self.inner.set_cluster(input);
126        self
127    }
128    /// <p>The short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.</p>
129    pub fn get_cluster(&self) -> &::std::option::Option<::std::string::String> {
130        self.inner.get_cluster()
131    }
132    ///
133    /// Appends an item to `tasks`.
134    ///
135    /// To override the contents of this collection use [`set_tasks`](Self::set_tasks).
136    ///
137    /// <p>A list of up to 10 task IDs or full ARN entries.</p>
138    pub fn tasks(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
139        self.inner = self.inner.tasks(input.into());
140        self
141    }
142    /// <p>A list of up to 10 task IDs or full ARN entries.</p>
143    pub fn set_tasks(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
144        self.inner = self.inner.set_tasks(input);
145        self
146    }
147    /// <p>A list of up to 10 task IDs or full ARN entries.</p>
148    pub fn get_tasks(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
149        self.inner.get_tasks()
150    }
151    /// <p>Specify <code>true</code> to mark a task for protection and <code>false</code> to unset protection, making it eligible for termination.</p>
152    pub fn protection_enabled(mut self, input: bool) -> Self {
153        self.inner = self.inner.protection_enabled(input);
154        self
155    }
156    /// <p>Specify <code>true</code> to mark a task for protection and <code>false</code> to unset protection, making it eligible for termination.</p>
157    pub fn set_protection_enabled(mut self, input: ::std::option::Option<bool>) -> Self {
158        self.inner = self.inner.set_protection_enabled(input);
159        self
160    }
161    /// <p>Specify <code>true</code> to mark a task for protection and <code>false</code> to unset protection, making it eligible for termination.</p>
162    pub fn get_protection_enabled(&self) -> &::std::option::Option<bool> {
163        self.inner.get_protection_enabled()
164    }
165    /// <p>If you set <code>protectionEnabled</code> to <code>true</code>, you can specify the duration for task protection in minutes. You can specify a value from 1 minute to up to 2,880 minutes (48 hours). During this time, your task will not be terminated by scale-in events from Service Auto Scaling or deployments. After this time period lapses, <code>protectionEnabled</code> will be reset to <code>false</code>.</p>
166    /// <p>If you don’t specify the time, then the task is automatically protected for 120 minutes (2 hours).</p>
167    pub fn expires_in_minutes(mut self, input: i32) -> Self {
168        self.inner = self.inner.expires_in_minutes(input);
169        self
170    }
171    /// <p>If you set <code>protectionEnabled</code> to <code>true</code>, you can specify the duration for task protection in minutes. You can specify a value from 1 minute to up to 2,880 minutes (48 hours). During this time, your task will not be terminated by scale-in events from Service Auto Scaling or deployments. After this time period lapses, <code>protectionEnabled</code> will be reset to <code>false</code>.</p>
172    /// <p>If you don’t specify the time, then the task is automatically protected for 120 minutes (2 hours).</p>
173    pub fn set_expires_in_minutes(mut self, input: ::std::option::Option<i32>) -> Self {
174        self.inner = self.inner.set_expires_in_minutes(input);
175        self
176    }
177    /// <p>If you set <code>protectionEnabled</code> to <code>true</code>, you can specify the duration for task protection in minutes. You can specify a value from 1 minute to up to 2,880 minutes (48 hours). During this time, your task will not be terminated by scale-in events from Service Auto Scaling or deployments. After this time period lapses, <code>protectionEnabled</code> will be reset to <code>false</code>.</p>
178    /// <p>If you don’t specify the time, then the task is automatically protected for 120 minutes (2 hours).</p>
179    pub fn get_expires_in_minutes(&self) -> &::std::option::Option<i32> {
180        self.inner.get_expires_in_minutes()
181    }
182}