pub struct Client { /* private fields */ }
Expand description
Client for Amazon Lex Runtime V2
Client for invoking operations on Amazon Lex Runtime V2. Each operation on Amazon Lex Runtime V2 is a method on this
this struct. .send()
MUST be invoked on the generated operations to dispatch the request to the service.
§Constructing a Client
A Config
is required to construct a client. For most use cases, the aws-config
crate should be used to automatically resolve this config using
aws_config::load_from_env()
, since this will resolve an SdkConfig
which can be shared
across multiple different AWS SDK clients. This config resolution process can be customized
by calling aws_config::from_env()
instead, which returns a ConfigLoader
that uses
the builder pattern to customize the default config.
In the simplest case, creating a client looks as follows:
let config = aws_config::load_from_env().await;
let client = aws_sdk_lexruntimev2::Client::new(&config);
Occasionally, SDKs may have additional service-specific values that can be set on the Config
that
is absent from SdkConfig
, or slightly different settings for a specific client may be desired.
The Builder
struct implements From<&SdkConfig>
, so setting these specific settings can be
done as follows:
let sdk_config = ::aws_config::load_from_env().await;
let config = aws_sdk_lexruntimev2::config::Builder::from(&sdk_config)
.some_service_specific_setting("value")
.build();
See the aws-config
docs and Config
for more information on customizing configuration.
Note: Client construction is expensive due to connection thread pool initialization, and should be done once at application start-up.
§Using the Client
A client has a function for every operation that can be performed by the service.
For example, the DeleteSession
operation has
a Client::delete_session
, function which returns a builder for that operation.
The fluent builder ultimately has a send()
function that returns an async future that
returns a result, as illustrated below:
let result = client.delete_session()
.bot_id("example")
.send()
.await;
The underlying HTTP requests that get made by this can be modified with the customize_operation
function on the fluent builder. See the customize
module for more
information.
Implementations§
Source§impl Client
impl Client
Sourcepub fn delete_session(&self) -> DeleteSessionFluentBuilder
pub fn delete_session(&self) -> DeleteSessionFluentBuilder
Constructs a fluent builder for the DeleteSession
operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)
/set_bot_id(Option<String>)
:
required: trueThe identifier of the bot that contains the session data.
bot_alias_id(impl Into<String>)
/set_bot_alias_id(Option<String>)
:
required: trueThe alias identifier in use for the bot that contains the session data.
locale_id(impl Into<String>)
/set_locale_id(Option<String>)
:
required: trueThe locale where the session is in use.
session_id(impl Into<String>)
/set_session_id(Option<String>)
:
required: trueThe identifier of the session to delete.
- On success, responds with
DeleteSessionOutput
with field(s):bot_id(Option<String>)
:The identifier of the bot that contained the session data.
bot_alias_id(Option<String>)
:The alias identifier in use for the bot that contained the session data.
locale_id(Option<String>)
:The locale where the session was used.
session_id(Option<String>)
:The identifier of the deleted session.
- On failure, responds with
SdkError<DeleteSessionError>
Source§impl Client
impl Client
Sourcepub fn get_session(&self) -> GetSessionFluentBuilder
pub fn get_session(&self) -> GetSessionFluentBuilder
Constructs a fluent builder for the GetSession
operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)
/set_bot_id(Option<String>)
:
required: trueThe identifier of the bot that contains the session data.
bot_alias_id(impl Into<String>)
/set_bot_alias_id(Option<String>)
:
required: trueThe alias identifier in use for the bot that contains the session data.
locale_id(impl Into<String>)
/set_locale_id(Option<String>)
:
required: trueThe locale where the session is in use.
session_id(impl Into<String>)
/set_session_id(Option<String>)
:
required: trueThe identifier of the session to return.
- On success, responds with
GetSessionOutput
with field(s):session_id(Option<String>)
:The identifier of the returned session.
messages(Option<Vec::<Message>>)
:A list of messages that were last sent to the user. The messages are ordered based on the order that your returned the messages from your Lambda function or the order that messages are defined in the bot.
interpretations(Option<Vec::<Interpretation>>)
:A list of intents that Amazon Lex V2 determined might satisfy the user’s utterance.
Each interpretation includes the intent, a score that indicates how confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.
session_state(Option<SessionState>)
:Represents the current state of the dialog between the user and the bot.
You can use this to determine the progress of the conversation and what the next action might be.
- On failure, responds with
SdkError<GetSessionError>
Source§impl Client
impl Client
Sourcepub fn put_session(&self) -> PutSessionFluentBuilder
pub fn put_session(&self) -> PutSessionFluentBuilder
Constructs a fluent builder for the PutSession
operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)
/set_bot_id(Option<String>)
:
required: trueThe identifier of the bot that receives the session data.
bot_alias_id(impl Into<String>)
/set_bot_alias_id(Option<String>)
:
required: trueThe alias identifier of the bot that receives the session data.
locale_id(impl Into<String>)
/set_locale_id(Option<String>)
:
required: trueThe locale where the session is in use.
session_id(impl Into<String>)
/set_session_id(Option<String>)
:
required: trueThe identifier of the session that receives the session data.
messages(Message)
/set_messages(Option<Vec::<Message>>)
:
required: falseA list of messages to send to the user. Messages are sent in the order that they are defined in the list.
session_state(SessionState)
/set_session_state(Option<SessionState>)
:
required: trueSets 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.
request_attributes(impl Into<String>, impl Into<String>)
/set_request_attributes(Option<HashMap::<String, String>>)
:
required: falseRequest-specific information passed between Amazon Lex V2 and the client application.
The namespace
x-amz-lex:
is reserved for special attributes. Don’t create any request attributes with the prefixx-amz-lex:
.response_content_type(impl Into<String>)
/set_response_content_type(Option<String>)
:
required: falseThe message that Amazon Lex V2 returns in the response can be either text or speech depending on the value of this parameter.
-
If the value is
text/plain; charset=utf-8
, Amazon Lex V2 returns text in the response.
-
- On success, responds with
PutSessionOutput
with field(s):content_type(Option<String>)
:The type of response. Same as the type specified in the
responseContentType
field in the request.messages(Option<String>)
:A list of messages that were last sent to the user. The messages are ordered based on how you return the messages from you Lambda function or the order that the messages are defined in the bot.
session_state(Option<String>)
:A base-64-encoded gzipped field that represents the current state of the dialog between the user and the bot. Use this to determine the progress of the conversation and what the next action may be.
request_attributes(Option<String>)
:A base-64-encoded gzipped field that provides request-specific information passed between the client application and Amazon Lex V2. These are the same as the
requestAttribute
parameter in the call to thePutSession
operation.session_id(Option<String>)
:The identifier of the session that received the data.
audio_stream(ByteStream)
:If the requested content type was audio, the audio version of the message to convey to the user.
- On failure, responds with
SdkError<PutSessionError>
Source§impl Client
impl Client
Sourcepub fn recognize_text(&self) -> RecognizeTextFluentBuilder
pub fn recognize_text(&self) -> RecognizeTextFluentBuilder
Constructs a fluent builder for the RecognizeText
operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)
/set_bot_id(Option<String>)
:
required: trueThe identifier of the bot that processes the request.
bot_alias_id(impl Into<String>)
/set_bot_alias_id(Option<String>)
:
required: trueThe alias identifier in use for the bot that processes the request.
locale_id(impl Into<String>)
/set_locale_id(Option<String>)
:
required: trueThe locale where the session is in use.
session_id(impl Into<String>)
/set_session_id(Option<String>)
:
required: trueThe identifier of the user session that is having the conversation.
text(impl Into<String>)
/set_text(Option<String>)
:
required: trueThe text that the user entered. Amazon Lex V2 interprets this text.
session_state(SessionState)
/set_session_state(Option<SessionState>)
:
required: falseThe current state of the dialog between the user and the bot.
request_attributes(impl Into<String>, impl Into<String>)
/set_request_attributes(Option<HashMap::<String, String>>)
:
required: falseRequest-specific information passed between the client application and Amazon Lex V2
The namespace
x-amz-lex:
is reserved for special attributes. Don’t create any request attributes with the prefixx-amz-lex:
.
- On success, responds with
RecognizeTextOutput
with field(s):messages(Option<Vec::<Message>>)
:A list of messages last sent to the user. The messages are ordered based on the order that you returned the messages from your Lambda function or the order that the messages are defined in the bot.
session_state(Option<SessionState>)
:Represents the current state of the dialog between the user and the bot.
Use this to determine the progress of the conversation and what the next action may be.
interpretations(Option<Vec::<Interpretation>>)
:A list of intents that Amazon Lex V2 determined might satisfy the user’s utterance.
Each interpretation includes the intent, a score that indicates now confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.
request_attributes(Option<HashMap::<String, String>>)
:The attributes sent in the request.
session_id(Option<String>)
:The identifier of the session in use.
recognized_bot_member(Option<RecognizedBotMember>)
:The bot member that recognized the text.
- On failure, responds with
SdkError<RecognizeTextError>
Source§impl Client
impl Client
Sourcepub fn recognize_utterance(&self) -> RecognizeUtteranceFluentBuilder
pub fn recognize_utterance(&self) -> RecognizeUtteranceFluentBuilder
Constructs a fluent builder for the RecognizeUtterance
operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)
/set_bot_id(Option<String>)
:
required: trueThe identifier of the bot that should receive the request.
bot_alias_id(impl Into<String>)
/set_bot_alias_id(Option<String>)
:
required: trueThe alias identifier in use for the bot that should receive the request.
locale_id(impl Into<String>)
/set_locale_id(Option<String>)
:
required: trueThe locale where the session is in use.
session_id(impl Into<String>)
/set_session_id(Option<String>)
:
required: trueThe identifier of the session in use.
session_state(impl Into<String>)
/set_session_state(Option<String>)
:
required: falseSets 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.
The
sessionState
field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.request_attributes(impl Into<String>)
/set_request_attributes(Option<String>)
:
required: falseRequest-specific information passed between the client application and Amazon Lex V2
The namespace
x-amz-lex:
is reserved for special attributes. Don’t create any request attributes for prefixx-amz-lex:
.The
requestAttributes
field must be compressed using gzip and then base64 encoded before sending to Amazon Lex V2.request_content_type(impl Into<String>)
/set_request_content_type(Option<String>)
:
required: trueIndicates the format for audio input or that the content is text. The header must start with one of the following prefixes:
-
PCM format, audio data must be in little-endian byte order.
-
audio/l16; rate=16000; channels=1
-
audio/x-l16; sample-rate=16000; channel-count=1
-
audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false
-
-
Opus format
-
audio/x-cbr-opus-with-preamble;preamble-size=0;bit-rate=256000;frame-size-milliseconds=4
-
-
Text format
-
text/plain; charset=utf-8
-
-
response_content_type(impl Into<String>)
/set_response_content_type(Option<String>)
:
required: falseThe message that Amazon Lex V2 returns in the response can be either text or speech based on the
responseContentType
value.-
If the value is
text/plain;charset=utf-8
, Amazon Lex V2 returns text in the response. -
If the value begins with
audio/
, 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 theresponseContentType
parameter. For example, if you specifyaudio/mpeg
as the value, Amazon Lex V2 returns speech in the MPEG format. -
If the value is
audio/pcm
, the speech returned isaudio/pcm
at 16 KHz in 16-bit, little-endian format. -
The following are the accepted values:
-
audio/mpeg
-
audio/ogg
-
audio/pcm (16 KHz)
-
audio/* (defaults to mpeg)
-
text/plain; charset=utf-8
-
-
input_stream(ByteStream)
/set_input_stream(ByteStream)
:
required: falseUser input in PCM or Opus audio format or text format as described in the
requestContentType
parameter.
- On success, responds with
RecognizeUtteranceOutput
with field(s):input_mode(Option<String>)
:Indicates whether the input mode to the operation was text, speech, or from a touch-tone keypad.
content_type(Option<String>)
:Content type as specified in the
responseContentType
in the request.messages(Option<String>)
:A list of messages that were last sent to the user. The messages are ordered based on the order that you returned the messages from your Lambda function or the order that the messages are defined in the bot.
The
messages
field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.interpretations(Option<String>)
:A list of intents that Amazon Lex V2 determined might satisfy the user’s utterance.
Each interpretation includes the intent, a score that indicates how confident Amazon Lex V2 is that the interpretation is the correct one, and an optional sentiment response that indicates the sentiment expressed in the utterance.
The
interpretations
field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.session_state(Option<String>)
:Represents the current state of the dialog between the user and the bot.
Use this to determine the progress of the conversation and what the next action might be.
The
sessionState
field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.request_attributes(Option<String>)
:The attributes sent in the request.
The
requestAttributes
field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents.session_id(Option<String>)
:The identifier of the session in use.
input_transcript(Option<String>)
:The text used to process the request.
If the input was an audio stream, the
inputTranscript
field contains the text extracted from the audio stream. This is the text that is actually processed to recognize intents and slot values. You can use this information to determine if Amazon Lex V2 is correctly processing the audio that you send.The
inputTranscript
field is compressed with gzip and then base64 encoded. Before you can use the contents of the field, you must decode and decompress the contents. See the example for a simple function to decode and decompress the contents.audio_stream(ByteStream)
:The prompt or statement to send to the user. This is based on the bot configuration and context. For example, if Amazon Lex V2 did not understand the user intent, it sends the
clarificationPrompt
configured for the bot. If the intent requires confirmation before taking the fulfillment action, it sends theconfirmationPrompt
. Another example: Suppose that the Lambda function successfully fulfilled the intent, and sent a message to convey to the user. Then Amazon Lex V2 sends that message in the response.recognized_bot_member(Option<String>)
:The bot member that recognized the utterance.
- On failure, responds with
SdkError<RecognizeUtteranceError>
Source§impl Client
impl Client
Sourcepub fn start_conversation(&self) -> StartConversationFluentBuilder
pub fn start_conversation(&self) -> StartConversationFluentBuilder
Constructs a fluent builder for the StartConversation
operation.
- The fluent builder is configurable:
bot_id(impl Into<String>)
/set_bot_id(Option<String>)
:
required: trueThe identifier of the bot to process the request.
bot_alias_id(impl Into<String>)
/set_bot_alias_id(Option<String>)
:
required: trueThe alias identifier in use for the bot that processes the request.
locale_id(impl Into<String>)
/set_locale_id(Option<String>)
:
required: trueThe locale where the session is in use.
session_id(impl Into<String>)
/set_session_id(Option<String>)
:
required: trueThe identifier of the user session that is having the conversation.
conversation_mode(ConversationMode)
/set_conversation_mode(Option<ConversationMode>)
:
required: falseThe conversation type that you are using the Amazon Lex V2. If the conversation mode is
AUDIO
you can send both audio and DTMF information. If the mode isTEXT
you can only send text.request_event_stream(EventStreamSender<StartConversationRequestEventStream, StartConversationRequestEventStreamError>)
/set_request_event_stream(EventStreamSender<StartConversationRequestEventStream, StartConversationRequestEventStreamError>)
:
required: trueRepresents the stream of events to Amazon Lex V2 from your application. The events are encoded as HTTP/2 data frames.
- On success, responds with
StartConversationOutput
with field(s):response_event_stream(EventReceiver<StartConversationResponseEventStream, StartConversationResponseEventStreamError>)
:Represents the stream of events from Amazon Lex V2 to your application. The events are encoded as HTTP/2 data frames.
- On failure, responds with
SdkError<StartConversationError>
Source§impl Client
impl Client
Sourcepub fn from_conf(conf: Config) -> Self
pub fn from_conf(conf: Config) -> Self
Creates a new client from the service Config
.
§Panics
This method will panic in the following cases:
- Retries or timeouts are enabled without a
sleep_impl
configured. - Identity caching is enabled without a
sleep_impl
andtime_source
configured. - No
behavior_version
is provided.
The panic message for each of these will have instructions on how to resolve them.
Source§impl Client
impl Client
Sourcepub fn new(sdk_config: &SdkConfig) -> Self
pub fn new(sdk_config: &SdkConfig) -> Self
Creates a new client from an SDK Config.
§Panics
- This method will panic if the
sdk_config
is missing an async sleep implementation. If you experience this panic, set thesleep_impl
on the Config passed into this function to fix it. - This method will panic if the
sdk_config
is missing an HTTP connector. If you experience this panic, set thehttp_connector
on the Config passed into this function to fix it. - This method will panic if no
BehaviorVersion
is provided. If you experience this panic, setbehavior_version
on the Config or enable thebehavior-version-latest
Cargo feature.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);