smithy-client 1.0.0.pre0 → 1.0.0.pre1
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 +4 -4
- data/CHANGELOG.md +2 -0
- data/VERSION +1 -1
- data/lib/smithy-client/anonymous_provider.rb +12 -0
- data/lib/smithy-client/auth_option.rb +23 -0
- data/lib/smithy-client/auth_scheme.rb +25 -0
- data/lib/smithy-client/auth_schemes/anonymous.rb +18 -0
- data/lib/smithy-client/auth_schemes/http_api_key.rb +18 -0
- data/lib/smithy-client/auth_schemes/http_basic.rb +18 -0
- data/lib/smithy-client/auth_schemes/http_bearer.rb +18 -0
- data/lib/smithy-client/auth_schemes/http_digest.rb +18 -0
- data/lib/smithy-client/base.rb +200 -0
- data/lib/smithy-client/block_io.rb +36 -0
- data/lib/smithy-client/configuration.rb +222 -0
- data/lib/smithy-client/default_params.rb +91 -0
- data/lib/smithy-client/dynamic_errors.rb +82 -0
- data/lib/smithy-client/endpoint_rules.rb +186 -0
- data/lib/smithy-client/handler.rb +29 -0
- data/lib/smithy-client/handler_builder.rb +33 -0
- data/lib/smithy-client/handler_context.rb +67 -0
- data/lib/smithy-client/handler_list.rb +197 -0
- data/lib/smithy-client/handler_list_entry.rb +102 -0
- data/lib/smithy-client/http/error_inspector.rb +87 -0
- data/lib/smithy-client/http/headers.rb +122 -0
- data/lib/smithy-client/http/request.rb +57 -0
- data/lib/smithy-client/http/response.rb +178 -0
- data/lib/smithy-client/http_api_key_provider.rb +18 -0
- data/lib/smithy-client/http_bearer_provider.rb +18 -0
- data/lib/smithy-client/http_login_provider.rb +19 -0
- data/lib/smithy-client/identities/anonymous.rb +10 -0
- data/lib/smithy-client/identities/http_api_key.rb +18 -0
- data/lib/smithy-client/identities/http_bearer.rb +18 -0
- data/lib/smithy-client/identities/http_login.rb +22 -0
- data/lib/smithy-client/identity.rb +15 -0
- data/lib/smithy-client/log_formatter.rb +215 -0
- data/lib/smithy-client/log_param_filter.rb +88 -0
- data/lib/smithy-client/log_param_formatter.rb +65 -0
- data/lib/smithy-client/managed_file.rb +14 -0
- data/lib/smithy-client/net_http/connection_pool.rb +297 -0
- data/lib/smithy-client/net_http/handler.rb +160 -0
- data/lib/smithy-client/net_http/patches.rb +28 -0
- data/lib/smithy-client/networking_error.rb +16 -0
- data/lib/smithy-client/pageable_response.rb +138 -0
- data/lib/smithy-client/param_converter.rb +243 -0
- data/lib/smithy-client/param_validator.rb +213 -0
- data/lib/smithy-client/plugin.rb +144 -0
- data/lib/smithy-client/plugin_list.rb +141 -0
- data/lib/smithy-client/plugins/anonymous_auth.rb +23 -0
- data/lib/smithy-client/plugins/checksum_required.rb +51 -0
- data/lib/smithy-client/plugins/content_length.rb +26 -0
- data/lib/smithy-client/plugins/default_params.rb +22 -0
- data/lib/smithy-client/plugins/host_prefix.rb +69 -0
- data/lib/smithy-client/plugins/http_api_key_auth.rb +37 -0
- data/lib/smithy-client/plugins/http_basic_auth.rb +47 -0
- data/lib/smithy-client/plugins/http_bearer_auth.rb +37 -0
- data/lib/smithy-client/plugins/http_digest_auth.rb +60 -0
- data/lib/smithy-client/plugins/idempotency_token.rb +34 -0
- data/lib/smithy-client/plugins/logging.rb +56 -0
- data/lib/smithy-client/plugins/net_http.rb +163 -0
- data/lib/smithy-client/plugins/pageable_response.rb +37 -0
- data/lib/smithy-client/plugins/param_converter.rb +32 -0
- data/lib/smithy-client/plugins/param_validator.rb +30 -0
- data/lib/smithy-client/plugins/protocol.rb +66 -0
- data/lib/smithy-client/plugins/raise_response_errors.rb +33 -0
- data/lib/smithy-client/plugins/request_compression.rb +200 -0
- data/lib/smithy-client/plugins/response_target.rb +71 -0
- data/lib/smithy-client/plugins/retry_errors.rb +125 -0
- data/lib/smithy-client/plugins/sign_requests.rb +24 -0
- data/lib/smithy-client/plugins/stub_responses.rb +102 -0
- data/lib/smithy-client/protocol_spec_matcher.rb +60 -0
- data/lib/smithy-client/refreshing_identity_provider.rb +65 -0
- data/lib/smithy-client/request.rb +76 -0
- data/lib/smithy-client/response.rb +48 -0
- data/lib/smithy-client/retry/adaptive.rb +66 -0
- data/lib/smithy-client/retry/client_rate_limiter.rb +142 -0
- data/lib/smithy-client/retry/quota.rb +58 -0
- data/lib/smithy-client/retry/standard.rb +52 -0
- data/lib/smithy-client/retry.rb +36 -0
- data/lib/smithy-client/rpc_v2_cbor/protocol.rb +38 -0
- data/lib/smithy-client/rpc_v2_cbor/request_builder.rb +76 -0
- data/lib/smithy-client/rpc_v2_cbor/response_parser.rb +86 -0
- data/lib/smithy-client/rpc_v2_cbor/response_stubber.rb +34 -0
- data/lib/smithy-client/service_error.rb +57 -0
- data/lib/smithy-client/signer.rb +16 -0
- data/lib/smithy-client/signers/anonymous.rb +13 -0
- data/lib/smithy-client/signers/http_api_key.rb +52 -0
- data/lib/smithy-client/signers/http_basic.rb +23 -0
- data/lib/smithy-client/signers/http_bearer.rb +19 -0
- data/lib/smithy-client/signers/http_digest.rb +21 -0
- data/lib/smithy-client/stubbing/data_applicator.rb +61 -0
- data/lib/smithy-client/stubbing/empty_stub.rb +69 -0
- data/lib/smithy-client/stubbing/endpoint_provider.rb +22 -0
- data/lib/smithy-client/stubbing/protocol.rb +29 -0
- data/lib/smithy-client/stubbing/stub_data.rb +25 -0
- data/lib/smithy-client/stubbing.rb +14 -0
- data/lib/smithy-client/stubs.rb +212 -0
- data/lib/smithy-client/util.rb +15 -0
- data/lib/smithy-client/waiters/poller.rb +93 -0
- data/lib/smithy-client/waiters/waiter.rb +113 -0
- data/lib/smithy-client.rb +66 -1
- metadata +163 -9
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../http_api_key_provider'
|
4
|
+
require_relative '../identities/http_api_key'
|
5
|
+
require_relative '../signers/http_api_key'
|
6
|
+
require_relative '../auth_schemes/http_api_key'
|
7
|
+
|
8
|
+
module Smithy
|
9
|
+
module Client
|
10
|
+
module Plugins
|
11
|
+
# @api private
|
12
|
+
class HttpApiKeyAuth < Plugin
|
13
|
+
option(
|
14
|
+
:http_api_key,
|
15
|
+
doc_type: String,
|
16
|
+
docstring: 'The API key to use for authentication.'
|
17
|
+
) do |config|
|
18
|
+
'stubbed-api-key' if config.stub_responses
|
19
|
+
end
|
20
|
+
|
21
|
+
option(
|
22
|
+
:http_api_key_provider,
|
23
|
+
doc_type: HttpApiKeyProvider,
|
24
|
+
docstring: <<~DOCS) do |config|
|
25
|
+
An API key identity provider. This can be an instance of a {Smithy::Client::HttpApiKeyProvider} or any
|
26
|
+
class that responds to #identity(properties) and returns a {Smithy::Client::Identities::HttpApiKey}.
|
27
|
+
DOCS
|
28
|
+
HttpApiKeyProvider.new(config.http_api_key) if config.http_api_key
|
29
|
+
end
|
30
|
+
|
31
|
+
option(:http_api_key_auth_scheme) do |_config|
|
32
|
+
Smithy::Client::AuthSchemes::HttpApiKey.new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../http_login_provider'
|
4
|
+
require_relative '../identities/http_login'
|
5
|
+
require_relative '../signers/http_basic'
|
6
|
+
require_relative '../auth_schemes/http_basic'
|
7
|
+
|
8
|
+
module Smithy
|
9
|
+
module Client
|
10
|
+
module Plugins
|
11
|
+
# @api private
|
12
|
+
class HttpBasicAuth < Plugin
|
13
|
+
option(
|
14
|
+
:http_login_username,
|
15
|
+
doc_type: String,
|
16
|
+
docstring: 'The username to use for authentication.'
|
17
|
+
) do |config|
|
18
|
+
'stubbed-username' if config.stub_responses
|
19
|
+
end
|
20
|
+
|
21
|
+
option(
|
22
|
+
:http_login_password,
|
23
|
+
doc_type: String,
|
24
|
+
docstring: 'The password to use for authentication.'
|
25
|
+
) do |config|
|
26
|
+
'stubbed-password' if config.stub_responses
|
27
|
+
end
|
28
|
+
|
29
|
+
option(
|
30
|
+
:http_login_provider,
|
31
|
+
doc_type: Smithy::Client::HttpLoginProvider,
|
32
|
+
docstring: <<~DOCS) do |config|
|
33
|
+
A login identity provider. This can be an instance of a {Smithy::Client::HttpLoginProvider} or any
|
34
|
+
class that responds to #identity(properties) and returns a {Smithy::Client::Identities::HttpLogin}.
|
35
|
+
DOCS
|
36
|
+
if config.http_login_username && config.http_login_password
|
37
|
+
Smithy::Client::HttpLoginProvider.new(config.http_login_username, config.http_login_password)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
option(:http_basic_auth_scheme) do |_config|
|
42
|
+
Smithy::Client::AuthSchemes::HttpBasic.new
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../http_bearer_provider'
|
4
|
+
require_relative '../identities/http_bearer'
|
5
|
+
require_relative '../signers/http_bearer'
|
6
|
+
require_relative '../auth_schemes/http_bearer'
|
7
|
+
|
8
|
+
module Smithy
|
9
|
+
module Client
|
10
|
+
module Plugins
|
11
|
+
# @api private
|
12
|
+
class HttpBearerAuth < Plugin
|
13
|
+
option(
|
14
|
+
:http_bearer_token,
|
15
|
+
doc_type: String,
|
16
|
+
docstring: 'The bearer token to use for authentication.'
|
17
|
+
) do |config|
|
18
|
+
'stubbed-bearer-token' if config.stub_responses
|
19
|
+
end
|
20
|
+
|
21
|
+
option(
|
22
|
+
:http_bearer_provider,
|
23
|
+
doc_type: Smithy::Client::HttpBearerProvider,
|
24
|
+
docstring: <<~DOCS) do |config|
|
25
|
+
A bearer token identity provider. This can be an instance of a {Smithy::Client::HttpBearerProvider} or any
|
26
|
+
class that responds to #identity(properties) and returns a {Smithy::Client::Identities::HttpBearer}.
|
27
|
+
DOCS
|
28
|
+
Smithy::Client::HttpBearerProvider.new(config.http_bearer_token) if config.http_bearer_token
|
29
|
+
end
|
30
|
+
|
31
|
+
option(:http_bearer_auth_scheme) do |_config|
|
32
|
+
Smithy::Client::AuthSchemes::HttpBearer.new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../http_login_provider'
|
4
|
+
require_relative '../identities/http_login'
|
5
|
+
require_relative '../signers/http_digest'
|
6
|
+
require_relative '../auth_schemes/http_digest'
|
7
|
+
|
8
|
+
module Smithy
|
9
|
+
module Client
|
10
|
+
module Plugins
|
11
|
+
# @api private
|
12
|
+
class HttpDigestAuth < Plugin
|
13
|
+
option(
|
14
|
+
:http_login_username,
|
15
|
+
doc_type: String,
|
16
|
+
docstring: 'The username to use for authentication.'
|
17
|
+
) do |config|
|
18
|
+
'stubbed-username' if config.stub_responses
|
19
|
+
end
|
20
|
+
|
21
|
+
option(
|
22
|
+
:http_login_password,
|
23
|
+
doc_type: String,
|
24
|
+
docstring: 'The password to use for authentication.'
|
25
|
+
) do |config|
|
26
|
+
'stubbed-password' if config.stub_responses
|
27
|
+
end
|
28
|
+
|
29
|
+
option(
|
30
|
+
:http_login_identity,
|
31
|
+
doc_type: Identities::HttpLogin,
|
32
|
+
docstring: 'The login identity to use for authentication.'
|
33
|
+
) do |config|
|
34
|
+
if config.http_login_username && config.http_login_password
|
35
|
+
Identities::HttpLogin.new(
|
36
|
+
username: config.http_login_username,
|
37
|
+
password: config.http_login_password
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
option(
|
43
|
+
:http_login_provider,
|
44
|
+
doc_type: Smithy::Client::HttpLoginProvider,
|
45
|
+
docstring: <<~DOCS) do |config|
|
46
|
+
A login identity provider. This can be an instance of a {Smithy::Client::HttpLoginProvider} or any
|
47
|
+
class that responds to #identity(properties) and returns a {Smithy::Client::Identities::HttpLogin}.
|
48
|
+
DOCS
|
49
|
+
if config.http_login_username && config.http_login_password
|
50
|
+
Smithy::Client::HttpLoginProvider.new(config.http_login_username, config.http_login_password)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
option(:http_digest_auth_scheme) do |_config|
|
55
|
+
Smithy::Client::AuthSchemes::HttpDigest.new
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
module Smithy
|
6
|
+
module Client
|
7
|
+
module Plugins
|
8
|
+
# @api private
|
9
|
+
class IdempotencyToken < Plugin
|
10
|
+
def add_handlers(handlers, _config)
|
11
|
+
handlers.add(Handler, step: :initialize)
|
12
|
+
end
|
13
|
+
|
14
|
+
# @api private
|
15
|
+
class Handler < Client::Handler
|
16
|
+
def call(context)
|
17
|
+
apply_idempotency_token(context.operation.input, context.params)
|
18
|
+
@handler.call(context)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def apply_idempotency_token(input, params)
|
24
|
+
input.shape.members.each do |member_name, member_ref|
|
25
|
+
next unless member_ref.traits.key?('smithy.api#idempotencyToken')
|
26
|
+
|
27
|
+
params[member_name] ||= SecureRandom.uuid
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
module Smithy
|
6
|
+
module Client
|
7
|
+
module Plugins
|
8
|
+
# @api private
|
9
|
+
class Logging < Plugin
|
10
|
+
option(
|
11
|
+
:logger,
|
12
|
+
default: nil,
|
13
|
+
doc_type: Logger,
|
14
|
+
docstring: 'The Logger instance to send log messages to. If this option is not set, logging is disabled.'
|
15
|
+
)
|
16
|
+
|
17
|
+
option(
|
18
|
+
:log_level,
|
19
|
+
default: :info,
|
20
|
+
doc_type: Symbol,
|
21
|
+
docstring: 'The log level to send messages to the logger at.'
|
22
|
+
)
|
23
|
+
|
24
|
+
option(
|
25
|
+
:log_formatter,
|
26
|
+
doc_type: 'Smithy::Client::LogFormatter',
|
27
|
+
doc_default: 'Aws::Log::Formatter.default',
|
28
|
+
docstring: 'The log formatter used by the logger.'
|
29
|
+
) do |config|
|
30
|
+
LogFormatter.default if config.logger
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_handlers(handlers, config)
|
34
|
+
handlers.add(Handler, step: :validate) if config.logger
|
35
|
+
end
|
36
|
+
|
37
|
+
# @api private
|
38
|
+
class Handler < Client::Handler
|
39
|
+
def call(context)
|
40
|
+
context[:logging_started_at] = Time.now
|
41
|
+
response = @handler.call(context)
|
42
|
+
context[:logging_completed_at] = Time.now
|
43
|
+
log(context.config, response)
|
44
|
+
response
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def log(config, response)
|
50
|
+
config.logger.send(config.log_level, config.log_formatter.format(response))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../net_http/handler'
|
4
|
+
|
5
|
+
module Smithy
|
6
|
+
module Client
|
7
|
+
module Plugins
|
8
|
+
# @api private
|
9
|
+
class NetHTTP < Plugin
|
10
|
+
## Connections
|
11
|
+
|
12
|
+
option(
|
13
|
+
:http_continue_timeout,
|
14
|
+
default: nil,
|
15
|
+
doc_type: Numeric,
|
16
|
+
docstring: <<~DOCS)
|
17
|
+
Sets the continue timeout value, which is the number of seconds to wait for an
|
18
|
+
expected 100 Continue response. If the HTTP object does not receive a response
|
19
|
+
in this many seconds it sends the request body. Defaults to `nil` which uses the
|
20
|
+
Net::HTTP default value.
|
21
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-continue_timeout Net::HTTP#continue_timeout}.
|
22
|
+
DOCS
|
23
|
+
|
24
|
+
option(
|
25
|
+
:http_keep_alive_timeout,
|
26
|
+
default: nil,
|
27
|
+
doc_type: Numeric,
|
28
|
+
docstring: <<~DOCS)
|
29
|
+
The number of seconds to keep the connection open after a request is sent. If a
|
30
|
+
new request is made during the given interval, the still-open connection is used;
|
31
|
+
otherwise the connection will have been closed and a new connection is opened.
|
32
|
+
Defaults to `nil` which uses the Net::HTTP default value.
|
33
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-keep_alive_timeout Net::HTTP#keep_alive_timeout}.
|
34
|
+
DOCS
|
35
|
+
|
36
|
+
option(
|
37
|
+
:http_open_timeout,
|
38
|
+
default: nil,
|
39
|
+
doc_type: Numeric,
|
40
|
+
docstring: <<~DOCS)
|
41
|
+
The number of seconds to wait for a connection to open. If the connection is not
|
42
|
+
made in the given interval, an exception is raised. Defaults to `nil` which uses
|
43
|
+
the Net::HTTP default value.
|
44
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-open_timeout Net::HTTP#open_timeout}.
|
45
|
+
DOCS
|
46
|
+
|
47
|
+
option(
|
48
|
+
:http_read_timeout,
|
49
|
+
default: nil,
|
50
|
+
doc_type: Numeric,
|
51
|
+
docstring: <<~DOCS)
|
52
|
+
The number of seconds to wait for one block to be read (via one read(2) call).
|
53
|
+
Defaults to `nil` which uses the Net::HTTP default value.
|
54
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-read_timeout Net::HTTP#read_timeout}.
|
55
|
+
DOCS
|
56
|
+
|
57
|
+
option(
|
58
|
+
:http_ssl_timeout,
|
59
|
+
default: nil,
|
60
|
+
doc_type: Numeric,
|
61
|
+
docstring: <<~DOCS)
|
62
|
+
Sets the SSL timeout seconds. Defaults to `nil` which uses the Net::HTTP default value.
|
63
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-ssl_timeout Net::HTTP#ssl_timeout}.
|
64
|
+
DOCS
|
65
|
+
|
66
|
+
option(
|
67
|
+
:http_write_timeout,
|
68
|
+
default: nil,
|
69
|
+
doc_type: Numeric,
|
70
|
+
docstring: <<~DOCS)
|
71
|
+
The number of seconds to wait for one block to be written (via one write(2) call).
|
72
|
+
Defaults to `nil` which uses the Net::HTTP default value.
|
73
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-write_timeout Net::HTTP#write_timeout}.
|
74
|
+
DOCS
|
75
|
+
|
76
|
+
## Security
|
77
|
+
|
78
|
+
option(
|
79
|
+
:http_ca_file,
|
80
|
+
default: nil,
|
81
|
+
doc_type: String,
|
82
|
+
docstring: <<~DOCS)
|
83
|
+
The path to a CA certification file in PEM format. Defaults to `nil` which uses
|
84
|
+
the Net::HTTP default value.
|
85
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-ca_file Net::HTTP#ca_file}.
|
86
|
+
DOCS
|
87
|
+
|
88
|
+
option(
|
89
|
+
:http_ca_path,
|
90
|
+
default: nil,
|
91
|
+
doc_type: String,
|
92
|
+
docstring: <<~DOCS)
|
93
|
+
The path of to CA directory containing certification files in PEM format. Defaults to
|
94
|
+
`nil` which uses the Net::HTTP default value.
|
95
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-ca_path Net::HTTP#ca_path}.
|
96
|
+
DOCS
|
97
|
+
|
98
|
+
option(
|
99
|
+
:http_cert,
|
100
|
+
default: nil,
|
101
|
+
doc_type: OpenSSL::X509::Certificate,
|
102
|
+
docstring: <<~DOCS)
|
103
|
+
Sets the OpenSSL::X509::Certificate object to be used for client certification. Defaults
|
104
|
+
to `nil` which uses the Net::HTTP default value.
|
105
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-cert Net::HTTP#cert}.
|
106
|
+
DOCS
|
107
|
+
|
108
|
+
option(
|
109
|
+
:http_cert_store,
|
110
|
+
default: nil,
|
111
|
+
doc_type: OpenSSL::X509::Store,
|
112
|
+
docstring: <<~DOCS)
|
113
|
+
Sets the OpenSSL::X509::Store to be used for verifying peer certificate. Defaults to
|
114
|
+
`nil` which uses the Net::HTTP default value.
|
115
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-cert_store Net::HTTP#cert_store}.
|
116
|
+
DOCS
|
117
|
+
|
118
|
+
option(
|
119
|
+
:http_key,
|
120
|
+
default: nil,
|
121
|
+
doc_type: 'OpenSSL::PKey::RSA, OpenSSL::PKey::DSA',
|
122
|
+
docstring: <<~DOCS)
|
123
|
+
Sets the OpenSSL::PKey object to be used for client private key. Defaults to `nil` which
|
124
|
+
uses the Net::HTTP default value.
|
125
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-key Net::HTTP#key}.
|
126
|
+
DOCS
|
127
|
+
|
128
|
+
option(
|
129
|
+
:http_verify_mode,
|
130
|
+
default: OpenSSL::SSL::VERIFY_PEER,
|
131
|
+
doc_type: Integer,
|
132
|
+
doc_default: 'OpenSSL::SSL::VERIFY_PEER',
|
133
|
+
docstring: <<~DOCS)
|
134
|
+
Sets the verify mode for SSL. Defaults to `OpenSSL::SSL::VERIFY_PEER`.
|
135
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#attribute-i-verify_mode Net::HTTP#verify_mode}.
|
136
|
+
DOCS
|
137
|
+
|
138
|
+
## Debugging
|
139
|
+
|
140
|
+
option(
|
141
|
+
:http_debug_output,
|
142
|
+
default: false,
|
143
|
+
doc_type: 'Boolean',
|
144
|
+
docstring: <<~DOCS)
|
145
|
+
When `true`, Net::HTTP debug output will be sent to the configured logger.
|
146
|
+
See {https://docs.ruby-lang.org/en/master/Net/HTTP.html#method-i-set_debug_output Net::HTTP#set_debug_output}.
|
147
|
+
DOCS
|
148
|
+
|
149
|
+
## Proxies
|
150
|
+
|
151
|
+
option(
|
152
|
+
:http_proxy,
|
153
|
+
default: nil,
|
154
|
+
doc_type: 'URI::HTTP, String',
|
155
|
+
docstring: <<~DOCS)
|
156
|
+
A proxy to send requests through. Formatted like 'http://proxy.com:123'.
|
157
|
+
DOCS
|
158
|
+
|
159
|
+
handler(Client::NetHTTP::Handler, step: :send)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Smithy
|
4
|
+
module Client
|
5
|
+
module Plugins
|
6
|
+
# @api private
|
7
|
+
class PageableResponse < Plugin
|
8
|
+
# @api private
|
9
|
+
class Handler < Client::Handler
|
10
|
+
def call(context)
|
11
|
+
response = @handler.call(context)
|
12
|
+
response.extend(Client::PageableResponse)
|
13
|
+
response.paginator = context.operation[:paginator] || NullPaginator.new
|
14
|
+
response
|
15
|
+
end
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
class NullPaginator
|
19
|
+
def next_tokens(_data)
|
20
|
+
{}
|
21
|
+
end
|
22
|
+
|
23
|
+
def prev_tokens(_params)
|
24
|
+
{}
|
25
|
+
end
|
26
|
+
|
27
|
+
def items(_data)
|
28
|
+
raise NotImplementedError, 'item iteration is not implemented for this operation'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
handler(Handler, step: :initialize, priority: 95)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Smithy
|
4
|
+
module Client
|
5
|
+
module Plugins
|
6
|
+
# @api private
|
7
|
+
class ParamConverter < Plugin
|
8
|
+
option(
|
9
|
+
:convert_params,
|
10
|
+
default: true,
|
11
|
+
doc_type: 'Boolean',
|
12
|
+
docstring: <<~DOCS)
|
13
|
+
When `true`, request parameters are coerced into the required types.
|
14
|
+
DOCS
|
15
|
+
|
16
|
+
def add_handlers(handlers, config)
|
17
|
+
handlers.add(Handler, step: :initialize) if config.convert_params
|
18
|
+
end
|
19
|
+
|
20
|
+
# @api private
|
21
|
+
class Handler < Client::Handler
|
22
|
+
def call(context)
|
23
|
+
converter = Client::ParamConverter.new(context.operation.input)
|
24
|
+
context.params = converter.convert(context.params)
|
25
|
+
context.http_response.on_done { converter.close_opened_files }
|
26
|
+
@handler.call(context)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Smithy
|
4
|
+
module Client
|
5
|
+
module Plugins
|
6
|
+
# @api private
|
7
|
+
class ParamValidator < Plugin
|
8
|
+
option(
|
9
|
+
:validate_params,
|
10
|
+
default: true,
|
11
|
+
doc_type: 'Boolean',
|
12
|
+
docstring: <<~DOCS)
|
13
|
+
When `true`, request parameters are validated before sending the request.
|
14
|
+
DOCS
|
15
|
+
|
16
|
+
def add_handlers(handlers, config)
|
17
|
+
handlers.add(Handler, step: :validate) if config.validate_params
|
18
|
+
end
|
19
|
+
|
20
|
+
# @api private
|
21
|
+
class Handler < Client::Handler
|
22
|
+
def call(context)
|
23
|
+
Client::ParamValidator.new(context.operation.input).validate!(context.params)
|
24
|
+
@handler.call(context)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Smithy
|
4
|
+
module Client
|
5
|
+
module Plugins
|
6
|
+
# @api private
|
7
|
+
class Protocol < Plugin
|
8
|
+
option(
|
9
|
+
:protocol,
|
10
|
+
doc_default: '<DEFAULT_PROTOCOL>',
|
11
|
+
doc_type: 'String, Class',
|
12
|
+
docstring: 'The protocol to use for request serialization and response deserialization.'
|
13
|
+
)
|
14
|
+
|
15
|
+
# @api private
|
16
|
+
class BuildHandler < Handler
|
17
|
+
def call(context)
|
18
|
+
context.config.protocol.build_request(context)
|
19
|
+
@handler.call(context)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# @api private
|
24
|
+
class ParseHandler < Handler
|
25
|
+
def call(context)
|
26
|
+
response = @handler.call(context)
|
27
|
+
response.error = context.config.protocol.parse_error(response) unless response.error
|
28
|
+
response.data = context.config.protocol.parse_data(response) unless response.error
|
29
|
+
response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_handlers(handlers, _config)
|
34
|
+
handlers.add(BuildHandler)
|
35
|
+
handlers.add(ParseHandler, step: :parse)
|
36
|
+
end
|
37
|
+
|
38
|
+
def before_initialize(client_class, options)
|
39
|
+
protocol = options[:protocol]
|
40
|
+
case protocol
|
41
|
+
when nil
|
42
|
+
resolve_default_protocol(client_class, options)
|
43
|
+
when String
|
44
|
+
protocol_class = client_class.protocols[protocol]
|
45
|
+
raise ArgumentError, "Unknown protocol: #{protocol}" unless protocol_class
|
46
|
+
|
47
|
+
options[:protocol] = protocol_class.new
|
48
|
+
else
|
49
|
+
options[:protocol] = protocol
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def resolve_default_protocol(client_class, options)
|
56
|
+
protocol_class = client_class.protocols.values.first
|
57
|
+
if protocol_class
|
58
|
+
options[:protocol] = protocol_class.new
|
59
|
+
elsif options[:stub_responses]
|
60
|
+
options[:protocol] = Stubbing::Protocol.new
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Smithy
|
4
|
+
module Client
|
5
|
+
module Plugins
|
6
|
+
# @api private
|
7
|
+
class RaiseResponseErrors < Plugin
|
8
|
+
option(
|
9
|
+
:raise_response_errors,
|
10
|
+
default: true,
|
11
|
+
doc_type: 'Boolean',
|
12
|
+
docstring: <<~DOCS)
|
13
|
+
When `true`, response errors are raised. When `false`, the error is placed on the
|
14
|
+
output in the {Smithy::Client::Response#error error accessor}.
|
15
|
+
DOCS
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
class Handler < Client::Handler
|
19
|
+
def call(context)
|
20
|
+
response = @handler.call(context)
|
21
|
+
raise response.error if response.error
|
22
|
+
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_handlers(handlers, config)
|
28
|
+
handlers.add(Handler, step: :validate, priority: 95) if config.raise_response_errors
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|