aws_sdk_lexruntimev2/operation/recognize_utterance/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::recognize_utterance::_recognize_utterance_output::RecognizeUtteranceOutputBuilder;
3
4pub use crate::operation::recognize_utterance::_recognize_utterance_input::RecognizeUtteranceInputBuilder;
5
6impl crate::operation::recognize_utterance::builders::RecognizeUtteranceInputBuilder {
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_utterance::RecognizeUtteranceOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::recognize_utterance::RecognizeUtteranceError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.recognize_utterance();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `RecognizeUtterance`.
24///
25/// <p>Sends user input to Amazon Lex V2. You can send text or speech. Clients use this API to send text and audio requests to Amazon Lex V2 at runtime. Amazon Lex V2 interprets the user input using the machine learning model built for the bot.</p>
26/// <p>The following request fields must be compressed with gzip and then base64 encoded before you send them to Amazon Lex V2.</p>
27/// <ul>
28/// <li>
29/// <p>requestAttributes</p></li>
30/// <li>
31/// <p>sessionState</p></li>
32/// </ul>
33/// <p>The following response fields are compressed using gzip and then base64 encoded by Amazon Lex V2. Before you can use these fields, you must decode and decompress them.</p>
34/// <ul>
35/// <li>
36/// <p>inputTranscript</p></li>
37/// <li>
38/// <p>interpretations</p></li>
39/// <li>
40/// <p>messages</p></li>
41/// <li>
42/// <p>requestAttributes</p></li>
43/// <li>
44/// <p>sessionState</p></li>
45/// </ul>
46/// <p>The example contains a Java application that compresses and encodes a Java object to send to Amazon Lex V2, and a second that decodes and decompresses a response from Amazon Lex V2.</p>
47/// <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>
48/// <ul>
49/// <li>
50/// <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>
51/// <li>
52/// <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>
53/// <li>
54/// <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>
55/// </ul>
56/// <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>
57#[derive(::std::fmt::Debug)]
58pub struct RecognizeUtteranceFluentBuilder {
59 handle: ::std::sync::Arc<crate::client::Handle>,
60 inner: crate::operation::recognize_utterance::builders::RecognizeUtteranceInputBuilder,
61 config_override: ::std::option::Option<crate::config::Builder>,
62}
63impl
64 crate::client::customize::internal::CustomizableSend<
65 crate::operation::recognize_utterance::RecognizeUtteranceOutput,
66 crate::operation::recognize_utterance::RecognizeUtteranceError,
67 > for RecognizeUtteranceFluentBuilder
68{
69 fn send(
70 self,
71 config_override: crate::config::Builder,
72 ) -> crate::client::customize::internal::BoxFuture<
73 crate::client::customize::internal::SendResult<
74 crate::operation::recognize_utterance::RecognizeUtteranceOutput,
75 crate::operation::recognize_utterance::RecognizeUtteranceError,
76 >,
77 > {
78 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
79 }
80}
81impl RecognizeUtteranceFluentBuilder {
82 /// Creates a new `RecognizeUtteranceFluentBuilder`.
83 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
84 Self {
85 handle,
86 inner: ::std::default::Default::default(),
87 config_override: ::std::option::Option::None,
88 }
89 }
90 /// Access the RecognizeUtterance as a reference.
91 pub fn as_input(&self) -> &crate::operation::recognize_utterance::builders::RecognizeUtteranceInputBuilder {
92 &self.inner
93 }
94 /// Sends the request and returns the response.
95 ///
96 /// If an error occurs, an `SdkError` will be returned with additional details that
97 /// can be matched against.
98 ///
99 /// By default, any retryable failures will be retried twice. Retry behavior
100 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
101 /// set when configuring the client.
102 pub async fn send(
103 self,
104 ) -> ::std::result::Result<
105 crate::operation::recognize_utterance::RecognizeUtteranceOutput,
106 ::aws_smithy_runtime_api::client::result::SdkError<
107 crate::operation::recognize_utterance::RecognizeUtteranceError,
108 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
109 >,
110 > {
111 let input = self
112 .inner
113 .build()
114 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
115 let runtime_plugins = crate::operation::recognize_utterance::RecognizeUtterance::operation_runtime_plugins(
116 self.handle.runtime_plugins.clone(),
117 &self.handle.conf,
118 self.config_override,
119 );
120 crate::operation::recognize_utterance::RecognizeUtterance::orchestrate(&runtime_plugins, input).await
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::recognize_utterance::RecognizeUtteranceOutput,
128 crate::operation::recognize_utterance::RecognizeUtteranceError,
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 identifier of the bot that should receive the request.</p>
143 pub fn bot_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
144 self.inner = self.inner.bot_id(input.into());
145 self
146 }
147 /// <p>The identifier of the bot that should receive the request.</p>
148 pub fn set_bot_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
149 self.inner = self.inner.set_bot_id(input);
150 self
151 }
152 /// <p>The identifier of the bot that should receive the request.</p>
153 pub fn get_bot_id(&self) -> &::std::option::Option<::std::string::String> {
154 self.inner.get_bot_id()
155 }
156 /// <p>The alias identifier in use for the bot that should receive the request.</p>
157 pub fn bot_alias_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
158 self.inner = self.inner.bot_alias_id(input.into());
159 self
160 }
161 /// <p>The alias identifier in use for the bot that should receive the request.</p>
162 pub fn set_bot_alias_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
163 self.inner = self.inner.set_bot_alias_id(input);
164 self
165 }
166 /// <p>The alias identifier in use for the bot that should receive the request.</p>
167 pub fn get_bot_alias_id(&self) -> &::std::option::Option<::std::string::String> {
168 self.inner.get_bot_alias_id()
169 }
170 /// <p>The locale where the session is in use.</p>
171 pub fn locale_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
172 self.inner = self.inner.locale_id(input.into());
173 self
174 }
175 /// <p>The locale where the session is in use.</p>
176 pub fn set_locale_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
177 self.inner = self.inner.set_locale_id(input);
178 self
179 }
180 /// <p>The locale where the session is in use.</p>
181 pub fn get_locale_id(&self) -> &::std::option::Option<::std::string::String> {
182 self.inner.get_locale_id()
183 }
184 /// <p>The identifier of the session in use.</p>
185 pub fn session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
186 self.inner = self.inner.session_id(input.into());
187 self
188 }
189 /// <p>The identifier of the session in use.</p>
190 pub fn set_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
191 self.inner = self.inner.set_session_id(input);
192 self
193 }
194 /// <p>The identifier of the session in use.</p>
195 pub fn get_session_id(&self) -> &::std::option::Option<::std::string::String> {
196 self.inner.get_session_id()
197 }
198 /// <p>Sets the state of the session with the user. You can use this to set the current intent, attributes, context, and dialog action. Use the dialog action to determine the next step that Amazon Lex V2 should use in the conversation with the user.</p>
199 /// <p>The <code>sessionState</code> field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.</p>
200 pub fn session_state(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
201 self.inner = self.inner.session_state(input.into());
202 self
203 }
204 /// <p>Sets the state of the session with the user. You can use this to set the current intent, attributes, context, and dialog action. Use the dialog action to determine the next step that Amazon Lex V2 should use in the conversation with the user.</p>
205 /// <p>The <code>sessionState</code> field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.</p>
206 pub fn set_session_state(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
207 self.inner = self.inner.set_session_state(input);
208 self
209 }
210 /// <p>Sets the state of the session with the user. You can use this to set the current intent, attributes, context, and dialog action. Use the dialog action to determine the next step that Amazon Lex V2 should use in the conversation with the user.</p>
211 /// <p>The <code>sessionState</code> field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.</p>
212 pub fn get_session_state(&self) -> &::std::option::Option<::std::string::String> {
213 self.inner.get_session_state()
214 }
215 /// <p>Request-specific information passed between the client application and Amazon Lex V2</p>
216 /// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes for prefix <code>x-amz-lex:</code>.</p>
217 /// <p>The <code>requestAttributes</code> field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.</p>
218 pub fn request_attributes(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
219 self.inner = self.inner.request_attributes(input.into());
220 self
221 }
222 /// <p>Request-specific information passed between the client application and Amazon Lex V2</p>
223 /// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes for prefix <code>x-amz-lex:</code>.</p>
224 /// <p>The <code>requestAttributes</code> field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.</p>
225 pub fn set_request_attributes(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
226 self.inner = self.inner.set_request_attributes(input);
227 self
228 }
229 /// <p>Request-specific information passed between the client application and Amazon Lex V2</p>
230 /// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes for prefix <code>x-amz-lex:</code>.</p>
231 /// <p>The <code>requestAttributes</code> field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.</p>
232 pub fn get_request_attributes(&self) -> &::std::option::Option<::std::string::String> {
233 self.inner.get_request_attributes()
234 }
235 /// <p>Indicates the format for audio input or that the content is text. The header must start with one of the following prefixes:</p>
236 /// <ul>
237 /// <li>
238 /// <p>PCM format, audio data must be in little-endian byte order.</p>
239 /// <ul>
240 /// <li>
241 /// <p>audio/l16; rate=16000; channels=1</p></li>
242 /// <li>
243 /// <p>audio/x-l16; sample-rate=16000; channel-count=1</p></li>
244 /// <li>
245 /// <p>audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false</p></li>
246 /// </ul></li>
247 /// <li>
248 /// <p>Opus format</p>
249 /// <ul>
250 /// <li>
251 /// <p>audio/x-cbr-opus-with-preamble;preamble-size=0;bit-rate=256000;frame-size-milliseconds=4</p></li>
252 /// </ul></li>
253 /// <li>
254 /// <p>Text format</p>
255 /// <ul>
256 /// <li>
257 /// <p>text/plain; charset=utf-8</p></li>
258 /// </ul></li>
259 /// </ul>
260 pub fn request_content_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
261 self.inner = self.inner.request_content_type(input.into());
262 self
263 }
264 /// <p>Indicates the format for audio input or that the content is text. The header must start with one of the following prefixes:</p>
265 /// <ul>
266 /// <li>
267 /// <p>PCM format, audio data must be in little-endian byte order.</p>
268 /// <ul>
269 /// <li>
270 /// <p>audio/l16; rate=16000; channels=1</p></li>
271 /// <li>
272 /// <p>audio/x-l16; sample-rate=16000; channel-count=1</p></li>
273 /// <li>
274 /// <p>audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false</p></li>
275 /// </ul></li>
276 /// <li>
277 /// <p>Opus format</p>
278 /// <ul>
279 /// <li>
280 /// <p>audio/x-cbr-opus-with-preamble;preamble-size=0;bit-rate=256000;frame-size-milliseconds=4</p></li>
281 /// </ul></li>
282 /// <li>
283 /// <p>Text format</p>
284 /// <ul>
285 /// <li>
286 /// <p>text/plain; charset=utf-8</p></li>
287 /// </ul></li>
288 /// </ul>
289 pub fn set_request_content_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
290 self.inner = self.inner.set_request_content_type(input);
291 self
292 }
293 /// <p>Indicates the format for audio input or that the content is text. The header must start with one of the following prefixes:</p>
294 /// <ul>
295 /// <li>
296 /// <p>PCM format, audio data must be in little-endian byte order.</p>
297 /// <ul>
298 /// <li>
299 /// <p>audio/l16; rate=16000; channels=1</p></li>
300 /// <li>
301 /// <p>audio/x-l16; sample-rate=16000; channel-count=1</p></li>
302 /// <li>
303 /// <p>audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false</p></li>
304 /// </ul></li>
305 /// <li>
306 /// <p>Opus format</p>
307 /// <ul>
308 /// <li>
309 /// <p>audio/x-cbr-opus-with-preamble;preamble-size=0;bit-rate=256000;frame-size-milliseconds=4</p></li>
310 /// </ul></li>
311 /// <li>
312 /// <p>Text format</p>
313 /// <ul>
314 /// <li>
315 /// <p>text/plain; charset=utf-8</p></li>
316 /// </ul></li>
317 /// </ul>
318 pub fn get_request_content_type(&self) -> &::std::option::Option<::std::string::String> {
319 self.inner.get_request_content_type()
320 }
321 /// <p>The message that Amazon Lex V2 returns in the response can be either text or speech based on the <code>responseContentType</code> value.</p>
322 /// <ul>
323 /// <li>
324 /// <p>If the value is <code>text/plain;charset=utf-8</code>, Amazon Lex V2 returns text in the response.</p></li>
325 /// <li>
326 /// <p>If the value begins with <code>audio/</code>, Amazon Lex V2 returns speech in the response. Amazon Lex V2 uses Amazon Polly to generate the speech using the configuration that you specified in the <code>responseContentType</code> parameter. For example, if you specify <code>audio/mpeg</code> as the value, Amazon Lex V2 returns speech in the MPEG format.</p></li>
327 /// <li>
328 /// <p>If the value is <code>audio/pcm</code>, the speech returned is <code>audio/pcm</code> at 16 KHz in 16-bit, little-endian format.</p></li>
329 /// <li>
330 /// <p>The following are the accepted values:</p>
331 /// <ul>
332 /// <li>
333 /// <p>audio/mpeg</p></li>
334 /// <li>
335 /// <p>audio/ogg</p></li>
336 /// <li>
337 /// <p>audio/pcm (16 KHz)</p></li>
338 /// <li>
339 /// <p>audio/* (defaults to mpeg)</p></li>
340 /// <li>
341 /// <p>text/plain; charset=utf-8</p></li>
342 /// </ul></li>
343 /// </ul>
344 pub fn response_content_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
345 self.inner = self.inner.response_content_type(input.into());
346 self
347 }
348 /// <p>The message that Amazon Lex V2 returns in the response can be either text or speech based on the <code>responseContentType</code> value.</p>
349 /// <ul>
350 /// <li>
351 /// <p>If the value is <code>text/plain;charset=utf-8</code>, Amazon Lex V2 returns text in the response.</p></li>
352 /// <li>
353 /// <p>If the value begins with <code>audio/</code>, Amazon Lex V2 returns speech in the response. Amazon Lex V2 uses Amazon Polly to generate the speech using the configuration that you specified in the <code>responseContentType</code> parameter. For example, if you specify <code>audio/mpeg</code> as the value, Amazon Lex V2 returns speech in the MPEG format.</p></li>
354 /// <li>
355 /// <p>If the value is <code>audio/pcm</code>, the speech returned is <code>audio/pcm</code> at 16 KHz in 16-bit, little-endian format.</p></li>
356 /// <li>
357 /// <p>The following are the accepted values:</p>
358 /// <ul>
359 /// <li>
360 /// <p>audio/mpeg</p></li>
361 /// <li>
362 /// <p>audio/ogg</p></li>
363 /// <li>
364 /// <p>audio/pcm (16 KHz)</p></li>
365 /// <li>
366 /// <p>audio/* (defaults to mpeg)</p></li>
367 /// <li>
368 /// <p>text/plain; charset=utf-8</p></li>
369 /// </ul></li>
370 /// </ul>
371 pub fn set_response_content_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
372 self.inner = self.inner.set_response_content_type(input);
373 self
374 }
375 /// <p>The message that Amazon Lex V2 returns in the response can be either text or speech based on the <code>responseContentType</code> value.</p>
376 /// <ul>
377 /// <li>
378 /// <p>If the value is <code>text/plain;charset=utf-8</code>, Amazon Lex V2 returns text in the response.</p></li>
379 /// <li>
380 /// <p>If the value begins with <code>audio/</code>, Amazon Lex V2 returns speech in the response. Amazon Lex V2 uses Amazon Polly to generate the speech using the configuration that you specified in the <code>responseContentType</code> parameter. For example, if you specify <code>audio/mpeg</code> as the value, Amazon Lex V2 returns speech in the MPEG format.</p></li>
381 /// <li>
382 /// <p>If the value is <code>audio/pcm</code>, the speech returned is <code>audio/pcm</code> at 16 KHz in 16-bit, little-endian format.</p></li>
383 /// <li>
384 /// <p>The following are the accepted values:</p>
385 /// <ul>
386 /// <li>
387 /// <p>audio/mpeg</p></li>
388 /// <li>
389 /// <p>audio/ogg</p></li>
390 /// <li>
391 /// <p>audio/pcm (16 KHz)</p></li>
392 /// <li>
393 /// <p>audio/* (defaults to mpeg)</p></li>
394 /// <li>
395 /// <p>text/plain; charset=utf-8</p></li>
396 /// </ul></li>
397 /// </ul>
398 pub fn get_response_content_type(&self) -> &::std::option::Option<::std::string::String> {
399 self.inner.get_response_content_type()
400 }
401 /// <p>User input in PCM or Opus audio format or text format as described in the <code>requestContentType</code> parameter.</p>
402 pub fn input_stream(mut self, input: ::aws_smithy_types::byte_stream::ByteStream) -> Self {
403 self.inner = self.inner.input_stream(input);
404 self
405 }
406 /// <p>User input in PCM or Opus audio format or text format as described in the <code>requestContentType</code> parameter.</p>
407 pub fn set_input_stream(mut self, input: ::std::option::Option<::aws_smithy_types::byte_stream::ByteStream>) -> Self {
408 self.inner = self.inner.set_input_stream(input);
409 self
410 }
411 /// <p>User input in PCM or Opus audio format or text format as described in the <code>requestContentType</code> parameter.</p>
412 pub fn get_input_stream(&self) -> &::std::option::Option<::aws_smithy_types::byte_stream::ByteStream> {
413 self.inner.get_input_stream()
414 }
415}