aws_sdk_kms/operation/get_parameters_for_import/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::get_parameters_for_import::_get_parameters_for_import_output::GetParametersForImportOutputBuilder;
3
4pub use crate::operation::get_parameters_for_import::_get_parameters_for_import_input::GetParametersForImportInputBuilder;
5
6impl crate::operation::get_parameters_for_import::builders::GetParametersForImportInputBuilder {
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::get_parameters_for_import::GetParametersForImportOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::get_parameters_for_import::GetParametersForImportError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.get_parameters_for_import();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `GetParametersForImport`.
24///
25/// <p>Returns the public key and an import token you need to import or reimport key material for a KMS key.</p>
26/// <p>By default, KMS keys are created with key material that KMS generates. This operation supports <a href="https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html">Importing key material</a>, an advanced feature that lets you generate and import the cryptographic key material for a KMS key. For more information about importing key material into KMS, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html">Importing key material</a> in the <i>Key Management Service Developer Guide</i>.</p>
27/// <p>Before calling <code>GetParametersForImport</code>, use the <code>CreateKey</code> operation with an <code>Origin</code> value of <code>EXTERNAL</code> to create a KMS key with no key material. You can import key material for a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, or asymmetric signing KMS key. You can also import key material into a <a href="https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html">multi-Region key</a> of any supported type. However, you can't import key material into a KMS key in a <a href="https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html">custom key store</a>. You can also use <code>GetParametersForImport</code> to get a public key and import token to <a href="https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html#reimport-key-material">reimport the original key material</a> into a KMS key whose key material expired or was deleted.</p>
28/// <p><code>GetParametersForImport</code> returns the items that you need to import your key material.</p>
29/// <ul>
30/// <li>
31/// <p>The public key (or "wrapping key") of an RSA key pair that KMS generates.</p>
32/// <p>You will use this public key to encrypt ("wrap") your key material while it's in transit to KMS.</p></li>
33/// <li>
34/// <p>A import token that ensures that KMS can decrypt your key material and associate it with the correct KMS key.</p></li>
35/// </ul>
36/// <p>The public key and its import token are permanently linked and must be used together. Each public key and import token set is valid for 24 hours. The expiration date and time appear in the <code>ParametersValidTo</code> field in the <code>GetParametersForImport</code> response. You cannot use an expired public key or import token in an <code>ImportKeyMaterial</code> request. If your key and token expire, send another <code>GetParametersForImport</code> request.</p>
37/// <p><code>GetParametersForImport</code> requires the following information:</p>
38/// <ul>
39/// <li>
40/// <p>The key ID of the KMS key for which you are importing the key material.</p></li>
41/// <li>
42/// <p>The key spec of the public key ("wrapping key") that you will use to encrypt your key material during import.</p></li>
43/// <li>
44/// <p>The wrapping algorithm that you will use with the public key to encrypt your key material.</p></li>
45/// </ul>
46/// <p>You can use the same or a different public key spec and wrapping algorithm each time you import or reimport the same key material.</p>
47/// <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>
48/// <p><b>Cross-account use</b>: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.</p>
49/// <p><b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:GetParametersForImport</a> (key policy)</p>
50/// <p><b>Related operations:</b></p>
51/// <ul>
52/// <li>
53/// <p><code>ImportKeyMaterial</code></p></li>
54/// <li>
55/// <p><code>DeleteImportedKeyMaterial</code></p></li>
56/// </ul>
57/// <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>
58#[derive(::std::clone::Clone, ::std::fmt::Debug)]
59pub struct GetParametersForImportFluentBuilder {
60    handle: ::std::sync::Arc<crate::client::Handle>,
61    inner: crate::operation::get_parameters_for_import::builders::GetParametersForImportInputBuilder,
62    config_override: ::std::option::Option<crate::config::Builder>,
63}
64impl
65    crate::client::customize::internal::CustomizableSend<
66        crate::operation::get_parameters_for_import::GetParametersForImportOutput,
67        crate::operation::get_parameters_for_import::GetParametersForImportError,
68    > for GetParametersForImportFluentBuilder
69{
70    fn send(
71        self,
72        config_override: crate::config::Builder,
73    ) -> crate::client::customize::internal::BoxFuture<
74        crate::client::customize::internal::SendResult<
75            crate::operation::get_parameters_for_import::GetParametersForImportOutput,
76            crate::operation::get_parameters_for_import::GetParametersForImportError,
77        >,
78    > {
79        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
80    }
81}
82impl GetParametersForImportFluentBuilder {
83    /// Creates a new `GetParametersForImportFluentBuilder`.
84    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
85        Self {
86            handle,
87            inner: ::std::default::Default::default(),
88            config_override: ::std::option::Option::None,
89        }
90    }
91    /// Access the GetParametersForImport as a reference.
92    pub fn as_input(&self) -> &crate::operation::get_parameters_for_import::builders::GetParametersForImportInputBuilder {
93        &self.inner
94    }
95    /// Sends the request and returns the response.
96    ///
97    /// If an error occurs, an `SdkError` will be returned with additional details that
98    /// can be matched against.
99    ///
100    /// By default, any retryable failures will be retried twice. Retry behavior
101    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
102    /// set when configuring the client.
103    pub async fn send(
104        self,
105    ) -> ::std::result::Result<
106        crate::operation::get_parameters_for_import::GetParametersForImportOutput,
107        ::aws_smithy_runtime_api::client::result::SdkError<
108            crate::operation::get_parameters_for_import::GetParametersForImportError,
109            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
110        >,
111    > {
112        let input = self
113            .inner
114            .build()
115            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
116        let runtime_plugins = crate::operation::get_parameters_for_import::GetParametersForImport::operation_runtime_plugins(
117            self.handle.runtime_plugins.clone(),
118            &self.handle.conf,
119            self.config_override,
120        );
121        crate::operation::get_parameters_for_import::GetParametersForImport::orchestrate(&runtime_plugins, input).await
122    }
123
124    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
125    pub fn customize(
126        self,
127    ) -> crate::client::customize::CustomizableOperation<
128        crate::operation::get_parameters_for_import::GetParametersForImportOutput,
129        crate::operation::get_parameters_for_import::GetParametersForImportError,
130        Self,
131    > {
132        crate::client::customize::CustomizableOperation::new(self)
133    }
134    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
135        self.set_config_override(::std::option::Option::Some(config_override.into()));
136        self
137    }
138
139    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
140        self.config_override = config_override;
141        self
142    }
143    /// <p>The identifier of the KMS key that will be associated with the imported key material. The <code>Origin</code> of the KMS key must be <code>EXTERNAL</code>.</p>
144    /// <p>All KMS key types are supported, including multi-Region keys. However, you cannot import key material into a KMS key in a custom key store.</p>
145    /// <p>Specify the key ID or key ARN of the KMS key.</p>
146    /// <p>For example:</p>
147    /// <ul>
148    /// <li>
149    /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
150    /// <li>
151    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
152    /// </ul>
153    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
154    pub fn key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
155        self.inner = self.inner.key_id(input.into());
156        self
157    }
158    /// <p>The identifier of the KMS key that will be associated with the imported key material. The <code>Origin</code> of the KMS key must be <code>EXTERNAL</code>.</p>
159    /// <p>All KMS key types are supported, including multi-Region keys. However, you cannot import key material into a KMS key in a custom key store.</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    pub fn set_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
170        self.inner = self.inner.set_key_id(input);
171        self
172    }
173    /// <p>The identifier of the KMS key that will be associated with the imported key material. The <code>Origin</code> of the KMS key must be <code>EXTERNAL</code>.</p>
174    /// <p>All KMS key types are supported, including multi-Region keys. However, you cannot import key material into a KMS key in a custom key store.</p>
175    /// <p>Specify the key ID or key ARN of the KMS key.</p>
176    /// <p>For example:</p>
177    /// <ul>
178    /// <li>
179    /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
180    /// <li>
181    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
182    /// </ul>
183    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
184    pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
185        self.inner.get_key_id()
186    }
187    /// <p>The algorithm you will use with the RSA public key (<code>PublicKey</code>) in the response to protect your key material during import. For more information, see <a href="kms/latest/developerguide/importing-keys-get-public-key-and-token.html#select-wrapping-algorithm">Select a wrapping algorithm</a> in the <i>Key Management Service Developer Guide</i>.</p>
188    /// <p>For RSA_AES wrapping algorithms, you encrypt your key material with an AES key that you generate, then encrypt your AES key with the RSA public key from KMS. For RSAES wrapping algorithms, you encrypt your key material directly with the RSA public key from KMS.</p>
189    /// <p>The wrapping algorithms that you can use depend on the type of key material that you are importing. To import an RSA private key, you must use an RSA_AES wrapping algorithm.</p>
190    /// <ul>
191    /// <li>
192    /// <p><b>RSA_AES_KEY_WRAP_SHA_256</b> — Supported for wrapping RSA and ECC key material.</p></li>
193    /// <li>
194    /// <p><b>RSA_AES_KEY_WRAP_SHA_1</b> — Supported for wrapping RSA and ECC key material.</p></li>
195    /// <li>
196    /// <p><b>RSAES_OAEP_SHA_256</b> — Supported for all types of key material, except RSA key material (private key).</p>
197    /// <p>You cannot use the RSAES_OAEP_SHA_256 wrapping algorithm with the RSA_2048 wrapping key spec to wrap ECC_NIST_P521 key material.</p></li>
198    /// <li>
199    /// <p><b>RSAES_OAEP_SHA_1</b> — Supported for all types of key material, except RSA key material (private key).</p>
200    /// <p>You cannot use the RSAES_OAEP_SHA_1 wrapping algorithm with the RSA_2048 wrapping key spec to wrap ECC_NIST_P521 key material.</p></li>
201    /// <li>
202    /// <p><b>RSAES_PKCS1_V1_5</b> (Deprecated) — As of October 10, 2023, KMS does not support the RSAES_PKCS1_V1_5 wrapping algorithm.</p></li>
203    /// </ul>
204    pub fn wrapping_algorithm(mut self, input: crate::types::AlgorithmSpec) -> Self {
205        self.inner = self.inner.wrapping_algorithm(input);
206        self
207    }
208    /// <p>The algorithm you will use with the RSA public key (<code>PublicKey</code>) in the response to protect your key material during import. For more information, see <a href="kms/latest/developerguide/importing-keys-get-public-key-and-token.html#select-wrapping-algorithm">Select a wrapping algorithm</a> in the <i>Key Management Service Developer Guide</i>.</p>
209    /// <p>For RSA_AES wrapping algorithms, you encrypt your key material with an AES key that you generate, then encrypt your AES key with the RSA public key from KMS. For RSAES wrapping algorithms, you encrypt your key material directly with the RSA public key from KMS.</p>
210    /// <p>The wrapping algorithms that you can use depend on the type of key material that you are importing. To import an RSA private key, you must use an RSA_AES wrapping algorithm.</p>
211    /// <ul>
212    /// <li>
213    /// <p><b>RSA_AES_KEY_WRAP_SHA_256</b> — Supported for wrapping RSA and ECC key material.</p></li>
214    /// <li>
215    /// <p><b>RSA_AES_KEY_WRAP_SHA_1</b> — Supported for wrapping RSA and ECC key material.</p></li>
216    /// <li>
217    /// <p><b>RSAES_OAEP_SHA_256</b> — Supported for all types of key material, except RSA key material (private key).</p>
218    /// <p>You cannot use the RSAES_OAEP_SHA_256 wrapping algorithm with the RSA_2048 wrapping key spec to wrap ECC_NIST_P521 key material.</p></li>
219    /// <li>
220    /// <p><b>RSAES_OAEP_SHA_1</b> — Supported for all types of key material, except RSA key material (private key).</p>
221    /// <p>You cannot use the RSAES_OAEP_SHA_1 wrapping algorithm with the RSA_2048 wrapping key spec to wrap ECC_NIST_P521 key material.</p></li>
222    /// <li>
223    /// <p><b>RSAES_PKCS1_V1_5</b> (Deprecated) — As of October 10, 2023, KMS does not support the RSAES_PKCS1_V1_5 wrapping algorithm.</p></li>
224    /// </ul>
225    pub fn set_wrapping_algorithm(mut self, input: ::std::option::Option<crate::types::AlgorithmSpec>) -> Self {
226        self.inner = self.inner.set_wrapping_algorithm(input);
227        self
228    }
229    /// <p>The algorithm you will use with the RSA public key (<code>PublicKey</code>) in the response to protect your key material during import. For more information, see <a href="kms/latest/developerguide/importing-keys-get-public-key-and-token.html#select-wrapping-algorithm">Select a wrapping algorithm</a> in the <i>Key Management Service Developer Guide</i>.</p>
230    /// <p>For RSA_AES wrapping algorithms, you encrypt your key material with an AES key that you generate, then encrypt your AES key with the RSA public key from KMS. For RSAES wrapping algorithms, you encrypt your key material directly with the RSA public key from KMS.</p>
231    /// <p>The wrapping algorithms that you can use depend on the type of key material that you are importing. To import an RSA private key, you must use an RSA_AES wrapping algorithm.</p>
232    /// <ul>
233    /// <li>
234    /// <p><b>RSA_AES_KEY_WRAP_SHA_256</b> — Supported for wrapping RSA and ECC key material.</p></li>
235    /// <li>
236    /// <p><b>RSA_AES_KEY_WRAP_SHA_1</b> — Supported for wrapping RSA and ECC key material.</p></li>
237    /// <li>
238    /// <p><b>RSAES_OAEP_SHA_256</b> — Supported for all types of key material, except RSA key material (private key).</p>
239    /// <p>You cannot use the RSAES_OAEP_SHA_256 wrapping algorithm with the RSA_2048 wrapping key spec to wrap ECC_NIST_P521 key material.</p></li>
240    /// <li>
241    /// <p><b>RSAES_OAEP_SHA_1</b> — Supported for all types of key material, except RSA key material (private key).</p>
242    /// <p>You cannot use the RSAES_OAEP_SHA_1 wrapping algorithm with the RSA_2048 wrapping key spec to wrap ECC_NIST_P521 key material.</p></li>
243    /// <li>
244    /// <p><b>RSAES_PKCS1_V1_5</b> (Deprecated) — As of October 10, 2023, KMS does not support the RSAES_PKCS1_V1_5 wrapping algorithm.</p></li>
245    /// </ul>
246    pub fn get_wrapping_algorithm(&self) -> &::std::option::Option<crate::types::AlgorithmSpec> {
247        self.inner.get_wrapping_algorithm()
248    }
249    /// <p>The type of RSA public key to return in the response. You will use this wrapping key with the specified wrapping algorithm to protect your key material during import.</p>
250    /// <p>Use the longest RSA wrapping key that is practical.</p>
251    /// <p>You cannot use an RSA_2048 public key to directly wrap an ECC_NIST_P521 private key. Instead, use an RSA_AES wrapping algorithm or choose a longer RSA public key.</p>
252    pub fn wrapping_key_spec(mut self, input: crate::types::WrappingKeySpec) -> Self {
253        self.inner = self.inner.wrapping_key_spec(input);
254        self
255    }
256    /// <p>The type of RSA public key to return in the response. You will use this wrapping key with the specified wrapping algorithm to protect your key material during import.</p>
257    /// <p>Use the longest RSA wrapping key that is practical.</p>
258    /// <p>You cannot use an RSA_2048 public key to directly wrap an ECC_NIST_P521 private key. Instead, use an RSA_AES wrapping algorithm or choose a longer RSA public key.</p>
259    pub fn set_wrapping_key_spec(mut self, input: ::std::option::Option<crate::types::WrappingKeySpec>) -> Self {
260        self.inner = self.inner.set_wrapping_key_spec(input);
261        self
262    }
263    /// <p>The type of RSA public key to return in the response. You will use this wrapping key with the specified wrapping algorithm to protect your key material during import.</p>
264    /// <p>Use the longest RSA wrapping key that is practical.</p>
265    /// <p>You cannot use an RSA_2048 public key to directly wrap an ECC_NIST_P521 private key. Instead, use an RSA_AES wrapping algorithm or choose a longer RSA public key.</p>
266    pub fn get_wrapping_key_spec(&self) -> &::std::option::Option<crate::types::WrappingKeySpec> {
267        self.inner.get_wrapping_key_spec()
268    }
269}