aws_sdk_kms/operation/get_public_key/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::get_public_key::_get_public_key_output::GetPublicKeyOutputBuilder;
3
4pub use crate::operation::get_public_key::_get_public_key_input::GetPublicKeyInputBuilder;
5
6impl crate::operation::get_public_key::builders::GetPublicKeyInputBuilder {
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_public_key::GetPublicKeyOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::get_public_key::GetPublicKeyError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.get_public_key();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `GetPublicKey`.
24///
25/// <p>Returns the public key of an asymmetric KMS key. Unlike the private key of a asymmetric KMS key, which never leaves KMS unencrypted, callers with <code>kms:GetPublicKey</code> permission can download the public key of an asymmetric KMS key. You can share the public key to allow others to encrypt messages and verify signatures outside of KMS. For information about asymmetric KMS keys, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html">Asymmetric KMS keys</a> in the <i>Key Management Service Developer Guide</i>.</p>
26/// <p>You do not need to download the public key. Instead, you can use the public key within KMS by calling the <code>Encrypt</code>, <code>ReEncrypt</code>, or <code>Verify</code> operations with the identifier of an asymmetric KMS key. When you use the public key within KMS, you benefit from the authentication, authorization, and logging that are part of every KMS operation. You also reduce of risk of encrypting data that cannot be decrypted. These features are not effective outside of KMS.</p>
27/// <p>To help you use the public key safely outside of KMS, <code>GetPublicKey</code> returns important information about the public key in the response, including:</p>
28/// <ul>
29/// <li>
30/// <p><a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_GetPublicKey.html#KMS-GetPublicKey-response-KeySpec">KeySpec</a>: The type of key material in the public key, such as <code>RSA_4096</code> or <code>ECC_NIST_P521</code>.</p></li>
31/// <li>
32/// <p><a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_GetPublicKey.html#KMS-GetPublicKey-response-KeyUsage">KeyUsage</a>: Whether the key is used for encryption, signing, or deriving a shared secret.</p></li>
33/// <li>
34/// <p><a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_GetPublicKey.html#KMS-GetPublicKey-response-EncryptionAlgorithms">EncryptionAlgorithms</a> or <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_GetPublicKey.html#KMS-GetPublicKey-response-SigningAlgorithms">SigningAlgorithms</a>: A list of the encryption algorithms or the signing algorithms for the key.</p></li>
35/// </ul>
36/// <p>Although KMS cannot enforce these restrictions on external operations, it is crucial that you use this information to prevent the public key from being used improperly. For example, you can prevent a public signing key from being used encrypt data, or prevent a public key from being used with an encryption algorithm that is not supported by KMS. You can also avoid errors, such as using the wrong signing algorithm in a verification operation.</p>
37/// <p>To verify a signature outside of KMS with an SM2 public key (China Regions only), you must specify the distinguishing ID. By default, KMS uses <code>1234567812345678</code> as the distinguishing ID. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/asymmetric-key-specs.html#key-spec-sm-offline-verification">Offline verification with SM2 key pairs</a>.</p>
38/// <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>
39/// <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>
40/// <p><b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:GetPublicKey</a> (key policy)</p>
41/// <p><b>Related operations</b>: <code>CreateKey</code></p>
42/// <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>
43#[derive(::std::clone::Clone, ::std::fmt::Debug)]
44pub struct GetPublicKeyFluentBuilder {
45 handle: ::std::sync::Arc<crate::client::Handle>,
46 inner: crate::operation::get_public_key::builders::GetPublicKeyInputBuilder,
47 config_override: ::std::option::Option<crate::config::Builder>,
48}
49impl
50 crate::client::customize::internal::CustomizableSend<
51 crate::operation::get_public_key::GetPublicKeyOutput,
52 crate::operation::get_public_key::GetPublicKeyError,
53 > for GetPublicKeyFluentBuilder
54{
55 fn send(
56 self,
57 config_override: crate::config::Builder,
58 ) -> crate::client::customize::internal::BoxFuture<
59 crate::client::customize::internal::SendResult<
60 crate::operation::get_public_key::GetPublicKeyOutput,
61 crate::operation::get_public_key::GetPublicKeyError,
62 >,
63 > {
64 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
65 }
66}
67impl GetPublicKeyFluentBuilder {
68 /// Creates a new `GetPublicKeyFluentBuilder`.
69 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
70 Self {
71 handle,
72 inner: ::std::default::Default::default(),
73 config_override: ::std::option::Option::None,
74 }
75 }
76 /// Access the GetPublicKey as a reference.
77 pub fn as_input(&self) -> &crate::operation::get_public_key::builders::GetPublicKeyInputBuilder {
78 &self.inner
79 }
80 /// Sends the request and returns the response.
81 ///
82 /// If an error occurs, an `SdkError` will be returned with additional details that
83 /// can be matched against.
84 ///
85 /// By default, any retryable failures will be retried twice. Retry behavior
86 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
87 /// set when configuring the client.
88 pub async fn send(
89 self,
90 ) -> ::std::result::Result<
91 crate::operation::get_public_key::GetPublicKeyOutput,
92 ::aws_smithy_runtime_api::client::result::SdkError<
93 crate::operation::get_public_key::GetPublicKeyError,
94 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
95 >,
96 > {
97 let input = self
98 .inner
99 .build()
100 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
101 let runtime_plugins = crate::operation::get_public_key::GetPublicKey::operation_runtime_plugins(
102 self.handle.runtime_plugins.clone(),
103 &self.handle.conf,
104 self.config_override,
105 );
106 crate::operation::get_public_key::GetPublicKey::orchestrate(&runtime_plugins, input).await
107 }
108
109 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
110 pub fn customize(
111 self,
112 ) -> crate::client::customize::CustomizableOperation<
113 crate::operation::get_public_key::GetPublicKeyOutput,
114 crate::operation::get_public_key::GetPublicKeyError,
115 Self,
116 > {
117 crate::client::customize::CustomizableOperation::new(self)
118 }
119 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
120 self.set_config_override(::std::option::Option::Some(config_override.into()));
121 self
122 }
123
124 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
125 self.config_override = config_override;
126 self
127 }
128 /// <p>Identifies the asymmetric KMS key that includes the public key.</p>
129 /// <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>
130 /// <p>For example:</p>
131 /// <ul>
132 /// <li>
133 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
134 /// <li>
135 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
136 /// <li>
137 /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
138 /// <li>
139 /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</code></p></li>
140 /// </ul>
141 /// <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>
142 pub fn key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
143 self.inner = self.inner.key_id(input.into());
144 self
145 }
146 /// <p>Identifies the asymmetric KMS key that includes the public key.</p>
147 /// <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>
148 /// <p>For example:</p>
149 /// <ul>
150 /// <li>
151 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
152 /// <li>
153 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
154 /// <li>
155 /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
156 /// <li>
157 /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</code></p></li>
158 /// </ul>
159 /// <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>
160 pub fn set_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
161 self.inner = self.inner.set_key_id(input);
162 self
163 }
164 /// <p>Identifies the asymmetric KMS key that includes the public key.</p>
165 /// <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>
166 /// <p>For example:</p>
167 /// <ul>
168 /// <li>
169 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
170 /// <li>
171 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
172 /// <li>
173 /// <p>Alias name: <code>alias/ExampleAlias</code></p></li>
174 /// <li>
175 /// <p>Alias ARN: <code>arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias</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>. To get the alias name and alias ARN, use <code>ListAliases</code>.</p>
178 pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
179 self.inner.get_key_id()
180 }
181 ///
182 /// Appends an item to `GrantTokens`.
183 ///
184 /// To override the contents of this collection use [`set_grant_tokens`](Self::set_grant_tokens).
185 ///
186 /// <p>A list of grant tokens.</p>
187 /// <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/grant-manage.html#using-grant-token">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
188 pub fn grant_tokens(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
189 self.inner = self.inner.grant_tokens(input.into());
190 self
191 }
192 /// <p>A list of grant tokens.</p>
193 /// <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/grant-manage.html#using-grant-token">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
194 pub fn set_grant_tokens(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
195 self.inner = self.inner.set_grant_tokens(input);
196 self
197 }
198 /// <p>A list of grant tokens.</p>
199 /// <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/grant-manage.html#using-grant-token">Using a grant token</a> in the <i>Key Management Service Developer Guide</i>.</p>
200 pub fn get_grant_tokens(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
201 self.inner.get_grant_tokens()
202 }
203}