aws_sdk_lexruntime/operation/post_text/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::post_text::_post_text_output::PostTextOutputBuilder;
3
4pub use crate::operation::post_text::_post_text_input::PostTextInputBuilder;
5
6impl crate::operation::post_text::builders::PostTextInputBuilder {
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::post_text::PostTextOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::post_text::PostTextError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.post_text();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `PostText`.
24///
25/// <p>Sends user input to Amazon Lex. Client applications can use this API to send requests to Amazon Lex at runtime. Amazon Lex then interprets the user input using the machine learning model it built for the bot.</p>
26/// <p>In response, Amazon Lex returns the next <code>message</code> to convey to the user an optional <code>responseCard</code> to display. Consider the following example messages:</p>
27/// <ul>
28/// <li>
29/// <p>For a user input "I would like a pizza", Amazon Lex might return a response with a message eliciting slot data (for example, PizzaSize): "What size pizza would you like?"</p></li>
30/// <li>
31/// <p>After the user provides all of the pizza order information, Amazon Lex might return a response with a message to obtain user confirmation "Proceed with the pizza order?".</p></li>
32/// <li>
33/// <p>After the user replies to a confirmation prompt with a "yes", Amazon Lex might return a conclusion statement: "Thank you, your cheese pizza has been ordered.".</p></li>
34/// </ul>
35/// <p>Not all Amazon Lex messages require a user response. For example, a conclusion statement does not require a response. Some messages require only a "yes" or "no" user response. In addition to the <code>message</code>, Amazon Lex provides additional context about the message in the response that you might use to enhance client behavior, for example, to display the appropriate client user interface. These are the <code>slotToElicit</code>, <code>dialogState</code>, <code>intentName</code>, and <code>slots</code> fields in the response. Consider the following examples:</p>
36/// <ul>
37/// <li>
38/// <p>If the message is to elicit slot data, Amazon Lex returns the following context information:</p>
39/// <ul>
40/// <li>
41/// <p><code>dialogState</code> set to ElicitSlot</p></li>
42/// <li>
43/// <p><code>intentName</code> set to the intent name in the current context</p></li>
44/// <li>
45/// <p><code>slotToElicit</code> set to the slot name for which the <code>message</code> is eliciting information</p></li>
46/// <li>
47/// <p><code>slots</code> set to a map of slots, configured for the intent, with currently known values</p></li>
48/// </ul></li>
49/// <li>
50/// <p>If the message is a confirmation prompt, the <code>dialogState</code> is set to ConfirmIntent and <code>SlotToElicit</code> is set to null.</p></li>
51/// <li>
52/// <p>If the message is a clarification prompt (configured for the intent) that indicates that user intent is not understood, the <code>dialogState</code> is set to ElicitIntent and <code>slotToElicit</code> is set to null.</p></li>
53/// </ul>
54/// <p>In addition, Amazon Lex also returns your application-specific <code>sessionAttributes</code>. For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html">Managing Conversation Context</a>.</p>
55#[derive(::std::clone::Clone, ::std::fmt::Debug)]
56pub struct PostTextFluentBuilder {
57 handle: ::std::sync::Arc<crate::client::Handle>,
58 inner: crate::operation::post_text::builders::PostTextInputBuilder,
59 config_override: ::std::option::Option<crate::config::Builder>,
60}
61impl crate::client::customize::internal::CustomizableSend<crate::operation::post_text::PostTextOutput, crate::operation::post_text::PostTextError>
62 for PostTextFluentBuilder
63{
64 fn send(
65 self,
66 config_override: crate::config::Builder,
67 ) -> crate::client::customize::internal::BoxFuture<
68 crate::client::customize::internal::SendResult<crate::operation::post_text::PostTextOutput, crate::operation::post_text::PostTextError>,
69 > {
70 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
71 }
72}
73impl PostTextFluentBuilder {
74 /// Creates a new `PostTextFluentBuilder`.
75 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
76 Self {
77 handle,
78 inner: ::std::default::Default::default(),
79 config_override: ::std::option::Option::None,
80 }
81 }
82 /// Access the PostText as a reference.
83 pub fn as_input(&self) -> &crate::operation::post_text::builders::PostTextInputBuilder {
84 &self.inner
85 }
86 /// Sends the request and returns the response.
87 ///
88 /// If an error occurs, an `SdkError` will be returned with additional details that
89 /// can be matched against.
90 ///
91 /// By default, any retryable failures will be retried twice. Retry behavior
92 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
93 /// set when configuring the client.
94 pub async fn send(
95 self,
96 ) -> ::std::result::Result<
97 crate::operation::post_text::PostTextOutput,
98 ::aws_smithy_runtime_api::client::result::SdkError<
99 crate::operation::post_text::PostTextError,
100 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
101 >,
102 > {
103 let input = self
104 .inner
105 .build()
106 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
107 let runtime_plugins = crate::operation::post_text::PostText::operation_runtime_plugins(
108 self.handle.runtime_plugins.clone(),
109 &self.handle.conf,
110 self.config_override,
111 );
112 crate::operation::post_text::PostText::orchestrate(&runtime_plugins, input).await
113 }
114
115 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
116 pub fn customize(
117 self,
118 ) -> crate::client::customize::CustomizableOperation<crate::operation::post_text::PostTextOutput, crate::operation::post_text::PostTextError, Self>
119 {
120 crate::client::customize::CustomizableOperation::new(self)
121 }
122 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
123 self.set_config_override(::std::option::Option::Some(config_override.into()));
124 self
125 }
126
127 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
128 self.config_override = config_override;
129 self
130 }
131 /// <p>The name of the Amazon Lex bot.</p>
132 pub fn bot_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
133 self.inner = self.inner.bot_name(input.into());
134 self
135 }
136 /// <p>The name of the Amazon Lex bot.</p>
137 pub fn set_bot_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
138 self.inner = self.inner.set_bot_name(input);
139 self
140 }
141 /// <p>The name of the Amazon Lex bot.</p>
142 pub fn get_bot_name(&self) -> &::std::option::Option<::std::string::String> {
143 self.inner.get_bot_name()
144 }
145 /// <p>The alias of the Amazon Lex bot.</p>
146 pub fn bot_alias(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
147 self.inner = self.inner.bot_alias(input.into());
148 self
149 }
150 /// <p>The alias of the Amazon Lex bot.</p>
151 pub fn set_bot_alias(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
152 self.inner = self.inner.set_bot_alias(input);
153 self
154 }
155 /// <p>The alias of the Amazon Lex bot.</p>
156 pub fn get_bot_alias(&self) -> &::std::option::Option<::std::string::String> {
157 self.inner.get_bot_alias()
158 }
159 /// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p>
160 /// <p>To decide the user ID to use for your application, consider the following factors.</p>
161 /// <ul>
162 /// <li>
163 /// <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p></li>
164 /// <li>
165 /// <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p></li>
166 /// <li>
167 /// <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p></li>
168 /// <li>
169 /// <p>A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p></li>
170 /// </ul>
171 pub fn user_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
172 self.inner = self.inner.user_id(input.into());
173 self
174 }
175 /// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p>
176 /// <p>To decide the user ID to use for your application, consider the following factors.</p>
177 /// <ul>
178 /// <li>
179 /// <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p></li>
180 /// <li>
181 /// <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p></li>
182 /// <li>
183 /// <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p></li>
184 /// <li>
185 /// <p>A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p></li>
186 /// </ul>
187 pub fn set_user_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
188 self.inner = self.inner.set_user_id(input);
189 self
190 }
191 /// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p>
192 /// <p>To decide the user ID to use for your application, consider the following factors.</p>
193 /// <ul>
194 /// <li>
195 /// <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p></li>
196 /// <li>
197 /// <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p></li>
198 /// <li>
199 /// <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p></li>
200 /// <li>
201 /// <p>A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p></li>
202 /// </ul>
203 pub fn get_user_id(&self) -> &::std::option::Option<::std::string::String> {
204 self.inner.get_user_id()
205 }
206 ///
207 /// Adds a key-value pair to `sessionAttributes`.
208 ///
209 /// To override the contents of this collection use [`set_session_attributes`](Self::set_session_attributes).
210 ///
211 /// <p>Application-specific information passed between Amazon Lex and a client application.</p>
212 /// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
213 pub fn session_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.session_attributes(k.into(), v.into());
219 self
220 }
221 /// <p>Application-specific information passed between Amazon Lex and a client application.</p>
222 /// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
223 pub fn set_session_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_session_attributes(input);
228 self
229 }
230 /// <p>Application-specific information passed between Amazon Lex and a client application.</p>
231 /// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
232 pub fn get_session_attributes(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
233 self.inner.get_session_attributes()
234 }
235 ///
236 /// Adds a key-value pair to `requestAttributes`.
237 ///
238 /// To override the contents of this collection use [`set_request_attributes`](Self::set_request_attributes).
239 ///
240 /// <p>Request-specific information passed between Amazon Lex and a client application.</p>
241 /// <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>
242 /// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
243 pub fn request_attributes(
244 mut self,
245 k: impl ::std::convert::Into<::std::string::String>,
246 v: impl ::std::convert::Into<::std::string::String>,
247 ) -> Self {
248 self.inner = self.inner.request_attributes(k.into(), v.into());
249 self
250 }
251 /// <p>Request-specific information passed between Amazon Lex and a client application.</p>
252 /// <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>
253 /// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
254 pub fn set_request_attributes(
255 mut self,
256 input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
257 ) -> Self {
258 self.inner = self.inner.set_request_attributes(input);
259 self
260 }
261 /// <p>Request-specific information passed between Amazon Lex and a client application.</p>
262 /// <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>
263 /// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
264 pub fn get_request_attributes(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
265 self.inner.get_request_attributes()
266 }
267 /// <p>The text that the user entered (Amazon Lex interprets this text).</p>
268 pub fn input_text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
269 self.inner = self.inner.input_text(input.into());
270 self
271 }
272 /// <p>The text that the user entered (Amazon Lex interprets this text).</p>
273 pub fn set_input_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
274 self.inner = self.inner.set_input_text(input);
275 self
276 }
277 /// <p>The text that the user entered (Amazon Lex interprets this text).</p>
278 pub fn get_input_text(&self) -> &::std::option::Option<::std::string::String> {
279 self.inner.get_input_text()
280 }
281 ///
282 /// Appends an item to `activeContexts`.
283 ///
284 /// To override the contents of this collection use [`set_active_contexts`](Self::set_active_contexts).
285 ///
286 /// <p>A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request,</p>
287 /// <p>If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.</p>
288 pub fn active_contexts(mut self, input: crate::types::ActiveContext) -> Self {
289 self.inner = self.inner.active_contexts(input);
290 self
291 }
292 /// <p>A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request,</p>
293 /// <p>If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.</p>
294 pub fn set_active_contexts(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::ActiveContext>>) -> Self {
295 self.inner = self.inner.set_active_contexts(input);
296 self
297 }
298 /// <p>A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request,</p>
299 /// <p>If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.</p>
300 pub fn get_active_contexts(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::ActiveContext>> {
301 self.inner.get_active_contexts()
302 }
303}