aws_sdk_kms/operation/update_primary_region/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::update_primary_region::_update_primary_region_output::UpdatePrimaryRegionOutputBuilder;
3
4pub use crate::operation::update_primary_region::_update_primary_region_input::UpdatePrimaryRegionInputBuilder;
5
6impl crate::operation::update_primary_region::builders::UpdatePrimaryRegionInputBuilder {
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_primary_region::UpdatePrimaryRegionOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::update_primary_region::UpdatePrimaryRegionError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.update_primary_region();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `UpdatePrimaryRegion`.
24///
25/// <p>Changes the primary key of a multi-Region key.</p>
26/// <p>This operation changes the replica key in the specified Region to a primary key and changes the former primary key to a replica key. For example, suppose you have a primary key in <code>us-east-1</code> and a replica key in <code>eu-west-2</code>. If you run <code>UpdatePrimaryRegion</code> with a <code>PrimaryRegion</code> value of <code>eu-west-2</code>, the primary key is now the key in <code>eu-west-2</code>, and the key in <code>us-east-1</code> becomes a replica key. For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-manage.html#multi-region-update">Updating the primary Region</a> in the <i>Key Management Service Developer Guide</i>.</p>
27/// <p>This operation supports <i>multi-Region keys</i>, an KMS feature that lets you create multiple interoperable KMS keys in different Amazon Web Services Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them interchangeably to encrypt data in one Amazon Web Services Region and decrypt it in a different Amazon Web Services Region without re-encrypting the data or making a cross-Region call. For more information about multi-Region keys, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html">Multi-Region keys in KMS</a> in the <i>Key Management Service Developer Guide</i>.</p>
28/// <p>The <i>primary key</i> of a multi-Region key is the source for properties that are always shared by primary and replica keys, including the key material, <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-id-key-id">key ID</a>, <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-spec">key spec</a>, <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-usage">key usage</a>, <a href="https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#key-origin">key material origin</a>, and <a href="https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html">automatic key rotation</a>. It's the only key that can be replicated. You cannot <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_ScheduleKeyDeletion.html">delete the primary key</a> until all replica keys are deleted.</p>
29/// <p>The key ID and primary Region that you specify uniquely identify the replica key that will become the primary key. The primary Region must already have a replica key. This operation does not create a KMS key in the specified Region. To find the replica keys, use the <code>DescribeKey</code> operation on the primary key or any replica key. To create a replica key, use the <code>ReplicateKey</code> operation.</p>
30/// <p>You can run this operation while using the affected multi-Region keys in cryptographic operations. This operation should not delay, interrupt, or cause failures in cryptographic operations.</p>
31/// <p>Even after this operation completes, the process of updating the primary Region might still be in progress for a few more seconds. Operations such as <code>DescribeKey</code> might display both the old and new primary keys as replicas. The old and new primary keys have a transient key state of <code>Updating</code>. The original key state is restored when the update is complete. While the key state is <code>Updating</code>, you can use the keys in cryptographic operations, but you cannot replicate the new primary key or perform certain management operations, such as enabling or disabling these keys. For details about the <code>Updating</code> key state, 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>This operation does not return any output. To verify that primary key is changed, use the <code>DescribeKey</code> operation.</p>
33/// <p><b>Cross-account use</b>: No. You cannot use this operation in a different Amazon Web Services account.</p>
34/// <p><b>Required permissions</b>:</p>
35/// <ul>
36/// <li>
37/// <p><code>kms:UpdatePrimaryRegion</code> on the current primary key (in the primary key's Region). Include this permission primary key's key policy.</p></li>
38/// <li>
39/// <p><code>kms:UpdatePrimaryRegion</code> on the current replica key (in the replica key's Region). Include this permission in the replica key's key policy.</p></li>
40/// </ul>
41/// <p><b>Related operations</b></p>
42/// <ul>
43/// <li>
44/// <p><code>CreateKey</code></p></li>
45/// <li>
46/// <p><code>ReplicateKey</code></p></li>
47/// </ul>
48/// <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>
49#[derive(::std::clone::Clone, ::std::fmt::Debug)]
50pub struct UpdatePrimaryRegionFluentBuilder {
51    handle: ::std::sync::Arc<crate::client::Handle>,
52    inner: crate::operation::update_primary_region::builders::UpdatePrimaryRegionInputBuilder,
53    config_override: ::std::option::Option<crate::config::Builder>,
54}
55impl
56    crate::client::customize::internal::CustomizableSend<
57        crate::operation::update_primary_region::UpdatePrimaryRegionOutput,
58        crate::operation::update_primary_region::UpdatePrimaryRegionError,
59    > for UpdatePrimaryRegionFluentBuilder
60{
61    fn send(
62        self,
63        config_override: crate::config::Builder,
64    ) -> crate::client::customize::internal::BoxFuture<
65        crate::client::customize::internal::SendResult<
66            crate::operation::update_primary_region::UpdatePrimaryRegionOutput,
67            crate::operation::update_primary_region::UpdatePrimaryRegionError,
68        >,
69    > {
70        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
71    }
72}
73impl UpdatePrimaryRegionFluentBuilder {
74    /// Creates a new `UpdatePrimaryRegionFluentBuilder`.
75    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
76        Self {
77            handle,
78            inner: ::std::default::Default::default(),
79            config_override: ::std::option::Option::None,
80        }
81    }
82    /// Access the UpdatePrimaryRegion as a reference.
83    pub fn as_input(&self) -> &crate::operation::update_primary_region::builders::UpdatePrimaryRegionInputBuilder {
84        &self.inner
85    }
86    /// Sends the request and returns the response.
87    ///
88    /// If an error occurs, an `SdkError` will be returned with additional details that
89    /// can be matched against.
90    ///
91    /// By default, any retryable failures will be retried twice. Retry behavior
92    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
93    /// set when configuring the client.
94    pub async fn send(
95        self,
96    ) -> ::std::result::Result<
97        crate::operation::update_primary_region::UpdatePrimaryRegionOutput,
98        ::aws_smithy_runtime_api::client::result::SdkError<
99            crate::operation::update_primary_region::UpdatePrimaryRegionError,
100            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
101        >,
102    > {
103        let input = self
104            .inner
105            .build()
106            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
107        let runtime_plugins = crate::operation::update_primary_region::UpdatePrimaryRegion::operation_runtime_plugins(
108            self.handle.runtime_plugins.clone(),
109            &self.handle.conf,
110            self.config_override,
111        );
112        crate::operation::update_primary_region::UpdatePrimaryRegion::orchestrate(&runtime_plugins, input).await
113    }
114
115    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
116    pub fn customize(
117        self,
118    ) -> crate::client::customize::CustomizableOperation<
119        crate::operation::update_primary_region::UpdatePrimaryRegionOutput,
120        crate::operation::update_primary_region::UpdatePrimaryRegionError,
121        Self,
122    > {
123        crate::client::customize::CustomizableOperation::new(self)
124    }
125    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
126        self.set_config_override(::std::option::Option::Some(config_override.into()));
127        self
128    }
129
130    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
131        self.config_override = config_override;
132        self
133    }
134    /// <p>Identifies the current primary key. When the operation completes, this KMS key will be a replica key.</p>
135    /// <p>Specify the key ID or key ARN of a multi-Region primary key.</p>
136    /// <p>For example:</p>
137    /// <ul>
138    /// <li>
139    /// <p>Key ID: <code>mrk-1234abcd12ab34cd56ef1234567890ab</code></p></li>
140    /// <li>
141    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/mrk-1234abcd12ab34cd56ef1234567890ab</code></p></li>
142    /// </ul>
143    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
144    pub fn key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
145        self.inner = self.inner.key_id(input.into());
146        self
147    }
148    /// <p>Identifies the current primary key. When the operation completes, this KMS key will be a replica key.</p>
149    /// <p>Specify the key ID or key ARN of a multi-Region primary key.</p>
150    /// <p>For example:</p>
151    /// <ul>
152    /// <li>
153    /// <p>Key ID: <code>mrk-1234abcd12ab34cd56ef1234567890ab</code></p></li>
154    /// <li>
155    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/mrk-1234abcd12ab34cd56ef1234567890ab</code></p></li>
156    /// </ul>
157    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
158    pub fn set_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
159        self.inner = self.inner.set_key_id(input);
160        self
161    }
162    /// <p>Identifies the current primary key. When the operation completes, this KMS key will be a replica key.</p>
163    /// <p>Specify the key ID or key ARN of a multi-Region primary key.</p>
164    /// <p>For example:</p>
165    /// <ul>
166    /// <li>
167    /// <p>Key ID: <code>mrk-1234abcd12ab34cd56ef1234567890ab</code></p></li>
168    /// <li>
169    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/mrk-1234abcd12ab34cd56ef1234567890ab</code></p></li>
170    /// </ul>
171    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
172    pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
173        self.inner.get_key_id()
174    }
175    /// <p>The Amazon Web Services Region of the new primary key. Enter the Region ID, such as <code>us-east-1</code> or <code>ap-southeast-2</code>. There must be an existing replica key in this Region.</p>
176    /// <p>When the operation completes, the multi-Region key in this Region will be the primary key.</p>
177    pub fn primary_region(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
178        self.inner = self.inner.primary_region(input.into());
179        self
180    }
181    /// <p>The Amazon Web Services Region of the new primary key. Enter the Region ID, such as <code>us-east-1</code> or <code>ap-southeast-2</code>. There must be an existing replica key in this Region.</p>
182    /// <p>When the operation completes, the multi-Region key in this Region will be the primary key.</p>
183    pub fn set_primary_region(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
184        self.inner = self.inner.set_primary_region(input);
185        self
186    }
187    /// <p>The Amazon Web Services Region of the new primary key. Enter the Region ID, such as <code>us-east-1</code> or <code>ap-southeast-2</code>. There must be an existing replica key in this Region.</p>
188    /// <p>When the operation completes, the multi-Region key in this Region will be the primary key.</p>
189    pub fn get_primary_region(&self) -> &::std::option::Option<::std::string::String> {
190        self.inner.get_primary_region()
191    }
192}