aws_sdk_lambda/operation/add_permission/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::add_permission::_add_permission_output::AddPermissionOutputBuilder;
3
4pub use crate::operation::add_permission::_add_permission_input::AddPermissionInputBuilder;
5
6impl crate::operation::add_permission::builders::AddPermissionInputBuilder {
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::add_permission::AddPermissionOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::add_permission::AddPermissionError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.add_permission();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `AddPermission`.
24///
25/// <p>Grants a <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#Principal_specifying">principal</a> permission to use a function. You can apply the policy at the function level, or specify a qualifier to restrict access to a single version or alias. If you use a qualifier, the invoker must use the full Amazon Resource Name (ARN) of that version or alias to invoke the function. Note: Lambda does not support adding policies to version $LATEST.</p>
26/// <p>To grant permission to another account, specify the account ID as the <code>Principal</code>. To grant permission to an organization defined in Organizations, specify the organization ID as the <code>PrincipalOrgID</code>. For Amazon Web Services services, the principal is a domain-style identifier that the service defines, such as <code>s3.amazonaws.com</code> or <code>sns.amazonaws.com</code>. For Amazon Web Services services, you can also specify the ARN of the associated resource as the <code>SourceArn</code>. If you grant permission to a service principal without specifying the source, other accounts could potentially configure resources in their account to invoke your Lambda function.</p>
27/// <p>This operation adds a statement to a resource-based permissions policy for the function. For more information about function policies, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html">Using resource-based policies for Lambda</a>.</p>
28#[derive(::std::clone::Clone, ::std::fmt::Debug)]
29pub struct AddPermissionFluentBuilder {
30    handle: ::std::sync::Arc<crate::client::Handle>,
31    inner: crate::operation::add_permission::builders::AddPermissionInputBuilder,
32    config_override: ::std::option::Option<crate::config::Builder>,
33}
34impl
35    crate::client::customize::internal::CustomizableSend<
36        crate::operation::add_permission::AddPermissionOutput,
37        crate::operation::add_permission::AddPermissionError,
38    > for AddPermissionFluentBuilder
39{
40    fn send(
41        self,
42        config_override: crate::config::Builder,
43    ) -> crate::client::customize::internal::BoxFuture<
44        crate::client::customize::internal::SendResult<
45            crate::operation::add_permission::AddPermissionOutput,
46            crate::operation::add_permission::AddPermissionError,
47        >,
48    > {
49        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
50    }
51}
52impl AddPermissionFluentBuilder {
53    /// Creates a new `AddPermissionFluentBuilder`.
54    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
55        Self {
56            handle,
57            inner: ::std::default::Default::default(),
58            config_override: ::std::option::Option::None,
59        }
60    }
61    /// Access the AddPermission as a reference.
62    pub fn as_input(&self) -> &crate::operation::add_permission::builders::AddPermissionInputBuilder {
63        &self.inner
64    }
65    /// Sends the request and returns the response.
66    ///
67    /// If an error occurs, an `SdkError` will be returned with additional details that
68    /// can be matched against.
69    ///
70    /// By default, any retryable failures will be retried twice. Retry behavior
71    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
72    /// set when configuring the client.
73    pub async fn send(
74        self,
75    ) -> ::std::result::Result<
76        crate::operation::add_permission::AddPermissionOutput,
77        ::aws_smithy_runtime_api::client::result::SdkError<
78            crate::operation::add_permission::AddPermissionError,
79            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
80        >,
81    > {
82        let input = self
83            .inner
84            .build()
85            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
86        let runtime_plugins = crate::operation::add_permission::AddPermission::operation_runtime_plugins(
87            self.handle.runtime_plugins.clone(),
88            &self.handle.conf,
89            self.config_override,
90        );
91        crate::operation::add_permission::AddPermission::orchestrate(&runtime_plugins, input).await
92    }
93
94    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
95    pub fn customize(
96        self,
97    ) -> crate::client::customize::CustomizableOperation<
98        crate::operation::add_permission::AddPermissionOutput,
99        crate::operation::add_permission::AddPermissionError,
100        Self,
101    > {
102        crate::client::customize::CustomizableOperation::new(self)
103    }
104    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
105        self.set_config_override(::std::option::Option::Some(config_override.into()));
106        self
107    }
108
109    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
110        self.config_override = config_override;
111        self
112    }
113    /// <p>The name or ARN of the Lambda function, version, or alias.</p>
114    /// <p class="title"><b>Name formats</b></p>
115    /// <ul>
116    /// <li>
117    /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
118    /// <li>
119    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
120    /// <li>
121    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
122    /// </ul>
123    /// <p>You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.</p>
124    pub fn function_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
125        self.inner = self.inner.function_name(input.into());
126        self
127    }
128    /// <p>The name or ARN of the Lambda function, version, or alias.</p>
129    /// <p class="title"><b>Name formats</b></p>
130    /// <ul>
131    /// <li>
132    /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
133    /// <li>
134    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
135    /// <li>
136    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
137    /// </ul>
138    /// <p>You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.</p>
139    pub fn set_function_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
140        self.inner = self.inner.set_function_name(input);
141        self
142    }
143    /// <p>The name or ARN of the Lambda function, version, or alias.</p>
144    /// <p class="title"><b>Name formats</b></p>
145    /// <ul>
146    /// <li>
147    /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
148    /// <li>
149    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
150    /// <li>
151    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
152    /// </ul>
153    /// <p>You can append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.</p>
154    pub fn get_function_name(&self) -> &::std::option::Option<::std::string::String> {
155        self.inner.get_function_name()
156    }
157    /// <p>A statement identifier that differentiates the statement from others in the same policy.</p>
158    pub fn statement_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
159        self.inner = self.inner.statement_id(input.into());
160        self
161    }
162    /// <p>A statement identifier that differentiates the statement from others in the same policy.</p>
163    pub fn set_statement_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
164        self.inner = self.inner.set_statement_id(input);
165        self
166    }
167    /// <p>A statement identifier that differentiates the statement from others in the same policy.</p>
168    pub fn get_statement_id(&self) -> &::std::option::Option<::std::string::String> {
169        self.inner.get_statement_id()
170    }
171    /// <p>The action that the principal can use on the function. For example, <code>lambda:InvokeFunction</code> or <code>lambda:GetFunction</code>.</p>
172    pub fn action(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
173        self.inner = self.inner.action(input.into());
174        self
175    }
176    /// <p>The action that the principal can use on the function. For example, <code>lambda:InvokeFunction</code> or <code>lambda:GetFunction</code>.</p>
177    pub fn set_action(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
178        self.inner = self.inner.set_action(input);
179        self
180    }
181    /// <p>The action that the principal can use on the function. For example, <code>lambda:InvokeFunction</code> or <code>lambda:GetFunction</code>.</p>
182    pub fn get_action(&self) -> &::std::option::Option<::std::string::String> {
183        self.inner.get_action()
184    }
185    /// <p>The Amazon Web Services service, Amazon Web Services account, IAM user, or IAM role that invokes the function. If you specify a service, use <code>SourceArn</code> or <code>SourceAccount</code> to limit who can invoke the function through that service.</p>
186    pub fn principal(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
187        self.inner = self.inner.principal(input.into());
188        self
189    }
190    /// <p>The Amazon Web Services service, Amazon Web Services account, IAM user, or IAM role that invokes the function. If you specify a service, use <code>SourceArn</code> or <code>SourceAccount</code> to limit who can invoke the function through that service.</p>
191    pub fn set_principal(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
192        self.inner = self.inner.set_principal(input);
193        self
194    }
195    /// <p>The Amazon Web Services service, Amazon Web Services account, IAM user, or IAM role that invokes the function. If you specify a service, use <code>SourceArn</code> or <code>SourceAccount</code> to limit who can invoke the function through that service.</p>
196    pub fn get_principal(&self) -> &::std::option::Option<::std::string::String> {
197        self.inner.get_principal()
198    }
199    /// <p>For Amazon Web Services services, the ARN of the Amazon Web Services resource that invokes the function. For example, an Amazon S3 bucket or Amazon SNS topic.</p>
200    /// <p>Note that Lambda configures the comparison using the <code>StringLike</code> operator.</p>
201    pub fn source_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
202        self.inner = self.inner.source_arn(input.into());
203        self
204    }
205    /// <p>For Amazon Web Services services, the ARN of the Amazon Web Services resource that invokes the function. For example, an Amazon S3 bucket or Amazon SNS topic.</p>
206    /// <p>Note that Lambda configures the comparison using the <code>StringLike</code> operator.</p>
207    pub fn set_source_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
208        self.inner = self.inner.set_source_arn(input);
209        self
210    }
211    /// <p>For Amazon Web Services services, the ARN of the Amazon Web Services resource that invokes the function. For example, an Amazon S3 bucket or Amazon SNS topic.</p>
212    /// <p>Note that Lambda configures the comparison using the <code>StringLike</code> operator.</p>
213    pub fn get_source_arn(&self) -> &::std::option::Option<::std::string::String> {
214        self.inner.get_source_arn()
215    }
216    /// <p>For Amazon Web Services service, the ID of the Amazon Web Services account that owns the resource. Use this together with <code>SourceArn</code> to ensure that the specified account owns the resource. It is possible for an Amazon S3 bucket to be deleted by its owner and recreated by another account.</p>
217    pub fn source_account(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
218        self.inner = self.inner.source_account(input.into());
219        self
220    }
221    /// <p>For Amazon Web Services service, the ID of the Amazon Web Services account that owns the resource. Use this together with <code>SourceArn</code> to ensure that the specified account owns the resource. It is possible for an Amazon S3 bucket to be deleted by its owner and recreated by another account.</p>
222    pub fn set_source_account(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
223        self.inner = self.inner.set_source_account(input);
224        self
225    }
226    /// <p>For Amazon Web Services service, the ID of the Amazon Web Services account that owns the resource. Use this together with <code>SourceArn</code> to ensure that the specified account owns the resource. It is possible for an Amazon S3 bucket to be deleted by its owner and recreated by another account.</p>
227    pub fn get_source_account(&self) -> &::std::option::Option<::std::string::String> {
228        self.inner.get_source_account()
229    }
230    /// <p>For Alexa Smart Home functions, a token that the invoker must supply.</p>
231    pub fn event_source_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
232        self.inner = self.inner.event_source_token(input.into());
233        self
234    }
235    /// <p>For Alexa Smart Home functions, a token that the invoker must supply.</p>
236    pub fn set_event_source_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
237        self.inner = self.inner.set_event_source_token(input);
238        self
239    }
240    /// <p>For Alexa Smart Home functions, a token that the invoker must supply.</p>
241    pub fn get_event_source_token(&self) -> &::std::option::Option<::std::string::String> {
242        self.inner.get_event_source_token()
243    }
244    /// <p>Specify a version or alias to add permissions to a published version of the function.</p>
245    pub fn qualifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
246        self.inner = self.inner.qualifier(input.into());
247        self
248    }
249    /// <p>Specify a version or alias to add permissions to a published version of the function.</p>
250    pub fn set_qualifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
251        self.inner = self.inner.set_qualifier(input);
252        self
253    }
254    /// <p>Specify a version or alias to add permissions to a published version of the function.</p>
255    pub fn get_qualifier(&self) -> &::std::option::Option<::std::string::String> {
256        self.inner.get_qualifier()
257    }
258    /// <p>Update the policy only if the revision ID matches the ID that's specified. Use this option to avoid modifying a policy that has changed since you last read it.</p>
259    pub fn revision_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
260        self.inner = self.inner.revision_id(input.into());
261        self
262    }
263    /// <p>Update the policy only if the revision ID matches the ID that's specified. Use this option to avoid modifying a policy that has changed since you last read it.</p>
264    pub fn set_revision_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
265        self.inner = self.inner.set_revision_id(input);
266        self
267    }
268    /// <p>Update the policy only if the revision ID matches the ID that's specified. Use this option to avoid modifying a policy that has changed since you last read it.</p>
269    pub fn get_revision_id(&self) -> &::std::option::Option<::std::string::String> {
270        self.inner.get_revision_id()
271    }
272    /// <p>The identifier for your organization in Organizations. Use this to grant permissions to all the Amazon Web Services accounts under this organization.</p>
273    pub fn principal_org_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
274        self.inner = self.inner.principal_org_id(input.into());
275        self
276    }
277    /// <p>The identifier for your organization in Organizations. Use this to grant permissions to all the Amazon Web Services accounts under this organization.</p>
278    pub fn set_principal_org_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
279        self.inner = self.inner.set_principal_org_id(input);
280        self
281    }
282    /// <p>The identifier for your organization in Organizations. Use this to grant permissions to all the Amazon Web Services accounts under this organization.</p>
283    pub fn get_principal_org_id(&self) -> &::std::option::Option<::std::string::String> {
284        self.inner.get_principal_org_id()
285    }
286    /// <p>The type of authentication that your function URL uses. Set to <code>AWS_IAM</code> if you want to restrict access to authenticated users only. Set to <code>NONE</code> if you want to bypass IAM authentication to create a public endpoint. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html">Security and auth model for Lambda function URLs</a>.</p>
287    pub fn function_url_auth_type(mut self, input: crate::types::FunctionUrlAuthType) -> Self {
288        self.inner = self.inner.function_url_auth_type(input);
289        self
290    }
291    /// <p>The type of authentication that your function URL uses. Set to <code>AWS_IAM</code> if you want to restrict access to authenticated users only. Set to <code>NONE</code> if you want to bypass IAM authentication to create a public endpoint. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html">Security and auth model for Lambda function URLs</a>.</p>
292    pub fn set_function_url_auth_type(mut self, input: ::std::option::Option<crate::types::FunctionUrlAuthType>) -> Self {
293        self.inner = self.inner.set_function_url_auth_type(input);
294        self
295    }
296    /// <p>The type of authentication that your function URL uses. Set to <code>AWS_IAM</code> if you want to restrict access to authenticated users only. Set to <code>NONE</code> if you want to bypass IAM authentication to create a public endpoint. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html">Security and auth model for Lambda function URLs</a>.</p>
297    pub fn get_function_url_auth_type(&self) -> &::std::option::Option<crate::types::FunctionUrlAuthType> {
298        self.inner.get_function_url_auth_type()
299    }
300}