aws-sdk-lexruntimev2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/aws-sdk-lexruntimev2.rb +55 -0
- data/lib/aws-sdk-lexruntimev2/async_client.rb +601 -0
- data/lib/aws-sdk-lexruntimev2/client.rb +949 -0
- data/lib/aws-sdk-lexruntimev2/client_api.rb +512 -0
- data/lib/aws-sdk-lexruntimev2/customizations.rb +0 -0
- data/lib/aws-sdk-lexruntimev2/errors.rb +38 -0
- data/lib/aws-sdk-lexruntimev2/event_streams.rb +266 -0
- data/lib/aws-sdk-lexruntimev2/resource.rb +26 -0
- data/lib/aws-sdk-lexruntimev2/types.rb +2060 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3b27294a6b8c0c120c13aa0f5dfe5eadac1a2e0f7c6748aebb0e4f7548b0b811
|
4
|
+
data.tar.gz: 894edbde9056b387e6779f01f567b847a5fbfd2e8b0792b6b6994c3e0c5d21c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bfd3fa23a174a2fbbab448a4c6096fb50cd561e649f03690243d68529d15330b878d15f62b1cff5fe7e856070fd97b67b28baa86ffa0ad53e2ab0968c4fd0fa0
|
7
|
+
data.tar.gz: 3517fa666e4405f0a0b68a0f20987730aff9e291620944c7767b35eec3687d660102f082ddfa7dfca0eff4621098630f4e8173e81eb87a7a1fa5ba5b04a71c12
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# WARNING ABOUT GENERATED CODE
|
4
|
+
#
|
5
|
+
# This file is generated. See the contributing guide for more information:
|
6
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
7
|
+
#
|
8
|
+
# WARNING ABOUT GENERATED CODE
|
9
|
+
|
10
|
+
|
11
|
+
require 'aws-sdk-core'
|
12
|
+
require 'aws-sigv4'
|
13
|
+
|
14
|
+
require_relative 'aws-sdk-lexruntimev2/types'
|
15
|
+
require_relative 'aws-sdk-lexruntimev2/client_api'
|
16
|
+
require_relative 'aws-sdk-lexruntimev2/client'
|
17
|
+
require_relative 'aws-sdk-lexruntimev2/errors'
|
18
|
+
require_relative 'aws-sdk-lexruntimev2/resource'
|
19
|
+
require_relative 'aws-sdk-lexruntimev2/customizations'
|
20
|
+
require_relative 'aws-sdk-lexruntimev2/async_client'
|
21
|
+
require_relative 'aws-sdk-lexruntimev2/event_streams'
|
22
|
+
|
23
|
+
# This module provides support for Amazon Lex Runtime V2. This module is available in the
|
24
|
+
# `aws-sdk-lexruntimev2` gem.
|
25
|
+
#
|
26
|
+
# # Client
|
27
|
+
#
|
28
|
+
# The {Client} class provides one method for each API operation. Operation
|
29
|
+
# methods each accept a hash of request parameters and return a response
|
30
|
+
# structure.
|
31
|
+
#
|
32
|
+
# lex_runtime_v2 = Aws::LexRuntimeV2::Client.new
|
33
|
+
# resp = lex_runtime_v2.delete_session(params)
|
34
|
+
#
|
35
|
+
# See {Client} for more information.
|
36
|
+
#
|
37
|
+
# # Errors
|
38
|
+
#
|
39
|
+
# Errors returned from Amazon Lex Runtime V2 are defined in the
|
40
|
+
# {Errors} module and all extend {Errors::ServiceError}.
|
41
|
+
#
|
42
|
+
# begin
|
43
|
+
# # do stuff
|
44
|
+
# rescue Aws::LexRuntimeV2::Errors::ServiceError
|
45
|
+
# # rescues all Amazon Lex Runtime V2 API errors
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# See {Errors} for more information.
|
49
|
+
#
|
50
|
+
# @!group service
|
51
|
+
module Aws::LexRuntimeV2
|
52
|
+
|
53
|
+
GEM_VERSION = '1.0.0'
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,601 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# WARNING ABOUT GENERATED CODE
|
4
|
+
#
|
5
|
+
# This file is generated. See the contributing guide for more information:
|
6
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
7
|
+
#
|
8
|
+
# WARNING ABOUT GENERATED CODE
|
9
|
+
|
10
|
+
if RUBY_VERSION >= '2.1'
|
11
|
+
begin
|
12
|
+
require 'http/2'
|
13
|
+
rescue LoadError; end
|
14
|
+
end
|
15
|
+
require 'seahorse/client/plugins/content_length.rb'
|
16
|
+
require 'aws-sdk-core/plugins/credentials_configuration.rb'
|
17
|
+
require 'aws-sdk-core/plugins/logging.rb'
|
18
|
+
require 'aws-sdk-core/plugins/param_converter.rb'
|
19
|
+
require 'aws-sdk-core/plugins/param_validator.rb'
|
20
|
+
require 'aws-sdk-core/plugins/user_agent.rb'
|
21
|
+
require 'aws-sdk-core/plugins/helpful_socket_errors.rb'
|
22
|
+
require 'aws-sdk-core/plugins/retry_errors.rb'
|
23
|
+
require 'aws-sdk-core/plugins/global_configuration.rb'
|
24
|
+
require 'aws-sdk-core/plugins/regional_endpoint.rb'
|
25
|
+
require 'aws-sdk-core/plugins/stub_responses.rb'
|
26
|
+
require 'aws-sdk-core/plugins/idempotency_token.rb'
|
27
|
+
require 'aws-sdk-core/plugins/jsonvalue_converter.rb'
|
28
|
+
require 'aws-sdk-core/plugins/http_checksum.rb'
|
29
|
+
require 'aws-sdk-core/plugins/invocation_id.rb'
|
30
|
+
require 'aws-sdk-core/plugins/signature_v4.rb'
|
31
|
+
require 'aws-sdk-core/plugins/protocols/rest_json.rb'
|
32
|
+
require 'aws-sdk-core/plugins/event_stream_configuration.rb'
|
33
|
+
|
34
|
+
Aws::Plugins::GlobalConfiguration.add_identifier(:lexruntimev2)
|
35
|
+
|
36
|
+
module Aws::LexRuntimeV2
|
37
|
+
class AsyncClient < Seahorse::Client::AsyncBase
|
38
|
+
|
39
|
+
include Aws::AsyncClientStubs
|
40
|
+
|
41
|
+
@identifier = :lexruntimev2
|
42
|
+
|
43
|
+
set_api(ClientApi::API)
|
44
|
+
|
45
|
+
add_plugin(Seahorse::Client::Plugins::ContentLength)
|
46
|
+
add_plugin(Aws::Plugins::CredentialsConfiguration)
|
47
|
+
add_plugin(Aws::Plugins::Logging)
|
48
|
+
add_plugin(Aws::Plugins::ParamConverter)
|
49
|
+
add_plugin(Aws::Plugins::ParamValidator)
|
50
|
+
add_plugin(Aws::Plugins::UserAgent)
|
51
|
+
add_plugin(Aws::Plugins::HelpfulSocketErrors)
|
52
|
+
add_plugin(Aws::Plugins::RetryErrors)
|
53
|
+
add_plugin(Aws::Plugins::GlobalConfiguration)
|
54
|
+
add_plugin(Aws::Plugins::RegionalEndpoint)
|
55
|
+
add_plugin(Aws::Plugins::StubResponses)
|
56
|
+
add_plugin(Aws::Plugins::IdempotencyToken)
|
57
|
+
add_plugin(Aws::Plugins::JsonvalueConverter)
|
58
|
+
add_plugin(Aws::Plugins::HttpChecksum)
|
59
|
+
add_plugin(Aws::Plugins::InvocationId)
|
60
|
+
add_plugin(Aws::Plugins::SignatureV4)
|
61
|
+
add_plugin(Aws::Plugins::Protocols::RestJson)
|
62
|
+
add_plugin(Aws::Plugins::EventStreamConfiguration)
|
63
|
+
|
64
|
+
# @option options [required, Aws::CredentialProvider] :credentials
|
65
|
+
# Your AWS credentials. This can be an instance of any one of the
|
66
|
+
# following classes:
|
67
|
+
#
|
68
|
+
# * `Aws::Credentials` - Used for configuring static, non-refreshing
|
69
|
+
# credentials.
|
70
|
+
#
|
71
|
+
# * `Aws::SharedCredentials` - Used for loading static credentials from a
|
72
|
+
# shared file, such as `~/.aws/config`.
|
73
|
+
#
|
74
|
+
# * `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
|
75
|
+
#
|
76
|
+
# * `Aws::AssumeRoleWebIdentityCredentials` - Used when you need to
|
77
|
+
# assume a role after providing credentials via the web.
|
78
|
+
#
|
79
|
+
# * `Aws::SSOCredentials` - Used for loading credentials from AWS SSO using an
|
80
|
+
# access token generated from `aws login`.
|
81
|
+
#
|
82
|
+
# * `Aws::ProcessCredentials` - Used for loading credentials from a
|
83
|
+
# process that outputs to stdout.
|
84
|
+
#
|
85
|
+
# * `Aws::InstanceProfileCredentials` - Used for loading credentials
|
86
|
+
# from an EC2 IMDS on an EC2 instance.
|
87
|
+
#
|
88
|
+
# * `Aws::ECSCredentials` - Used for loading credentials from
|
89
|
+
# instances running in ECS.
|
90
|
+
#
|
91
|
+
# * `Aws::CognitoIdentityCredentials` - Used for loading credentials
|
92
|
+
# from the Cognito Identity service.
|
93
|
+
#
|
94
|
+
# When `:credentials` are not configured directly, the following
|
95
|
+
# locations will be searched for credentials:
|
96
|
+
#
|
97
|
+
# * `Aws.config[:credentials]`
|
98
|
+
# * The `:access_key_id`, `:secret_access_key`, and `:session_token` options.
|
99
|
+
# * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
|
100
|
+
# * `~/.aws/credentials`
|
101
|
+
# * `~/.aws/config`
|
102
|
+
# * EC2/ECS IMDS instance profile - When used by default, the timeouts
|
103
|
+
# are very aggressive. Construct and pass an instance of
|
104
|
+
# `Aws::InstanceProfileCredentails` or `Aws::ECSCredentials` to
|
105
|
+
# enable retries and extended timeouts.
|
106
|
+
#
|
107
|
+
# @option options [required, String] :region
|
108
|
+
# The AWS region to connect to. The configured `:region` is
|
109
|
+
# used to determine the service `:endpoint`. When not passed,
|
110
|
+
# a default `:region` is searched for in the following locations:
|
111
|
+
#
|
112
|
+
# * `Aws.config[:region]`
|
113
|
+
# * `ENV['AWS_REGION']`
|
114
|
+
# * `ENV['AMAZON_REGION']`
|
115
|
+
# * `ENV['AWS_DEFAULT_REGION']`
|
116
|
+
# * `~/.aws/credentials`
|
117
|
+
# * `~/.aws/config`
|
118
|
+
#
|
119
|
+
# @option options [String] :access_key_id
|
120
|
+
#
|
121
|
+
# @option options [Boolean] :adaptive_retry_wait_to_fill (true)
|
122
|
+
# Used only in `adaptive` retry mode. When true, the request will sleep
|
123
|
+
# until there is sufficent client side capacity to retry the request.
|
124
|
+
# When false, the request will raise a `RetryCapacityNotAvailableError` and will
|
125
|
+
# not retry instead of sleeping.
|
126
|
+
#
|
127
|
+
# @option options [Boolean] :convert_params (true)
|
128
|
+
# When `true`, an attempt is made to coerce request parameters into
|
129
|
+
# the required types.
|
130
|
+
#
|
131
|
+
# @option options [Boolean] :correct_clock_skew (true)
|
132
|
+
# Used only in `standard` and adaptive retry modes. Specifies whether to apply
|
133
|
+
# a clock skew correction and retry requests with skewed client clocks.
|
134
|
+
#
|
135
|
+
# @option options [String] :endpoint
|
136
|
+
# The client endpoint is normally constructed from the `:region`
|
137
|
+
# option. You should only configure an `:endpoint` when connecting
|
138
|
+
# to test or custom endpoints. This should be a valid HTTP(S) URI.
|
139
|
+
#
|
140
|
+
# @option options [Proc] :event_stream_handler
|
141
|
+
# When an EventStream or Proc object is provided, it will be used as callback for each chunk of event stream response received along the way.
|
142
|
+
#
|
143
|
+
# @option options [Proc] :input_event_stream_handler
|
144
|
+
# When an EventStream or Proc object is provided, it can be used for sending events for the event stream.
|
145
|
+
#
|
146
|
+
# @option options [Aws::Log::Formatter] :log_formatter (Aws::Log::Formatter.default)
|
147
|
+
# The log formatter.
|
148
|
+
#
|
149
|
+
# @option options [Symbol] :log_level (:info)
|
150
|
+
# The log level to send messages to the `:logger` at.
|
151
|
+
#
|
152
|
+
# @option options [Logger] :logger
|
153
|
+
# The Logger instance to send log messages to. If this option
|
154
|
+
# is not set, logging will be disabled.
|
155
|
+
#
|
156
|
+
# @option options [Integer] :max_attempts (3)
|
157
|
+
# An integer representing the maximum number attempts that will be made for
|
158
|
+
# a single request, including the initial attempt. For example,
|
159
|
+
# setting this value to 5 will result in a request being retried up to
|
160
|
+
# 4 times. Used in `standard` and `adaptive` retry modes.
|
161
|
+
#
|
162
|
+
# @option options [Proc] :output_event_stream_handler
|
163
|
+
# When an EventStream or Proc object is provided, it will be used as callback for each chunk of event stream response received along the way.
|
164
|
+
#
|
165
|
+
# @option options [String] :profile ("default")
|
166
|
+
# Used when loading credentials from the shared credentials file
|
167
|
+
# at HOME/.aws/credentials. When not specified, 'default' is used.
|
168
|
+
#
|
169
|
+
# @option options [Proc] :retry_backoff
|
170
|
+
# A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
|
171
|
+
# This option is only used in the `legacy` retry mode.
|
172
|
+
#
|
173
|
+
# @option options [Float] :retry_base_delay (0.3)
|
174
|
+
# The base delay in seconds used by the default backoff function. This option
|
175
|
+
# is only used in the `legacy` retry mode.
|
176
|
+
#
|
177
|
+
# @option options [Symbol] :retry_jitter (:none)
|
178
|
+
# A delay randomiser function used by the default backoff function.
|
179
|
+
# Some predefined functions can be referenced by name - :none, :equal, :full,
|
180
|
+
# otherwise a Proc that takes and returns a number. This option is only used
|
181
|
+
# in the `legacy` retry mode.
|
182
|
+
#
|
183
|
+
# @see https://www.awsarchitectureblog.com/2015/03/backoff.html
|
184
|
+
#
|
185
|
+
# @option options [Integer] :retry_limit (3)
|
186
|
+
# The maximum number of times to retry failed requests. Only
|
187
|
+
# ~ 500 level server errors and certain ~ 400 level client errors
|
188
|
+
# are retried. Generally, these are throttling errors, data
|
189
|
+
# checksum errors, networking errors, timeout errors, auth errors,
|
190
|
+
# endpoint discovery, and errors from expired credentials.
|
191
|
+
# This option is only used in the `legacy` retry mode.
|
192
|
+
#
|
193
|
+
# @option options [Integer] :retry_max_delay (0)
|
194
|
+
# The maximum number of seconds to delay between retries (0 for no limit)
|
195
|
+
# used by the default backoff function. This option is only used in the
|
196
|
+
# `legacy` retry mode.
|
197
|
+
#
|
198
|
+
# @option options [String] :retry_mode ("legacy")
|
199
|
+
# Specifies which retry algorithm to use. Values are:
|
200
|
+
#
|
201
|
+
# * `legacy` - The pre-existing retry behavior. This is default value if
|
202
|
+
# no retry mode is provided.
|
203
|
+
#
|
204
|
+
# * `standard` - A standardized set of retry rules across the AWS SDKs.
|
205
|
+
# This includes support for retry quotas, which limit the number of
|
206
|
+
# unsuccessful retries a client can make.
|
207
|
+
#
|
208
|
+
# * `adaptive` - An experimental retry mode that includes all the
|
209
|
+
# functionality of `standard` mode along with automatic client side
|
210
|
+
# throttling. This is a provisional mode that may change behavior
|
211
|
+
# in the future.
|
212
|
+
#
|
213
|
+
#
|
214
|
+
# @option options [String] :secret_access_key
|
215
|
+
#
|
216
|
+
# @option options [String] :session_token
|
217
|
+
#
|
218
|
+
# @option options [Boolean] :stub_responses (false)
|
219
|
+
# Causes the client to return stubbed responses. By default
|
220
|
+
# fake responses are generated and returned. You can specify
|
221
|
+
# the response data to return or errors to raise by calling
|
222
|
+
# {ClientStubs#stub_responses}. See {ClientStubs} for more information.
|
223
|
+
#
|
224
|
+
# ** Please note ** When response stubbing is enabled, no HTTP
|
225
|
+
# requests are made, and retries are disabled.
|
226
|
+
#
|
227
|
+
# @option options [Boolean] :validate_params (true)
|
228
|
+
# When `true`, request parameters are validated before
|
229
|
+
# sending the request.
|
230
|
+
#
|
231
|
+
def initialize(*args)
|
232
|
+
unless Kernel.const_defined?("HTTP2")
|
233
|
+
raise "Must include http/2 gem to use AsyncClient instances."
|
234
|
+
end
|
235
|
+
super
|
236
|
+
end
|
237
|
+
|
238
|
+
# @!group API Operations
|
239
|
+
|
240
|
+
# Starts an HTTP/2 bidirectional event stream that enables you to send
|
241
|
+
# audio, text, or DTMF input in real time. After your application starts
|
242
|
+
# a conversation, users send input to Amazon Lex as a stream of events.
|
243
|
+
# Amazon Lex processes the incoming events and responds with streaming
|
244
|
+
# text or audio events.
|
245
|
+
#
|
246
|
+
# @option params [required, String] :bot_id
|
247
|
+
# The identifier of the bot to process the request.
|
248
|
+
#
|
249
|
+
# @option params [required, String] :bot_alias_id
|
250
|
+
# The alias identifier in use for the bot that processes the request.
|
251
|
+
#
|
252
|
+
# @option params [required, String] :locale_id
|
253
|
+
# The locale where the session is in use.
|
254
|
+
#
|
255
|
+
# @option params [required, String] :session_id
|
256
|
+
# The identifier of the user session that is having the conversation.
|
257
|
+
#
|
258
|
+
# @option params [String] :conversation_mode
|
259
|
+
# The conversation type that you are using the Amazon Lex. If the
|
260
|
+
# conversation mode is `AUDIO` you can send both audio and DTMF
|
261
|
+
# information. If the mode is `TEXT` you can only send text.
|
262
|
+
#
|
263
|
+
# @return [Types::StartConversationResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
|
264
|
+
#
|
265
|
+
# * {Types::StartConversationResponse#response_event_stream #response_event_stream} => Types::StartConversationResponseEventStream
|
266
|
+
#
|
267
|
+
# @example Bi-directional EventStream Operation Example
|
268
|
+
#
|
269
|
+
# You can signal input events after initial request is
|
270
|
+
# established, events will be sent to stream
|
271
|
+
# immediately (once stream connection is established successfully).
|
272
|
+
#
|
273
|
+
# To signal events, you can call #signal methods from an Aws::LexRuntimeV2::EventStreams::StartConversationRequestEventStream object.
|
274
|
+
# Make sure signal events before calling #wait or #join! at async response.
|
275
|
+
#
|
276
|
+
# input_stream = Aws::LexRuntimeV2::EventStreams::StartConversationRequestEventStream.new
|
277
|
+
#
|
278
|
+
# async_resp = client.start_conversation( # params input,
|
279
|
+
# input_event_stream_handler: input_stream) do |out_stream|
|
280
|
+
#
|
281
|
+
# # register callbacks for events arrival
|
282
|
+
# out_stream.on_playback_interruption_event_event do |event|
|
283
|
+
# event # => Aws::LexRuntimeV2::Types::PlaybackInterruptionEvent
|
284
|
+
# end
|
285
|
+
# out_stream.on_transcript_event_event do |event|
|
286
|
+
# event # => Aws::LexRuntimeV2::Types::TranscriptEvent
|
287
|
+
# end
|
288
|
+
# out_stream.on_intent_result_event_event do |event|
|
289
|
+
# event # => Aws::LexRuntimeV2::Types::IntentResultEvent
|
290
|
+
# end
|
291
|
+
# out_stream.on_text_response_event_event do |event|
|
292
|
+
# event # => Aws::LexRuntimeV2::Types::TextResponseEvent
|
293
|
+
# end
|
294
|
+
# out_stream.on_audio_response_event_event do |event|
|
295
|
+
# event # => Aws::LexRuntimeV2::Types::AudioResponseEvent
|
296
|
+
# end
|
297
|
+
# out_stream.on_heartbeat_event_event do |event|
|
298
|
+
# event # => Aws::LexRuntimeV2::Types::HeartbeatEvent
|
299
|
+
# end
|
300
|
+
# out_stream.on_access_denied_exception_event do |event|
|
301
|
+
# event # => Aws::LexRuntimeV2::Types::AccessDeniedException
|
302
|
+
# end
|
303
|
+
# out_stream.on_resource_not_found_exception_event do |event|
|
304
|
+
# event # => Aws::LexRuntimeV2::Types::ResourceNotFoundException
|
305
|
+
# end
|
306
|
+
# out_stream.on_validation_exception_event do |event|
|
307
|
+
# event # => Aws::LexRuntimeV2::Types::ValidationException
|
308
|
+
# end
|
309
|
+
# out_stream.on_throttling_exception_event do |event|
|
310
|
+
# event # => Aws::LexRuntimeV2::Types::ThrottlingException
|
311
|
+
# end
|
312
|
+
# out_stream.on_internal_server_exception_event do |event|
|
313
|
+
# event # => Aws::LexRuntimeV2::Types::InternalServerException
|
314
|
+
# end
|
315
|
+
# out_stream.on_conflict_exception_event do |event|
|
316
|
+
# event # => Aws::LexRuntimeV2::Types::ConflictException
|
317
|
+
# end
|
318
|
+
# out_stream.on_dependency_failed_exception_event do |event|
|
319
|
+
# event # => Aws::LexRuntimeV2::Types::DependencyFailedException
|
320
|
+
# end
|
321
|
+
# out_stream.on_bad_gateway_exception_event do |event|
|
322
|
+
# event # => Aws::LexRuntimeV2::Types::BadGatewayException
|
323
|
+
# end
|
324
|
+
#
|
325
|
+
# end
|
326
|
+
# # => returns Aws::Seahorse::Client::AsyncResponse
|
327
|
+
#
|
328
|
+
# # signal events
|
329
|
+
# input_stream.signal_configuration_event_event( ... )
|
330
|
+
# input_stream.signal_audio_input_event_event( ... )
|
331
|
+
# input_stream.signal_dtmf_input_event_event( ... )
|
332
|
+
# input_stream.signal_text_input_event_event( ... )
|
333
|
+
# input_stream.signal_playback_completion_event_event( ... )
|
334
|
+
# input_stream.signal_disconnection_event_event( ... )
|
335
|
+
#
|
336
|
+
# # make sure signaling :end_stream in the end
|
337
|
+
# input_stream.signal_end_stream
|
338
|
+
#
|
339
|
+
# # wait until stream is closed before finalizing sync response
|
340
|
+
# resp = async_resp.wait
|
341
|
+
# # Or close stream and finalizing sync response immediately
|
342
|
+
# # resp = async_resp.join!
|
343
|
+
#
|
344
|
+
# Inorder to streamingly processing events received, you can also provide an Aws::LexRuntimeV2::EventStreams::StartConversationResponseEventStream
|
345
|
+
# object to register callbacks before initializing request instead of processing from request block
|
346
|
+
#
|
347
|
+
# output_stream = Aws::LexRuntimeV2::EventStreams::StartConversationResponseEventStream.new
|
348
|
+
# # register callbacks for events arrival
|
349
|
+
# output_stream.on_playback_interruption_event_event do |event|
|
350
|
+
# event # => Aws::LexRuntimeV2::Types::PlaybackInterruptionEvent
|
351
|
+
# end
|
352
|
+
# output_stream.on_transcript_event_event do |event|
|
353
|
+
# event # => Aws::LexRuntimeV2::Types::TranscriptEvent
|
354
|
+
# end
|
355
|
+
# output_stream.on_intent_result_event_event do |event|
|
356
|
+
# event # => Aws::LexRuntimeV2::Types::IntentResultEvent
|
357
|
+
# end
|
358
|
+
# output_stream.on_text_response_event_event do |event|
|
359
|
+
# event # => Aws::LexRuntimeV2::Types::TextResponseEvent
|
360
|
+
# end
|
361
|
+
# output_stream.on_audio_response_event_event do |event|
|
362
|
+
# event # => Aws::LexRuntimeV2::Types::AudioResponseEvent
|
363
|
+
# end
|
364
|
+
# output_stream.on_heartbeat_event_event do |event|
|
365
|
+
# event # => Aws::LexRuntimeV2::Types::HeartbeatEvent
|
366
|
+
# end
|
367
|
+
# output_stream.on_access_denied_exception_event do |event|
|
368
|
+
# event # => Aws::LexRuntimeV2::Types::AccessDeniedException
|
369
|
+
# end
|
370
|
+
# output_stream.on_resource_not_found_exception_event do |event|
|
371
|
+
# event # => Aws::LexRuntimeV2::Types::ResourceNotFoundException
|
372
|
+
# end
|
373
|
+
# output_stream.on_validation_exception_event do |event|
|
374
|
+
# event # => Aws::LexRuntimeV2::Types::ValidationException
|
375
|
+
# end
|
376
|
+
# output_stream.on_throttling_exception_event do |event|
|
377
|
+
# event # => Aws::LexRuntimeV2::Types::ThrottlingException
|
378
|
+
# end
|
379
|
+
# output_stream.on_internal_server_exception_event do |event|
|
380
|
+
# event # => Aws::LexRuntimeV2::Types::InternalServerException
|
381
|
+
# end
|
382
|
+
# output_stream.on_conflict_exception_event do |event|
|
383
|
+
# event # => Aws::LexRuntimeV2::Types::ConflictException
|
384
|
+
# end
|
385
|
+
# output_stream.on_dependency_failed_exception_event do |event|
|
386
|
+
# event # => Aws::LexRuntimeV2::Types::DependencyFailedException
|
387
|
+
# end
|
388
|
+
# output_stream.on_bad_gateway_exception_event do |event|
|
389
|
+
# event # => Aws::LexRuntimeV2::Types::BadGatewayException
|
390
|
+
# end
|
391
|
+
# output_stream.on_error_event do |event|
|
392
|
+
# # catch unmodeled error event in the stream
|
393
|
+
# raise event
|
394
|
+
# # => Aws::Errors::EventError
|
395
|
+
# # event.event_type => :error
|
396
|
+
# # event.error_code => String
|
397
|
+
# # event.error_message => String
|
398
|
+
# end
|
399
|
+
#
|
400
|
+
# async_resp = client.start_conversation ( #params input,
|
401
|
+
# input_event_stream_handler: input_stream
|
402
|
+
# output_event_stream_handler: output_stream
|
403
|
+
# )
|
404
|
+
#
|
405
|
+
# resp = async_resp.wait!
|
406
|
+
#
|
407
|
+
# Besides above usage patterns for process events when they arrive immediately, you can also
|
408
|
+
# iterate through events after response complete.
|
409
|
+
#
|
410
|
+
# Events are available at resp.response_event_stream # => Enumerator
|
411
|
+
#
|
412
|
+
# @example Request syntax with placeholder values
|
413
|
+
#
|
414
|
+
# async_resp = async_client.start_conversation({
|
415
|
+
# bot_id: "BotIdentifier", # required
|
416
|
+
# bot_alias_id: "BotAliasIdentifier", # required
|
417
|
+
# locale_id: "LocaleId", # required
|
418
|
+
# session_id: "SessionId", # required
|
419
|
+
# conversation_mode: "AUDIO", # accepts AUDIO, TEXT
|
420
|
+
# input_event_stream_hander: EventStreams::StartConversationRequestEventStream.new,
|
421
|
+
# })
|
422
|
+
# # => Seahorse::Client::AsyncResponse
|
423
|
+
# async_resp.wait
|
424
|
+
# # => Seahorse::Client::Response
|
425
|
+
# # Or use async_resp.join!
|
426
|
+
#
|
427
|
+
# @example Response structure
|
428
|
+
#
|
429
|
+
# All events are available at resp.response_event_stream:
|
430
|
+
# resp.response_event_stream #=> Enumerator
|
431
|
+
# resp.response_event_stream.event_types #=> [:playback_interruption_event, :transcript_event, :intent_result_event, :text_response_event, :audio_response_event, :heartbeat_event, :access_denied_exception, :resource_not_found_exception, :validation_exception, :throttling_exception, :internal_server_exception, :conflict_exception, :dependency_failed_exception, :bad_gateway_exception]
|
432
|
+
#
|
433
|
+
# For :playback_interruption_event event available at #on_playback_interruption_event_event callback and response eventstream enumerator:
|
434
|
+
# event.event_reason #=> String, one of "DTMF_START_DETECTED", "TEXT_DETECTED", "VOICE_START_DETECTED"
|
435
|
+
# event.caused_by_event_id #=> String
|
436
|
+
# event.event_id #=> String
|
437
|
+
#
|
438
|
+
# For :transcript_event event available at #on_transcript_event_event callback and response eventstream enumerator:
|
439
|
+
# event.transcript #=> String
|
440
|
+
# event.event_id #=> String
|
441
|
+
#
|
442
|
+
# For :intent_result_event event available at #on_intent_result_event_event callback and response eventstream enumerator:
|
443
|
+
# event.input_mode #=> String, one of "Text", "Speech", "DTMF"
|
444
|
+
# event.interpretations #=> Array
|
445
|
+
# event.interpretations[0].nlu_confidence.score #=> Float
|
446
|
+
# event.interpretations[0].sentiment_response.sentiment #=> String, one of "MIXED", "NEGATIVE", "NEUTRAL", "POSITIVE"
|
447
|
+
# event.interpretations[0].sentiment_response.sentiment_score.positive #=> Float
|
448
|
+
# event.interpretations[0].sentiment_response.sentiment_score.negative #=> Float
|
449
|
+
# event.interpretations[0].sentiment_response.sentiment_score.neutral #=> Float
|
450
|
+
# event.interpretations[0].sentiment_response.sentiment_score.mixed #=> Float
|
451
|
+
# event.interpretations[0].intent.name #=> String
|
452
|
+
# event.interpretations[0].intent.slots #=> Hash
|
453
|
+
# event.interpretations[0].intent.slots["NonEmptyString"].value.original_value #=> String
|
454
|
+
# event.interpretations[0].intent.slots["NonEmptyString"].value.interpreted_value #=> String
|
455
|
+
# event.interpretations[0].intent.slots["NonEmptyString"].value.resolved_values #=> Array
|
456
|
+
# event.interpretations[0].intent.slots["NonEmptyString"].value.resolved_values[0] #=> String
|
457
|
+
# event.interpretations[0].intent.state #=> String, one of "Failed", "Fulfilled", "InProgress", "ReadyForFulfillment", "Waiting"
|
458
|
+
# event.interpretations[0].intent.confirmation_state #=> String, one of "Confirmed", "Denied", "None"
|
459
|
+
# event.session_state.dialog_action.type #=> String, one of "Close", "ConfirmIntent", "Delegate", "ElicitIntent", "ElicitSlot"
|
460
|
+
# event.session_state.dialog_action.slot_to_elicit #=> String
|
461
|
+
# event.session_state.intent.name #=> String
|
462
|
+
# event.session_state.intent.slots #=> Hash
|
463
|
+
# event.session_state.intent.slots["NonEmptyString"].value.original_value #=> String
|
464
|
+
# event.session_state.intent.slots["NonEmptyString"].value.interpreted_value #=> String
|
465
|
+
# event.session_state.intent.slots["NonEmptyString"].value.resolved_values #=> Array
|
466
|
+
# event.session_state.intent.slots["NonEmptyString"].value.resolved_values[0] #=> String
|
467
|
+
# event.session_state.intent.state #=> String, one of "Failed", "Fulfilled", "InProgress", "ReadyForFulfillment", "Waiting"
|
468
|
+
# event.session_state.intent.confirmation_state #=> String, one of "Confirmed", "Denied", "None"
|
469
|
+
# event.session_state.active_contexts #=> Array
|
470
|
+
# event.session_state.active_contexts[0].name #=> String
|
471
|
+
# event.session_state.active_contexts[0].time_to_live.time_to_live_in_seconds #=> Integer
|
472
|
+
# event.session_state.active_contexts[0].time_to_live.turns_to_live #=> Integer
|
473
|
+
# event.session_state.active_contexts[0].context_attributes #=> Hash
|
474
|
+
# event.session_state.active_contexts[0].context_attributes["ParameterName"] #=> String
|
475
|
+
# event.session_state.session_attributes #=> Hash
|
476
|
+
# event.session_state.session_attributes["NonEmptyString"] #=> String
|
477
|
+
# event.session_state.originating_request_id #=> String
|
478
|
+
# event.request_attributes #=> Hash
|
479
|
+
# event.request_attributes["NonEmptyString"] #=> String
|
480
|
+
# event.session_id #=> String
|
481
|
+
# event.event_id #=> String
|
482
|
+
#
|
483
|
+
# For :text_response_event event available at #on_text_response_event_event callback and response eventstream enumerator:
|
484
|
+
# event.messages #=> Array
|
485
|
+
# event.messages[0].content #=> String
|
486
|
+
# event.messages[0].content_type #=> String, one of "CustomPayload", "ImageResponseCard", "PlainText", "SSML"
|
487
|
+
# event.messages[0].image_response_card.title #=> String
|
488
|
+
# event.messages[0].image_response_card.subtitle #=> String
|
489
|
+
# event.messages[0].image_response_card.image_url #=> String
|
490
|
+
# event.messages[0].image_response_card.buttons #=> Array
|
491
|
+
# event.messages[0].image_response_card.buttons[0].text #=> String
|
492
|
+
# event.messages[0].image_response_card.buttons[0].value #=> String
|
493
|
+
# event.event_id #=> String
|
494
|
+
#
|
495
|
+
# For :audio_response_event event available at #on_audio_response_event_event callback and response eventstream enumerator:
|
496
|
+
# event.audio_chunk #=> String
|
497
|
+
# event.content_type #=> String
|
498
|
+
# event.event_id #=> String
|
499
|
+
#
|
500
|
+
# For :heartbeat_event event available at #on_heartbeat_event_event callback and response eventstream enumerator:
|
501
|
+
# event.event_id #=> String
|
502
|
+
#
|
503
|
+
# For :access_denied_exception event available at #on_access_denied_exception_event callback and response eventstream enumerator:
|
504
|
+
# event.message #=> String
|
505
|
+
#
|
506
|
+
# For :resource_not_found_exception event available at #on_resource_not_found_exception_event callback and response eventstream enumerator:
|
507
|
+
# event.message #=> String
|
508
|
+
#
|
509
|
+
# For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
|
510
|
+
# event.message #=> String
|
511
|
+
#
|
512
|
+
# For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
|
513
|
+
# event.message #=> String
|
514
|
+
#
|
515
|
+
# For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
|
516
|
+
# event.message #=> String
|
517
|
+
#
|
518
|
+
# For :conflict_exception event available at #on_conflict_exception_event callback and response eventstream enumerator:
|
519
|
+
# event.message #=> String
|
520
|
+
#
|
521
|
+
# For :dependency_failed_exception event available at #on_dependency_failed_exception_event callback and response eventstream enumerator:
|
522
|
+
# event.message #=> String
|
523
|
+
#
|
524
|
+
# For :bad_gateway_exception event available at #on_bad_gateway_exception_event callback and response eventstream enumerator:
|
525
|
+
# event.message #=> String
|
526
|
+
#
|
527
|
+
# @see http://docs.aws.amazon.com/goto/WebAPI/runtime.lex.v2-2020-08-07/StartConversation AWS API Documentation
|
528
|
+
#
|
529
|
+
# @overload start_conversation(params = {})
|
530
|
+
# @param [Hash] params ({})
|
531
|
+
def start_conversation(params = {}, options = {}, &block)
|
532
|
+
params = params.dup
|
533
|
+
input_event_stream_handler = _event_stream_handler(
|
534
|
+
:input,
|
535
|
+
params.delete(:input_event_stream_handler),
|
536
|
+
EventStreams::StartConversationRequestEventStream
|
537
|
+
)
|
538
|
+
output_event_stream_handler = _event_stream_handler(
|
539
|
+
:output,
|
540
|
+
params.delete(:output_event_stream_handler) || params.delete(:event_stream_handler),
|
541
|
+
EventStreams::StartConversationResponseEventStream
|
542
|
+
)
|
543
|
+
|
544
|
+
yield(output_event_stream_handler) if block_given?
|
545
|
+
|
546
|
+
req = build_request(:start_conversation, params)
|
547
|
+
|
548
|
+
req.context[:input_event_stream_handler] = input_event_stream_handler
|
549
|
+
req.handlers.add(Aws::Binary::EncodeHandler, priority: 95)
|
550
|
+
req.context[:output_event_stream_handler] = output_event_stream_handler
|
551
|
+
req.handlers.add(Aws::Binary::DecodeHandler, priority: 95)
|
552
|
+
|
553
|
+
req.send_request(options, &block)
|
554
|
+
end
|
555
|
+
|
556
|
+
# @!endgroup
|
557
|
+
|
558
|
+
# @param params ({})
|
559
|
+
# @api private
|
560
|
+
def build_request(operation_name, params = {})
|
561
|
+
handlers = @handlers.for(operation_name)
|
562
|
+
context = Seahorse::Client::RequestContext.new(
|
563
|
+
operation_name: operation_name,
|
564
|
+
operation: config.api.operation(operation_name),
|
565
|
+
client: self,
|
566
|
+
params: params,
|
567
|
+
http_response: Seahorse::Client::Http::AsyncResponse.new,
|
568
|
+
config: config)
|
569
|
+
context[:gem_name] = 'aws-sdk-lexruntimev2'
|
570
|
+
context[:gem_version] = '1.0.0'
|
571
|
+
Seahorse::Client::Request.new(handlers, context)
|
572
|
+
end
|
573
|
+
|
574
|
+
private
|
575
|
+
|
576
|
+
def _event_stream_handler(type, handler, event_stream_class)
|
577
|
+
case handler
|
578
|
+
when event_stream_class then handler
|
579
|
+
when Proc then event_stream_class.new.tap(&handler)
|
580
|
+
when nil then event_stream_class.new
|
581
|
+
else
|
582
|
+
msg = "expected #{type}_event_stream_handler to be a block or "\
|
583
|
+
"instance of Aws::LexRuntimeV2::#{event_stream_class}"\
|
584
|
+
", got `#{handler.inspect}` instead"
|
585
|
+
raise ArgumentError, msg
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
class << self
|
590
|
+
|
591
|
+
# @api private
|
592
|
+
attr_reader :identifier
|
593
|
+
|
594
|
+
# @api private
|
595
|
+
def errors_module
|
596
|
+
Errors
|
597
|
+
end
|
598
|
+
|
599
|
+
end
|
600
|
+
end
|
601
|
+
end
|