aws_sdk_kms/operation/update_alias/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::update_alias::_update_alias_output::UpdateAliasOutputBuilder;
3
4pub use crate::operation::update_alias::_update_alias_input::UpdateAliasInputBuilder;
5
6impl crate::operation::update_alias::builders::UpdateAliasInputBuilder {
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_alias::UpdateAliasOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::update_alias::UpdateAliasError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.update_alias();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `UpdateAlias`.
24///
25/// <p>Associates an existing KMS alias with a different KMS key. Each alias is associated with only one KMS key at a time, although a KMS key can have multiple aliases. The alias and the KMS key must be in the same Amazon Web Services account and Region.</p><note>
26/// <p>Adding, deleting, or updating an alias can allow or deny permission to the KMS key. For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/abac.html">ABAC for KMS</a> in the <i>Key Management Service Developer Guide</i>.</p>
27/// </note>
28/// <p>The current and new KMS key must be the same type (both symmetric or both asymmetric or both HMAC), and they must have the same key usage. This restriction prevents errors in code that uses aliases. If you must assign an alias to a different type of KMS key, use <code>DeleteAlias</code> to delete the old alias and <code>CreateAlias</code> to create a new alias.</p>
29/// <p>You cannot use <code>UpdateAlias</code> to change an alias name. To change an alias name, use <code>DeleteAlias</code> to delete the old alias and <code>CreateAlias</code> to create a new alias.</p>
30/// <p>Because an alias is not a property of a KMS key, you can create, update, and delete the aliases of a KMS key without affecting the KMS key. Also, aliases do not appear in the response from the <code>DescribeKey</code> operation. To get the aliases of all KMS keys in the account, use the <code>ListAliases</code> operation.</p>
31/// <p>The KMS key that you use for this operation must be in a compatible key state. For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html">Key states of KMS keys</a> in the <i>Key Management Service Developer Guide</i>.</p>
32/// <p><b>Cross-account use</b>: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.</p>
33/// <p><b>Required permissions</b></p>
34/// <ul>
35/// <li>
36/// <p><a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:UpdateAlias</a> on the alias (IAM policy).</p></li>
37/// <li>
38/// <p><a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:UpdateAlias</a> on the current KMS key (key policy).</p></li>
39/// <li>
40/// <p><a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:UpdateAlias</a> on the new KMS key (key policy).</p></li>
41/// </ul>
42/// <p>For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-alias.html#alias-access">Controlling access to aliases</a> in the <i>Key Management Service Developer Guide</i>.</p>
43/// <p><b>Related operations:</b></p>
44/// <ul>
45/// <li>
46/// <p><code>CreateAlias</code></p></li>
47/// <li>
48/// <p><code>DeleteAlias</code></p></li>
49/// <li>
50/// <p><code>ListAliases</code></p></li>
51/// </ul>
52/// <p><b>Eventual consistency</b>: The KMS API follows an eventual consistency model. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/programming-eventual-consistency.html">KMS eventual consistency</a>.</p>
53#[derive(::std::clone::Clone, ::std::fmt::Debug)]
54pub struct UpdateAliasFluentBuilder {
55    handle: ::std::sync::Arc<crate::client::Handle>,
56    inner: crate::operation::update_alias::builders::UpdateAliasInputBuilder,
57    config_override: ::std::option::Option<crate::config::Builder>,
58}
59impl
60    crate::client::customize::internal::CustomizableSend<
61        crate::operation::update_alias::UpdateAliasOutput,
62        crate::operation::update_alias::UpdateAliasError,
63    > for UpdateAliasFluentBuilder
64{
65    fn send(
66        self,
67        config_override: crate::config::Builder,
68    ) -> crate::client::customize::internal::BoxFuture<
69        crate::client::customize::internal::SendResult<
70            crate::operation::update_alias::UpdateAliasOutput,
71            crate::operation::update_alias::UpdateAliasError,
72        >,
73    > {
74        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
75    }
76}
77impl UpdateAliasFluentBuilder {
78    /// Creates a new `UpdateAliasFluentBuilder`.
79    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
80        Self {
81            handle,
82            inner: ::std::default::Default::default(),
83            config_override: ::std::option::Option::None,
84        }
85    }
86    /// Access the UpdateAlias as a reference.
87    pub fn as_input(&self) -> &crate::operation::update_alias::builders::UpdateAliasInputBuilder {
88        &self.inner
89    }
90    /// Sends the request and returns the response.
91    ///
92    /// If an error occurs, an `SdkError` will be returned with additional details that
93    /// can be matched against.
94    ///
95    /// By default, any retryable failures will be retried twice. Retry behavior
96    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
97    /// set when configuring the client.
98    pub async fn send(
99        self,
100    ) -> ::std::result::Result<
101        crate::operation::update_alias::UpdateAliasOutput,
102        ::aws_smithy_runtime_api::client::result::SdkError<
103            crate::operation::update_alias::UpdateAliasError,
104            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
105        >,
106    > {
107        let input = self
108            .inner
109            .build()
110            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
111        let runtime_plugins = crate::operation::update_alias::UpdateAlias::operation_runtime_plugins(
112            self.handle.runtime_plugins.clone(),
113            &self.handle.conf,
114            self.config_override,
115        );
116        crate::operation::update_alias::UpdateAlias::orchestrate(&runtime_plugins, input).await
117    }
118
119    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
120    pub fn customize(
121        self,
122    ) -> crate::client::customize::CustomizableOperation<
123        crate::operation::update_alias::UpdateAliasOutput,
124        crate::operation::update_alias::UpdateAliasError,
125        Self,
126    > {
127        crate::client::customize::CustomizableOperation::new(self)
128    }
129    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
130        self.set_config_override(::std::option::Option::Some(config_override.into()));
131        self
132    }
133
134    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
135        self.config_override = config_override;
136        self
137    }
138    /// <p>Identifies the alias that is changing its KMS key. This value must begin with <code>alias/</code> followed by the alias name, such as <code>alias/ExampleAlias</code>. You cannot use <code>UpdateAlias</code> to change the alias name.</p><important>
139    /// <p>Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output.</p>
140    /// </important>
141    pub fn alias_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
142        self.inner = self.inner.alias_name(input.into());
143        self
144    }
145    /// <p>Identifies the alias that is changing its KMS key. This value must begin with <code>alias/</code> followed by the alias name, such as <code>alias/ExampleAlias</code>. You cannot use <code>UpdateAlias</code> to change the alias name.</p><important>
146    /// <p>Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output.</p>
147    /// </important>
148    pub fn set_alias_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
149        self.inner = self.inner.set_alias_name(input);
150        self
151    }
152    /// <p>Identifies the alias that is changing its KMS key. This value must begin with <code>alias/</code> followed by the alias name, such as <code>alias/ExampleAlias</code>. You cannot use <code>UpdateAlias</code> to change the alias name.</p><important>
153    /// <p>Do not include confidential or sensitive information in this field. This field may be displayed in plaintext in CloudTrail logs and other output.</p>
154    /// </important>
155    pub fn get_alias_name(&self) -> &::std::option::Option<::std::string::String> {
156        self.inner.get_alias_name()
157    }
158    /// <p>Identifies the <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk">customer managed key</a> to associate with the alias. You don't have permission to associate an alias with an <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk">Amazon Web Services managed key</a>.</p>
159    /// <p>The KMS key must be in the same Amazon Web Services account and Region as the alias. Also, the new target KMS key must be the same type as the current target KMS key (both symmetric or both asymmetric or both HMAC) and they must have the same key usage.</p>
160    /// <p>Specify the key ID or key ARN of the KMS key.</p>
161    /// <p>For example:</p>
162    /// <ul>
163    /// <li>
164    /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
165    /// <li>
166    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
167    /// </ul>
168    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
169    /// <p>To verify that the alias is mapped to the correct KMS key, use <code>ListAliases</code>.</p>
170    pub fn target_key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
171        self.inner = self.inner.target_key_id(input.into());
172        self
173    }
174    /// <p>Identifies the <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk">customer managed key</a> to associate with the alias. You don't have permission to associate an alias with an <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk">Amazon Web Services managed key</a>.</p>
175    /// <p>The KMS key must be in the same Amazon Web Services account and Region as the alias. Also, the new target KMS key must be the same type as the current target KMS key (both symmetric or both asymmetric or both HMAC) and they must have the same key usage.</p>
176    /// <p>Specify the key ID or key ARN of the KMS key.</p>
177    /// <p>For example:</p>
178    /// <ul>
179    /// <li>
180    /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
181    /// <li>
182    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
183    /// </ul>
184    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
185    /// <p>To verify that the alias is mapped to the correct KMS key, use <code>ListAliases</code>.</p>
186    pub fn set_target_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
187        self.inner = self.inner.set_target_key_id(input);
188        self
189    }
190    /// <p>Identifies the <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk">customer managed key</a> to associate with the alias. You don't have permission to associate an alias with an <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk">Amazon Web Services managed key</a>.</p>
191    /// <p>The KMS key must be in the same Amazon Web Services account and Region as the alias. Also, the new target KMS key must be the same type as the current target KMS key (both symmetric or both asymmetric or both HMAC) and they must have the same key usage.</p>
192    /// <p>Specify the key ID or key ARN of the KMS key.</p>
193    /// <p>For example:</p>
194    /// <ul>
195    /// <li>
196    /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
197    /// <li>
198    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
199    /// </ul>
200    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
201    /// <p>To verify that the alias is mapped to the correct KMS key, use <code>ListAliases</code>.</p>
202    pub fn get_target_key_id(&self) -> &::std::option::Option<::std::string::String> {
203        self.inner.get_target_key_id()
204    }
205}