aws_sdk_kms/operation/get_key_policy/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::get_key_policy::_get_key_policy_output::GetKeyPolicyOutputBuilder;
3
4pub use crate::operation::get_key_policy::_get_key_policy_input::GetKeyPolicyInputBuilder;
5
6impl crate::operation::get_key_policy::builders::GetKeyPolicyInputBuilder {
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_policy::GetKeyPolicyOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::get_key_policy::GetKeyPolicyError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.get_key_policy();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `GetKeyPolicy`.
24///
25/// <p>Gets a key policy attached to the specified KMS key.</p>
26/// <p><b>Cross-account use</b>: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.</p>
27/// <p><b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:GetKeyPolicy</a> (key policy)</p>
28/// <p><b>Related operations</b>: <a href="https://docs.aws.amazon.com/kms/latest/APIReference/API_PutKeyPolicy.html">PutKeyPolicy</a></p>
29/// <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>
30#[derive(::std::clone::Clone, ::std::fmt::Debug)]
31pub struct GetKeyPolicyFluentBuilder {
32 handle: ::std::sync::Arc<crate::client::Handle>,
33 inner: crate::operation::get_key_policy::builders::GetKeyPolicyInputBuilder,
34 config_override: ::std::option::Option<crate::config::Builder>,
35}
36impl
37 crate::client::customize::internal::CustomizableSend<
38 crate::operation::get_key_policy::GetKeyPolicyOutput,
39 crate::operation::get_key_policy::GetKeyPolicyError,
40 > for GetKeyPolicyFluentBuilder
41{
42 fn send(
43 self,
44 config_override: crate::config::Builder,
45 ) -> crate::client::customize::internal::BoxFuture<
46 crate::client::customize::internal::SendResult<
47 crate::operation::get_key_policy::GetKeyPolicyOutput,
48 crate::operation::get_key_policy::GetKeyPolicyError,
49 >,
50 > {
51 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
52 }
53}
54impl GetKeyPolicyFluentBuilder {
55 /// Creates a new `GetKeyPolicyFluentBuilder`.
56 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
57 Self {
58 handle,
59 inner: ::std::default::Default::default(),
60 config_override: ::std::option::Option::None,
61 }
62 }
63 /// Access the GetKeyPolicy as a reference.
64 pub fn as_input(&self) -> &crate::operation::get_key_policy::builders::GetKeyPolicyInputBuilder {
65 &self.inner
66 }
67 /// Sends the request and returns the response.
68 ///
69 /// If an error occurs, an `SdkError` will be returned with additional details that
70 /// can be matched against.
71 ///
72 /// By default, any retryable failures will be retried twice. Retry behavior
73 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
74 /// set when configuring the client.
75 pub async fn send(
76 self,
77 ) -> ::std::result::Result<
78 crate::operation::get_key_policy::GetKeyPolicyOutput,
79 ::aws_smithy_runtime_api::client::result::SdkError<
80 crate::operation::get_key_policy::GetKeyPolicyError,
81 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
82 >,
83 > {
84 let input = self
85 .inner
86 .build()
87 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
88 let runtime_plugins = crate::operation::get_key_policy::GetKeyPolicy::operation_runtime_plugins(
89 self.handle.runtime_plugins.clone(),
90 &self.handle.conf,
91 self.config_override,
92 );
93 crate::operation::get_key_policy::GetKeyPolicy::orchestrate(&runtime_plugins, input).await
94 }
95
96 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
97 pub fn customize(
98 self,
99 ) -> crate::client::customize::CustomizableOperation<
100 crate::operation::get_key_policy::GetKeyPolicyOutput,
101 crate::operation::get_key_policy::GetKeyPolicyError,
102 Self,
103 > {
104 crate::client::customize::CustomizableOperation::new(self)
105 }
106 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
107 self.set_config_override(::std::option::Option::Some(config_override.into()));
108 self
109 }
110
111 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
112 self.config_override = config_override;
113 self
114 }
115 /// <p>Gets the key policy for the specified KMS key.</p>
116 /// <p>Specify the key ID or key ARN of the KMS key.</p>
117 /// <p>For example:</p>
118 /// <ul>
119 /// <li>
120 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
121 /// <li>
122 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
123 /// </ul>
124 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
125 pub fn key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
126 self.inner = self.inner.key_id(input.into());
127 self
128 }
129 /// <p>Gets the key policy for the specified KMS key.</p>
130 /// <p>Specify the key ID or key ARN of the KMS key.</p>
131 /// <p>For example:</p>
132 /// <ul>
133 /// <li>
134 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
135 /// <li>
136 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
137 /// </ul>
138 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
139 pub fn set_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
140 self.inner = self.inner.set_key_id(input);
141 self
142 }
143 /// <p>Gets the key policy for the specified KMS key.</p>
144 /// <p>Specify the key ID or key ARN of the KMS key.</p>
145 /// <p>For example:</p>
146 /// <ul>
147 /// <li>
148 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
149 /// <li>
150 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
151 /// </ul>
152 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
153 pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
154 self.inner.get_key_id()
155 }
156 /// <p>Specifies the name of the key policy. If no policy name is specified, the default value is <code>default</code>. The only valid name is <code>default</code>. To get the names of key policies, use <code>ListKeyPolicies</code>.</p>
157 pub fn policy_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
158 self.inner = self.inner.policy_name(input.into());
159 self
160 }
161 /// <p>Specifies the name of the key policy. If no policy name is specified, the default value is <code>default</code>. The only valid name is <code>default</code>. To get the names of key policies, use <code>ListKeyPolicies</code>.</p>
162 pub fn set_policy_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
163 self.inner = self.inner.set_policy_name(input);
164 self
165 }
166 /// <p>Specifies the name of the key policy. If no policy name is specified, the default value is <code>default</code>. The only valid name is <code>default</code>. To get the names of key policies, use <code>ListKeyPolicies</code>.</p>
167 pub fn get_policy_name(&self) -> &::std::option::Option<::std::string::String> {
168 self.inner.get_policy_name()
169 }
170}