aws_sdk_kms/operation/get_key_last_usage/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::get_key_last_usage::_get_key_last_usage_input::GetKeyLastUsageInputBuilder;
3
4pub use crate::operation::get_key_last_usage::_get_key_last_usage_output::GetKeyLastUsageOutputBuilder;
5
6impl crate::operation::get_key_last_usage::builders::GetKeyLastUsageInputBuilder {
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_key_last_usage::GetKeyLastUsageOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::get_key_last_usage::GetKeyLastUsageError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.get_key_last_usage();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `GetKeyLastUsage`.
24///
25/// <p>Returns usage information about the last successful cryptographic operation performed with a specified KMS key, including the operation type, timestamp, and associated CloudTrail event ID.</p>
26/// <p>The <code>TrackingStartDate</code> in the <code>GetKeyLastUsage</code> response indicates the date from which KMS began recording cryptographic activity for a given key. Use this value together with <code>KeyCreationDate</code> to understand the key's usage history:</p>
27/// <ul>
28/// <li>
29/// <p>If the <code>KeyLastUsage</code> response element is <i>present</i>, the key has been used for a successful cryptographic operation since the <code>TrackingStartDate</code>. The response includes the operation type, timestamp, and associated CloudTrail event ID.</p></li>
30/// <li>
31/// <p>If the <code>KeyLastUsage</code> response element is <i>empty</i> and <code>KeyCreationDate</code> is on or after <code>TrackingStartDate</code>, the key has not been used for a successful cryptographic operation since it was created.</p></li>
32/// <li>
33/// <p>If the <code>KeyLastUsage</code> response element is <i>empty</i> and <code>KeyCreationDate</code> is before <code>TrackingStartDate</code>, there is no record of the key being used for a successful cryptographic operation since the <code>TrackingStartDate</code>. However, the key may have been used before tracking began. To determine whether the key was used before the <code>TrackingStartDate</code>, examine your past CloudTrail logs.</p></li>
34/// </ul>
35/// <p>For multi-Region KMS keys, primary and replica keys track last usage independently. Each key in a multi-Region key set maintains its own usage information.</p>
36/// <p>The <code>ReEncrypt</code> operation uses two keys: a source key for decryption and a destination key for encryption. Usage information is recorded for both keys independently, each with the CloudTrail event ID from the respective key owner's account.</p><note>
37/// <p>Do not use <code>GetKeyLastUsage</code> as the sole indicator when scheduling a key for deletion. Instead, first <a href="https://docs.aws.amazon.com/kms/latest/developerguide/enabling-keys.html">disable the key</a> and monitor CloudTrail for <code>DisabledException</code> entries, as there could be infrequent workflows that are dependent on the key. By looking for this exception, you can identify potential dependencies and workload failures before they occur. CloudTrail remains the authoritative source for all API calls made to your key.</p>
38/// </note>
39/// <p><b>Cross-account use</b>: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.</p>
40/// <p><b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:GetKeyLastUsage</a> (key policy)</p>
41/// <p><b>Related operations:</b></p>
42/// <ul>
43/// <li>
44/// <p><code>DescribeKey</code></p></li>
45/// <li>
46/// <p><code>DisableKey</code></p></li>
47/// <li>
48/// <p><code>ScheduleKeyDeletion</code></p></li>
49/// </ul>
50/// <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>
51#[derive(::std::clone::Clone, ::std::fmt::Debug)]
52pub struct GetKeyLastUsageFluentBuilder {
53 handle: ::std::sync::Arc<crate::client::Handle>,
54 inner: crate::operation::get_key_last_usage::builders::GetKeyLastUsageInputBuilder,
55 config_override: ::std::option::Option<crate::config::Builder>,
56}
57impl
58 crate::client::customize::internal::CustomizableSend<
59 crate::operation::get_key_last_usage::GetKeyLastUsageOutput,
60 crate::operation::get_key_last_usage::GetKeyLastUsageError,
61 > for GetKeyLastUsageFluentBuilder
62{
63 fn send(
64 self,
65 config_override: crate::config::Builder,
66 ) -> crate::client::customize::internal::BoxFuture<
67 crate::client::customize::internal::SendResult<
68 crate::operation::get_key_last_usage::GetKeyLastUsageOutput,
69 crate::operation::get_key_last_usage::GetKeyLastUsageError,
70 >,
71 > {
72 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
73 }
74}
75impl GetKeyLastUsageFluentBuilder {
76 /// Creates a new `GetKeyLastUsageFluentBuilder`.
77 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
78 Self {
79 handle,
80 inner: ::std::default::Default::default(),
81 config_override: ::std::option::Option::None,
82 }
83 }
84 /// Access the GetKeyLastUsage as a reference.
85 pub fn as_input(&self) -> &crate::operation::get_key_last_usage::builders::GetKeyLastUsageInputBuilder {
86 &self.inner
87 }
88 /// Sends the request and returns the response.
89 ///
90 /// If an error occurs, an `SdkError` will be returned with additional details that
91 /// can be matched against.
92 ///
93 /// By default, any retryable failures will be retried twice. Retry behavior
94 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
95 /// set when configuring the client.
96 pub async fn send(
97 self,
98 ) -> ::std::result::Result<
99 crate::operation::get_key_last_usage::GetKeyLastUsageOutput,
100 ::aws_smithy_runtime_api::client::result::SdkError<
101 crate::operation::get_key_last_usage::GetKeyLastUsageError,
102 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
103 >,
104 > {
105 let input = self
106 .inner
107 .build()
108 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
109 let runtime_plugins = crate::operation::get_key_last_usage::GetKeyLastUsage::operation_runtime_plugins(
110 self.handle.runtime_plugins.clone(),
111 &self.handle.conf,
112 self.config_override,
113 );
114 crate::operation::get_key_last_usage::GetKeyLastUsage::orchestrate(&runtime_plugins, input).await
115 }
116
117 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
118 pub fn customize(
119 self,
120 ) -> crate::client::customize::CustomizableOperation<
121 crate::operation::get_key_last_usage::GetKeyLastUsageOutput,
122 crate::operation::get_key_last_usage::GetKeyLastUsageError,
123 Self,
124 > {
125 crate::client::customize::CustomizableOperation::new(self)
126 }
127 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
128 self.set_config_override(::std::option::Option::Some(config_override.into()));
129 self
130 }
131
132 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
133 self.config_override = config_override;
134 self
135 }
136 /// <p>Identifies the KMS key to get usage information for. To specify a KMS key, use its key ID or key ARN. Alias names are not supported.</p>
137 /// <p>Specify the key ID or key ARN of the KMS key.</p>
138 /// <p>For example:</p>
139 /// <ul>
140 /// <li>
141 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
142 /// <li>
143 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
144 /// </ul>
145 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
146 pub fn key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
147 self.inner = self.inner.key_id(input.into());
148 self
149 }
150 /// <p>Identifies the KMS key to get usage information for. To specify a KMS key, use its key ID or key ARN. Alias names are not supported.</p>
151 /// <p>Specify the key ID or key ARN of the KMS key.</p>
152 /// <p>For example:</p>
153 /// <ul>
154 /// <li>
155 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
156 /// <li>
157 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</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>.</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 KMS key to get usage information for. To specify a KMS key, use its key ID or key ARN. Alias names are not supported.</p>
165 /// <p>Specify the key ID or key ARN of the KMS key.</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 /// </ul>
173 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
174 pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
175 self.inner.get_key_id()
176 }
177}