aws_sdk_lexruntimev2/operation/recognize_text/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::recognize_text::_recognize_text_output::RecognizeTextOutputBuilder;
3
4pub use crate::operation::recognize_text::_recognize_text_input::RecognizeTextInputBuilder;
5
6impl crate::operation::recognize_text::builders::RecognizeTextInputBuilder {
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::recognize_text::RecognizeTextOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::recognize_text::RecognizeTextError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.recognize_text();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `RecognizeText`.
24///
25/// <p>Sends user input to Amazon Lex V2. Client applications use this API to send requests to Amazon Lex V2 at runtime. Amazon Lex V2 then interprets the user input using the machine learning model that it build for the bot.</p>
26/// <p>In response, Amazon Lex V2 returns the next message to convey to the user and an optional response card to display.</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#[derive(::std::clone::Clone, ::std::fmt::Debug)]
38pub struct RecognizeTextFluentBuilder {
39    handle: ::std::sync::Arc<crate::client::Handle>,
40    inner: crate::operation::recognize_text::builders::RecognizeTextInputBuilder,
41    config_override: ::std::option::Option<crate::config::Builder>,
42}
43impl
44    crate::client::customize::internal::CustomizableSend<
45        crate::operation::recognize_text::RecognizeTextOutput,
46        crate::operation::recognize_text::RecognizeTextError,
47    > for RecognizeTextFluentBuilder
48{
49    fn send(
50        self,
51        config_override: crate::config::Builder,
52    ) -> crate::client::customize::internal::BoxFuture<
53        crate::client::customize::internal::SendResult<
54            crate::operation::recognize_text::RecognizeTextOutput,
55            crate::operation::recognize_text::RecognizeTextError,
56        >,
57    > {
58        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
59    }
60}
61impl RecognizeTextFluentBuilder {
62    /// Creates a new `RecognizeTextFluentBuilder`.
63    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
64        Self {
65            handle,
66            inner: ::std::default::Default::default(),
67            config_override: ::std::option::Option::None,
68        }
69    }
70    /// Access the RecognizeText as a reference.
71    pub fn as_input(&self) -> &crate::operation::recognize_text::builders::RecognizeTextInputBuilder {
72        &self.inner
73    }
74    /// Sends the request and returns the response.
75    ///
76    /// If an error occurs, an `SdkError` will be returned with additional details that
77    /// can be matched against.
78    ///
79    /// By default, any retryable failures will be retried twice. Retry behavior
80    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
81    /// set when configuring the client.
82    pub async fn send(
83        self,
84    ) -> ::std::result::Result<
85        crate::operation::recognize_text::RecognizeTextOutput,
86        ::aws_smithy_runtime_api::client::result::SdkError<
87            crate::operation::recognize_text::RecognizeTextError,
88            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
89        >,
90    > {
91        let input = self
92            .inner
93            .build()
94            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
95        let runtime_plugins = crate::operation::recognize_text::RecognizeText::operation_runtime_plugins(
96            self.handle.runtime_plugins.clone(),
97            &self.handle.conf,
98            self.config_override,
99        );
100        crate::operation::recognize_text::RecognizeText::orchestrate(&runtime_plugins, input).await
101    }
102
103    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
104    pub fn customize(
105        self,
106    ) -> crate::client::customize::CustomizableOperation<
107        crate::operation::recognize_text::RecognizeTextOutput,
108        crate::operation::recognize_text::RecognizeTextError,
109        Self,
110    > {
111        crate::client::customize::CustomizableOperation::new(self)
112    }
113    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
114        self.set_config_override(::std::option::Option::Some(config_override.into()));
115        self
116    }
117
118    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
119        self.config_override = config_override;
120        self
121    }
122    /// <p>The identifier of the bot that processes the request.</p>
123    pub fn bot_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
124        self.inner = self.inner.bot_id(input.into());
125        self
126    }
127    /// <p>The identifier of the bot that processes the request.</p>
128    pub fn set_bot_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
129        self.inner = self.inner.set_bot_id(input);
130        self
131    }
132    /// <p>The identifier of the bot that processes the request.</p>
133    pub fn get_bot_id(&self) -> &::std::option::Option<::std::string::String> {
134        self.inner.get_bot_id()
135    }
136    /// <p>The alias identifier in use for the bot that processes the request.</p>
137    pub fn bot_alias_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
138        self.inner = self.inner.bot_alias_id(input.into());
139        self
140    }
141    /// <p>The alias identifier in use for the bot that processes the request.</p>
142    pub fn set_bot_alias_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
143        self.inner = self.inner.set_bot_alias_id(input);
144        self
145    }
146    /// <p>The alias identifier in use for the bot that processes the request.</p>
147    pub fn get_bot_alias_id(&self) -> &::std::option::Option<::std::string::String> {
148        self.inner.get_bot_alias_id()
149    }
150    /// <p>The locale where the session is in use.</p>
151    pub fn locale_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
152        self.inner = self.inner.locale_id(input.into());
153        self
154    }
155    /// <p>The locale where the session is in use.</p>
156    pub fn set_locale_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
157        self.inner = self.inner.set_locale_id(input);
158        self
159    }
160    /// <p>The locale where the session is in use.</p>
161    pub fn get_locale_id(&self) -> &::std::option::Option<::std::string::String> {
162        self.inner.get_locale_id()
163    }
164    /// <p>The identifier of the user session that is having the conversation.</p>
165    pub fn session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
166        self.inner = self.inner.session_id(input.into());
167        self
168    }
169    /// <p>The identifier of the user session that is having the conversation.</p>
170    pub fn set_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
171        self.inner = self.inner.set_session_id(input);
172        self
173    }
174    /// <p>The identifier of the user session that is having the conversation.</p>
175    pub fn get_session_id(&self) -> &::std::option::Option<::std::string::String> {
176        self.inner.get_session_id()
177    }
178    /// <p>The text that the user entered. Amazon Lex V2 interprets this text.</p>
179    pub fn text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
180        self.inner = self.inner.text(input.into());
181        self
182    }
183    /// <p>The text that the user entered. Amazon Lex V2 interprets this text.</p>
184    pub fn set_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
185        self.inner = self.inner.set_text(input);
186        self
187    }
188    /// <p>The text that the user entered. Amazon Lex V2 interprets this text.</p>
189    pub fn get_text(&self) -> &::std::option::Option<::std::string::String> {
190        self.inner.get_text()
191    }
192    /// <p>The current state of the dialog between the user and the bot.</p>
193    pub fn session_state(mut self, input: crate::types::SessionState) -> Self {
194        self.inner = self.inner.session_state(input);
195        self
196    }
197    /// <p>The current state of the dialog between the user and the bot.</p>
198    pub fn set_session_state(mut self, input: ::std::option::Option<crate::types::SessionState>) -> Self {
199        self.inner = self.inner.set_session_state(input);
200        self
201    }
202    /// <p>The current state of the dialog between the user and the bot.</p>
203    pub fn get_session_state(&self) -> &::std::option::Option<crate::types::SessionState> {
204        self.inner.get_session_state()
205    }
206    ///
207    /// Adds a key-value pair to `requestAttributes`.
208    ///
209    /// To override the contents of this collection use [`set_request_attributes`](Self::set_request_attributes).
210    ///
211    /// <p>Request-specific information passed between the client application and Amazon Lex V2</p>
212    /// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p>
213    pub fn request_attributes(
214        mut self,
215        k: impl ::std::convert::Into<::std::string::String>,
216        v: impl ::std::convert::Into<::std::string::String>,
217    ) -> Self {
218        self.inner = self.inner.request_attributes(k.into(), v.into());
219        self
220    }
221    /// <p>Request-specific information passed between the client application and Amazon Lex V2</p>
222    /// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p>
223    pub fn set_request_attributes(
224        mut self,
225        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
226    ) -> Self {
227        self.inner = self.inner.set_request_attributes(input);
228        self
229    }
230    /// <p>Request-specific information passed between the client application and Amazon Lex V2</p>
231    /// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p>
232    pub fn get_request_attributes(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
233        self.inner.get_request_attributes()
234    }
235}