aws_sdk_dynamodb/operation/put_resource_policy/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_resource_policy::_put_resource_policy_output::PutResourcePolicyOutputBuilder;
3
4pub use crate::operation::put_resource_policy::_put_resource_policy_input::PutResourcePolicyInputBuilder;
5
6impl crate::operation::put_resource_policy::builders::PutResourcePolicyInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(self, client: &crate::Client) -> ::std::result::Result<
9 crate::operation::put_resource_policy::PutResourcePolicyOutput,
10 ::aws_smithy_runtime_api::client::result::SdkError<
11 crate::operation::put_resource_policy::PutResourcePolicyError,
12 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse
13 >
14 > {
15 let mut fluent_builder = client.put_resource_policy();
16 fluent_builder.inner = self;
17 fluent_builder.send().await
18 }
19 }
20/// Fluent builder constructing a request to `PutResourcePolicy`.
21///
22/// <p>Attaches a resource-based policy document to the resource, which can be a table or stream. When you attach a resource-based policy using this API, the policy application is <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html"> <i>eventually consistent</i> </a>.</p>
23/// <p><code>PutResourcePolicy</code> is an idempotent operation; running it multiple times on the same resource using the same policy document will return the same revision ID. If you specify an <code>ExpectedRevisionId</code> that doesn't match the current policy's <code>RevisionId</code>, the <code>PolicyNotFoundException</code> will be returned.</p><note>
24/// <p><code>PutResourcePolicy</code> is an asynchronous operation. If you issue a <code>GetResourcePolicy</code> request immediately after a <code>PutResourcePolicy</code> request, DynamoDB might return your previous policy, if there was one, or return the <code>PolicyNotFoundException</code>. This is because <code>GetResourcePolicy</code> uses an eventually consistent query, and the metadata for your policy or table might not be available at that moment. Wait for a few seconds, and then try the <code>GetResourcePolicy</code> request again.</p>
25/// </note>
26#[derive(::std::clone::Clone, ::std::fmt::Debug)]
27pub struct PutResourcePolicyFluentBuilder {
28 handle: ::std::sync::Arc<crate::client::Handle>,
29 inner: crate::operation::put_resource_policy::builders::PutResourcePolicyInputBuilder,
30config_override: ::std::option::Option<crate::config::Builder>,
31 }
32impl
33 crate::client::customize::internal::CustomizableSend<
34 crate::operation::put_resource_policy::PutResourcePolicyOutput,
35 crate::operation::put_resource_policy::PutResourcePolicyError,
36 > for PutResourcePolicyFluentBuilder
37 {
38 fn send(
39 self,
40 config_override: crate::config::Builder,
41 ) -> crate::client::customize::internal::BoxFuture<
42 crate::client::customize::internal::SendResult<
43 crate::operation::put_resource_policy::PutResourcePolicyOutput,
44 crate::operation::put_resource_policy::PutResourcePolicyError,
45 >,
46 > {
47 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
48 }
49 }
50impl PutResourcePolicyFluentBuilder {
51 /// Creates a new `PutResourcePolicyFluentBuilder`.
52 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
53 Self {
54 handle,
55 inner: ::std::default::Default::default(),
56 config_override: ::std::option::Option::None,
57 }
58 }
59 /// Access the PutResourcePolicy as a reference.
60 pub fn as_input(&self) -> &crate::operation::put_resource_policy::builders::PutResourcePolicyInputBuilder {
61 &self.inner
62 }
63 /// Sends the request and returns the response.
64 ///
65 /// If an error occurs, an `SdkError` will be returned with additional details that
66 /// can be matched against.
67 ///
68 /// By default, any retryable failures will be retried twice. Retry behavior
69 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
70 /// set when configuring the client. Note: retries are enabled by default when using
71 /// `aws_config::load_from_env()` or when using `BehaviorVersion::v2025_01_17()` or later.
72 pub async fn send(self) -> ::std::result::Result<crate::operation::put_resource_policy::PutResourcePolicyOutput, ::aws_smithy_runtime_api::client::result::SdkError<crate::operation::put_resource_policy::PutResourcePolicyError, ::aws_smithy_runtime_api::client::orchestrator::HttpResponse>> {
73 let input = self.inner.build().map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
74 let runtime_plugins = crate::operation::put_resource_policy::PutResourcePolicy::operation_runtime_plugins(
75 self.handle.runtime_plugins.clone(),
76 &self.handle.conf,
77 self.config_override,
78 );
79 crate::operation::put_resource_policy::PutResourcePolicy::orchestrate(&runtime_plugins, input).await
80 }
81
82 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
83 pub fn customize(
84 self,
85 ) -> crate::client::customize::CustomizableOperation<crate::operation::put_resource_policy::PutResourcePolicyOutput, crate::operation::put_resource_policy::PutResourcePolicyError, Self> {
86 crate::client::customize::CustomizableOperation::new(self)
87 }
88 pub(crate) fn config_override(
89 mut self,
90 config_override: impl ::std::convert::Into<crate::config::Builder>,
91 ) -> Self {
92 self.set_config_override(::std::option::Option::Some(config_override.into()));
93 self
94 }
95
96 pub(crate) fn set_config_override(
97 &mut self,
98 config_override: ::std::option::Option<crate::config::Builder>,
99 ) -> &mut Self {
100 self.config_override = config_override;
101 self
102 }
103 /// <p>The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams.</p>
104 /// <p>You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the <code>Resource</code> field of a given <code>Statement</code> in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple <code>Statement</code> fields in your policy document.</p>
105 pub fn resource_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
106 self.inner = self.inner.resource_arn(input.into());
107 self
108 }
109 /// <p>The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams.</p>
110 /// <p>You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the <code>Resource</code> field of a given <code>Statement</code> in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple <code>Statement</code> fields in your policy document.</p>
111 pub fn set_resource_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
112 self.inner = self.inner.set_resource_arn(input);
113 self
114 }
115 /// <p>The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached. The resources you can specify include tables and streams.</p>
116 /// <p>You can control index permissions using the base table's policy. To specify the same permission level for your table and its indexes, you can provide both the table and index Amazon Resource Name (ARN)s in the <code>Resource</code> field of a given <code>Statement</code> in your policy document. Alternatively, to specify different permissions for your table, indexes, or both, you can define multiple <code>Statement</code> fields in your policy document.</p>
117 pub fn get_resource_arn(&self) -> &::std::option::Option<::std::string::String> {
118 self.inner.get_resource_arn()
119 }
120 /// <p>An Amazon Web Services resource-based policy document in JSON format.</p>
121 /// <ul>
122 /// <li>
123 /// <p>The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit.</p></li>
124 /// <li>
125 /// <p>Within a resource-based policy, if the action for a DynamoDB service-linked role (SLR) to replicate data for a global table is denied, adding or deleting a replica will fail with an error.</p></li>
126 /// </ul>
127 /// <p>For a full list of all considerations that apply while attaching a resource-based policy, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/rbac-considerations.html">Resource-based policy considerations</a>.</p>
128 pub fn policy(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
129 self.inner = self.inner.policy(input.into());
130 self
131 }
132 /// <p>An Amazon Web Services resource-based policy document in JSON format.</p>
133 /// <ul>
134 /// <li>
135 /// <p>The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit.</p></li>
136 /// <li>
137 /// <p>Within a resource-based policy, if the action for a DynamoDB service-linked role (SLR) to replicate data for a global table is denied, adding or deleting a replica will fail with an error.</p></li>
138 /// </ul>
139 /// <p>For a full list of all considerations that apply while attaching a resource-based policy, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/rbac-considerations.html">Resource-based policy considerations</a>.</p>
140 pub fn set_policy(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
141 self.inner = self.inner.set_policy(input);
142 self
143 }
144 /// <p>An Amazon Web Services resource-based policy document in JSON format.</p>
145 /// <ul>
146 /// <li>
147 /// <p>The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit.</p></li>
148 /// <li>
149 /// <p>Within a resource-based policy, if the action for a DynamoDB service-linked role (SLR) to replicate data for a global table is denied, adding or deleting a replica will fail with an error.</p></li>
150 /// </ul>
151 /// <p>For a full list of all considerations that apply while attaching a resource-based policy, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/rbac-considerations.html">Resource-based policy considerations</a>.</p>
152 pub fn get_policy(&self) -> &::std::option::Option<::std::string::String> {
153 self.inner.get_policy()
154 }
155 /// <p>A string value that you can use to conditionally update your policy. You can provide the revision ID of your existing policy to make mutating requests against that policy.</p><note>
156 /// <p>When you provide an expected revision ID, if the revision ID of the existing policy on the resource doesn't match or if there's no policy attached to the resource, your request will be rejected with a <code>PolicyNotFoundException</code>.</p>
157 /// </note>
158 /// <p>To conditionally attach a policy when no policy exists for the resource, specify <code>NO_POLICY</code> for the revision ID.</p>
159 pub fn expected_revision_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
160 self.inner = self.inner.expected_revision_id(input.into());
161 self
162 }
163 /// <p>A string value that you can use to conditionally update your policy. You can provide the revision ID of your existing policy to make mutating requests against that policy.</p><note>
164 /// <p>When you provide an expected revision ID, if the revision ID of the existing policy on the resource doesn't match or if there's no policy attached to the resource, your request will be rejected with a <code>PolicyNotFoundException</code>.</p>
165 /// </note>
166 /// <p>To conditionally attach a policy when no policy exists for the resource, specify <code>NO_POLICY</code> for the revision ID.</p>
167 pub fn set_expected_revision_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
168 self.inner = self.inner.set_expected_revision_id(input);
169 self
170 }
171 /// <p>A string value that you can use to conditionally update your policy. You can provide the revision ID of your existing policy to make mutating requests against that policy.</p><note>
172 /// <p>When you provide an expected revision ID, if the revision ID of the existing policy on the resource doesn't match or if there's no policy attached to the resource, your request will be rejected with a <code>PolicyNotFoundException</code>.</p>
173 /// </note>
174 /// <p>To conditionally attach a policy when no policy exists for the resource, specify <code>NO_POLICY</code> for the revision ID.</p>
175 pub fn get_expected_revision_id(&self) -> &::std::option::Option<::std::string::String> {
176 self.inner.get_expected_revision_id()
177 }
178 /// <p>Set this parameter to <code>true</code> to confirm that you want to remove your permissions to change the policy of this resource in the future.</p>
179 pub fn confirm_remove_self_resource_access(mut self, input: bool) -> Self {
180 self.inner = self.inner.confirm_remove_self_resource_access(input);
181 self
182 }
183 /// <p>Set this parameter to <code>true</code> to confirm that you want to remove your permissions to change the policy of this resource in the future.</p>
184 pub fn set_confirm_remove_self_resource_access(mut self, input: ::std::option::Option<bool>) -> Self {
185 self.inner = self.inner.set_confirm_remove_self_resource_access(input);
186 self
187 }
188 /// <p>Set this parameter to <code>true</code> to confirm that you want to remove your permissions to change the policy of this resource in the future.</p>
189 pub fn get_confirm_remove_self_resource_access(&self) -> &::std::option::Option<bool> {
190 self.inner.get_confirm_remove_self_resource_access()
191 }
192}
193