aws_sdk_kms/operation/list_grants/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::list_grants::_list_grants_input::ListGrantsInputBuilder;
3
4pub use crate::operation::list_grants::_list_grants_output::ListGrantsOutputBuilder;
5
6impl crate::operation::list_grants::builders::ListGrantsInputBuilder {
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::list_grants::ListGrantsOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::list_grants::ListGrantsError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.list_grants();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `ListGrants`.
24///
25/// <p>Gets a list of all grants for the specified KMS key.</p>
26/// <p>You must specify the KMS key in all requests. You can filter the grant list by grant ID, grantee principal, or grantee service principal.</p>
27/// <p>For detailed information about grants, including grant terminology, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html">Grants in KMS</a> in the <i> <i>Key Management Service Developer Guide</i> </i>. For examples of creating grants in several programming languages, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/example_kms_CreateGrant_section.html">Use CreateGrant with an Amazon Web Services SDK or CLI</a>.</p><note>
28/// <p>When a grant is created with the <code>GranteePrincipal</code> field, the <code>ListGrants</code> response usually contains the user or role designated as the grantee principal in the grant. However, if the grantee principal is an Amazon Web Services service, the <code>GranteePrincipal</code> field contains an Amazon Web Services <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services">service principal</a>, which might correspond to several different grantee principals, such as an IAM user, IAM role, or Amazon Web Services account.</p>
29/// <p>When a grant is created with the <code>GranteeServicePrincipal</code> field, the <code>ListGrants</code> response always includes a <code>GranteeServicePrincipal</code> that indicates the grantee is actually an Amazon Web Services <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-services">service principal</a>.</p>
30/// </note>
31/// <p><b>Cross-account use</b>: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the <code>KeyId</code> parameter.</p>
32/// <p><b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:ListGrants</a> (key policy)</p>
33/// <p><b>Related operations:</b></p>
34/// <ul>
35/// <li>
36/// <p><code>CreateGrant</code></p></li>
37/// <li>
38/// <p><code>ListRetirableGrants</code></p></li>
39/// <li>
40/// <p><code>RetireGrant</code></p></li>
41/// <li>
42/// <p><code>RevokeGrant</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 ListGrantsFluentBuilder {
47 handle: ::std::sync::Arc<crate::client::Handle>,
48 inner: crate::operation::list_grants::builders::ListGrantsInputBuilder,
49 config_override: ::std::option::Option<crate::config::Builder>,
50}
51impl
52 crate::client::customize::internal::CustomizableSend<
53 crate::operation::list_grants::ListGrantsOutput,
54 crate::operation::list_grants::ListGrantsError,
55 > for ListGrantsFluentBuilder
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::list_grants::ListGrantsOutput,
63 crate::operation::list_grants::ListGrantsError,
64 >,
65 > {
66 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
67 }
68}
69impl ListGrantsFluentBuilder {
70 /// Creates a new `ListGrantsFluentBuilder`.
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 ListGrants as a reference.
79 pub fn as_input(&self) -> &crate::operation::list_grants::builders::ListGrantsInputBuilder {
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::list_grants::ListGrantsOutput,
94 ::aws_smithy_runtime_api::client::result::SdkError<
95 crate::operation::list_grants::ListGrantsError,
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::list_grants::ListGrants::operation_runtime_plugins(
104 self.handle.runtime_plugins.clone(),
105 &self.handle.conf,
106 self.config_override,
107 );
108 crate::operation::list_grants::ListGrants::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::list_grants::ListGrantsOutput,
116 crate::operation::list_grants::ListGrantsError,
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 /// Create a paginator for this request
131 ///
132 /// Paginators are used by calling [`send().await`](crate::operation::list_grants::paginator::ListGrantsPaginator::send) which returns a [`PaginationStream`](aws_smithy_async::future::pagination_stream::PaginationStream).
133 pub fn into_paginator(self) -> crate::operation::list_grants::paginator::ListGrantsPaginator {
134 crate::operation::list_grants::paginator::ListGrantsPaginator::new(self.handle, self.inner)
135 }
136 /// <p>Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer.</p>
137 /// <p>This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50.</p>
138 pub fn limit(mut self, input: i32) -> Self {
139 self.inner = self.inner.limit(input);
140 self
141 }
142 /// <p>Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer.</p>
143 /// <p>This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50.</p>
144 pub fn set_limit(mut self, input: ::std::option::Option<i32>) -> Self {
145 self.inner = self.inner.set_limit(input);
146 self
147 }
148 /// <p>Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer.</p>
149 /// <p>This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50.</p>
150 pub fn get_limit(&self) -> &::std::option::Option<i32> {
151 self.inner.get_limit()
152 }
153 /// <p>Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of <code>NextMarker</code> from the truncated response you just received.</p>
154 pub fn marker(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
155 self.inner = self.inner.marker(input.into());
156 self
157 }
158 /// <p>Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of <code>NextMarker</code> from the truncated response you just received.</p>
159 pub fn set_marker(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
160 self.inner = self.inner.set_marker(input);
161 self
162 }
163 /// <p>Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of <code>NextMarker</code> from the truncated response you just received.</p>
164 pub fn get_marker(&self) -> &::std::option::Option<::std::string::String> {
165 self.inner.get_marker()
166 }
167 /// <p>Returns only grants for the specified KMS key. This parameter is required.</p>
168 /// <p>Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN.</p>
169 /// <p>For example:</p>
170 /// <ul>
171 /// <li>
172 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
173 /// <li>
174 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
175 /// </ul>
176 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
177 pub fn key_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
178 self.inner = self.inner.key_id(input.into());
179 self
180 }
181 /// <p>Returns only grants for the specified KMS key. This parameter is required.</p>
182 /// <p>Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN.</p>
183 /// <p>For example:</p>
184 /// <ul>
185 /// <li>
186 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
187 /// <li>
188 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
189 /// </ul>
190 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
191 pub fn set_key_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
192 self.inner = self.inner.set_key_id(input);
193 self
194 }
195 /// <p>Returns only grants for the specified KMS key. This parameter is required.</p>
196 /// <p>Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN.</p>
197 /// <p>For example:</p>
198 /// <ul>
199 /// <li>
200 /// <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
201 /// <li>
202 /// <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code></p></li>
203 /// </ul>
204 /// <p>To get the key ID and key ARN for a KMS key, use <code>ListKeys</code> or <code>DescribeKey</code>.</p>
205 pub fn get_key_id(&self) -> &::std::option::Option<::std::string::String> {
206 self.inner.get_key_id()
207 }
208 /// <p>Returns only the grant with the specified grant ID. The grant ID uniquely identifies the grant.</p>
209 pub fn grant_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
210 self.inner = self.inner.grant_id(input.into());
211 self
212 }
213 /// <p>Returns only the grant with the specified grant ID. The grant ID uniquely identifies the grant.</p>
214 pub fn set_grant_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
215 self.inner = self.inner.set_grant_id(input);
216 self
217 }
218 /// <p>Returns only the grant with the specified grant ID. The grant ID uniquely identifies the grant.</p>
219 pub fn get_grant_id(&self) -> &::std::option::Option<::std::string::String> {
220 self.inner.get_grant_id()
221 }
222 /// <p>Returns only grants where the specified principal is the grantee principal for the grant.</p>
223 /// <p>You can specify either <code>GranteePrincipal</code> or <code>GranteeServicePrincipal</code>, but not both.</p>
224 pub fn grantee_principal(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
225 self.inner = self.inner.grantee_principal(input.into());
226 self
227 }
228 /// <p>Returns only grants where the specified principal is the grantee principal for the grant.</p>
229 /// <p>You can specify either <code>GranteePrincipal</code> or <code>GranteeServicePrincipal</code>, but not both.</p>
230 pub fn set_grantee_principal(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
231 self.inner = self.inner.set_grantee_principal(input);
232 self
233 }
234 /// <p>Returns only grants where the specified principal is the grantee principal for the grant.</p>
235 /// <p>You can specify either <code>GranteePrincipal</code> or <code>GranteeServicePrincipal</code>, but not both.</p>
236 pub fn get_grantee_principal(&self) -> &::std::option::Option<::std::string::String> {
237 self.inner.get_grantee_principal()
238 }
239 /// <p>Returns only grants where the specified Amazon Web Services service principal is the grantee service principal for the grant. This filter is only usable by callers in a service principal.</p>
240 /// <p>You can specify either <code>GranteePrincipal</code> or <code>GranteeServicePrincipal</code>, but not both.</p>
241 pub fn grantee_service_principal(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
242 self.inner = self.inner.grantee_service_principal(input.into());
243 self
244 }
245 /// <p>Returns only grants where the specified Amazon Web Services service principal is the grantee service principal for the grant. This filter is only usable by callers in a service principal.</p>
246 /// <p>You can specify either <code>GranteePrincipal</code> or <code>GranteeServicePrincipal</code>, but not both.</p>
247 pub fn set_grantee_service_principal(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
248 self.inner = self.inner.set_grantee_service_principal(input);
249 self
250 }
251 /// <p>Returns only grants where the specified Amazon Web Services service principal is the grantee service principal for the grant. This filter is only usable by callers in a service principal.</p>
252 /// <p>You can specify either <code>GranteePrincipal</code> or <code>GranteeServicePrincipal</code>, but not both.</p>
253 pub fn get_grantee_service_principal(&self) -> &::std::option::Option<::std::string::String> {
254 self.inner.get_grantee_service_principal()
255 }
256}