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 synchronous invocations, the maximum payload size is 6 MB. For asynchronous invocations, the maximum payload size is 1 MB.</p>
27/// <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>
28/// <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>
29/// <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>
30/// <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>
31/// <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>
32/// <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>
33#[derive(::std::clone::Clone, ::std::fmt::Debug)]
34pub struct InvokeFluentBuilder {
35 handle: ::std::sync::Arc<crate::client::Handle>,
36 inner: crate::operation::invoke::builders::InvokeInputBuilder,
37 config_override: ::std::option::Option<crate::config::Builder>,
38}
39impl crate::client::customize::internal::CustomizableSend<crate::operation::invoke::InvokeOutput, crate::operation::invoke::InvokeError>
40 for InvokeFluentBuilder
41{
42 fn send(
43 self,
44 config_override: crate::config::Builder,
45 ) -> crate::client::customize::internal::BoxFuture<
46 crate::client::customize::internal::SendResult<crate::operation::invoke::InvokeOutput, crate::operation::invoke::InvokeError>,
47 > {
48 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
49 }
50}
51impl InvokeFluentBuilder {
52 /// Creates a new `InvokeFluentBuilder`.
53 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
54 Self {
55 handle,
56 inner: ::std::default::Default::default(),
57 config_override: ::std::option::Option::None,
58 }
59 }
60 /// Access the Invoke as a reference.
61 pub fn as_input(&self) -> &crate::operation::invoke::builders::InvokeInputBuilder {
62 &self.inner
63 }
64 /// Sends the request and returns the response.
65 ///
66 /// If an error occurs, an `SdkError` will be returned with additional details that
67 /// can be matched against.
68 ///
69 /// By default, any retryable failures will be retried twice. Retry behavior
70 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
71 /// set when configuring the client.
72 pub async fn send(
73 self,
74 ) -> ::std::result::Result<
75 crate::operation::invoke::InvokeOutput,
76 ::aws_smithy_runtime_api::client::result::SdkError<
77 crate::operation::invoke::InvokeError,
78 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
79 >,
80 > {
81 let input = self
82 .inner
83 .build()
84 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
85 let runtime_plugins =
86 crate::operation::invoke::Invoke::operation_runtime_plugins(self.handle.runtime_plugins.clone(), &self.handle.conf, self.config_override);
87 crate::operation::invoke::Invoke::orchestrate(&runtime_plugins, input).await
88 }
89
90 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
91 pub fn customize(
92 self,
93 ) -> crate::client::customize::CustomizableOperation<crate::operation::invoke::InvokeOutput, crate::operation::invoke::InvokeError, Self> {
94 crate::client::customize::CustomizableOperation::new(self)
95 }
96 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
97 self.set_config_override(::std::option::Option::Some(config_override.into()));
98 self
99 }
100
101 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
102 self.config_override = config_override;
103 self
104 }
105 /// <p>The name or ARN of the Lambda function, version, or alias.</p>
106 /// <p class="title"><b>Name formats</b></p>
107 /// <ul>
108 /// <li>
109 /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
110 /// <li>
111 /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
112 /// <li>
113 /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
114 /// </ul>
115 /// <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>
116 pub fn function_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
117 self.inner = self.inner.function_name(input.into());
118 self
119 }
120 /// <p>The name or ARN of the Lambda function, version, or alias.</p>
121 /// <p class="title"><b>Name formats</b></p>
122 /// <ul>
123 /// <li>
124 /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
125 /// <li>
126 /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
127 /// <li>
128 /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
129 /// </ul>
130 /// <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>
131 pub fn set_function_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
132 self.inner = self.inner.set_function_name(input);
133 self
134 }
135 /// <p>The name or ARN of the Lambda function, version, or alias.</p>
136 /// <p class="title"><b>Name formats</b></p>
137 /// <ul>
138 /// <li>
139 /// <p><b>Function name</b> – <code>my-function</code> (name-only), <code>my-function:v1</code> (with alias).</p></li>
140 /// <li>
141 /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
142 /// <li>
143 /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
144 /// </ul>
145 /// <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>
146 pub fn get_function_name(&self) -> &::std::option::Option<::std::string::String> {
147 self.inner.get_function_name()
148 }
149 /// <p>Choose from the following options.</p>
150 /// <ul>
151 /// <li>
152 /// <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>
153 /// <li>
154 /// <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>
155 /// <li>
156 /// <p><code>DryRun</code> – Validate parameter values and verify that the user or role has permission to invoke the function.</p></li>
157 /// </ul>
158 pub fn invocation_type(mut self, input: crate::types::InvocationType) -> Self {
159 self.inner = self.inner.invocation_type(input);
160 self
161 }
162 /// <p>Choose from the following options.</p>
163 /// <ul>
164 /// <li>
165 /// <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>
166 /// <li>
167 /// <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>
168 /// <li>
169 /// <p><code>DryRun</code> – Validate parameter values and verify that the user or role has permission to invoke the function.</p></li>
170 /// </ul>
171 pub fn set_invocation_type(mut self, input: ::std::option::Option<crate::types::InvocationType>) -> Self {
172 self.inner = self.inner.set_invocation_type(input);
173 self
174 }
175 /// <p>Choose from the following options.</p>
176 /// <ul>
177 /// <li>
178 /// <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>
179 /// <li>
180 /// <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>
181 /// <li>
182 /// <p><code>DryRun</code> – Validate parameter values and verify that the user or role has permission to invoke the function.</p></li>
183 /// </ul>
184 pub fn get_invocation_type(&self) -> &::std::option::Option<crate::types::InvocationType> {
185 self.inner.get_invocation_type()
186 }
187 /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
188 pub fn log_type(mut self, input: crate::types::LogType) -> Self {
189 self.inner = self.inner.log_type(input);
190 self
191 }
192 /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
193 pub fn set_log_type(mut self, input: ::std::option::Option<crate::types::LogType>) -> Self {
194 self.inner = self.inner.set_log_type(input);
195 self
196 }
197 /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
198 pub fn get_log_type(&self) -> &::std::option::Option<crate::types::LogType> {
199 self.inner.get_log_type()
200 }
201 /// <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>
202 pub fn client_context(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
203 self.inner = self.inner.client_context(input.into());
204 self
205 }
206 /// <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>
207 pub fn set_client_context(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
208 self.inner = self.inner.set_client_context(input);
209 self
210 }
211 /// <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>
212 pub fn get_client_context(&self) -> &::std::option::Option<::std::string::String> {
213 self.inner.get_client_context()
214 }
215 /// <p>The JSON that you want to provide to your Lambda function as input. The maximum payload size is 6 MB for synchronous invocations and 1 MB for asynchronous invocations.</p>
216 /// <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>
217 pub fn payload(mut self, input: ::aws_smithy_types::Blob) -> Self {
218 self.inner = self.inner.payload(input);
219 self
220 }
221 /// <p>The JSON that you want to provide to your Lambda function as input. The maximum payload size is 6 MB for synchronous invocations and 1 MB for asynchronous invocations.</p>
222 /// <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>
223 pub fn set_payload(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
224 self.inner = self.inner.set_payload(input);
225 self
226 }
227 /// <p>The JSON that you want to provide to your Lambda function as input. The maximum payload size is 6 MB for synchronous invocations and 1 MB for asynchronous invocations.</p>
228 /// <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>
229 pub fn get_payload(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
230 self.inner.get_payload()
231 }
232 /// <p>Specify a version or alias to invoke a published version of the function.</p>
233 pub fn qualifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
234 self.inner = self.inner.qualifier(input.into());
235 self
236 }
237 /// <p>Specify a version or alias to invoke a published version of the function.</p>
238 pub fn set_qualifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
239 self.inner = self.inner.set_qualifier(input);
240 self
241 }
242 /// <p>Specify a version or alias to invoke a published version of the function.</p>
243 pub fn get_qualifier(&self) -> &::std::option::Option<::std::string::String> {
244 self.inner.get_qualifier()
245 }
246}