aws_sdk_lambda/operation/invoke/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::invoke::_invoke_output::InvokeOutputBuilder;
3
4pub use crate::operation::invoke::_invoke_input::InvokeInputBuilder;
5
6impl crate::operation::invoke::builders::InvokeInputBuilder {
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::invoke::InvokeOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::invoke::InvokeError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.invoke();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `Invoke`.
24///
25/// <p>Invokes a Lambda function. You can invoke a function synchronously (and wait for the response), or asynchronously. By default, Lambda invokes your function synchronously (i.e. the<code>InvocationType</code> is <code>RequestResponse</code>). To invoke a function asynchronously, set <code>InvocationType</code> to <code>Event</code>. Lambda passes the <code>ClientContext</code> object to your function for synchronous invocations only.</p>
26/// <p>For <a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-sync.html">synchronous invocation</a>, details about the function response, including errors, are included in the response body and headers. For either invocation type, you can find more information in the <a href="https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions.html">execution log</a> and <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html">trace</a>.</p>
27/// <p>When an error occurs, your function may be invoked multiple times. Retry behavior varies by error type, client, event source, and invocation type. For example, if you invoke a function asynchronously and it returns an error, Lambda executes the function up to two more times. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-retries.html">Error handling and automatic retries in Lambda</a>.</p>
28/// <p>For <a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html">asynchronous invocation</a>, Lambda adds events to a queue before sending them to your function. If your function does not have enough capacity to keep up with the queue, events may be lost. Occasionally, your function may receive the same event multiple times, even if no error occurs. To retain events that were not processed, configure your function with a <a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq">dead-letter queue</a>.</p>
29/// <p>The status code in the API response doesn't reflect function errors. Error codes are reserved for errors that prevent your function from executing, such as permissions errors, <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html">quota</a> errors, or issues with your function's code and configuration. For example, Lambda returns <code>TooManyRequestsException</code> if running the function would cause you to exceed a concurrency limit at either the account level (<code>ConcurrentInvocationLimitExceeded</code>) or function level (<code>ReservedFunctionConcurrentInvocationLimitExceeded</code>).</p>
30/// <p>For functions with a long timeout, your client might disconnect during synchronous invocation while it waits for a response. Configure your HTTP client, SDK, firewall, proxy, or operating system to allow for long connections with timeout or keep-alive settings.</p>
31/// <p>This operation requires permission for the <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awslambda.html">lambda:InvokeFunction</a> action. For details on how to set up permissions for cross-account invocations, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html#permissions-resource-xaccountinvoke">Granting function access to other accounts</a>.</p>
32#[derive(::std::clone::Clone, ::std::fmt::Debug)]
33pub struct InvokeFluentBuilder {
34    handle: ::std::sync::Arc<crate::client::Handle>,
35    inner: crate::operation::invoke::builders::InvokeInputBuilder,
36    config_override: ::std::option::Option<crate::config::Builder>,
37}
38impl crate::client::customize::internal::CustomizableSend<crate::operation::invoke::InvokeOutput, crate::operation::invoke::InvokeError>
39    for InvokeFluentBuilder
40{
41    fn send(
42        self,
43        config_override: crate::config::Builder,
44    ) -> crate::client::customize::internal::BoxFuture<
45        crate::client::customize::internal::SendResult<crate::operation::invoke::InvokeOutput, crate::operation::invoke::InvokeError>,
46    > {
47        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
48    }
49}
50impl InvokeFluentBuilder {
51    /// Creates a new `InvokeFluentBuilder`.
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 Invoke as a reference.
60    pub fn as_input(&self) -> &crate::operation::invoke::builders::InvokeInputBuilder {
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.
71    pub async fn send(
72        self,
73    ) -> ::std::result::Result<
74        crate::operation::invoke::InvokeOutput,
75        ::aws_smithy_runtime_api::client::result::SdkError<
76            crate::operation::invoke::InvokeError,
77            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
78        >,
79    > {
80        let input = self
81            .inner
82            .build()
83            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
84        let runtime_plugins =
85            crate::operation::invoke::Invoke::operation_runtime_plugins(self.handle.runtime_plugins.clone(), &self.handle.conf, self.config_override);
86        crate::operation::invoke::Invoke::orchestrate(&runtime_plugins, input).await
87    }
88
89    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
90    pub fn customize(
91        self,
92    ) -> crate::client::customize::CustomizableOperation<crate::operation::invoke::InvokeOutput, crate::operation::invoke::InvokeError, Self> {
93        crate::client::customize::CustomizableOperation::new(self)
94    }
95    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
96        self.set_config_override(::std::option::Option::Some(config_override.into()));
97        self
98    }
99
100    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
101        self.config_override = config_override;
102        self
103    }
104    /// <p>The name or ARN of the Lambda function, version, or alias.</p>
105    /// <p class="title"><b>Name formats</b></p>
106    /// <ul>
107    /// <li>
108    /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
109    /// <li>
110    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
111    /// <li>
112    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
113    /// </ul>
114    /// <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>
115    pub fn function_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
116        self.inner = self.inner.function_name(input.into());
117        self
118    }
119    /// <p>The name or ARN of the Lambda function, version, or alias.</p>
120    /// <p class="title"><b>Name formats</b></p>
121    /// <ul>
122    /// <li>
123    /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
124    /// <li>
125    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
126    /// <li>
127    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
128    /// </ul>
129    /// <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>
130    pub fn set_function_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
131        self.inner = self.inner.set_function_name(input);
132        self
133    }
134    /// <p>The name or ARN of the Lambda function, version, or alias.</p>
135    /// <p class="title"><b>Name formats</b></p>
136    /// <ul>
137    /// <li>
138    /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
139    /// <li>
140    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
141    /// <li>
142    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
143    /// </ul>
144    /// <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>
145    pub fn get_function_name(&self) -> &::std::option::Option<::std::string::String> {
146        self.inner.get_function_name()
147    }
148    /// <p>Choose from the following options.</p>
149    /// <ul>
150    /// <li>
151    /// <p><code>RequestResponse</code> (default) – Invoke the function synchronously. Keep the connection open until the function returns a response or times out. The API response includes the function response and additional data.</p></li>
152    /// <li>
153    /// <p><code>Event</code> – Invoke the function asynchronously. Send events that fail multiple times to the function's dead-letter queue (if one is configured). The API response only includes a status code.</p></li>
154    /// <li>
155    /// <p><code>DryRun</code> – Validate parameter values and verify that the user or role has permission to invoke the function.</p></li>
156    /// </ul>
157    pub fn invocation_type(mut self, input: crate::types::InvocationType) -> Self {
158        self.inner = self.inner.invocation_type(input);
159        self
160    }
161    /// <p>Choose from the following options.</p>
162    /// <ul>
163    /// <li>
164    /// <p><code>RequestResponse</code> (default) – Invoke the function synchronously. Keep the connection open until the function returns a response or times out. The API response includes the function response and additional data.</p></li>
165    /// <li>
166    /// <p><code>Event</code> – Invoke the function asynchronously. Send events that fail multiple times to the function's dead-letter queue (if one is configured). The API response only includes a status code.</p></li>
167    /// <li>
168    /// <p><code>DryRun</code> – Validate parameter values and verify that the user or role has permission to invoke the function.</p></li>
169    /// </ul>
170    pub fn set_invocation_type(mut self, input: ::std::option::Option<crate::types::InvocationType>) -> Self {
171        self.inner = self.inner.set_invocation_type(input);
172        self
173    }
174    /// <p>Choose from the following options.</p>
175    /// <ul>
176    /// <li>
177    /// <p><code>RequestResponse</code> (default) – Invoke the function synchronously. Keep the connection open until the function returns a response or times out. The API response includes the function response and additional data.</p></li>
178    /// <li>
179    /// <p><code>Event</code> – Invoke the function asynchronously. Send events that fail multiple times to the function's dead-letter queue (if one is configured). The API response only includes a status code.</p></li>
180    /// <li>
181    /// <p><code>DryRun</code> – Validate parameter values and verify that the user or role has permission to invoke the function.</p></li>
182    /// </ul>
183    pub fn get_invocation_type(&self) -> &::std::option::Option<crate::types::InvocationType> {
184        self.inner.get_invocation_type()
185    }
186    /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
187    pub fn log_type(mut self, input: crate::types::LogType) -> Self {
188        self.inner = self.inner.log_type(input);
189        self
190    }
191    /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
192    pub fn set_log_type(mut self, input: ::std::option::Option<crate::types::LogType>) -> Self {
193        self.inner = self.inner.set_log_type(input);
194        self
195    }
196    /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
197    pub fn get_log_type(&self) -> &::std::option::Option<crate::types::LogType> {
198        self.inner.get_log_type()
199    }
200    /// <p>Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object. Lambda passes the <code>ClientContext</code> object to your function for synchronous invocations only.</p>
201    pub fn client_context(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
202        self.inner = self.inner.client_context(input.into());
203        self
204    }
205    /// <p>Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object. Lambda passes the <code>ClientContext</code> object to your function for synchronous invocations only.</p>
206    pub fn set_client_context(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
207        self.inner = self.inner.set_client_context(input);
208        self
209    }
210    /// <p>Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object. Lambda passes the <code>ClientContext</code> object to your function for synchronous invocations only.</p>
211    pub fn get_client_context(&self) -> &::std::option::Option<::std::string::String> {
212        self.inner.get_client_context()
213    }
214    /// <p>The JSON that you want to provide to your Lambda function as input.</p>
215    /// <p>You can enter the JSON directly. For example, <code>--payload '{ "key": "value" }'</code>. You can also specify a file path. For example, <code>--payload file://payload.json</code>.</p>
216    pub fn payload(mut self, input: ::aws_smithy_types::Blob) -> Self {
217        self.inner = self.inner.payload(input);
218        self
219    }
220    /// <p>The JSON that you want to provide to your Lambda function as input.</p>
221    /// <p>You can enter the JSON directly. For example, <code>--payload '{ "key": "value" }'</code>. You can also specify a file path. For example, <code>--payload file://payload.json</code>.</p>
222    pub fn set_payload(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
223        self.inner = self.inner.set_payload(input);
224        self
225    }
226    /// <p>The JSON that you want to provide to your Lambda function as input.</p>
227    /// <p>You can enter the JSON directly. For example, <code>--payload '{ "key": "value" }'</code>. You can also specify a file path. For example, <code>--payload file://payload.json</code>.</p>
228    pub fn get_payload(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
229        self.inner.get_payload()
230    }
231    /// <p>Specify a version or alias to invoke a published version of the function.</p>
232    pub fn qualifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
233        self.inner = self.inner.qualifier(input.into());
234        self
235    }
236    /// <p>Specify a version or alias to invoke a published version of the function.</p>
237    pub fn set_qualifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
238        self.inner = self.inner.set_qualifier(input);
239        self
240    }
241    /// <p>Specify a version or alias to invoke a published version of the function.</p>
242    pub fn get_qualifier(&self) -> &::std::option::Option<::std::string::String> {
243        self.inner.get_qualifier()
244    }
245}