aws_sdk_kms/operation/import_key_material/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::import_key_material::_import_key_material_output::ImportKeyMaterialOutputBuilder;
3
4pub use crate::operation::import_key_material::_import_key_material_input::ImportKeyMaterialInputBuilder;
5
6impl crate::operation::import_key_material::builders::ImportKeyMaterialInputBuilder {
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::import_key_material::ImportKeyMaterialOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::import_key_material::ImportKeyMaterialError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.import_key_material();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `ImportKeyMaterial`.
24///
25/// <p>Imports or reimports key material into an existing KMS key that was created without key material. <code>ImportKeyMaterial</code> also sets the expiration model and expiration date of the imported key material.</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>After you successfully import key material into a KMS key, you can <a href="https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html#reimport-key-material">reimport the same key material</a> into that KMS key, but you cannot import different key material. You might reimport key material to replace key material that expired or key material that you deleted. You might also reimport key material to change the expiration model or expiration date of the key material.</p>
28/// <p>Each time you import key material into KMS, you can determine whether (<code>ExpirationModel</code>) and when (<code>ValidTo</code>) the key material expires. To change the expiration of your key material, you must import it again, either by calling <code>ImportKeyMaterial</code> or using the <a href="kms/latest/developerguide/importing-keys-import-key-material.html#importing-keys-import-key-material-console">import features</a> of the KMS console.</p>
29/// <p>Before calling <code>ImportKeyMaterial</code>:</p>
30/// <ul>
31/// <li>
32/// <p>Create or identify a KMS key with no key material. The KMS key must have an <code>Origin</code> value of <code>EXTERNAL</code>, which indicates that the KMS key is designed for imported key material.</p>
33/// <p>To create an new KMS key for imported key material, call the <code>CreateKey</code> operation with an <code>Origin</code> value of <code>EXTERNAL</code>. You can create 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="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="kms/latest/developerguide/custom-key-store-overview.html">custom key store</a>.</p></li>
34/// <li>
35/// <p>Use the <code>DescribeKey</code> operation to verify that the <code>KeyState</code> of the KMS key is <code>PendingImport</code>, which indicates that the KMS key has no key material.</p>
36/// <p>If you are reimporting the same key material into an existing KMS key, you might need to call the <code>DeleteImportedKeyMaterial</code> to delete its existing key material.</p></li>
37/// <li>
38/// <p>Call the <code>GetParametersForImport</code> operation to get a public key and import token set for importing key material.</p></li>
39/// <li>
40/// <p>Use the public key in the <code>GetParametersForImport</code> response to encrypt your key material.</p></li>
41/// </ul>
42/// <p>Then, in an <code>ImportKeyMaterial</code> request, you submit your encrypted key material and import token. When calling this operation, you must specify the following values:</p>
43/// <ul>
44/// <li>
45/// <p>The key ID or key ARN of the KMS key to associate with the imported key material. Its <code>Origin</code> must be <code>EXTERNAL</code> and its <code>KeyState</code> must be <code>PendingImport</code>. You cannot perform this operation on a KMS key in a <a href="kms/latest/developerguide/custom-key-store-overview.html">custom key store</a>, or on a KMS key in a different Amazon Web Services account. To get the <code>Origin</code> and <code>KeyState</code> of a KMS key, call <code>DescribeKey</code>.</p></li>
46/// <li>
47/// <p>The encrypted key material.</p></li>
48/// <li>
49/// <p>The import token that <code>GetParametersForImport</code> returned. You must use a public key and token from the same <code>GetParametersForImport</code> response.</p></li>
50/// <li>
51/// <p>Whether the key material expires (<code>ExpirationModel</code>) and, if so, when (<code>ValidTo</code>). For help with this choice, see <a href="https://docs.aws.amazon.com/en_us/kms/latest/developerguide/importing-keys.html#importing-keys-expiration">Setting an expiration time</a> in the <i>Key Management Service Developer Guide</i>.</p>
52/// <p>If you set an expiration date, KMS deletes the key material from the KMS key on the specified date, making the KMS key unusable. To use the KMS key in cryptographic operations again, you must reimport the same key material. However, you can delete and reimport the key material at any time, including before the key material expires. Each time you reimport, you can eliminate or reset the expiration time.</p></li>
53/// </ul>
54/// <p>When this operation is successful, the key state of the KMS key changes from <code>PendingImport</code> to <code>Enabled</code>, and you can use the KMS key in cryptographic operations.</p>
55/// <p>If this operation fails, use the exception to help determine the problem. If the error is related to the key material, the import token, or wrapping key, use <code>GetParametersForImport</code> to get a new public key and import token for the KMS key and repeat the import procedure. For help, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys.html#importing-keys-overview">How To Import Key Material</a> in the <i>Key Management Service Developer Guide</i>.</p>
56/// <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>
57/// <p><b>Cross-account use</b>: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.</p>
58/// <p><b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:ImportKeyMaterial</a> (key policy)</p>
59/// <p><b>Related operations:</b></p>
60/// <ul>
61/// <li>
62/// <p><code>DeleteImportedKeyMaterial</code></p></li>
63/// <li>
64/// <p><code>GetParametersForImport</code></p></li>
65/// </ul>
66/// <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>
67#[derive(::std::clone::Clone, ::std::fmt::Debug)]
68pub struct ImportKeyMaterialFluentBuilder {
69 handle: ::std::sync::Arc<crate::client::Handle>,
70 inner: crate::operation::import_key_material::builders::ImportKeyMaterialInputBuilder,
71 config_override: ::std::option::Option<crate::config::Builder>,
72}
73impl
74 crate::client::customize::internal::CustomizableSend<
75 crate::operation::import_key_material::ImportKeyMaterialOutput,
76 crate::operation::import_key_material::ImportKeyMaterialError,
77 > for ImportKeyMaterialFluentBuilder
78{
79 fn send(
80 self,
81 config_override: crate::config::Builder,
82 ) -> crate::client::customize::internal::BoxFuture<
83 crate::client::customize::internal::SendResult<
84 crate::operation::import_key_material::ImportKeyMaterialOutput,
85 crate::operation::import_key_material::ImportKeyMaterialError,
86 >,
87 > {
88 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
89 }
90}
91impl ImportKeyMaterialFluentBuilder {
92 /// Creates a new `ImportKeyMaterialFluentBuilder`.
93 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
94 Self {
95 handle,
96 inner: ::std::default::Default::default(),
97 config_override: ::std::option::Option::None,
98 }
99 }
100 /// Access the ImportKeyMaterial as a reference.
101 pub fn as_input(&self) -> &crate::operation::import_key_material::builders::ImportKeyMaterialInputBuilder {
102 &self.inner
103 }
104 /// Sends the request and returns the response.
105 ///
106 /// If an error occurs, an `SdkError` will be returned with additional details that
107 /// can be matched against.
108 ///
109 /// By default, any retryable failures will be retried twice. Retry behavior
110 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
111 /// set when configuring the client.
112 pub async fn send(
113 self,
114 ) -> ::std::result::Result<
115 crate::operation::import_key_material::ImportKeyMaterialOutput,
116 ::aws_smithy_runtime_api::client::result::SdkError<
117 crate::operation::import_key_material::ImportKeyMaterialError,
118 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
119 >,
120 > {
121 let input = self
122 .inner
123 .build()
124 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
125 let runtime_plugins = crate::operation::import_key_material::ImportKeyMaterial::operation_runtime_plugins(
126 self.handle.runtime_plugins.clone(),
127 &self.handle.conf,
128 self.config_override,
129 );
130 crate::operation::import_key_material::ImportKeyMaterial::orchestrate(&runtime_plugins, input).await
131 }
132
133 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
134 pub fn customize(
135 self,
136 ) -> crate::client::customize::CustomizableOperation<
137 crate::operation::import_key_material::ImportKeyMaterialOutput,
138 crate::operation::import_key_material::ImportKeyMaterialError,
139 Self,
140 > {
141 crate::client::customize::CustomizableOperation::new(self)
142 }
143 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
144 self.set_config_override(::std::option::Option::Some(config_override.into()));
145 self
146 }
147
148 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
149 self.config_override = config_override;
150 self
151 }
152 /// <p>The identifier of the KMS key that will be associated with the imported key material. This must be the same KMS key specified in the <code>KeyID</code> parameter of the corresponding <code>GetParametersForImport</code> request. The <code>Origin</code> of the KMS key must be <code>EXTERNAL</code> and its <code>KeyState</code> must be <code>PendingImport</code>.</p>
153 /// <p>The KMS key can be a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, or asymmetric signing KMS key, including a <a href="kms/latest/developerguide/multi-region-keys-overview.html">multi-Region key</a> of any supported type. You cannot perform this operation on a KMS key in a custom key store, or on a KMS key in a different Amazon Web Services account.</p>
154 /// <p>Specify the key ID or key ARN of the KMS key.</p>
155 /// <p>For example:</p>
156 /// <ul>
157 /// <li>
158 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
159 /// <li>
160 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
161 /// </ul>
162 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
163 pub fn key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
164 self.inner = self.inner.key_id(input.into());
165 self
166 }
167 /// <p>The identifier of the KMS key that will be associated with the imported key material. This must be the same KMS key specified in the <code>KeyID</code> parameter of the corresponding <code>GetParametersForImport</code> request. The <code>Origin</code> of the KMS key must be <code>EXTERNAL</code> and its <code>KeyState</code> must be <code>PendingImport</code>.</p>
168 /// <p>The KMS key can be a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, or asymmetric signing KMS key, including a <a href="kms/latest/developerguide/multi-region-keys-overview.html">multi-Region key</a> of any supported type. You cannot perform this operation on a KMS key in a custom key store, or on a KMS key in a different Amazon Web Services account.</p>
169 /// <p>Specify the key ID or key ARN of the KMS key.</p>
170 /// <p>For example:</p>
171 /// <ul>
172 /// <li>
173 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
174 /// <li>
175 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
176 /// </ul>
177 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
178 pub fn set_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
179 self.inner = self.inner.set_key_id(input);
180 self
181 }
182 /// <p>The identifier of the KMS key that will be associated with the imported key material. This must be the same KMS key specified in the <code>KeyID</code> parameter of the corresponding <code>GetParametersForImport</code> request. The <code>Origin</code> of the KMS key must be <code>EXTERNAL</code> and its <code>KeyState</code> must be <code>PendingImport</code>.</p>
183 /// <p>The KMS key can be a symmetric encryption KMS key, HMAC KMS key, asymmetric encryption KMS key, or asymmetric signing KMS key, including a <a href="kms/latest/developerguide/multi-region-keys-overview.html">multi-Region key</a> of any supported type. You cannot perform this operation on a KMS key in a custom key store, or on a KMS key in a different Amazon Web Services account.</p>
184 /// <p>Specify the key ID or key ARN of the KMS key.</p>
185 /// <p>For example:</p>
186 /// <ul>
187 /// <li>
188 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
189 /// <li>
190 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
191 /// </ul>
192 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
193 pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
194 self.inner.get_key_id()
195 }
196 /// <p>The import token that you received in the response to a previous <code>GetParametersForImport</code> request. It must be from the same response that contained the public key that you used to encrypt the key material.</p>
197 pub fn import_token(mut self, input: ::aws_smithy_types::Blob) -> Self {
198 self.inner = self.inner.import_token(input);
199 self
200 }
201 /// <p>The import token that you received in the response to a previous <code>GetParametersForImport</code> request. It must be from the same response that contained the public key that you used to encrypt the key material.</p>
202 pub fn set_import_token(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
203 self.inner = self.inner.set_import_token(input);
204 self
205 }
206 /// <p>The import token that you received in the response to a previous <code>GetParametersForImport</code> request. It must be from the same response that contained the public key that you used to encrypt the key material.</p>
207 pub fn get_import_token(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
208 self.inner.get_import_token()
209 }
210 /// <p>The encrypted key material to import. The key material must be encrypted under the public wrapping key that <code>GetParametersForImport</code> returned, using the wrapping algorithm that you specified in the same <code>GetParametersForImport</code> request.</p>
211 pub fn encrypted_key_material(mut self, input: ::aws_smithy_types::Blob) -> Self {
212 self.inner = self.inner.encrypted_key_material(input);
213 self
214 }
215 /// <p>The encrypted key material to import. The key material must be encrypted under the public wrapping key that <code>GetParametersForImport</code> returned, using the wrapping algorithm that you specified in the same <code>GetParametersForImport</code> request.</p>
216 pub fn set_encrypted_key_material(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
217 self.inner = self.inner.set_encrypted_key_material(input);
218 self
219 }
220 /// <p>The encrypted key material to import. The key material must be encrypted under the public wrapping key that <code>GetParametersForImport</code> returned, using the wrapping algorithm that you specified in the same <code>GetParametersForImport</code> request.</p>
221 pub fn get_encrypted_key_material(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
222 self.inner.get_encrypted_key_material()
223 }
224 /// <p>The date and time when the imported key material expires. This parameter is required when the value of the <code>ExpirationModel</code> parameter is <code>KEY_MATERIAL_EXPIRES</code>. Otherwise it is not valid.</p>
225 /// <p>The value of this parameter must be a future date and time. The maximum value is 365 days from the request date.</p>
226 /// <p>When the key material expires, KMS deletes the key material from the KMS key. Without its key material, the KMS key is unusable. To use the KMS key in cryptographic operations, you must reimport the same key material.</p>
227 /// <p>You cannot change the <code>ExpirationModel</code> or <code>ValidTo</code> values for the current import after the request completes. To change either value, you must delete (<code>DeleteImportedKeyMaterial</code>) and reimport the key material.</p>
228 pub fn valid_to(mut self, input: ::aws_smithy_types::DateTime) -> Self {
229 self.inner = self.inner.valid_to(input);
230 self
231 }
232 /// <p>The date and time when the imported key material expires. This parameter is required when the value of the <code>ExpirationModel</code> parameter is <code>KEY_MATERIAL_EXPIRES</code>. Otherwise it is not valid.</p>
233 /// <p>The value of this parameter must be a future date and time. The maximum value is 365 days from the request date.</p>
234 /// <p>When the key material expires, KMS deletes the key material from the KMS key. Without its key material, the KMS key is unusable. To use the KMS key in cryptographic operations, you must reimport the same key material.</p>
235 /// <p>You cannot change the <code>ExpirationModel</code> or <code>ValidTo</code> values for the current import after the request completes. To change either value, you must delete (<code>DeleteImportedKeyMaterial</code>) and reimport the key material.</p>
236 pub fn set_valid_to(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
237 self.inner = self.inner.set_valid_to(input);
238 self
239 }
240 /// <p>The date and time when the imported key material expires. This parameter is required when the value of the <code>ExpirationModel</code> parameter is <code>KEY_MATERIAL_EXPIRES</code>. Otherwise it is not valid.</p>
241 /// <p>The value of this parameter must be a future date and time. The maximum value is 365 days from the request date.</p>
242 /// <p>When the key material expires, KMS deletes the key material from the KMS key. Without its key material, the KMS key is unusable. To use the KMS key in cryptographic operations, you must reimport the same key material.</p>
243 /// <p>You cannot change the <code>ExpirationModel</code> or <code>ValidTo</code> values for the current import after the request completes. To change either value, you must delete (<code>DeleteImportedKeyMaterial</code>) and reimport the key material.</p>
244 pub fn get_valid_to(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
245 self.inner.get_valid_to()
246 }
247 /// <p>Specifies whether the key material expires. The default is <code>KEY_MATERIAL_EXPIRES</code>. For help with this choice, see <a href="https://docs.aws.amazon.com/en_us/kms/latest/developerguide/importing-keys.html#importing-keys-expiration">Setting an expiration time</a> in the <i>Key Management Service Developer Guide</i>.</p>
248 /// <p>When the value of <code>ExpirationModel</code> is <code>KEY_MATERIAL_EXPIRES</code>, you must specify a value for the <code>ValidTo</code> parameter. When value is <code>KEY_MATERIAL_DOES_NOT_EXPIRE</code>, you must omit the <code>ValidTo</code> parameter.</p>
249 /// <p>You cannot change the <code>ExpirationModel</code> or <code>ValidTo</code> values for the current import after the request completes. To change either value, you must reimport the key material.</p>
250 pub fn expiration_model(mut self, input: crate::types::ExpirationModelType) -> Self {
251 self.inner = self.inner.expiration_model(input);
252 self
253 }
254 /// <p>Specifies whether the key material expires. The default is <code>KEY_MATERIAL_EXPIRES</code>. For help with this choice, see <a href="https://docs.aws.amazon.com/en_us/kms/latest/developerguide/importing-keys.html#importing-keys-expiration">Setting an expiration time</a> in the <i>Key Management Service Developer Guide</i>.</p>
255 /// <p>When the value of <code>ExpirationModel</code> is <code>KEY_MATERIAL_EXPIRES</code>, you must specify a value for the <code>ValidTo</code> parameter. When value is <code>KEY_MATERIAL_DOES_NOT_EXPIRE</code>, you must omit the <code>ValidTo</code> parameter.</p>
256 /// <p>You cannot change the <code>ExpirationModel</code> or <code>ValidTo</code> values for the current import after the request completes. To change either value, you must reimport the key material.</p>
257 pub fn set_expiration_model(mut self, input: ::std::option::Option<crate::types::ExpirationModelType>) -> Self {
258 self.inner = self.inner.set_expiration_model(input);
259 self
260 }
261 /// <p>Specifies whether the key material expires. The default is <code>KEY_MATERIAL_EXPIRES</code>. For help with this choice, see <a href="https://docs.aws.amazon.com/en_us/kms/latest/developerguide/importing-keys.html#importing-keys-expiration">Setting an expiration time</a> in the <i>Key Management Service Developer Guide</i>.</p>
262 /// <p>When the value of <code>ExpirationModel</code> is <code>KEY_MATERIAL_EXPIRES</code>, you must specify a value for the <code>ValidTo</code> parameter. When value is <code>KEY_MATERIAL_DOES_NOT_EXPIRE</code>, you must omit the <code>ValidTo</code> parameter.</p>
263 /// <p>You cannot change the <code>ExpirationModel</code> or <code>ValidTo</code> values for the current import after the request completes. To change either value, you must reimport the key material.</p>
264 pub fn get_expiration_model(&self) -> &::std::option::Option<crate::types::ExpirationModelType> {
265 self.inner.get_expiration_model()
266 }
267}