aws-sdk-sagemakerruntimehttp2 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.
@@ -0,0 +1,662 @@
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/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ begin
11
+ require 'http/2'
12
+ rescue LoadError; end
13
+ require 'aws-sdk-core/plugins/credentials_configuration'
14
+ require 'aws-sdk-core/plugins/logging'
15
+ require 'aws-sdk-core/plugins/param_converter'
16
+ require 'aws-sdk-core/plugins/param_validator'
17
+ require 'aws-sdk-core/plugins/user_agent'
18
+ require 'aws-sdk-core/plugins/helpful_socket_errors'
19
+ require 'aws-sdk-core/plugins/retry_errors'
20
+ require 'aws-sdk-core/plugins/global_configuration'
21
+ require 'aws-sdk-core/plugins/regional_endpoint'
22
+ require 'aws-sdk-core/plugins/stub_responses'
23
+ require 'aws-sdk-core/plugins/idempotency_token'
24
+ require 'aws-sdk-core/plugins/invocation_id'
25
+ require 'aws-sdk-core/plugins/jsonvalue_converter'
26
+ require 'aws-sdk-core/plugins/http_checksum'
27
+ require 'aws-sdk-core/plugins/checksum_algorithm'
28
+ require 'aws-sdk-core/plugins/request_compression'
29
+ require 'aws-sdk-core/plugins/defaults_mode'
30
+ require 'aws-sdk-core/plugins/recursion_detection'
31
+ require 'aws-sdk-core/plugins/telemetry'
32
+ require 'aws-sdk-core/plugins/sign'
33
+ require 'aws-sdk-core/plugins/protocols/rest_json'
34
+ require 'aws-sdk-core/plugins/event_stream_configuration'
35
+
36
+ Aws::Plugins::GlobalConfiguration.add_identifier(:sagemakerruntimehttp2)
37
+
38
+ module Aws::SageMakerRuntimeHTTP2
39
+ # An API async client for SageMakerRuntimeHTTP2. To construct an async client, you need to configure a `:region` and `:credentials`.
40
+ #
41
+ # async_client = Aws::SageMakerRuntimeHTTP2::AsyncClient.new(
42
+ # region: region_name,
43
+ # credentials: credentials,
44
+ # # ...
45
+ # )
46
+ #
47
+ # For details on configuring region and credentials see
48
+ # the [developer guide](/sdk-for-ruby/v3/developer-guide/setup-config.html).
49
+ #
50
+ # See {#initialize} for a full list of supported configuration options.
51
+ class AsyncClient < Seahorse::Client::AsyncBase
52
+
53
+ include Aws::AsyncClientStubs
54
+
55
+ @identifier = :sagemakerruntimehttp2
56
+
57
+ set_api(ClientApi::API)
58
+
59
+ add_plugin(Aws::Plugins::CredentialsConfiguration)
60
+ add_plugin(Aws::Plugins::Logging)
61
+ add_plugin(Aws::Plugins::ParamConverter)
62
+ add_plugin(Aws::Plugins::ParamValidator)
63
+ add_plugin(Aws::Plugins::UserAgent)
64
+ add_plugin(Aws::Plugins::HelpfulSocketErrors)
65
+ add_plugin(Aws::Plugins::RetryErrors)
66
+ add_plugin(Aws::Plugins::GlobalConfiguration)
67
+ add_plugin(Aws::Plugins::RegionalEndpoint)
68
+ add_plugin(Aws::Plugins::StubResponses)
69
+ add_plugin(Aws::Plugins::IdempotencyToken)
70
+ add_plugin(Aws::Plugins::InvocationId)
71
+ add_plugin(Aws::Plugins::JsonvalueConverter)
72
+ add_plugin(Aws::Plugins::HttpChecksum)
73
+ add_plugin(Aws::Plugins::ChecksumAlgorithm)
74
+ add_plugin(Aws::Plugins::RequestCompression)
75
+ add_plugin(Aws::Plugins::DefaultsMode)
76
+ add_plugin(Aws::Plugins::RecursionDetection)
77
+ add_plugin(Aws::Plugins::Telemetry)
78
+ add_plugin(Aws::Plugins::Sign)
79
+ add_plugin(Aws::Plugins::Protocols::RestJson)
80
+ add_plugin(Aws::Plugins::EventStreamConfiguration)
81
+ add_plugin(Aws::SageMakerRuntimeHTTP2::Plugins::Endpoints)
82
+
83
+ # @overload initialize(options)
84
+ # @param [Hash] options
85
+ #
86
+ # @option options [Array<Seahorse::Client::Plugin>] :plugins ([]])
87
+ # A list of plugins to apply to the client. Each plugin is either a
88
+ # class name or an instance of a plugin class.
89
+ #
90
+ # @option options [required, Aws::CredentialProvider] :credentials
91
+ # Your AWS credentials used for authentication. This can be any class that includes and implements
92
+ # `Aws::CredentialProvider`, or instance of any one of the following classes:
93
+ #
94
+ # * `Aws::Credentials` - Used for configuring static, non-refreshing
95
+ # credentials.
96
+ #
97
+ # * `Aws::SharedCredentials` - Used for loading static credentials from a
98
+ # shared file, such as `~/.aws/config`.
99
+ #
100
+ # * `Aws::AssumeRoleCredentials` - Used when you need to assume a role.
101
+ #
102
+ # * `Aws::AssumeRoleWebIdentityCredentials` - Used when you need to
103
+ # assume a role after providing credentials via the web.
104
+ #
105
+ # * `Aws::SSOCredentials` - Used for loading credentials from AWS SSO using an
106
+ # access token generated from `aws login`.
107
+ #
108
+ # * `Aws::ProcessCredentials` - Used for loading credentials from a
109
+ # process that outputs to stdout.
110
+ #
111
+ # * `Aws::InstanceProfileCredentials` - Used for loading credentials
112
+ # from an EC2 IMDS on an EC2 instance.
113
+ #
114
+ # * `Aws::ECSCredentials` - Used for loading credentials from
115
+ # instances running in ECS.
116
+ #
117
+ # * `Aws::CognitoIdentityCredentials` - Used for loading credentials
118
+ # from the Cognito Identity service.
119
+ #
120
+ # When `:credentials` are not configured directly, the following locations will be searched for credentials:
121
+ #
122
+ # * `Aws.config[:credentials]`
123
+ #
124
+ # * The `:access_key_id`, `:secret_access_key`, `:session_token`, and
125
+ # `:account_id` options.
126
+ #
127
+ # * `ENV['AWS_ACCESS_KEY_ID']`, `ENV['AWS_SECRET_ACCESS_KEY']`,
128
+ # `ENV['AWS_SESSION_TOKEN']`, and `ENV['AWS_ACCOUNT_ID']`.
129
+ #
130
+ # * `~/.aws/credentials`
131
+ #
132
+ # * `~/.aws/config`
133
+ #
134
+ # * EC2/ECS IMDS instance profile - When used by default, the timeouts are very aggressive.
135
+ # Construct and pass an instance of `Aws::InstanceProfileCredentials` or `Aws::ECSCredentials` to
136
+ # enable retries and extended timeouts. Instance profile credential fetching can be disabled by
137
+ # setting `ENV['AWS_EC2_METADATA_DISABLED']` to `true`.
138
+ #
139
+ # @option options [required, String] :region
140
+ # The AWS region to connect to. The configured `:region` is
141
+ # used to determine the service `:endpoint`. When not passed,
142
+ # a default `:region` is searched for in the following locations:
143
+ #
144
+ # * `Aws.config[:region]`
145
+ # * `ENV['AWS_REGION']`
146
+ # * `ENV['AMAZON_REGION']`
147
+ # * `ENV['AWS_DEFAULT_REGION']`
148
+ # * `~/.aws/credentials`
149
+ # * `~/.aws/config`
150
+ #
151
+ # @option options [String] :access_key_id
152
+ #
153
+ # @option options [String] :account_id
154
+ #
155
+ # @option options [Boolean] :adaptive_retry_wait_to_fill (true)
156
+ # Used only in `adaptive` retry mode. When true, the request will sleep
157
+ # until there is sufficent client side capacity to retry the request.
158
+ # When false, the request will raise a `RetryCapacityNotAvailableError` and will
159
+ # not retry instead of sleeping.
160
+ #
161
+ # @option options [Array<String>] :auth_scheme_preference
162
+ # A list of preferred authentication schemes to use when making a request. Supported values are:
163
+ # `sigv4`, `sigv4a`, `httpBearerAuth`, and `noAuth`. When set using `ENV['AWS_AUTH_SCHEME_PREFERENCE']` or in
164
+ # shared config as `auth_scheme_preference`, the value should be a comma-separated list.
165
+ #
166
+ # @option options [Boolean] :convert_params (true)
167
+ # When `true`, an attempt is made to coerce request parameters into
168
+ # the required types.
169
+ #
170
+ # @option options [Boolean] :correct_clock_skew (true)
171
+ # Used only in `standard` and adaptive retry modes. Specifies whether to apply
172
+ # a clock skew correction and retry requests with skewed client clocks.
173
+ #
174
+ # @option options [String] :defaults_mode ("legacy")
175
+ # See {Aws::DefaultsModeConfiguration} for a list of the
176
+ # accepted modes and the configuration defaults that are included.
177
+ #
178
+ # @option options [Boolean] :disable_request_compression (false)
179
+ # When set to 'true' the request body will not be compressed
180
+ # for supported operations.
181
+ #
182
+ # @option options [String, URI::HTTPS, URI::HTTP] :endpoint
183
+ # Normally you should not configure the `:endpoint` option
184
+ # directly. This is normally constructed from the `:region`
185
+ # option. Configuring `:endpoint` is normally reserved for
186
+ # connecting to test or custom endpoints. The endpoint should
187
+ # be a URI formatted like:
188
+ #
189
+ # 'http://example.com'
190
+ # 'https://example.com'
191
+ # 'http://example.com:123'
192
+ #
193
+ # @option options [Proc] :event_stream_handler
194
+ # 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.
195
+ #
196
+ # @option options [Boolean] :ignore_configured_endpoint_urls
197
+ # Setting to true disables use of endpoint URLs provided via environment
198
+ # variables and the shared configuration file.
199
+ #
200
+ # @option options [Proc] :input_event_stream_handler
201
+ # When an EventStream or Proc object is provided, it can be used for sending events for the event stream.
202
+ #
203
+ # @option options [Aws::Log::Formatter] :log_formatter (Aws::Log::Formatter.default)
204
+ # The log formatter.
205
+ #
206
+ # @option options [Symbol] :log_level (:info)
207
+ # The log level to send messages to the `:logger` at.
208
+ #
209
+ # @option options [Logger] :logger
210
+ # The Logger instance to send log messages to. If this option
211
+ # is not set, logging will be disabled.
212
+ #
213
+ # @option options [Integer] :max_attempts (3)
214
+ # An integer representing the maximum number attempts that will be made for
215
+ # a single request, including the initial attempt. For example,
216
+ # setting this value to 5 will result in a request being retried up to
217
+ # 4 times. Used in `standard` and `adaptive` retry modes.
218
+ #
219
+ # @option options [Proc] :output_event_stream_handler
220
+ # 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.
221
+ #
222
+ # @option options [String] :profile ("default")
223
+ # Used when loading credentials from the shared credentials file at `HOME/.aws/credentials`.
224
+ # When not specified, 'default' is used.
225
+ #
226
+ # @option options [String] :request_checksum_calculation ("when_supported")
227
+ # Determines when a checksum will be calculated for request payloads. Values are:
228
+ #
229
+ # * `when_supported` - (default) When set, a checksum will be
230
+ # calculated for all request payloads of operations modeled with the
231
+ # `httpChecksum` trait where `requestChecksumRequired` is `true` and/or a
232
+ # `requestAlgorithmMember` is modeled.
233
+ # * `when_required` - When set, a checksum will only be calculated for
234
+ # request payloads of operations modeled with the `httpChecksum` trait where
235
+ # `requestChecksumRequired` is `true` or where a `requestAlgorithmMember`
236
+ # is modeled and supplied.
237
+ #
238
+ # @option options [Integer] :request_min_compression_size_bytes (10240)
239
+ # The minimum size in bytes that triggers compression for request
240
+ # bodies. The value must be non-negative integer value between 0
241
+ # and 10485780 bytes inclusive.
242
+ #
243
+ # @option options [String] :response_checksum_validation ("when_supported")
244
+ # Determines when checksum validation will be performed on response payloads. Values are:
245
+ #
246
+ # * `when_supported` - (default) When set, checksum validation is performed on all
247
+ # response payloads of operations modeled with the `httpChecksum` trait where
248
+ # `responseAlgorithms` is modeled, except when no modeled checksum algorithms
249
+ # are supported.
250
+ # * `when_required` - When set, checksum validation is not performed on
251
+ # response payloads of operations unless the checksum algorithm is supported and
252
+ # the `requestValidationModeMember` member is set to `ENABLED`.
253
+ #
254
+ # @option options [Proc] :retry_backoff
255
+ # A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
256
+ # This option is only used in the `legacy` retry mode.
257
+ #
258
+ # @option options [Float] :retry_base_delay (0.3)
259
+ # The base delay in seconds used by the default backoff function. This option
260
+ # is only used in the `legacy` retry mode.
261
+ #
262
+ # @option options [Symbol] :retry_jitter (:none)
263
+ # A delay randomiser function used by the default backoff function.
264
+ # Some predefined functions can be referenced by name - :none, :equal, :full,
265
+ # otherwise a Proc that takes and returns a number. This option is only used
266
+ # in the `legacy` retry mode.
267
+ #
268
+ # @see https://www.awsarchitectureblog.com/2015/03/backoff.html
269
+ #
270
+ # @option options [Integer] :retry_limit (3)
271
+ # The maximum number of times to retry failed requests. Only
272
+ # ~ 500 level server errors and certain ~ 400 level client errors
273
+ # are retried. Generally, these are throttling errors, data
274
+ # checksum errors, networking errors, timeout errors, auth errors,
275
+ # endpoint discovery, and errors from expired credentials.
276
+ # This option is only used in the `legacy` retry mode.
277
+ #
278
+ # @option options [Integer] :retry_max_delay (0)
279
+ # The maximum number of seconds to delay between retries (0 for no limit)
280
+ # used by the default backoff function. This option is only used in the
281
+ # `legacy` retry mode.
282
+ #
283
+ # @option options [String] :retry_mode ("legacy")
284
+ # Specifies which retry algorithm to use. Values are:
285
+ #
286
+ # * `legacy` - The pre-existing retry behavior. This is default value if
287
+ # no retry mode is provided.
288
+ #
289
+ # * `standard` - A standardized set of retry rules across the AWS SDKs.
290
+ # This includes support for retry quotas, which limit the number of
291
+ # unsuccessful retries a client can make.
292
+ #
293
+ # * `adaptive` - An experimental retry mode that includes all the
294
+ # functionality of `standard` mode along with automatic client side
295
+ # throttling. This is a provisional mode that may change behavior
296
+ # in the future.
297
+ #
298
+ # @option options [String] :sdk_ua_app_id
299
+ # A unique and opaque application ID that is appended to the
300
+ # User-Agent header as app/sdk_ua_app_id. It should have a
301
+ # maximum length of 50. This variable is sourced from environment
302
+ # variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
303
+ #
304
+ # @option options [String] :secret_access_key
305
+ #
306
+ # @option options [String] :session_token
307
+ #
308
+ # @option options [Array] :sigv4a_signing_region_set
309
+ # A list of regions that should be signed with SigV4a signing. When
310
+ # not passed, a default `:sigv4a_signing_region_set` is searched for
311
+ # in the following locations:
312
+ #
313
+ # * `Aws.config[:sigv4a_signing_region_set]`
314
+ # * `ENV['AWS_SIGV4A_SIGNING_REGION_SET']`
315
+ # * `~/.aws/config`
316
+ #
317
+ # @option options [Boolean] :stub_responses (false)
318
+ # Causes the client to return stubbed responses. By default
319
+ # fake responses are generated and returned. You can specify
320
+ # the response data to return or errors to raise by calling
321
+ # {ClientStubs#stub_responses}. See {ClientStubs} for more information.
322
+ #
323
+ # ** Please note ** When response stubbing is enabled, no HTTP
324
+ # requests are made, and retries are disabled.
325
+ #
326
+ # @option options [Aws::Telemetry::TelemetryProviderBase] :telemetry_provider (Aws::Telemetry::NoOpTelemetryProvider)
327
+ # Allows you to provide a telemetry provider, which is used to
328
+ # emit telemetry data. By default, uses `NoOpTelemetryProvider` which
329
+ # will not record or emit any telemetry data. The SDK supports the
330
+ # following telemetry providers:
331
+ #
332
+ # * OpenTelemetry (OTel) - To use the OTel provider, install and require the
333
+ # `opentelemetry-sdk` gem and then, pass in an instance of a
334
+ # `Aws::Telemetry::OTelProvider` for telemetry provider.
335
+ #
336
+ # @option options [Aws::TokenProvider] :token_provider
337
+ # Your Bearer token used for authentication. This can be any class that includes and implements
338
+ # `Aws::TokenProvider`, or instance of any one of the following classes:
339
+ #
340
+ # * `Aws::StaticTokenProvider` - Used for configuring static, non-refreshing
341
+ # tokens.
342
+ #
343
+ # * `Aws::SSOTokenProvider` - Used for loading tokens from AWS SSO using an
344
+ # access token generated from `aws login`.
345
+ #
346
+ # When `:token_provider` is not configured directly, the `Aws::TokenProviderChain`
347
+ # will be used to search for tokens configured for your profile in shared configuration files.
348
+ #
349
+ # @option options [Boolean] :use_dualstack_endpoint
350
+ # When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
351
+ # will be used if available.
352
+ #
353
+ # @option options [Boolean] :use_fips_endpoint
354
+ # When set to `true`, fips compatible endpoints will be used if available.
355
+ # When a `fips` region is used, the region is normalized and this config
356
+ # is set to `true`.
357
+ #
358
+ # @option options [Boolean] :validate_params (true)
359
+ # When `true`, request parameters are validated before
360
+ # sending the request.
361
+ #
362
+ # @option options [Aws::SageMakerRuntimeHTTP2::EndpointProvider] :endpoint_provider
363
+ # The endpoint provider used to resolve endpoints. Any object that responds to
364
+ # `#resolve_endpoint(parameters)` where `parameters` is a Struct similar to
365
+ # `Aws::SageMakerRuntimeHTTP2::EndpointParameters`.
366
+ #
367
+ # @option options [Integer] :connection_read_timeout (60)
368
+ # Connection read timeout in seconds, defaults to 60 sec.
369
+ #
370
+ # @option options [Integer] :connection_timeout (60)
371
+ # Connection timeout in seconds, defaults to 60 sec.
372
+ #
373
+ # @option options [Boolean] :enable_alpn (true)
374
+ # Set to `false` to disable ALPN in HTTP2 over TLS. ALPN requires Openssl version >= 1.0.2.
375
+ # Note: RFC7540 requires HTTP2 to use ALPN over TLS but some
376
+ # services may not fully support ALPN and require setting this to `false`.
377
+ #
378
+ # @option options [Boolean] :http_wire_trace (false)
379
+ # When `true`, HTTP2 debug output will be sent to the `:logger`.
380
+ #
381
+ # @option options [Integer] :max_concurrent_streams (100)
382
+ # Maximum concurrent streams used in HTTP2 connection, defaults to 100. Note that server may send back
383
+ # :settings_max_concurrent_streams value which will take priority when initializing new streams.
384
+ #
385
+ # @option options [Boolean] :raise_response_errors (true)
386
+ # Defaults to `true`, raises errors if exist when #wait or #join! is called upon async response.
387
+ #
388
+ # @option options [Integer] :read_chunk_size (1024)
389
+ #
390
+ # @option options [String] :ssl_ca_bundle
391
+ # Full path to the SSL certificate authority bundle file that should be used when
392
+ # verifying peer certificates. If you do not pass `:ssl_ca_directory` or `:ssl_ca_bundle`
393
+ # the system default will be used if available.
394
+ #
395
+ # @option options [String] :ssl_ca_directory
396
+ # Full path of the directory that contains the unbundled SSL certificate authority
397
+ # files for verifying peer certificates. If you do not pass `:ssl_ca_bundle` or
398
+ # `:ssl_ca_directory` the system default will be used if available.
399
+ #
400
+ # @option options [String] :ssl_ca_store
401
+ #
402
+ # @option options [Boolean] :ssl_verify_peer (true)
403
+ # When `true`, SSL peer certificates are verified when establishing a connection.
404
+ #
405
+ def initialize(*args)
406
+ unless Kernel.const_defined?("HTTP2")
407
+ raise "Must include http/2 gem to use AsyncClient instances."
408
+ end
409
+ super
410
+ end
411
+
412
+ # @!group API Operations
413
+
414
+ # Invokes a model endpoint with bidirectional streaming capabilities.
415
+ # This operation establishes a persistent connection that allows you to
416
+ # send multiple requests and receive streaming responses from the model
417
+ # in real-time.
418
+ #
419
+ # Bidirectional streaming is useful for interactive applications such as
420
+ # chatbots, real-time translation, or any scenario where you need to
421
+ # maintain a conversation-like interaction with the model. The
422
+ # connection remains open, allowing you to send additional input and
423
+ # receive responses without establishing a new connection for each
424
+ # request.
425
+ #
426
+ # For an overview of Amazon SageMaker AI, see [How It Works][1].
427
+ #
428
+ # Amazon SageMaker AI strips all POST headers except those supported by
429
+ # the API. Amazon SageMaker AI might add additional headers. You should
430
+ # not rely on the behavior of headers outside those enumerated in the
431
+ # request syntax.
432
+ #
433
+ # Calls to `InvokeEndpointWithBidirectionalStream` are authenticated by
434
+ # using Amazon Web Services Signature Version 4. For information, see
435
+ # [Authenticating Requests (Amazon Web Services Signature Version 4)][2]
436
+ # in the *Amazon S3 API Reference*.
437
+ #
438
+ # The bidirectional stream maintains the connection until either the
439
+ # client closes it or the model indicates completion. Each request and
440
+ # response in the stream is sent as an event with optional headers for
441
+ # data type and completion state.
442
+ #
443
+ # <note markdown="1"> Endpoints are scoped to an individual account, and are not public. The
444
+ # URL does not contain the account ID, but Amazon SageMaker AI
445
+ # determines the account ID from the authentication token that is
446
+ # supplied by the caller.
447
+ #
448
+ # </note>
449
+ #
450
+ #
451
+ #
452
+ # [1]: https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works.html
453
+ # [2]: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
454
+ #
455
+ # @option params [required, String] :endpoint_name
456
+ # The name of the endpoint to invoke.
457
+ #
458
+ # @option params [String] :target_variant
459
+ # Target variant for the request.
460
+ #
461
+ # @option params [String] :model_invocation_path
462
+ # Model invocation path.
463
+ #
464
+ # @option params [String] :model_query_string
465
+ # Model query string.
466
+ #
467
+ # @return [Types::InvokeEndpointWithBidirectionalStreamOutput] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
468
+ #
469
+ # * {Types::InvokeEndpointWithBidirectionalStreamOutput#body #body} => Types::ResponseStreamEvent
470
+ # * {Types::InvokeEndpointWithBidirectionalStreamOutput#invoked_production_variant #invoked_production_variant} => String
471
+ #
472
+ # @example Bi-directional EventStream Operation Example
473
+ # # You can signal input events after the initial request is established. Events
474
+ # # will be sent to the stream immediately once the stream connection is
475
+ # # established successfully.
476
+ #
477
+ # # To signal events, you can call the #signal methods from an
478
+ # # Aws::SageMakerRuntimeHTTP2::EventStreams::RequestStreamEvent object.
479
+ # # You must signal events before calling #wait or #join! on the async response.
480
+ # input_stream = Aws::SageMakerRuntimeHTTP2::EventStreams::RequestStreamEvent.new
481
+ #
482
+ # async_resp = client.invoke_endpoint_with_bidirectional_stream(
483
+ # # params input
484
+ # input_event_stream_handler: input_stream
485
+ # ) do |out_stream|
486
+ # # register callbacks for events
487
+ # out_stream.on_payload_part_event do |event|
488
+ # event # => Aws::SageMakerRuntimeHTTP2::Types::PayloadPart
489
+ # end
490
+ # out_stream.on_model_stream_error_event do |event|
491
+ # event # => Aws::SageMakerRuntimeHTTP2::Types::ModelStreamError
492
+ # end
493
+ # out_stream.on_internal_stream_failure_event do |event|
494
+ # event # => Aws::SageMakerRuntimeHTTP2::Types::InternalStreamFailure
495
+ # end
496
+ # end
497
+ # # => Aws::Seahorse::Client::AsyncResponse
498
+ #
499
+ # # signal events
500
+ # input_stream.signal_payload_part_event(
501
+ # # ...
502
+ # )
503
+ #
504
+ # # make sure to signal :end_stream at the end
505
+ # input_stream.signal_end_stream
506
+ #
507
+ # # wait until stream is closed before finalizing the sync response
508
+ # resp = async_resp.wait
509
+ #
510
+ # # Or close the stream and finalize sync response immediately
511
+ # resp = async_resp.join!
512
+ #
513
+ # # You can also provide an Aws::SageMakerRuntimeHTTP2::EventStreams::ResponseStreamEvent object
514
+ # # to register callbacks before initializing the request instead of processing
515
+ # # from the request block.
516
+ # output_stream = Aws::SageMakerRuntimeHTTP2::EventStreams::ResponseStreamEvent.new
517
+ #
518
+ # # register callbacks for output events
519
+ # output_stream.on_payload_part_event do |event|
520
+ # event # => Aws::SageMakerRuntimeHTTP2::Types::PayloadPart
521
+ # end
522
+ # output_stream.on_model_stream_error_event do |event|
523
+ # event # => Aws::SageMakerRuntimeHTTP2::Types::ModelStreamError
524
+ # end
525
+ # output_stream.on_internal_stream_failure_event do |event|
526
+ # event # => Aws::SageMakerRuntimeHTTP2::Types::InternalStreamFailure
527
+ # end
528
+ # output_stream.on_error_event do |event|
529
+ # # catch unmodeled error event in the stream
530
+ # raise event
531
+ # # => Aws::Errors::EventError
532
+ # # event.event_type => :error
533
+ # # event.error_code => String
534
+ # # event.error_message => String
535
+ # end
536
+ #
537
+ # async_resp = client.invoke_endpoint_with_bidirectional_stream(
538
+ # # params input
539
+ # input_event_stream_handler: input_stream,
540
+ # output_event_stream_handler: output_stream
541
+ # )
542
+ # resp = async_resp.join!
543
+ #
544
+ # # You can also iterate through events after the response is complete.
545
+ # # Events are available at
546
+ # resp.body # => Enumerator
547
+ #
548
+ # @example Request syntax with placeholder values
549
+ #
550
+ # async_resp = async_client.invoke_endpoint_with_bidirectional_stream({
551
+ # endpoint_name: "InvokeEndpointWithBidirectionalStreamInputEndpointNameString", # required
552
+ # input_event_stream_hander: EventStreams::RequestStreamEvent.new,
553
+ # target_variant: "InvokeEndpointWithBidirectionalStreamInputTargetVariantString",
554
+ # model_invocation_path: "InvokeEndpointWithBidirectionalStreamInputModelInvocationPathString",
555
+ # model_query_string: "InvokeEndpointWithBidirectionalStreamInputModelQueryStringString",
556
+ # })
557
+ # # => Seahorse::Client::AsyncResponse
558
+ # async_resp.wait
559
+ # # => Seahorse::Client::Response
560
+ # # Or use async_resp.join!
561
+ #
562
+ # @example Response structure
563
+ #
564
+ # # All events are available at resp.body:
565
+ # resp.body #=> Enumerator
566
+ # resp.body.event_types #=> [:payload_part, :model_stream_error, :internal_stream_failure]
567
+ #
568
+ # # For :payload_part event available at #on_payload_part_event callback and response eventstream enumerator:
569
+ # event.bytes #=> String
570
+ # event.data_type #=> String
571
+ # event.completion_state #=> String
572
+ # event.p #=> String
573
+ #
574
+ # # For :model_stream_error event available at #on_model_stream_error_event callback and response eventstream enumerator:
575
+ # event.message #=> String
576
+ # event.error_code #=> String
577
+ #
578
+ # # For :internal_stream_failure event available at #on_internal_stream_failure_event callback and response eventstream enumerator:
579
+ # event.message #=> String
580
+ #
581
+ # resp.invoked_production_variant #=> String
582
+ #
583
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemaker-runtime-http2-2025-10-01/InvokeEndpointWithBidirectionalStream AWS API Documentation
584
+ #
585
+ # @overload invoke_endpoint_with_bidirectional_stream(params = {})
586
+ # @param [Hash] params ({})
587
+ def invoke_endpoint_with_bidirectional_stream(params = {}, options = {}, &block)
588
+ params = params.dup
589
+ input_event_stream_handler = _event_stream_handler(
590
+ :input,
591
+ params.delete(:input_event_stream_handler),
592
+ EventStreams::RequestStreamEvent
593
+ )
594
+ output_event_stream_handler = _event_stream_handler(
595
+ :output,
596
+ params.delete(:output_event_stream_handler) || params.delete(:event_stream_handler),
597
+ EventStreams::ResponseStreamEvent
598
+ )
599
+
600
+ yield(output_event_stream_handler) if block_given?
601
+
602
+ req = build_request(:invoke_endpoint_with_bidirectional_stream, params)
603
+
604
+ req.context[:input_event_stream_handler] = input_event_stream_handler
605
+ req.handlers.add(Aws::Binary::EncodeHandler, priority: 55)
606
+ req.context[:output_event_stream_handler] = output_event_stream_handler
607
+ req.handlers.add(Aws::Binary::DecodeHandler, priority: 55)
608
+
609
+ req.send_request(options, &block)
610
+ end
611
+
612
+ # @!endgroup
613
+
614
+ # @param params ({})
615
+ # @api private
616
+ def build_request(operation_name, params = {})
617
+ handlers = @handlers.for(operation_name)
618
+ tracer = config.telemetry_provider.tracer_provider.tracer(
619
+ Aws::Telemetry.module_to_tracer_name('Aws::SageMakerRuntimeHTTP2')
620
+ )
621
+ context = Seahorse::Client::RequestContext.new(
622
+ operation_name: operation_name,
623
+ operation: config.api.operation(operation_name),
624
+ client: self,
625
+ params: params,
626
+ http_response: Seahorse::Client::Http::AsyncResponse.new,
627
+ config: config,
628
+ tracer: tracer
629
+ )
630
+ context[:gem_name] = 'aws-sdk-sagemakerruntimehttp2'
631
+ context[:gem_version] = '1.0.0'
632
+ Seahorse::Client::Request.new(handlers, context)
633
+ end
634
+
635
+ private
636
+
637
+ def _event_stream_handler(type, handler, event_stream_class)
638
+ case handler
639
+ when event_stream_class then handler
640
+ when Proc then event_stream_class.new.tap(&handler)
641
+ when nil then event_stream_class.new
642
+ else
643
+ msg = "expected #{type}_event_stream_handler to be a block or "\
644
+ "instance of Aws::SageMakerRuntimeHTTP2::#{event_stream_class}"\
645
+ ", got `#{handler.inspect}` instead"
646
+ raise ArgumentError, msg
647
+ end
648
+ end
649
+
650
+ class << self
651
+
652
+ # @api private
653
+ attr_reader :identifier
654
+
655
+ # @api private
656
+ def errors_module
657
+ Errors
658
+ end
659
+
660
+ end
661
+ end
662
+ end