aws-sdk-core 3.100.0 → 3.191.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1815 -0
- data/LICENSE.txt +202 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +153 -0
- data/lib/aws-defaults/defaults_mode_config_resolver.rb +107 -0
- data/lib/aws-defaults.rb +3 -0
- data/lib/aws-sdk-core/arn.rb +28 -0
- data/lib/aws-sdk-core/arn_parser.rb +2 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +23 -7
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +16 -10
- data/lib/aws-sdk-core/async_client_stubs.rb +2 -0
- data/lib/aws-sdk-core/binary/decode_handler.rb +2 -0
- data/lib/aws-sdk-core/binary/encode_handler.rb +14 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +2 -0
- data/lib/aws-sdk-core/binary/event_parser.rb +2 -0
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +2 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +2 -0
- data/lib/aws-sdk-core/binary.rb +2 -0
- data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +2 -0
- data/lib/aws-sdk-core/client_side_monitoring/request_metrics.rb +2 -0
- data/lib/aws-sdk-core/client_stubs.rb +22 -13
- data/lib/aws-sdk-core/credential_provider.rb +5 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +31 -6
- data/lib/aws-sdk-core/credentials.rb +2 -0
- data/lib/aws-sdk-core/deprecations.rb +2 -0
- data/lib/aws-sdk-core/eager_loader.rb +2 -0
- data/lib/aws-sdk-core/ec2_metadata.rb +238 -0
- data/lib/aws-sdk-core/ecs_credentials.rb +188 -53
- data/lib/aws-sdk-core/endpoint_cache.rb +2 -0
- data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
- data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
- data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
- data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
- data/lib/aws-sdk-core/endpoints/function.rb +80 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +131 -0
- data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
- data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
- data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
- data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
- data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
- data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
- data/lib/aws-sdk-core/endpoints/url.rb +60 -0
- data/lib/aws-sdk-core/endpoints.rb +78 -0
- data/lib/aws-sdk-core/errors.rb +27 -5
- data/lib/aws-sdk-core/event_emitter.rb +2 -0
- data/lib/aws-sdk-core/ini_parser.rb +9 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +167 -38
- data/lib/aws-sdk-core/json/builder.rb +2 -0
- data/lib/aws-sdk-core/json/error_handler.rb +22 -1
- data/lib/aws-sdk-core/json/handler.rb +10 -1
- data/lib/aws-sdk-core/json/json_engine.rb +12 -8
- data/lib/aws-sdk-core/json/oj_engine.rb +35 -6
- data/lib/aws-sdk-core/json/parser.rb +36 -1
- data/lib/aws-sdk-core/json.rb +10 -26
- data/lib/aws-sdk-core/log/formatter.rb +15 -3
- data/lib/aws-sdk-core/log/handler.rb +2 -0
- data/lib/aws-sdk-core/log/param_filter.rb +37 -12
- data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
- data/lib/aws-sdk-core/pageable_response.rb +91 -32
- data/lib/aws-sdk-core/pager.rb +5 -0
- data/lib/aws-sdk-core/param_converter.rb +2 -0
- data/lib/aws-sdk-core/param_validator.rb +56 -6
- data/lib/aws-sdk-core/plugins/api_key.rb +5 -1
- data/lib/aws-sdk-core/plugins/apig_authorizer_token.rb +2 -0
- data/lib/aws-sdk-core/plugins/apig_credentials_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/apig_user_agent.rb +2 -0
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +342 -0
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +3 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +2 -0
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +52 -7
- data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
- data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +8 -2
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +8 -6
- data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/global_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/helpful_socket_errors.rb +2 -0
- data/lib/aws-sdk-core/plugins/http_checksum.rb +11 -1
- data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
- data/lib/aws-sdk-core/plugins/invocation_id.rb +2 -0
- data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +36 -6
- data/lib/aws-sdk-core/plugins/logging.rb +4 -0
- data/lib/aws-sdk-core/plugins/param_converter.rb +2 -0
- data/lib/aws-sdk-core/plugins/param_validator.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +19 -0
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/query.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +18 -1
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +2 -0
- data/lib/aws-sdk-core/plugins/recursion_detection.rb +38 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +146 -17
- data/lib/aws-sdk-core/plugins/request_compression.rb +217 -0
- data/lib/aws-sdk-core/plugins/response_paging.rb +3 -1
- data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +2 -0
- data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +2 -0
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +9 -4
- data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +2 -0
- data/lib/aws-sdk-core/plugins/retry_errors.rb +29 -8
- data/lib/aws-sdk-core/plugins/sign.rb +206 -0
- data/lib/aws-sdk-core/plugins/signature_v2.rb +3 -0
- data/lib/aws-sdk-core/plugins/signature_v4.rb +30 -31
- data/lib/aws-sdk-core/plugins/stub_responses.rb +10 -1
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +2 -0
- data/lib/aws-sdk-core/plugins/user_agent.rb +119 -14
- data/lib/aws-sdk-core/process_credentials.rb +14 -15
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
- data/lib/aws-sdk-core/query/handler.rb +2 -0
- data/lib/aws-sdk-core/query/param.rb +2 -0
- data/lib/aws-sdk-core/query/param_builder.rb +2 -0
- data/lib/aws-sdk-core/query/param_list.rb +2 -0
- data/lib/aws-sdk-core/query.rb +2 -0
- data/lib/aws-sdk-core/refreshing_credentials.rb +50 -17
- data/lib/aws-sdk-core/refreshing_token.rb +71 -0
- data/lib/aws-sdk-core/resources/collection.rb +2 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -1
- data/lib/aws-sdk-core/rest/request/body.rb +21 -1
- data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +2 -0
- data/lib/aws-sdk-core/rest/request/headers.rb +16 -6
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +45 -29
- data/lib/aws-sdk-core/rest/response/body.rb +2 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
- data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
- data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
- data/lib/aws-sdk-core/rest.rb +2 -0
- data/lib/aws-sdk-core/shared_config.rb +163 -8
- data/lib/aws-sdk-core/shared_credentials.rb +9 -1
- data/lib/aws-sdk-core/sso_credentials.rb +172 -0
- data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
- data/lib/aws-sdk-core/static_token_provider.rb +14 -0
- data/lib/aws-sdk-core/structure.rb +19 -6
- data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
- data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
- data/lib/aws-sdk-core/stubbing/stub_data.rb +13 -0
- data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
- data/lib/aws-sdk-core/token.rb +31 -0
- data/lib/aws-sdk-core/token_provider.rb +15 -0
- data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
- data/lib/aws-sdk-core/type_builder.rb +2 -0
- data/lib/aws-sdk-core/util.rb +2 -0
- data/lib/aws-sdk-core/waiters/errors.rb +2 -0
- data/lib/aws-sdk-core/waiters/poller.rb +6 -2
- data/lib/aws-sdk-core/waiters/waiter.rb +2 -0
- data/lib/aws-sdk-core/waiters.rb +2 -0
- data/lib/aws-sdk-core/xml/builder.rb +4 -2
- data/lib/aws-sdk-core/xml/default_list.rb +2 -0
- data/lib/aws-sdk-core/xml/default_map.rb +2 -0
- data/lib/aws-sdk-core/xml/doc_builder.rb +8 -1
- data/lib/aws-sdk-core/xml/error_handler.rb +9 -0
- data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/oga.rb +4 -0
- data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
- data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
- data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +7 -0
- data/lib/aws-sdk-core/xml.rb +2 -0
- data/lib/aws-sdk-core.rb +29 -3
- data/lib/aws-sdk-sso/client.rb +630 -0
- data/lib/aws-sdk-sso/client_api.rb +190 -0
- data/lib/aws-sdk-sso/customizations.rb +1 -0
- data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-sso/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-sso/endpoints.rb +72 -0
- data/lib/aws-sdk-sso/errors.rb +102 -0
- data/lib/aws-sdk-sso/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-sso/resource.rb +26 -0
- data/lib/aws-sdk-sso/types.rb +317 -0
- data/lib/aws-sdk-sso.rb +59 -0
- data/lib/aws-sdk-ssooidc/client.rb +935 -0
- data/lib/aws-sdk-ssooidc/client_api.rb +271 -0
- data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +57 -0
- data/lib/aws-sdk-ssooidc/endpoints.rb +72 -0
- data/lib/aws-sdk-ssooidc/errors.rb +321 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +78 -0
- data/lib/aws-sdk-ssooidc/resource.rb +26 -0
- data/lib/aws-sdk-ssooidc/types.rb +755 -0
- data/lib/aws-sdk-ssooidc.rb +59 -0
- data/lib/aws-sdk-sts/client.rb +655 -490
- data/lib/aws-sdk-sts/client_api.rb +21 -2
- data/lib/aws-sdk-sts/customizations.rb +2 -0
- data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
- data/lib/aws-sdk-sts/endpoint_provider.rb +112 -0
- data/lib/aws-sdk-sts/endpoints.rb +136 -0
- data/lib/aws-sdk-sts/errors.rb +3 -1
- data/lib/aws-sdk-sts/plugins/endpoints.rb +86 -0
- data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +7 -1
- data/lib/aws-sdk-sts/presigner.rb +16 -10
- data/lib/aws-sdk-sts/resource.rb +3 -1
- data/lib/aws-sdk-sts/types.rb +416 -316
- data/lib/aws-sdk-sts.rb +14 -3
- data/lib/seahorse/client/async_base.rb +2 -1
- data/lib/seahorse/client/async_response.rb +2 -0
- data/lib/seahorse/client/base.rb +3 -0
- data/lib/seahorse/client/block_io.rb +5 -2
- data/lib/seahorse/client/configuration.rb +7 -5
- data/lib/seahorse/client/events.rb +2 -0
- data/lib/seahorse/client/h2/connection.rb +29 -24
- data/lib/seahorse/client/h2/handler.rb +6 -5
- data/lib/seahorse/client/handler.rb +2 -0
- data/lib/seahorse/client/handler_builder.rb +2 -0
- data/lib/seahorse/client/handler_list.rb +2 -0
- data/lib/seahorse/client/handler_list_entry.rb +2 -0
- data/lib/seahorse/client/http/async_response.rb +2 -0
- data/lib/seahorse/client/http/headers.rb +2 -0
- data/lib/seahorse/client/http/request.rb +2 -0
- data/lib/seahorse/client/http/response.rb +3 -1
- data/lib/seahorse/client/logging/formatter.rb +2 -0
- data/lib/seahorse/client/logging/handler.rb +2 -0
- data/lib/seahorse/client/managed_file.rb +2 -0
- data/lib/seahorse/client/net_http/connection_pool.rb +12 -4
- data/lib/seahorse/client/net_http/handler.rb +19 -8
- data/lib/seahorse/client/net_http/patches.rb +14 -86
- data/lib/seahorse/client/networking_error.rb +2 -0
- data/lib/seahorse/client/plugin.rb +3 -0
- data/lib/seahorse/client/plugin_list.rb +2 -0
- data/lib/seahorse/client/plugins/content_length.rb +13 -5
- data/lib/seahorse/client/plugins/endpoint.rb +2 -0
- data/lib/seahorse/client/plugins/h2.rb +9 -4
- data/lib/seahorse/client/plugins/logging.rb +2 -0
- data/lib/seahorse/client/plugins/net_http.rb +39 -3
- data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
- data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
- data/lib/seahorse/client/plugins/request_callback.rb +141 -0
- data/lib/seahorse/client/plugins/response_target.rb +8 -8
- data/lib/seahorse/client/request.rb +2 -0
- data/lib/seahorse/client/request_context.rb +2 -0
- data/lib/seahorse/client/response.rb +8 -0
- data/lib/seahorse/model/api.rb +2 -0
- data/lib/seahorse/model/authorizer.rb +2 -0
- data/lib/seahorse/model/operation.rb +8 -0
- data/lib/seahorse/model/shapes.rb +27 -0
- data/lib/seahorse/util.rb +12 -1
- data/lib/seahorse/version.rb +2 -0
- data/lib/seahorse.rb +3 -0
- data/sig/aws-sdk-core/client_stubs.rbs +10 -0
- data/sig/aws-sdk-core/errors.rbs +22 -0
- data/sig/aws-sdk-core/resources/collection.rbs +21 -0
- data/sig/aws-sdk-core/structure.rbs +4 -0
- data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -0
- data/sig/seahorse/client/base.rbs +25 -0
- data/sig/seahorse/client/handler_builder.rbs +16 -0
- data/sig/seahorse/client/response.rbs +61 -0
- metadata +93 -19
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'seahorse/client/h2/handler'
|
2
4
|
|
3
5
|
module Seahorse
|
@@ -26,11 +28,14 @@ Defaults to `true`, raises errors if exist when #wait or #join! is called upon a
|
|
26
28
|
DOCS
|
27
29
|
|
28
30
|
# SSL Context
|
29
|
-
option(:ssl_ca_bundle, default: nil, doc_type: String, docstring: <<-DOCS)
|
31
|
+
option(:ssl_ca_bundle, default: nil, doc_type: String, docstring: <<-DOCS) do |cfg|
|
30
32
|
Full path to the SSL certificate authority bundle file that should be used when
|
31
33
|
verifying peer certificates. If you do not pass `:ssl_ca_directory` or `:ssl_ca_bundle`
|
32
34
|
the system default will be used if available.
|
33
35
|
DOCS
|
36
|
+
ENV['AWS_CA_BUNDLE'] ||
|
37
|
+
Aws.shared_config.ca_bundle(profile: cfg.profile) if cfg.respond_to?(:profile)
|
38
|
+
end
|
34
39
|
|
35
40
|
option(:ssl_ca_directory, default: nil, doc_type: String, docstring: <<-DOCS)
|
36
41
|
Full path of the directory that contains the unbundled SSL certificate authority
|
@@ -49,9 +54,9 @@ When `true`, HTTP2 debug output will be sent to the `:logger`.
|
|
49
54
|
DOCS
|
50
55
|
|
51
56
|
option(:enable_alpn, default: false, doc_type: 'Boolean', docstring: <<-DOCS)
|
52
|
-
|
53
|
-
|
54
|
-
|
57
|
+
Set to `true` to enable ALPN in HTTP2 over TLS. Requires Openssl version >= 1.0.2.
|
58
|
+
Defaults to false. Note: not all service HTTP2 operations supports ALPN on server
|
59
|
+
side, please refer to service documentation.
|
55
60
|
DOCS
|
56
61
|
|
57
62
|
option(:logger)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'seahorse/client/net_http/handler'
|
2
4
|
|
3
5
|
module Seahorse
|
@@ -7,9 +9,13 @@ module Seahorse
|
|
7
9
|
|
8
10
|
option(:http_proxy, default: nil, doc_type: String, docstring: '')
|
9
11
|
|
10
|
-
option(:http_open_timeout, default: 15, doc_type: Integer, docstring: '')
|
12
|
+
option(:http_open_timeout, default: 15, doc_type: Integer, docstring: '') do |cfg|
|
13
|
+
resolve_http_open_timeout(cfg)
|
14
|
+
end
|
11
15
|
|
12
|
-
option(:http_read_timeout, default: 60, doc_type: Integer, docstring: '')
|
16
|
+
option(:http_read_timeout, default: 60, doc_type: Integer, docstring: '') do |cfg|
|
17
|
+
resolve_http_read_timeout(cfg)
|
18
|
+
end
|
13
19
|
|
14
20
|
option(:http_idle_timeout, default: 5, doc_type: Integer, docstring: '')
|
15
21
|
|
@@ -19,16 +25,46 @@ module Seahorse
|
|
19
25
|
|
20
26
|
option(:ssl_verify_peer, default: true, doc_type: 'Boolean', docstring: '')
|
21
27
|
|
22
|
-
option(:ssl_ca_bundle,
|
28
|
+
option(:ssl_ca_bundle, doc_type: String, docstring: '') do |cfg|
|
29
|
+
ENV['AWS_CA_BUNDLE'] ||
|
30
|
+
Aws.shared_config.ca_bundle(profile: cfg.profile) if cfg.respond_to?(:profile)
|
31
|
+
end
|
23
32
|
|
24
33
|
option(:ssl_ca_directory, default: nil, doc_type: String, docstring: '')
|
25
34
|
|
26
35
|
option(:ssl_ca_store, default: nil, doc_type: String, docstring: '')
|
27
36
|
|
37
|
+
option(:ssl_timeout, default: nil, doc_type: Float, docstring: '') do |cfg|
|
38
|
+
resolve_ssl_timeout(cfg)
|
39
|
+
end
|
40
|
+
|
28
41
|
option(:logger) # for backwards compat
|
29
42
|
|
30
43
|
handler(Client::NetHttp::Handler, step: :send)
|
31
44
|
|
45
|
+
def self.resolve_http_open_timeout(cfg)
|
46
|
+
default_mode_value =
|
47
|
+
if cfg.respond_to?(:defaults_mode_config_resolver)
|
48
|
+
cfg.defaults_mode_config_resolver.resolve(:http_open_timeout)
|
49
|
+
end
|
50
|
+
default_mode_value || 15
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.resolve_http_read_timeout(cfg)
|
54
|
+
default_mode_value =
|
55
|
+
if cfg.respond_to?(:defaults_mode_config_resolver)
|
56
|
+
cfg.defaults_mode_config_resolver.resolve(:http_read_timeout)
|
57
|
+
end
|
58
|
+
default_mode_value || 60
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.resolve_ssl_timeout(cfg)
|
62
|
+
default_mode_value =
|
63
|
+
if cfg.respond_to?(:defaults_mode_config_resolver)
|
64
|
+
cfg.defaults_mode_config_resolver.resolve(:ssl_timeout)
|
65
|
+
end
|
66
|
+
default_mode_value || nil
|
67
|
+
end
|
32
68
|
end
|
33
69
|
end
|
34
70
|
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
module Seahorse
|
7
|
+
module Client
|
8
|
+
module Plugins
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
class ReadCallbackIO
|
12
|
+
extend Forwardable
|
13
|
+
def_delegators :@io, :size
|
14
|
+
|
15
|
+
def initialize(io, on_read = nil)
|
16
|
+
@io = io
|
17
|
+
@on_read = on_read if on_read.is_a? Proc
|
18
|
+
@bytes_read = 0
|
19
|
+
|
20
|
+
# Some IO objects support readpartial - IO.copy_stream used by the
|
21
|
+
# request will call readpartial if available, so define a wrapper
|
22
|
+
# for it if the underlying IO supports it.
|
23
|
+
if @io.respond_to?(:readpartial)
|
24
|
+
def self.readpartial(*args)
|
25
|
+
@io.readpartial(*args).tap do |chunk|
|
26
|
+
handle_chunk(chunk)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_reader :io
|
33
|
+
|
34
|
+
def read(*args)
|
35
|
+
@io.read(*args).tap do |chunk|
|
36
|
+
handle_chunk(chunk)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def handle_chunk(chunk)
|
43
|
+
@bytes_read += chunk.bytesize if chunk && chunk.respond_to?(:bytesize)
|
44
|
+
total_size = @io.respond_to?(:size) ? @io.size : nil
|
45
|
+
@on_read.call(chunk, @bytes_read, total_size) if @on_read
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# @api private
|
50
|
+
class RequestCallback < Plugin
|
51
|
+
|
52
|
+
option(
|
53
|
+
:on_chunk_sent,
|
54
|
+
default: nil,
|
55
|
+
doc_type: 'Proc',
|
56
|
+
docstring: <<-DOCS)
|
57
|
+
When a Proc object is provided, it will be used as callback when each chunk
|
58
|
+
of the request body is sent. It provides three arguments: the chunk,
|
59
|
+
the number of bytes read from the body, and the total number of
|
60
|
+
bytes in the body.
|
61
|
+
DOCS
|
62
|
+
|
63
|
+
option(:on_chunk_received,
|
64
|
+
default: nil,
|
65
|
+
doc_type: 'Proc',
|
66
|
+
docstring: <<-DOCS)
|
67
|
+
When a Proc object is provided, it will be used as callback when each chunk
|
68
|
+
of the response body is received. It provides three arguments: the chunk,
|
69
|
+
the number of bytes received, and the total number of
|
70
|
+
bytes in the response (or nil if the server did not send a `content-length`).
|
71
|
+
DOCS
|
72
|
+
|
73
|
+
# @api private
|
74
|
+
class OptionHandler < Client::Handler
|
75
|
+
def call(context)
|
76
|
+
if context.params.is_a?(Hash) && context.params[:on_chunk_sent]
|
77
|
+
on_chunk_sent = context.params.delete(:on_chunk_sent)
|
78
|
+
end
|
79
|
+
on_chunk_sent = context.config.on_chunk_sent if on_chunk_sent.nil?
|
80
|
+
context[:on_chunk_sent] = on_chunk_sent if on_chunk_sent
|
81
|
+
|
82
|
+
if context.params.is_a?(Hash) && context.params[:on_chunk_received]
|
83
|
+
on_chunk_received = context.params.delete(:on_chunk_received)
|
84
|
+
end
|
85
|
+
on_chunk_received = context.config.on_chunk_received if on_chunk_received.nil?
|
86
|
+
|
87
|
+
add_response_events(on_chunk_received, context) if on_chunk_received
|
88
|
+
|
89
|
+
@handler.call(context)
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_response_events(on_chunk_received, context)
|
93
|
+
shared_data = {bytes_received: 0}
|
94
|
+
|
95
|
+
context.http_response.on_headers do |_status, headers|
|
96
|
+
shared_data[:content_length] = headers['content-length']&.to_i
|
97
|
+
end
|
98
|
+
|
99
|
+
context.http_response.on_data do |chunk|
|
100
|
+
shared_data[:bytes_received] += chunk.bytesize if chunk && chunk.respond_to?(:bytesize)
|
101
|
+
on_chunk_received.call(chunk, shared_data[:bytes_received], shared_data[:content_length])
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# @api private
|
107
|
+
class ReadCallbackHandler < Client::Handler
|
108
|
+
def call(context)
|
109
|
+
if (callback = context[:on_chunk_sent])
|
110
|
+
context.http_request.body = ReadCallbackIO.new(
|
111
|
+
context.http_request.body,
|
112
|
+
callback
|
113
|
+
)
|
114
|
+
@handler.call(context).tap do
|
115
|
+
unwrap_callback_body(context)
|
116
|
+
end
|
117
|
+
else
|
118
|
+
@handler.call(context)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def unwrap_callback_body(context)
|
123
|
+
body = context.http_request.body
|
124
|
+
if body.is_a? ReadCallbackIO
|
125
|
+
context.http_request.body = body.io
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# OptionHandler is needed to remove :on_chunk_sent
|
131
|
+
# from the params before build
|
132
|
+
handler(OptionHandler, step: :initialize)
|
133
|
+
|
134
|
+
# ReadCallbackHandlerneeds to go late in the call stack
|
135
|
+
# other plugins including Sigv4 and content_md5 read the request body
|
136
|
+
# and rewind it
|
137
|
+
handler(ReadCallbackHandler, step: :sign, priority: 0)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
|
3
5
|
module Seahorse
|
@@ -15,10 +17,9 @@ module Seahorse
|
|
15
17
|
|
16
18
|
def call(context)
|
17
19
|
if context.params.is_a?(Hash) && context.params[:response_target]
|
18
|
-
|
19
|
-
else
|
20
|
-
target = context[:response_target]
|
20
|
+
context[:response_target] = context.params.delete(:response_target)
|
21
21
|
end
|
22
|
+
target = context[:response_target]
|
22
23
|
add_event_listeners(context, target) if target
|
23
24
|
@handler.call(context)
|
24
25
|
end
|
@@ -26,20 +27,19 @@ module Seahorse
|
|
26
27
|
private
|
27
28
|
|
28
29
|
def add_event_listeners(context, target)
|
29
|
-
handler = self
|
30
30
|
context.http_response.on_headers(200..299) do
|
31
31
|
# In a fresh response body will be a StringIO
|
32
32
|
# However, when a request is retried we may have
|
33
33
|
# an existing ManagedFile or BlockIO and those
|
34
34
|
# should be reused.
|
35
35
|
if context.http_response.body.is_a? StringIO
|
36
|
-
context.http_response.body =
|
36
|
+
context.http_response.body = io(target, context.http_response.headers)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
context.http_response.on_success(200..299) do
|
41
41
|
body = context.http_response.body
|
42
|
-
if ManagedFile
|
42
|
+
if body.is_a?(ManagedFile) && body.open?
|
43
43
|
body.close
|
44
44
|
end
|
45
45
|
end
|
@@ -61,9 +61,9 @@ module Seahorse
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
def io(target)
|
64
|
+
def io(target, headers)
|
65
65
|
case target
|
66
|
-
when Proc then BlockIO.new(&target)
|
66
|
+
when Proc then BlockIO.new(headers, &target)
|
67
67
|
when String, Pathname then ManagedFile.new(target, 'w+b')
|
68
68
|
else target
|
69
69
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'delegate'
|
2
4
|
|
3
5
|
module Seahorse
|
@@ -28,6 +30,12 @@ module Seahorse
|
|
28
30
|
# @return [StandardError, nil]
|
29
31
|
attr_accessor :error
|
30
32
|
|
33
|
+
# @return [String, nil] returns the algorithm used to validate
|
34
|
+
# the response checksum. Returns nil if no verification was done.
|
35
|
+
def checksum_validated
|
36
|
+
context[:http_checksum][:validated] if context[:http_checksum]
|
37
|
+
end
|
38
|
+
|
31
39
|
# @overload on(status_code, &block)
|
32
40
|
# @param [Integer] status_code The block will be
|
33
41
|
# triggered only for responses with the given status code.
|
data/lib/seahorse/model/api.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Seahorse
|
2
4
|
module Model
|
3
5
|
class Operation
|
@@ -23,6 +25,12 @@ module Seahorse
|
|
23
25
|
# @return [Boolean]
|
24
26
|
attr_accessor :http_checksum_required
|
25
27
|
|
28
|
+
# @return [Hash]
|
29
|
+
attr_accessor :http_checksum
|
30
|
+
|
31
|
+
# @return [Hash]
|
32
|
+
attr_accessor :request_compression
|
33
|
+
|
26
34
|
# @return [Boolean]
|
27
35
|
attr_accessor :deprecated
|
28
36
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'set'
|
2
4
|
|
3
5
|
module Seahorse
|
@@ -59,6 +61,9 @@ module Seahorse
|
|
59
61
|
# @return [Boolean]
|
60
62
|
attr_accessor :eventheader_type
|
61
63
|
|
64
|
+
# @return [Boolean]
|
65
|
+
attr_accessor :document
|
66
|
+
|
62
67
|
# @return [String, nil]
|
63
68
|
def location
|
64
69
|
@location || (shape && shape[:location])
|
@@ -112,6 +117,9 @@ module Seahorse
|
|
112
117
|
# @return [String, nil]
|
113
118
|
attr_accessor :documentation
|
114
119
|
|
120
|
+
# @return [Boolean]
|
121
|
+
attr_accessor :union
|
122
|
+
|
115
123
|
# Gets metadata for the given `key`.
|
116
124
|
def [](key)
|
117
125
|
@metadata[key.to_s]
|
@@ -262,8 +270,27 @@ module Seahorse
|
|
262
270
|
|
263
271
|
end
|
264
272
|
|
273
|
+
class UnionShape < StructureShape
|
274
|
+
def initialize(options = {})
|
275
|
+
@member_subclasses = {}
|
276
|
+
super options.merge(union: true)
|
277
|
+
end
|
278
|
+
|
279
|
+
# @api private
|
280
|
+
def member_subclass(member)
|
281
|
+
@member_subclasses[member]
|
282
|
+
end
|
283
|
+
|
284
|
+
# @api private
|
285
|
+
def add_member_subclass(member, subclass)
|
286
|
+
@member_subclasses[member] = subclass
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
265
290
|
class TimestampShape < Shape; end
|
266
291
|
|
292
|
+
class DocumentShape < Shape; end
|
293
|
+
|
267
294
|
end
|
268
295
|
end
|
269
296
|
end
|
data/lib/seahorse/util.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'cgi'
|
2
4
|
|
3
5
|
module Seahorse
|
4
6
|
# @api private
|
5
7
|
module Util
|
6
8
|
class << self
|
7
|
-
|
8
9
|
def uri_escape(string)
|
9
10
|
CGI.escape(string.to_s.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~')
|
10
11
|
end
|
@@ -13,6 +14,16 @@ module Seahorse
|
|
13
14
|
path.gsub(/[^\/]+/) { |part| uri_escape(part) }
|
14
15
|
end
|
15
16
|
|
17
|
+
def escape_header_list_string(s)
|
18
|
+
s.include?('"') || s.include?(',') ? "\"#{s.gsub('"', '\"')}\"" : s
|
19
|
+
end
|
20
|
+
|
21
|
+
# Checks for a valid host label
|
22
|
+
# @see https://tools.ietf.org/html/rfc3986#section-3.2.2
|
23
|
+
# @see https://tools.ietf.org/html/rfc1123#page-13
|
24
|
+
def host_label?(str)
|
25
|
+
str =~ /^(?!-)[a-zA-Z0-9-]{1,63}(?<!-)$/
|
26
|
+
end
|
16
27
|
end
|
17
28
|
end
|
18
29
|
end
|
data/lib/seahorse/version.rb
CHANGED
data/lib/seahorse.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'seahorse/util'
|
2
4
|
|
3
5
|
# client
|
@@ -48,6 +50,7 @@ require_relative 'seahorse/client/plugins/net_http'
|
|
48
50
|
require_relative 'seahorse/client/plugins/h2'
|
49
51
|
require_relative 'seahorse/client/plugins/raise_response_errors'
|
50
52
|
require_relative 'seahorse/client/plugins/response_target'
|
53
|
+
require_relative 'seahorse/client/plugins/request_callback'
|
51
54
|
|
52
55
|
# model
|
53
56
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Aws
|
2
|
+
module ClientStubs
|
3
|
+
def stub_responses: (Symbol operation_name, *untyped stubs) -> void
|
4
|
+
|
5
|
+
def api_requests: (?exclude_presign: bool) -> Array[{ operation_name: Symbol, params: untyped, context: untyped }]
|
6
|
+
| (?Hash[:exclude_presign, bool] options) -> Array[{ operation_name: Symbol, params: untyped, context: untyped }]
|
7
|
+
|
8
|
+
def stub_data: (Symbol operation_name, ?untyped data) -> untyped
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Aws
|
2
|
+
module Errors
|
3
|
+
class NonSupportedRubyVersionError < RuntimeError
|
4
|
+
end
|
5
|
+
|
6
|
+
# The base class for all errors returned by an Amazon Web Service.
|
7
|
+
# All ~400 level client errors and ~500 level server errors are raised
|
8
|
+
# as service errors. This indicates it was an error returned from the
|
9
|
+
# service and not one generated by the client.
|
10
|
+
class ServiceError < RuntimeError
|
11
|
+
def initialize: (untyped context, String? message, ?untyped data) -> void
|
12
|
+
|
13
|
+
attr_reader code: String
|
14
|
+
|
15
|
+
attr_reader context: untyped
|
16
|
+
|
17
|
+
attr_reader data: untyped
|
18
|
+
|
19
|
+
attr_accessor self.code: String?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Aws
|
2
|
+
module Resources
|
3
|
+
class Collection[T]
|
4
|
+
include Enumerable[T]
|
5
|
+
|
6
|
+
def initialize: (Enumerable[Enumerable[T]] batches, ?size: Integer, ?limit: Integer) -> void
|
7
|
+
|
8
|
+
def each: () -> Enumerator[T, untyped]
|
9
|
+
| () { (T) -> untyped } -> Enumerator[T, untyped]
|
10
|
+
|
11
|
+
def size: () -> Integer?
|
12
|
+
|
13
|
+
alias length size
|
14
|
+
|
15
|
+
def first: () -> T?
|
16
|
+
| (Integer) -> self
|
17
|
+
|
18
|
+
def limit: (Integer) -> self
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Aws
|
2
|
+
module Waiters
|
3
|
+
module Errors
|
4
|
+
class WaiterFailed < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class FailureStateError < WaiterFailed
|
8
|
+
end
|
9
|
+
|
10
|
+
class TooManyAttemptsError < WaiterFailed
|
11
|
+
end
|
12
|
+
|
13
|
+
class UnexpectedError < WaiterFailed
|
14
|
+
end
|
15
|
+
|
16
|
+
class NoSuchWaiterError < ArgumentError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Seahorse
|
2
|
+
module Client
|
3
|
+
class Base
|
4
|
+
include HandlerBuilder
|
5
|
+
|
6
|
+
def self.new: (?untyped options) -> instance
|
7
|
+
def self.add_plugin: (untyped plugin) -> untyped
|
8
|
+
def self.remove_plugin: (untyped plugin) -> untyped
|
9
|
+
def self.clear_plugins: () -> untyped
|
10
|
+
def self.set_plugins: (Array[untyped] plugins) -> untyped
|
11
|
+
def self.plugins: () -> Array[untyped]
|
12
|
+
def self.api: () -> untyped
|
13
|
+
def self.set_api: (untyped api) -> untyped
|
14
|
+
def self.define: (?untyped options) -> untyped
|
15
|
+
|
16
|
+
attr_reader config: untyped
|
17
|
+
|
18
|
+
attr_reader handlers: untyped
|
19
|
+
|
20
|
+
def build_request: (_ToS operation_name, ?untyped params) -> untyped
|
21
|
+
|
22
|
+
def operation_names: () -> Array[Symbol]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Seahorse
|
2
|
+
module Client
|
3
|
+
# This module provides the ability to add handlers to a class or
|
4
|
+
# module. The including class or extending module must respond to
|
5
|
+
# `#handlers`, returning a {HandlerList}.
|
6
|
+
module HandlerBuilder
|
7
|
+
def handle_request: (*untyped) { (untyped context) -> void } -> untyped
|
8
|
+
|
9
|
+
def handle_response: (*untyped) { (untyped resp) -> void } -> untyped
|
10
|
+
|
11
|
+
def handle: (*untyped) ?{ (untyped context) -> void } -> untyped
|
12
|
+
|
13
|
+
alias handler handle
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|