aws_sdk_lexruntimev2/operation/start_conversation/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::start_conversation::_start_conversation_output::StartConversationOutputBuilder;
3
4pub use crate::operation::start_conversation::_start_conversation_input::StartConversationInputBuilder;
5
6impl crate::operation::start_conversation::builders::StartConversationInputBuilder {
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::start_conversation::StartConversationOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::start_conversation::StartConversationError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.start_conversation();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `StartConversation`.
24///
25/// <p>Starts an HTTP/2 bidirectional event stream that enables you to send audio, text, or DTMF input in real time. After your application starts a conversation, users send input to Amazon Lex V2 as a stream of events. Amazon Lex V2 processes the incoming events and responds with streaming text or audio events.</p>
26/// <p>Audio input must be in the following format: <code>audio/lpcm sample-rate=8000 sample-size-bits=16 channel-count=1; is-big-endian=false</code>.</p>
27/// <p>If the optional post-fulfillment response is specified, the messages are returned as follows. For more information, see <a href="https://docs.aws.amazon.com/lexv2/latest/dg/API_PostFulfillmentStatusSpecification.html">PostFulfillmentStatusSpecification</a>.</p>
28/// <ul>
29/// <li>
30/// <p><b>Success message</b> - Returned if the Lambda function completes successfully and the intent state is fulfilled or ready fulfillment if the message is present.</p></li>
31/// <li>
32/// <p><b>Failed message</b> - The failed message is returned if the Lambda function throws an exception or if the Lambda function returns a failed intent state without a message.</p></li>
33/// <li>
34/// <p><b>Timeout message</b> - If you don't configure a timeout message and a timeout, and the Lambda function doesn't return within 30 seconds, the timeout message is returned. If you configure a timeout, the timeout message is returned when the period times out.</p></li>
35/// </ul>
36/// <p>For more information, see <a href="https://docs.aws.amazon.com/lexv2/latest/dg/streaming-progress.html#progress-complete.html">Completion message</a>.</p>
37/// <p>If the optional update message is configured, it is played at the specified frequency while the Lambda function is running and the update message state is active. If the fulfillment update message is not active, the Lambda function runs with a 30 second timeout.</p>
38/// <p>For more information, see <a href="https://docs.aws.amazon.com/lexv2/latest/dg/streaming-progress.html#progress-update.html">Update message </a></p>
39/// <p>The <code>StartConversation</code> operation is supported only in the following SDKs:</p>
40/// <ul>
41/// <li>
42/// <p><a href="https://docs.aws.amazon.com/goto/SdkForCpp/runtime.lex.v2-2020-08-07/StartConversation">AWS SDK for C++</a></p></li>
43/// <li>
44/// <p><a href="https://docs.aws.amazon.com/goto/SdkForJavaV2/runtime.lex.v2-2020-08-07/StartConversation">AWS SDK for Java V2</a></p></li>
45/// <li>
46/// <p><a href="https://docs.aws.amazon.com/goto/SdkForRubyV3/runtime.lex.v2-2020-08-07/StartConversation">AWS SDK for Ruby V3</a></p></li>
47/// </ul>
48#[derive(::std::fmt::Debug)]
49pub struct StartConversationFluentBuilder {
50    handle: ::std::sync::Arc<crate::client::Handle>,
51    inner: crate::operation::start_conversation::builders::StartConversationInputBuilder,
52    config_override: ::std::option::Option<crate::config::Builder>,
53}
54impl
55    crate::client::customize::internal::CustomizableSend<
56        crate::operation::start_conversation::StartConversationOutput,
57        crate::operation::start_conversation::StartConversationError,
58    > for StartConversationFluentBuilder
59{
60    fn send(
61        self,
62        config_override: crate::config::Builder,
63    ) -> crate::client::customize::internal::BoxFuture<
64        crate::client::customize::internal::SendResult<
65            crate::operation::start_conversation::StartConversationOutput,
66            crate::operation::start_conversation::StartConversationError,
67        >,
68    > {
69        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
70    }
71}
72impl StartConversationFluentBuilder {
73    /// Creates a new `StartConversationFluentBuilder`.
74    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
75        Self {
76            handle,
77            inner: ::std::default::Default::default(),
78            config_override: ::std::option::Option::None,
79        }
80    }
81    /// Access the StartConversation as a reference.
82    pub fn as_input(&self) -> &crate::operation::start_conversation::builders::StartConversationInputBuilder {
83        &self.inner
84    }
85    /// Sends the request and returns the response.
86    ///
87    /// If an error occurs, an `SdkError` will be returned with additional details that
88    /// can be matched against.
89    ///
90    /// By default, any retryable failures will be retried twice. Retry behavior
91    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
92    /// set when configuring the client.
93    pub async fn send(
94        self,
95    ) -> ::std::result::Result<
96        crate::operation::start_conversation::StartConversationOutput,
97        ::aws_smithy_runtime_api::client::result::SdkError<
98            crate::operation::start_conversation::StartConversationError,
99            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
100        >,
101    > {
102        let input = self
103            .inner
104            .build()
105            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
106        let runtime_plugins = crate::operation::start_conversation::StartConversation::operation_runtime_plugins(
107            self.handle.runtime_plugins.clone(),
108            &self.handle.conf,
109            self.config_override,
110        );
111        let mut output = crate::operation::start_conversation::StartConversation::orchestrate(&runtime_plugins, input).await?;
112
113        // Converts any error encountered beyond this point into an `SdkError` response error
114        // with an `HttpResponse`. However, since we have already exited the `orchestrate`
115        // function, the original `HttpResponse` is no longer available and cannot be restored.
116        // This means that header information from the original response has been lost.
117        //
118        // Note that the response body would have been consumed by the deserializer
119        // regardless, even if the initial message was hypothetically processed during
120        // the orchestrator's deserialization phase but later resulted in an error.
121        fn response_error(
122            err: impl ::std::convert::Into<::aws_smithy_runtime_api::box_error::BoxError>,
123        ) -> ::aws_smithy_runtime_api::client::result::SdkError<
124            crate::operation::start_conversation::StartConversationError,
125            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
126        > {
127            ::aws_smithy_runtime_api::client::result::SdkError::response_error(
128                err,
129                ::aws_smithy_runtime_api::client::orchestrator::HttpResponse::new(
130                    ::aws_smithy_runtime_api::http::StatusCode::try_from(200).expect("valid successful code"),
131                    ::aws_smithy_types::body::SdkBody::empty(),
132                ),
133            )
134        }
135
136        let message = output.response_event_stream.try_recv_initial_response().await.map_err(response_error)?;
137
138        match message {
139            ::std::option::Option::Some(_message) => ::std::result::Result::Ok(output),
140            ::std::option::Option::None => ::std::result::Result::Ok(output),
141        }
142    }
143
144    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
145    pub fn customize(
146        self,
147    ) -> crate::client::customize::CustomizableOperation<
148        crate::operation::start_conversation::StartConversationOutput,
149        crate::operation::start_conversation::StartConversationError,
150        Self,
151    > {
152        crate::client::customize::CustomizableOperation::new(self)
153    }
154    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
155        self.set_config_override(::std::option::Option::Some(config_override.into()));
156        self
157    }
158
159    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
160        self.config_override = config_override;
161        self
162    }
163    /// <p>The identifier of the bot to process the request.</p>
164    pub fn bot_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
165        self.inner = self.inner.bot_id(input.into());
166        self
167    }
168    /// <p>The identifier of the bot to process the request.</p>
169    pub fn set_bot_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
170        self.inner = self.inner.set_bot_id(input);
171        self
172    }
173    /// <p>The identifier of the bot to process the request.</p>
174    pub fn get_bot_id(&self) -> &::std::option::Option<::std::string::String> {
175        self.inner.get_bot_id()
176    }
177    /// <p>The alias identifier in use for the bot that processes the request.</p>
178    pub fn bot_alias_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
179        self.inner = self.inner.bot_alias_id(input.into());
180        self
181    }
182    /// <p>The alias identifier in use for the bot that processes the request.</p>
183    pub fn set_bot_alias_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
184        self.inner = self.inner.set_bot_alias_id(input);
185        self
186    }
187    /// <p>The alias identifier in use for the bot that processes the request.</p>
188    pub fn get_bot_alias_id(&self) -> &::std::option::Option<::std::string::String> {
189        self.inner.get_bot_alias_id()
190    }
191    /// <p>The locale where the session is in use.</p>
192    pub fn locale_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
193        self.inner = self.inner.locale_id(input.into());
194        self
195    }
196    /// <p>The locale where the session is in use.</p>
197    pub fn set_locale_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
198        self.inner = self.inner.set_locale_id(input);
199        self
200    }
201    /// <p>The locale where the session is in use.</p>
202    pub fn get_locale_id(&self) -> &::std::option::Option<::std::string::String> {
203        self.inner.get_locale_id()
204    }
205    /// <p>The identifier of the user session that is having the conversation.</p>
206    pub fn session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
207        self.inner = self.inner.session_id(input.into());
208        self
209    }
210    /// <p>The identifier of the user session that is having the conversation.</p>
211    pub fn set_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
212        self.inner = self.inner.set_session_id(input);
213        self
214    }
215    /// <p>The identifier of the user session that is having the conversation.</p>
216    pub fn get_session_id(&self) -> &::std::option::Option<::std::string::String> {
217        self.inner.get_session_id()
218    }
219    /// <p>The conversation type that you are using the Amazon Lex V2. If the conversation mode is <code>AUDIO</code> you can send both audio and DTMF information. If the mode is <code>TEXT</code> you can only send text.</p>
220    pub fn conversation_mode(mut self, input: crate::types::ConversationMode) -> Self {
221        self.inner = self.inner.conversation_mode(input);
222        self
223    }
224    /// <p>The conversation type that you are using the Amazon Lex V2. If the conversation mode is <code>AUDIO</code> you can send both audio and DTMF information. If the mode is <code>TEXT</code> you can only send text.</p>
225    pub fn set_conversation_mode(mut self, input: ::std::option::Option<crate::types::ConversationMode>) -> Self {
226        self.inner = self.inner.set_conversation_mode(input);
227        self
228    }
229    /// <p>The conversation type that you are using the Amazon Lex V2. If the conversation mode is <code>AUDIO</code> you can send both audio and DTMF information. If the mode is <code>TEXT</code> you can only send text.</p>
230    pub fn get_conversation_mode(&self) -> &::std::option::Option<crate::types::ConversationMode> {
231        self.inner.get_conversation_mode()
232    }
233    /// <p>Represents the stream of events to Amazon Lex V2 from your application. The events are encoded as HTTP/2 data frames.</p>
234    pub fn request_event_stream(
235        mut self,
236        input: ::aws_smithy_http::event_stream::EventStreamSender<
237            crate::types::StartConversationRequestEventStream,
238            crate::types::error::StartConversationRequestEventStreamError,
239        >,
240    ) -> Self {
241        self.inner = self.inner.request_event_stream(input);
242        self
243    }
244    /// <p>Represents the stream of events to Amazon Lex V2 from your application. The events are encoded as HTTP/2 data frames.</p>
245    pub fn set_request_event_stream(
246        mut self,
247        input: ::std::option::Option<
248            ::aws_smithy_http::event_stream::EventStreamSender<
249                crate::types::StartConversationRequestEventStream,
250                crate::types::error::StartConversationRequestEventStreamError,
251            >,
252        >,
253    ) -> Self {
254        self.inner = self.inner.set_request_event_stream(input);
255        self
256    }
257    /// <p>Represents the stream of events to Amazon Lex V2 from your application. The events are encoded as HTTP/2 data frames.</p>
258    pub fn get_request_event_stream(
259        &self,
260    ) -> &::std::option::Option<
261        ::aws_smithy_http::event_stream::EventStreamSender<
262            crate::types::StartConversationRequestEventStream,
263            crate::types::error::StartConversationRequestEventStreamError,
264        >,
265    > {
266        self.inner.get_request_event_stream()
267    }
268}