Skip to main content

aws_sdk_kms/operation/encapsulate/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::encapsulate::_encapsulate_input::EncapsulateInputBuilder;
3
4pub use crate::operation::encapsulate::_encapsulate_output::EncapsulateOutputBuilder;
5
6impl crate::operation::encapsulate::builders::EncapsulateInputBuilder {
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::encapsulate::EncapsulateOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::encapsulate::EncapsulateError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.encapsulate();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `Encapsulate`.
24///
25/// <p>Generates a shared secret and its encapsulated (ciphertext) form using the public key of an ML-KEM KMS key pair. Module-Lattice-Based Key-Encapsulation Mechanism (ML-KEM), specified in <a href="https://csrc.nist.gov/pubs/fips/203/final">FIPS 203</a> on the NIST website, is a post-quantum algorithm for establishing a shared secret between two parties.</p>
26/// <p>For an example of how two parties establish a shared secret over an insecure channel using ML-KEM, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/pqkeys.html#mlkem">ML-KEM keys in KMS</a> in the <i>Key Management Service Developer Guide</i>.</p>
27/// <p>The Encapsulate operation is not available in China Regions.</p>
28/// <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>
29/// <p><b>Cross-account use</b>: Yes. To perform this operation with a KMS key in a different Amazon Web Services account, specify the key ARN or alias ARN in the value of the <code>KeyId</code> parameter.</p>
30/// <p><b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:Encapsulate</a> (key policy)</p>
31/// <p><b>Related operations:</b></p>
32/// <ul>
33/// <li>
34/// <p><code>Decapsulate</code></p></li>
35/// <li>
36/// <p><code>DeriveSharedSecret</code></p></li>
37/// <li>
38/// <p><code>CreateKey</code></p></li>
39/// <li>
40/// <p><code>GetPublicKey</code></p></li>
41/// <li>
42/// <p><code>DescribeKey</code></p></li>
43/// </ul>
44/// <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/accessing-kms.html#programming-eventual-consistency">KMS eventual consistency</a>.</p>
45#[derive(::std::clone::Clone, ::std::fmt::Debug)]
46pub struct EncapsulateFluentBuilder {
47    handle: ::std::sync::Arc<crate::client::Handle>,
48    inner: crate::operation::encapsulate::builders::EncapsulateInputBuilder,
49    config_override: ::std::option::Option<crate::config::Builder>,
50}
51impl
52    crate::client::customize::internal::CustomizableSend<
53        crate::operation::encapsulate::EncapsulateOutput,
54        crate::operation::encapsulate::EncapsulateError,
55    > for EncapsulateFluentBuilder
56{
57    fn send(
58        self,
59        config_override: crate::config::Builder,
60    ) -> crate::client::customize::internal::BoxFuture<
61        crate::client::customize::internal::SendResult<
62            crate::operation::encapsulate::EncapsulateOutput,
63            crate::operation::encapsulate::EncapsulateError,
64        >,
65    > {
66        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
67    }
68}
69impl EncapsulateFluentBuilder {
70    /// Creates a new `EncapsulateFluentBuilder`.
71    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
72        Self {
73            handle,
74            inner: ::std::default::Default::default(),
75            config_override: ::std::option::Option::None,
76        }
77    }
78    /// Access the Encapsulate as a reference.
79    pub fn as_input(&self) -> &crate::operation::encapsulate::builders::EncapsulateInputBuilder {
80        &self.inner
81    }
82    /// Sends the request and returns the response.
83    ///
84    /// If an error occurs, an `SdkError` will be returned with additional details that
85    /// can be matched against.
86    ///
87    /// By default, any retryable failures will be retried twice. Retry behavior
88    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
89    /// set when configuring the client.
90    pub async fn send(
91        self,
92    ) -> ::std::result::Result<
93        crate::operation::encapsulate::EncapsulateOutput,
94        ::aws_smithy_runtime_api::client::result::SdkError<
95            crate::operation::encapsulate::EncapsulateError,
96            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
97        >,
98    > {
99        let input = self
100            .inner
101            .build()
102            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
103        let runtime_plugins = crate::operation::encapsulate::Encapsulate::operation_runtime_plugins(
104            self.handle.runtime_plugins.clone(),
105            &self.handle.conf,
106            self.config_override,
107        );
108        crate::operation::encapsulate::Encapsulate::orchestrate(&runtime_plugins, input).await
109    }
110
111    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
112    pub fn customize(
113        self,
114    ) -> crate::client::customize::CustomizableOperation<
115        crate::operation::encapsulate::EncapsulateOutput,
116        crate::operation::encapsulate::EncapsulateError,
117        Self,
118    > {
119        crate::client::customize::CustomizableOperation::new(self)
120    }
121    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
122        self.set_config_override(::std::option::Option::Some(config_override.into()));
123        self
124    }
125
126    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
127        self.config_override = config_override;
128        self
129    }
130    /// <p>Identifies an asymmetric ML-KEM KMS key. KMS uses the public key in the specified key pair to encapsulate the shared secret. ML-KEM KMS keys have a <code>KeySpec</code> value of <code>ML_KEM_512</code>, <code>ML_KEM_768</code>, or <code>ML_KEM_1024</code> and a <code>KeyUsage</code> value of <code>ENCAPSULATE_DECAPSULATE</code>. To find the <code>KeySpec</code> and <code>KeyUsage</code> of a KMS key, use the <code>DescribeKey</code> operation.</p>
131    /// <p>To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with <code>"alias/"</code>. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.</p>
132    /// <p>For example:</p>
133    /// <ul>
134    /// <li>
135    /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
136    /// <li>
137    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
138    /// <li>
139    /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
140    /// <li>
141    /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</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>. To get the alias name and alias ARN, use <code>ListAliases</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 an asymmetric ML-KEM KMS key. KMS uses the public key in the specified key pair to encapsulate the shared secret. ML-KEM KMS keys have a <code>KeySpec</code> value of <code>ML_KEM_512</code>, <code>ML_KEM_768</code>, or <code>ML_KEM_1024</code> and a <code>KeyUsage</code> value of <code>ENCAPSULATE_DECAPSULATE</code>. To find the <code>KeySpec</code> and <code>KeyUsage</code> of a KMS key, use the <code>DescribeKey</code> operation.</p>
149    /// <p>To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with <code>"alias/"</code>. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.</p>
150    /// <p>For example:</p>
151    /// <ul>
152    /// <li>
153    /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
154    /// <li>
155    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
156    /// <li>
157    /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
158    /// <li>
159    /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</code></p></li>
160    /// </ul>
161    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>. To get the alias name and alias ARN, use <code>ListAliases</code>.</p>
162    pub fn set_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
163        self.inner = self.inner.set_key_id(input);
164        self
165    }
166    /// <p>Identifies an asymmetric ML-KEM KMS key. KMS uses the public key in the specified key pair to encapsulate the shared secret. ML-KEM KMS keys have a <code>KeySpec</code> value of <code>ML_KEM_512</code>, <code>ML_KEM_768</code>, or <code>ML_KEM_1024</code> and a <code>KeyUsage</code> value of <code>ENCAPSULATE_DECAPSULATE</code>. To find the <code>KeySpec</code> and <code>KeyUsage</code> of a KMS key, use the <code>DescribeKey</code> operation.</p>
167    /// <p>To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. When using an alias name, prefix it with <code>"alias/"</code>. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.</p>
168    /// <p>For example:</p>
169    /// <ul>
170    /// <li>
171    /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
172    /// <li>
173    /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
174    /// <li>
175    /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
176    /// <li>
177    /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</code></p></li>
178    /// </ul>
179    /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>. To get the alias name and alias ARN, use <code>ListAliases</code>.</p>
180    pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
181        self.inner.get_key_id()
182    }
183    /// <p>Specifies the key encapsulation algorithm used to generate the shared secret and its encapsulated form. The only valid value is <code>ML_KEM</code>.</p>
184    pub fn encapsulation_algorithm(mut self, input: crate::types::EncapsulationAlgorithmSpec) -> Self {
185        self.inner = self.inner.encapsulation_algorithm(input);
186        self
187    }
188    /// <p>Specifies the key encapsulation algorithm used to generate the shared secret and its encapsulated form. The only valid value is <code>ML_KEM</code>.</p>
189    pub fn set_encapsulation_algorithm(mut self, input: ::std::option::Option<crate::types::EncapsulationAlgorithmSpec>) -> Self {
190        self.inner = self.inner.set_encapsulation_algorithm(input);
191        self
192    }
193    /// <p>Specifies the key encapsulation algorithm used to generate the shared secret and its encapsulated form. The only valid value is <code>ML_KEM</code>.</p>
194    pub fn get_encapsulation_algorithm(&self) -> &::std::option::Option<crate::types::EncapsulationAlgorithmSpec> {
195        self.inner.get_encapsulation_algorithm()
196    }
197    ///
198    /// Appends an item to `GrantTokens`.
199    ///
200    /// To override the contents of this collection use [`set_grant_tokens`](Self::set_grant_tokens).
201    ///
202    /// <p>A list of grant tokens.</p>
203    /// <p>Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved <i>eventual consistency</i>. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token">Grant token</a> and <a href="https://docs.aws.amazon.com/kms/latest/developerguide/using-grant-token.html">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
204    pub fn grant_tokens(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
205        self.inner = self.inner.grant_tokens(input.into());
206        self
207    }
208    /// <p>A list of grant tokens.</p>
209    /// <p>Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved <i>eventual consistency</i>. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token">Grant token</a> and <a href="https://docs.aws.amazon.com/kms/latest/developerguide/using-grant-token.html">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
210    pub fn set_grant_tokens(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
211        self.inner = self.inner.set_grant_tokens(input);
212        self
213    }
214    /// <p>A list of grant tokens.</p>
215    /// <p>Use a grant token when your permission to call this operation comes from a new grant that has not yet achieved <i>eventual consistency</i>. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#grant_token">Grant token</a> and <a href="https://docs.aws.amazon.com/kms/latest/developerguide/using-grant-token.html">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
216    pub fn get_grant_tokens(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
217        self.inner.get_grant_tokens()
218    }
219    /// <p>Checks if your request will succeed. <code>DryRun</code> is an optional parameter.</p>
220    /// <p>To learn more about how to use this parameter, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/testing-permissions.html">Testing your permissions</a> in the <i>Key Management Service Developer Guide</i>.</p>
221    pub fn dry_run(mut self, input: bool) -> Self {
222        self.inner = self.inner.dry_run(input);
223        self
224    }
225    /// <p>Checks if your request will succeed. <code>DryRun</code> is an optional parameter.</p>
226    /// <p>To learn more about how to use this parameter, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/testing-permissions.html">Testing your permissions</a> in the <i>Key Management Service Developer Guide</i>.</p>
227    pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
228        self.inner = self.inner.set_dry_run(input);
229        self
230    }
231    /// <p>Checks if your request will succeed. <code>DryRun</code> is an optional parameter.</p>
232    /// <p>To learn more about how to use this parameter, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/testing-permissions.html">Testing your permissions</a> in the <i>Key Management Service Developer Guide</i>.</p>
233    pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
234        self.inner.get_dry_run()
235    }
236}