aws_sdk_ecs/operation/stop_task/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::stop_task::_stop_task_output::StopTaskOutputBuilder;
3
4pub use crate::operation::stop_task::_stop_task_input::StopTaskInputBuilder;
5
6impl crate::operation::stop_task::builders::StopTaskInputBuilder {
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::stop_task::StopTaskOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::stop_task::StopTaskError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.stop_task();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `StopTask`.
24///
25/// <p>Stops a running task. Any tags associated with the task will be deleted.</p>
26/// <p>When you call <code>StopTask</code> on a task, the equivalent of <code>docker stop</code> is issued to the containers running in the task. This results in a <code>SIGTERM</code> value and a default 30-second timeout, after which the <code>SIGKILL</code> value is sent and the containers are forcibly stopped. If the container handles the <code>SIGTERM</code> value gracefully and exits within 30 seconds from receiving it, no <code>SIGKILL</code> value is sent.</p>
27/// <p>For Windows containers, POSIX signals do not work and runtime stops the container by sending a <code>CTRL_SHUTDOWN_EVENT</code>. For more information, see <a href="https://github.com/moby/moby/issues/25982">Unable to react to graceful shutdown of (Windows) container #25982</a> on GitHub.</p><note>
28/// <p>The default 30-second timeout can be configured on the Amazon ECS container agent with the <code>ECS_CONTAINER_STOP_TIMEOUT</code> variable. For more information, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html">Amazon ECS Container Agent Configuration</a> in the <i>Amazon Elastic Container Service Developer Guide</i>.</p>
29/// </note>
30#[derive(::std::clone::Clone, ::std::fmt::Debug)]
31pub struct StopTaskFluentBuilder {
32    handle: ::std::sync::Arc<crate::client::Handle>,
33    inner: crate::operation::stop_task::builders::StopTaskInputBuilder,
34    config_override: ::std::option::Option<crate::config::Builder>,
35}
36impl crate::client::customize::internal::CustomizableSend<crate::operation::stop_task::StopTaskOutput, crate::operation::stop_task::StopTaskError>
37    for StopTaskFluentBuilder
38{
39    fn send(
40        self,
41        config_override: crate::config::Builder,
42    ) -> crate::client::customize::internal::BoxFuture<
43        crate::client::customize::internal::SendResult<crate::operation::stop_task::StopTaskOutput, crate::operation::stop_task::StopTaskError>,
44    > {
45        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
46    }
47}
48impl StopTaskFluentBuilder {
49    /// Creates a new `StopTaskFluentBuilder`.
50    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
51        Self {
52            handle,
53            inner: ::std::default::Default::default(),
54            config_override: ::std::option::Option::None,
55        }
56    }
57    /// Access the StopTask as a reference.
58    pub fn as_input(&self) -> &crate::operation::stop_task::builders::StopTaskInputBuilder {
59        &self.inner
60    }
61    /// Sends the request and returns the response.
62    ///
63    /// If an error occurs, an `SdkError` will be returned with additional details that
64    /// can be matched against.
65    ///
66    /// By default, any retryable failures will be retried twice. Retry behavior
67    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
68    /// set when configuring the client.
69    pub async fn send(
70        self,
71    ) -> ::std::result::Result<
72        crate::operation::stop_task::StopTaskOutput,
73        ::aws_smithy_runtime_api::client::result::SdkError<
74            crate::operation::stop_task::StopTaskError,
75            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
76        >,
77    > {
78        let input = self
79            .inner
80            .build()
81            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
82        let runtime_plugins = crate::operation::stop_task::StopTask::operation_runtime_plugins(
83            self.handle.runtime_plugins.clone(),
84            &self.handle.conf,
85            self.config_override,
86        );
87        crate::operation::stop_task::StopTask::orchestrate(&runtime_plugins, input).await
88    }
89
90    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
91    pub fn customize(
92        self,
93    ) -> crate::client::customize::CustomizableOperation<crate::operation::stop_task::StopTaskOutput, crate::operation::stop_task::StopTaskError, Self>
94    {
95        crate::client::customize::CustomizableOperation::new(self)
96    }
97    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
98        self.set_config_override(::std::option::Option::Some(config_override.into()));
99        self
100    }
101
102    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
103        self.config_override = config_override;
104        self
105    }
106    /// <p>The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task to stop. If you do not specify a cluster, the default cluster is assumed.</p>
107    pub fn cluster(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
108        self.inner = self.inner.cluster(input.into());
109        self
110    }
111    /// <p>The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task to stop. If you do not specify a cluster, the default cluster is assumed.</p>
112    pub fn set_cluster(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
113        self.inner = self.inner.set_cluster(input);
114        self
115    }
116    /// <p>The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task to stop. If you do not specify a cluster, the default cluster is assumed.</p>
117    pub fn get_cluster(&self) -> &::std::option::Option<::std::string::String> {
118        self.inner.get_cluster()
119    }
120    /// <p>Thefull Amazon Resource Name (ARN) of the task.</p>
121    pub fn task(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
122        self.inner = self.inner.task(input.into());
123        self
124    }
125    /// <p>Thefull Amazon Resource Name (ARN) of the task.</p>
126    pub fn set_task(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
127        self.inner = self.inner.set_task(input);
128        self
129    }
130    /// <p>Thefull Amazon Resource Name (ARN) of the task.</p>
131    pub fn get_task(&self) -> &::std::option::Option<::std::string::String> {
132        self.inner.get_task()
133    }
134    /// <p>An optional message specified when a task is stopped. For example, if you're using a custom scheduler, you can use this parameter to specify the reason for stopping the task here, and the message appears in subsequent <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTasks.html">DescribeTasks</a>&gt; API operations on this task.</p>
135    pub fn reason(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
136        self.inner = self.inner.reason(input.into());
137        self
138    }
139    /// <p>An optional message specified when a task is stopped. For example, if you're using a custom scheduler, you can use this parameter to specify the reason for stopping the task here, and the message appears in subsequent <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTasks.html">DescribeTasks</a>&gt; API operations on this task.</p>
140    pub fn set_reason(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
141        self.inner = self.inner.set_reason(input);
142        self
143    }
144    /// <p>An optional message specified when a task is stopped. For example, if you're using a custom scheduler, you can use this parameter to specify the reason for stopping the task here, and the message appears in subsequent <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTasks.html">DescribeTasks</a>&gt; API operations on this task.</p>
145    pub fn get_reason(&self) -> &::std::option::Option<::std::string::String> {
146        self.inner.get_reason()
147    }
148}