aws_sdk_ec2/operation/attach_volume/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::attach_volume::_attach_volume_output::AttachVolumeOutputBuilder;
3
4pub use crate::operation::attach_volume::_attach_volume_input::AttachVolumeInputBuilder;
5
6impl crate::operation::attach_volume::builders::AttachVolumeInputBuilder {
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::attach_volume::AttachVolumeOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::attach_volume::AttachVolumeError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.attach_volume();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `AttachVolume`.
24///
25/// <p>Attaches an Amazon EBS volume to a <code>running</code> or <code>stopped</code> instance, and exposes it to the instance with the specified device name.</p><note>
26/// <p>The maximum number of Amazon EBS volumes that you can attach to an instance depends on the instance type. If you exceed the volume attachment limit for an instance type, the attachment request fails with the <code>AttachmentLimitExceeded</code> error. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/volume_limits.html">Instance volume limits</a>.</p>
27/// </note>
28/// <p>After you attach an EBS volume, you must make it available for use. For more information, see <a href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-using-volumes.html">Make an EBS volume available for use</a>.</p>
29/// <p>If a volume has an Amazon Web Services Marketplace product code:</p>
30/// <ul>
31/// <li>
32/// <p>The volume can be attached only to a stopped instance.</p></li>
33/// <li>
34/// <p>Amazon Web Services Marketplace product codes are copied from the volume to the instance.</p></li>
35/// <li>
36/// <p>You must be subscribed to the product.</p></li>
37/// <li>
38/// <p>The instance type and operating system of the instance must support the product. For example, you can't detach a volume from a Windows instance and attach it to a Linux instance.</p></li>
39/// </ul>
40/// <p>For more information, see <a href="https://docs.aws.amazon.com/ebs/latest/userguide/ebs-attaching-volume.html">Attach an Amazon EBS volume to an instance</a> in the <i>Amazon EBS User Guide</i>.</p>
41#[derive(::std::clone::Clone, ::std::fmt::Debug)]
42pub struct AttachVolumeFluentBuilder {
43    handle: ::std::sync::Arc<crate::client::Handle>,
44    inner: crate::operation::attach_volume::builders::AttachVolumeInputBuilder,
45    config_override: ::std::option::Option<crate::config::Builder>,
46}
47impl
48    crate::client::customize::internal::CustomizableSend<
49        crate::operation::attach_volume::AttachVolumeOutput,
50        crate::operation::attach_volume::AttachVolumeError,
51    > for AttachVolumeFluentBuilder
52{
53    fn send(
54        self,
55        config_override: crate::config::Builder,
56    ) -> crate::client::customize::internal::BoxFuture<
57        crate::client::customize::internal::SendResult<
58            crate::operation::attach_volume::AttachVolumeOutput,
59            crate::operation::attach_volume::AttachVolumeError,
60        >,
61    > {
62        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
63    }
64}
65impl AttachVolumeFluentBuilder {
66    /// Creates a new `AttachVolumeFluentBuilder`.
67    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
68        Self {
69            handle,
70            inner: ::std::default::Default::default(),
71            config_override: ::std::option::Option::None,
72        }
73    }
74    /// Access the AttachVolume as a reference.
75    pub fn as_input(&self) -> &crate::operation::attach_volume::builders::AttachVolumeInputBuilder {
76        &self.inner
77    }
78    /// Sends the request and returns the response.
79    ///
80    /// If an error occurs, an `SdkError` will be returned with additional details that
81    /// can be matched against.
82    ///
83    /// By default, any retryable failures will be retried twice. Retry behavior
84    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
85    /// set when configuring the client.
86    pub async fn send(
87        self,
88    ) -> ::std::result::Result<
89        crate::operation::attach_volume::AttachVolumeOutput,
90        ::aws_smithy_runtime_api::client::result::SdkError<
91            crate::operation::attach_volume::AttachVolumeError,
92            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
93        >,
94    > {
95        let input = self
96            .inner
97            .build()
98            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
99        let runtime_plugins = crate::operation::attach_volume::AttachVolume::operation_runtime_plugins(
100            self.handle.runtime_plugins.clone(),
101            &self.handle.conf,
102            self.config_override,
103        );
104        crate::operation::attach_volume::AttachVolume::orchestrate(&runtime_plugins, input).await
105    }
106
107    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
108    pub fn customize(
109        self,
110    ) -> crate::client::customize::CustomizableOperation<
111        crate::operation::attach_volume::AttachVolumeOutput,
112        crate::operation::attach_volume::AttachVolumeError,
113        Self,
114    > {
115        crate::client::customize::CustomizableOperation::new(self)
116    }
117    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
118        self.set_config_override(::std::option::Option::Some(config_override.into()));
119        self
120    }
121
122    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
123        self.config_override = config_override;
124        self
125    }
126    /// <p>The device name (for example, <code>/dev/sdh</code> or <code>xvdh</code>).</p>
127    pub fn device(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
128        self.inner = self.inner.device(input.into());
129        self
130    }
131    /// <p>The device name (for example, <code>/dev/sdh</code> or <code>xvdh</code>).</p>
132    pub fn set_device(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
133        self.inner = self.inner.set_device(input);
134        self
135    }
136    /// <p>The device name (for example, <code>/dev/sdh</code> or <code>xvdh</code>).</p>
137    pub fn get_device(&self) -> &::std::option::Option<::std::string::String> {
138        self.inner.get_device()
139    }
140    /// <p>The ID of the instance.</p>
141    pub fn instance_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
142        self.inner = self.inner.instance_id(input.into());
143        self
144    }
145    /// <p>The ID of the instance.</p>
146    pub fn set_instance_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
147        self.inner = self.inner.set_instance_id(input);
148        self
149    }
150    /// <p>The ID of the instance.</p>
151    pub fn get_instance_id(&self) -> &::std::option::Option<::std::string::String> {
152        self.inner.get_instance_id()
153    }
154    /// <p>The ID of the EBS volume. The volume and instance must be within the same Availability Zone.</p>
155    pub fn volume_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
156        self.inner = self.inner.volume_id(input.into());
157        self
158    }
159    /// <p>The ID of the EBS volume. The volume and instance must be within the same Availability Zone.</p>
160    pub fn set_volume_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
161        self.inner = self.inner.set_volume_id(input);
162        self
163    }
164    /// <p>The ID of the EBS volume. The volume and instance must be within the same Availability Zone.</p>
165    pub fn get_volume_id(&self) -> &::std::option::Option<::std::string::String> {
166        self.inner.get_volume_id()
167    }
168    /// <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>
169    pub fn dry_run(mut self, input: bool) -> Self {
170        self.inner = self.inner.dry_run(input);
171        self
172    }
173    /// <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>
174    pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
175        self.inner = self.inner.set_dry_run(input);
176        self
177    }
178    /// <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>
179    pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
180        self.inner.get_dry_run()
181    }
182}