aws_sdk_lambda/operation/invoke_with_response_stream/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::invoke_with_response_stream::_invoke_with_response_stream_output::InvokeWithResponseStreamOutputBuilder;
3
4pub use crate::operation::invoke_with_response_stream::_invoke_with_response_stream_input::InvokeWithResponseStreamInputBuilder;
5
6impl crate::operation::invoke_with_response_stream::builders::InvokeWithResponseStreamInputBuilder {
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_with_response_stream::InvokeWithResponseStreamOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::invoke_with_response_stream::InvokeWithResponseStreamError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.invoke_with_response_stream();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `InvokeWithResponseStream`.
24///
25/// <p>Configure your Lambda functions to stream response payloads back to clients. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html">Configuring a Lambda function to stream responses</a>.</p>
26/// <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>
27#[derive(::std::clone::Clone, ::std::fmt::Debug)]
28pub struct InvokeWithResponseStreamFluentBuilder {
29    handle: ::std::sync::Arc<crate::client::Handle>,
30    inner: crate::operation::invoke_with_response_stream::builders::InvokeWithResponseStreamInputBuilder,
31    config_override: ::std::option::Option<crate::config::Builder>,
32}
33impl
34    crate::client::customize::internal::CustomizableSend<
35        crate::operation::invoke_with_response_stream::InvokeWithResponseStreamOutput,
36        crate::operation::invoke_with_response_stream::InvokeWithResponseStreamError,
37    > for InvokeWithResponseStreamFluentBuilder
38{
39    fn send(
40        self,
41        config_override: crate::config::Builder,
42    ) -> crate::client::customize::internal::BoxFuture<
43        crate::client::customize::internal::SendResult<
44            crate::operation::invoke_with_response_stream::InvokeWithResponseStreamOutput,
45            crate::operation::invoke_with_response_stream::InvokeWithResponseStreamError,
46        >,
47    > {
48        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
49    }
50}
51impl InvokeWithResponseStreamFluentBuilder {
52    /// Creates a new `InvokeWithResponseStreamFluentBuilder`.
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 InvokeWithResponseStream as a reference.
61    pub fn as_input(&self) -> &crate::operation::invoke_with_response_stream::builders::InvokeWithResponseStreamInputBuilder {
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_with_response_stream::InvokeWithResponseStreamOutput,
76        ::aws_smithy_runtime_api::client::result::SdkError<
77            crate::operation::invoke_with_response_stream::InvokeWithResponseStreamError,
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 = crate::operation::invoke_with_response_stream::InvokeWithResponseStream::operation_runtime_plugins(
86            self.handle.runtime_plugins.clone(),
87            &self.handle.conf,
88            self.config_override,
89        );
90        let mut output = crate::operation::invoke_with_response_stream::InvokeWithResponseStream::orchestrate(&runtime_plugins, input).await?;
91
92        // Converts any error encountered beyond this point into an `SdkError` response error
93        // with an `HttpResponse`. However, since we have already exited the `orchestrate`
94        // function, the original `HttpResponse` is no longer available and cannot be restored.
95        // This means that header information from the original response has been lost.
96        //
97        // Note that the response body would have been consumed by the deserializer
98        // regardless, even if the initial message was hypothetically processed during
99        // the orchestrator's deserialization phase but later resulted in an error.
100        fn response_error(
101            err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>,
102        ) -> ::aws_smithy_runtime_api::client::result::SdkError<
103            crate::operation::invoke_with_response_stream::InvokeWithResponseStreamError,
104            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
105        > {
106            ::aws_smithy_runtime_api::client::result::SdkError::response_error(
107                err,
108                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
109                    ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
110                    ::aws_smithy_types::body::SdkBody::empty(),
111                ),
112            )
113        }
114
115        let message = output.event_stream.try_recv_initial_response().await.map_err(response_error)?;
116
117        match message {
118            ::std::option::Option::Some(_message) => ::std::result::Result::Ok(output),
119            ::std::option::Option::None => ::std::result::Result::Ok(output),
120        }
121    }
122
123    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
124    pub fn customize(
125        self,
126    ) -> crate::client::customize::CustomizableOperation<
127        crate::operation::invoke_with_response_stream::InvokeWithResponseStreamOutput,
128        crate::operation::invoke_with_response_stream::InvokeWithResponseStreamError,
129        Self,
130    > {
131        crate::client::customize::CustomizableOperation::new(self)
132    }
133    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
134        self.set_config_override(::std::option::Option::Some(config_override.into()));
135        self
136    }
137
138    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
139        self.config_override = config_override;
140        self
141    }
142    /// <p>The name or ARN of the Lambda function.</p>
143    /// <p class="title"><b>Name formats</b></p>
144    /// <ul>
145    /// <li>
146    /// <p><b>Function name</b> – <code>my-function</code>.</p></li>
147    /// <li>
148    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
149    /// <li>
150    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
151    /// </ul>
152    /// <p>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>
153    pub fn function_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
154        self.inner = self.inner.function_name(input.into());
155        self
156    }
157    /// <p>The name or ARN of the Lambda function.</p>
158    /// <p class="title"><b>Name formats</b></p>
159    /// <ul>
160    /// <li>
161    /// <p><b>Function name</b> – <code>my-function</code>.</p></li>
162    /// <li>
163    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
164    /// <li>
165    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
166    /// </ul>
167    /// <p>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>
168    pub fn set_function_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
169        self.inner = self.inner.set_function_name(input);
170        self
171    }
172    /// <p>The name or ARN of the Lambda function.</p>
173    /// <p class="title"><b>Name formats</b></p>
174    /// <ul>
175    /// <li>
176    /// <p><b>Function name</b> – <code>my-function</code>.</p></li>
177    /// <li>
178    /// <p><b>Function ARN</b> – <code>arn:aws:lambda:us-west-2:123456789012:function:my-function</code>.</p></li>
179    /// <li>
180    /// <p><b>Partial ARN</b> – <code>123456789012:function:my-function</code>.</p></li>
181    /// </ul>
182    /// <p>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>
183    pub fn get_function_name(&self) -> &::std::option::Option<::std::string::String> {
184        self.inner.get_function_name()
185    }
186    /// <p>Use one of the following options:</p>
187    /// <ul>
188    /// <li>
189    /// <p><code>RequestResponse</code> (default) – Invoke the function synchronously. Keep the connection open until the function returns a response or times out. The API operation response includes the function response and additional data.</p></li>
190    /// <li>
191    /// <p><code>DryRun</code> – Validate parameter values and verify that the IAM user or role has permission to invoke the function.</p></li>
192    /// </ul>
193    pub fn invocation_type(mut self, input: crate::types::ResponseStreamingInvocationType) -> Self {
194        self.inner = self.inner.invocation_type(input);
195        self
196    }
197    /// <p>Use one of the following options:</p>
198    /// <ul>
199    /// <li>
200    /// <p><code>RequestResponse</code> (default) – Invoke the function synchronously. Keep the connection open until the function returns a response or times out. The API operation response includes the function response and additional data.</p></li>
201    /// <li>
202    /// <p><code>DryRun</code> – Validate parameter values and verify that the IAM user or role has permission to invoke the function.</p></li>
203    /// </ul>
204    pub fn set_invocation_type(mut self, input: ::std::option::Option<crate::types::ResponseStreamingInvocationType>) -> Self {
205        self.inner = self.inner.set_invocation_type(input);
206        self
207    }
208    /// <p>Use one of the following options:</p>
209    /// <ul>
210    /// <li>
211    /// <p><code>RequestResponse</code> (default) – Invoke the function synchronously. Keep the connection open until the function returns a response or times out. The API operation response includes the function response and additional data.</p></li>
212    /// <li>
213    /// <p><code>DryRun</code> – Validate parameter values and verify that the IAM user or role has permission to invoke the function.</p></li>
214    /// </ul>
215    pub fn get_invocation_type(&self) -> &::std::option::Option<crate::types::ResponseStreamingInvocationType> {
216        self.inner.get_invocation_type()
217    }
218    /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
219    pub fn log_type(mut self, input: crate::types::LogType) -> Self {
220        self.inner = self.inner.log_type(input);
221        self
222    }
223    /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
224    pub fn set_log_type(mut self, input: ::std::option::Option<crate::types::LogType>) -> Self {
225        self.inner = self.inner.set_log_type(input);
226        self
227    }
228    /// <p>Set to <code>Tail</code> to include the execution log in the response. Applies to synchronously invoked functions only.</p>
229    pub fn get_log_type(&self) -> &::std::option::Option<crate::types::LogType> {
230        self.inner.get_log_type()
231    }
232    /// <p>Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object.</p>
233    pub fn client_context(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
234        self.inner = self.inner.client_context(input.into());
235        self
236    }
237    /// <p>Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object.</p>
238    pub fn set_client_context(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
239        self.inner = self.inner.set_client_context(input);
240        self
241    }
242    /// <p>Up to 3,583 bytes of base64-encoded data about the invoking client to pass to the function in the context object.</p>
243    pub fn get_client_context(&self) -> &::std::option::Option<::std::string::String> {
244        self.inner.get_client_context()
245    }
246    /// <p>The alias name.</p>
247    pub fn qualifier(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
248        self.inner = self.inner.qualifier(input.into());
249        self
250    }
251    /// <p>The alias name.</p>
252    pub fn set_qualifier(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
253        self.inner = self.inner.set_qualifier(input);
254        self
255    }
256    /// <p>The alias name.</p>
257    pub fn get_qualifier(&self) -> &::std::option::Option<::std::string::String> {
258        self.inner.get_qualifier()
259    }
260    /// <p>The JSON that you want to provide to your Lambda function as input.</p>
261    /// <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>
262    pub fn payload(mut self, input: ::aws_smithy_types::Blob) -> Self {
263        self.inner = self.inner.payload(input);
264        self
265    }
266    /// <p>The JSON that you want to provide to your Lambda function as input.</p>
267    /// <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>
268    pub fn set_payload(mut self, input: ::std::option::Option<::aws_smithy_types::Blob>) -> Self {
269        self.inner = self.inner.set_payload(input);
270        self
271    }
272    /// <p>The JSON that you want to provide to your Lambda function as input.</p>
273    /// <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>
274    pub fn get_payload(&self) -> &::std::option::Option<::aws_smithy_types::Blob> {
275        self.inner.get_payload()
276    }
277}