aws-sdk-core 3.165.0 → 3.201.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 +462 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +4 -4
- data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
- data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
- data/lib/aws-sdk-core/cbor/cbor_engine.rb +19 -0
- data/lib/aws-sdk-core/cbor/decoder.rb +310 -0
- data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
- data/lib/aws-sdk-core/cbor.rb +106 -0
- data/lib/aws-sdk-core/client_stubs.rb +18 -14
- data/lib/aws-sdk-core/credential_provider.rb +4 -1
- data/lib/aws-sdk-core/credential_provider_chain.rb +8 -5
- data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
- data/lib/aws-sdk-core/ecs_credentials.rb +178 -53
- data/lib/aws-sdk-core/endpoints/condition.rb +5 -0
- data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +5 -1
- data/lib/aws-sdk-core/endpoints/error_rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/function.rb +5 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +18 -10
- data/lib/aws-sdk-core/endpoints/reference.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rule_set.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rules_provider.rb +5 -0
- data/lib/aws-sdk-core/endpoints/templater.rb +6 -0
- data/lib/aws-sdk-core/endpoints/tree_rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/url.rb +1 -0
- data/lib/aws-sdk-core/endpoints.rb +69 -19
- data/lib/aws-sdk-core/error_handler.rb +41 -0
- data/lib/aws-sdk-core/errors.rb +12 -3
- data/lib/aws-sdk-core/event_emitter.rb +0 -16
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +55 -32
- data/lib/aws-sdk-core/json/builder.rb +8 -1
- data/lib/aws-sdk-core/json/error_handler.rb +29 -14
- data/lib/aws-sdk-core/json/handler.rb +12 -6
- data/lib/aws-sdk-core/json/json_engine.rb +3 -1
- data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
- data/lib/aws-sdk-core/json/parser.rb +33 -3
- data/lib/aws-sdk-core/json.rb +43 -14
- data/lib/aws-sdk-core/log/formatter.rb +6 -0
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +3 -1
- data/lib/aws-sdk-core/param_validator.rb +9 -4
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +7 -4
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
- data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -1
- data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
- data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
- data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +140 -35
- data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +2 -1
- data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
- data/lib/aws-sdk-core/plugins/sign.rb +43 -19
- data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
- data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
- data/lib/aws-sdk-core/plugins/stub_responses.rb +1 -0
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
- data/lib/aws-sdk-core/plugins/user_agent.rb +152 -14
- data/lib/aws-sdk-core/process_credentials.rb +45 -27
- data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
- data/lib/aws-sdk-core/query/handler.rb +4 -4
- data/lib/aws-sdk-core/query/param_builder.rb +2 -2
- data/lib/aws-sdk-core/query.rb +2 -1
- data/lib/aws-sdk-core/refreshing_credentials.rb +12 -12
- data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -4
- data/lib/aws-sdk-core/rest/request/body.rb +32 -5
- data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
- data/lib/aws-sdk-core/rest/request/headers.rb +15 -7
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
- data/lib/aws-sdk-core/rest/response/body.rb +15 -1
- data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
- data/lib/aws-sdk-core/rest.rb +1 -0
- data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +45 -0
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +84 -0
- data/lib/aws-sdk-core/rpc_v2/handler.rb +74 -0
- data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
- data/lib/aws-sdk-core/rpc_v2.rb +6 -0
- data/lib/aws-sdk-core/shared_config.rb +77 -18
- data/lib/aws-sdk-core/sso_credentials.rb +80 -45
- data/lib/aws-sdk-core/sso_token_provider.rb +3 -2
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +41 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
- data/lib/aws-sdk-core/util.rb +39 -0
- data/lib/aws-sdk-core/waiters/poller.rb +4 -2
- data/lib/aws-sdk-core/xml/builder.rb +17 -9
- data/lib/aws-sdk-core/xml/error_handler.rb +32 -42
- data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
- data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +2 -0
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +2 -6
- data/lib/aws-sdk-core.rb +8 -2
- data/lib/aws-sdk-sso/client.rb +103 -46
- data/lib/aws-sdk-sso/client_api.rb +6 -0
- data/lib/aws-sdk-sso/endpoint_provider.rb +41 -96
- data/lib/aws-sdk-sso/endpoints.rb +1 -0
- data/lib/aws-sdk-sso/plugins/endpoints.rb +4 -2
- data/lib/aws-sdk-sso/types.rb +0 -35
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +488 -74
- data/lib/aws-sdk-ssooidc/client_api.rb +82 -1
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +41 -95
- data/lib/aws-sdk-ssooidc/endpoints.rb +15 -0
- data/lib/aws-sdk-ssooidc/errors.rb +52 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +6 -2
- data/lib/aws-sdk-ssooidc/types.rb +372 -83
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +361 -288
- data/lib/aws-sdk-sts/client_api.rb +24 -11
- data/lib/aws-sdk-sts/endpoint_provider.rb +96 -213
- data/lib/aws-sdk-sts/endpoints.rb +1 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +4 -2
- data/lib/aws-sdk-sts/presigner.rb +1 -1
- data/lib/aws-sdk-sts/types.rb +128 -197
- data/lib/aws-sdk-sts.rb +1 -1
- data/lib/seahorse/client/async_base.rb +1 -1
- data/lib/seahorse/client/async_response.rb +19 -0
- data/lib/seahorse/client/base.rb +18 -7
- data/lib/seahorse/client/configuration.rb +0 -4
- data/lib/seahorse/client/h2/connection.rb +12 -11
- data/lib/seahorse/client/h2/handler.rb +1 -0
- data/lib/seahorse/client/handler.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +3 -9
- data/lib/seahorse/client/net_http/patches.rb +1 -4
- data/lib/seahorse/client/plugin.rb +9 -0
- data/lib/seahorse/client/plugins/endpoint.rb +0 -1
- data/lib/seahorse/client/plugins/h2.rb +3 -3
- data/lib/seahorse/client/plugins/net_http.rb +48 -16
- data/lib/seahorse/client/plugins/request_callback.rb +31 -0
- data/lib/seahorse/client/response.rb +6 -0
- data/lib/seahorse/model/operation.rb +3 -0
- data/lib/seahorse/model/shapes.rb +2 -2
- 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 +44 -17
- /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -5,7 +5,8 @@ module Aws
|
|
5
5
|
|
6
6
|
# For Streaming Input Operations, when `requiresLength` is enabled
|
7
7
|
# checking whether `Content-Length` header can be set,
|
8
|
-
# for `v4-unsigned-body` operations,
|
8
|
+
# for `unsignedPayload` and `v4-unsigned-body` operations,
|
9
|
+
# set `Transfer-Encoding` header.
|
9
10
|
class TransferEncoding < Seahorse::Client::Plugin
|
10
11
|
|
11
12
|
# @api private
|
@@ -16,8 +17,8 @@ module Aws
|
|
16
17
|
unless context.http_request.body.respond_to?(:size)
|
17
18
|
if requires_length?(context.operation.input)
|
18
19
|
# if size of the IO is not available but required
|
19
|
-
raise Aws::Errors::MissingContentLength
|
20
|
-
elsif context.operation
|
20
|
+
raise Aws::Errors::MissingContentLength
|
21
|
+
elsif unsigned_payload?(context.operation)
|
21
22
|
context.http_request.headers['Transfer-Encoding'] = 'chunked'
|
22
23
|
end
|
23
24
|
end
|
@@ -29,18 +30,24 @@ module Aws
|
|
29
30
|
private
|
30
31
|
|
31
32
|
def streaming?(ref)
|
32
|
-
if payload = ref[:payload_member]
|
33
|
-
payload[
|
34
|
-
payload.shape["streaming"]
|
33
|
+
if (payload = ref[:payload_member])
|
34
|
+
payload['streaming'] || payload.shape['streaming']
|
35
35
|
else
|
36
36
|
false
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def unsigned_payload?(operation)
|
41
|
+
operation['unsignedPayload'] ||
|
42
|
+
operation['authtype'] == 'v4-unsigned-body'
|
43
|
+
end
|
44
|
+
|
40
45
|
def requires_length?(ref)
|
41
|
-
payload = ref[:payload_member]
|
42
|
-
|
43
|
-
|
46
|
+
if (payload = ref[:payload_member])
|
47
|
+
payload['requiresLength'] || payload.shape['requiresLength']
|
48
|
+
else
|
49
|
+
false
|
50
|
+
end
|
44
51
|
end
|
45
52
|
|
46
53
|
end
|
@@ -4,7 +4,57 @@ module Aws
|
|
4
4
|
module Plugins
|
5
5
|
# @api private
|
6
6
|
class UserAgent < Seahorse::Client::Plugin
|
7
|
+
METRICS = Aws::Json.load(<<-METRICS)
|
8
|
+
{
|
9
|
+
"RESOURCE_MODEL": "A",
|
10
|
+
"WAITER": "B",
|
11
|
+
"PAGINATOR": "C",
|
12
|
+
"RETRY_MODE_LEGACY": "D",
|
13
|
+
"RETRY_MODE_STANDARD": "E",
|
14
|
+
"RETRY_MODE_ADAPTIVE": "F",
|
15
|
+
"S3_TRANSFER": "G",
|
16
|
+
"S3_CRYPTO_V1N": "H",
|
17
|
+
"S3_CRYPTO_V2": "I",
|
18
|
+
"S3_EXPRESS_BUCKET": "J",
|
19
|
+
"S3_ACCESS_GRANTS": "K",
|
20
|
+
"GZIP_REQUEST_COMPRESSION": "L"
|
21
|
+
}
|
22
|
+
METRICS
|
23
|
+
|
24
|
+
# @api private
|
7
25
|
option(:user_agent_suffix)
|
26
|
+
# @api private
|
27
|
+
option(:user_agent_frameworks, default: [])
|
28
|
+
|
29
|
+
option(
|
30
|
+
:sdk_ua_app_id,
|
31
|
+
doc_type: 'String',
|
32
|
+
docstring: <<-DOCS) do |cfg|
|
33
|
+
A unique and opaque application ID that is appended to the
|
34
|
+
User-Agent header as app/sdk_ua_app_id. It should have a
|
35
|
+
maximum length of 50. This variable is sourced from environment
|
36
|
+
variable AWS_SDK_UA_APP_ID or the shared config profile attribute sdk_ua_app_id.
|
37
|
+
DOCS
|
38
|
+
app_id = ENV['AWS_SDK_UA_APP_ID']
|
39
|
+
app_id ||= Aws.shared_config.sdk_ua_app_id(profile: cfg.profile)
|
40
|
+
app_id
|
41
|
+
end
|
42
|
+
|
43
|
+
# Deprecated - must exist for old service gems
|
44
|
+
def self.feature(_feature, &block)
|
45
|
+
block.call
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.metric(metric, &block)
|
49
|
+
Thread.current[:aws_sdk_core_user_agent_metric] ||= []
|
50
|
+
Thread.current[:aws_sdk_core_user_agent_metric] << METRICS[metric]
|
51
|
+
block.call
|
52
|
+
ensure
|
53
|
+
Thread.current[:aws_sdk_core_user_agent_metric].pop
|
54
|
+
if Thread.current[:aws_sdk_core_user_agent_metric].empty?
|
55
|
+
Thread.current[:aws_sdk_core_user_agent_metric] = nil
|
56
|
+
end
|
57
|
+
end
|
8
58
|
|
9
59
|
# @api private
|
10
60
|
class Handler < Seahorse::Client::Handler
|
@@ -14,33 +64,121 @@ module Aws
|
|
14
64
|
end
|
15
65
|
|
16
66
|
def set_user_agent(context)
|
17
|
-
|
67
|
+
context.http_request.headers['User-Agent'] = UserAgent.new(context).to_s
|
68
|
+
end
|
18
69
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
ua += " RUBY_ENGINE_NA/#{RUBY_VERSION}"
|
70
|
+
class UserAgent
|
71
|
+
def initialize(context)
|
72
|
+
@context = context
|
23
73
|
end
|
24
74
|
|
25
|
-
|
75
|
+
def to_s
|
76
|
+
ua = "aws-sdk-ruby3/#{CORE_GEM_VERSION}"
|
77
|
+
ua += ' ua/2.1'
|
78
|
+
if (api_m = api_metadata)
|
79
|
+
ua += " #{api_m}"
|
80
|
+
end
|
81
|
+
ua += " #{os_metadata}"
|
82
|
+
ua += " #{language_metadata}"
|
83
|
+
if (env_m = env_metadata)
|
84
|
+
ua += " #{env_m}"
|
85
|
+
end
|
86
|
+
if (app_id_m = app_id_metadata)
|
87
|
+
ua += " #{app_id_m}"
|
88
|
+
end
|
89
|
+
if (framework_m = framework_metadata)
|
90
|
+
ua += " #{framework_m}"
|
91
|
+
end
|
92
|
+
if (metric_m = metric_metadata)
|
93
|
+
ua += " #{metric_m}"
|
94
|
+
end
|
95
|
+
if @context.config.user_agent_suffix
|
96
|
+
ua += " #{@context.config.user_agent_suffix}"
|
97
|
+
end
|
98
|
+
ua.strip
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
# Used to be gem_name/gem_version
|
104
|
+
def api_metadata
|
105
|
+
service_id = @context.config.api.metadata['serviceId']
|
106
|
+
return unless service_id
|
26
107
|
|
27
|
-
|
28
|
-
|
108
|
+
service_id = service_id.gsub(' ', '_').downcase
|
109
|
+
gem_version = @context[:gem_version]
|
110
|
+
"api/#{service_id}##{gem_version}"
|
29
111
|
end
|
30
112
|
|
31
|
-
|
32
|
-
|
113
|
+
# Used to be RUBY_PLATFORM
|
114
|
+
def os_metadata
|
115
|
+
os =
|
116
|
+
case RbConfig::CONFIG['host_os']
|
117
|
+
when /mac|darwin/
|
118
|
+
'macos'
|
119
|
+
when /linux|cygwin/
|
120
|
+
'linux'
|
121
|
+
when /mingw|mswin/
|
122
|
+
'windows'
|
123
|
+
else
|
124
|
+
'other'
|
125
|
+
end
|
126
|
+
metadata = "os/#{os}"
|
127
|
+
local_version = Gem::Platform.local.version
|
128
|
+
metadata += "##{local_version}" if local_version
|
129
|
+
metadata += " md/#{RbConfig::CONFIG['host_cpu']}"
|
33
130
|
end
|
34
131
|
|
35
|
-
|
36
|
-
|
132
|
+
# Used to be RUBY_ENGINE/RUBY_VERSION
|
133
|
+
def language_metadata
|
134
|
+
"lang/#{RUBY_ENGINE}##{RUBY_ENGINE_VERSION} md/#{RUBY_VERSION}"
|
37
135
|
end
|
38
136
|
|
39
|
-
|
137
|
+
def env_metadata
|
138
|
+
return unless (execution_env = ENV['AWS_EXECUTION_ENV'])
|
139
|
+
|
140
|
+
"exec-env/#{execution_env}"
|
141
|
+
end
|
142
|
+
|
143
|
+
def app_id_metadata
|
144
|
+
return unless (app_id = @context.config.sdk_ua_app_id)
|
145
|
+
|
146
|
+
# Sanitize and only allow these characters
|
147
|
+
app_id = app_id.gsub(/[^!#$%&'*+\-.^_`|~0-9A-Za-z]/, '-')
|
148
|
+
"app/#{app_id}"
|
149
|
+
end
|
150
|
+
|
151
|
+
def framework_metadata
|
152
|
+
if (frameworks_cfg = @context.config.user_agent_frameworks).empty?
|
153
|
+
return
|
154
|
+
end
|
155
|
+
|
156
|
+
# Frameworks may be aws-record, aws-sdk-rails, etc.
|
157
|
+
regex = /gems\/(?<name>#{frameworks_cfg.join('|')})-(?<version>\d+\.\d+\.\d+)/.freeze
|
158
|
+
frameworks = {}
|
159
|
+
Kernel.caller.each do |line|
|
160
|
+
match = line.match(regex)
|
161
|
+
next unless match
|
162
|
+
|
163
|
+
frameworks[match[:name]] = match[:version]
|
164
|
+
end
|
165
|
+
frameworks.map { |n, v| "lib/#{n}##{v}" }.join(' ')
|
166
|
+
end
|
167
|
+
|
168
|
+
def metric_metadata
|
169
|
+
return unless Thread.current[:aws_sdk_core_user_agent_metric]
|
170
|
+
|
171
|
+
metrics = Thread.current[:aws_sdk_core_user_agent_metric].join(',')
|
172
|
+
# Metric metadata is limited to 1024 bytes
|
173
|
+
return "m/#{metrics}" if metrics.bytesize <= 1024
|
174
|
+
|
175
|
+
# Removes the last unfinished metric
|
176
|
+
"m/#{metrics[0...metrics[0..1024].rindex(',')]}"
|
177
|
+
end
|
40
178
|
end
|
41
179
|
end
|
42
180
|
|
43
|
-
handler(Handler)
|
181
|
+
handler(Handler, step: :sign, priority: 97)
|
44
182
|
end
|
45
183
|
end
|
46
184
|
end
|
@@ -2,9 +2,15 @@
|
|
2
2
|
|
3
3
|
module Aws
|
4
4
|
# A credential provider that executes a given process and attempts
|
5
|
-
# to read its stdout to
|
5
|
+
# to read its stdout to receive a JSON payload containing the credentials.
|
6
6
|
#
|
7
|
-
# credentials = Aws::ProcessCredentials.new('/usr/bin/credential_proc')
|
7
|
+
# credentials = Aws::ProcessCredentials.new(['/usr/bin/credential_proc'])
|
8
|
+
# ec2 = Aws::EC2::Client.new(credentials: credentials)
|
9
|
+
#
|
10
|
+
# Arguments should be provided as strings in the array, for example:
|
11
|
+
#
|
12
|
+
# process = ['/usr/bin/credential_proc', 'arg1', 'arg2']
|
13
|
+
# credentials = Aws::ProcessCredentials.new(process)
|
8
14
|
# ec2 = Aws::EC2::Client.new(credentials: credentials)
|
9
15
|
#
|
10
16
|
# Automatically handles refreshing credentials if an Expiration time is
|
@@ -19,40 +25,49 @@ module Aws
|
|
19
25
|
# Creates a new ProcessCredentials object, which allows an
|
20
26
|
# external process to be used as a credential provider.
|
21
27
|
#
|
22
|
-
# @param [String] process
|
23
|
-
#
|
28
|
+
# @param [Array<String>, String] process An array of strings including
|
29
|
+
# the process name and its arguments to execute, or a single string to be
|
30
|
+
# executed by the shell (deprecated and insecure).
|
24
31
|
def initialize(process)
|
32
|
+
if process.is_a?(String)
|
33
|
+
warn('Passing a single string to Aws::ProcessCredentials.new '\
|
34
|
+
'is insecure, please use use an array of system arguments instead')
|
35
|
+
end
|
25
36
|
@process = process
|
26
|
-
@credentials = credentials_from_process
|
37
|
+
@credentials = credentials_from_process
|
27
38
|
@async_refresh = false
|
28
39
|
|
29
40
|
super
|
30
41
|
end
|
31
42
|
|
32
43
|
private
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
44
|
+
|
45
|
+
def credentials_from_process
|
46
|
+
r, w = IO.pipe
|
47
|
+
success = system(*@process, out: w)
|
48
|
+
w.close
|
49
|
+
raw_out = r.read
|
50
|
+
r.close
|
51
|
+
|
52
|
+
unless success
|
53
|
+
raise Errors::InvalidProcessCredentialsPayload.new(
|
54
|
+
'credential_process provider failure, the credential process had '\
|
55
|
+
'non zero exit status and failed to provide credentials'
|
56
|
+
)
|
39
57
|
end
|
40
58
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
raise Errors::InvalidProcessCredentialsPayload.new("Invalid JSON response")
|
46
|
-
end
|
47
|
-
payload_version = creds_json['Version']
|
48
|
-
if payload_version == 1
|
49
|
-
_parse_payload_format_v1(creds_json)
|
50
|
-
else
|
51
|
-
raise Errors::InvalidProcessCredentialsPayload.new("Invalid version #{payload_version} for credentials payload")
|
52
|
-
end
|
53
|
-
else
|
54
|
-
raise Errors::InvalidProcessCredentialsPayload.new('credential_process provider failure, the credential process had non zero exit status and failed to provide credentials')
|
59
|
+
begin
|
60
|
+
creds_json = Aws::Json.load(raw_out)
|
61
|
+
rescue Aws::Json::ParseError
|
62
|
+
raise Errors::InvalidProcessCredentialsPayload.new('Invalid JSON response')
|
55
63
|
end
|
64
|
+
|
65
|
+
payload_version = creds_json['Version']
|
66
|
+
return _parse_payload_format_v1(creds_json) if payload_version == 1
|
67
|
+
|
68
|
+
raise Errors::InvalidProcessCredentialsPayload.new(
|
69
|
+
"Invalid version #{payload_version} for credentials payload"
|
70
|
+
)
|
56
71
|
end
|
57
72
|
|
58
73
|
def _parse_payload_format_v1(creds_json)
|
@@ -64,11 +79,14 @@ module Aws
|
|
64
79
|
|
65
80
|
@expiration = creds_json['Expiration'] ? Time.iso8601(creds_json['Expiration']) : nil
|
66
81
|
return creds if creds.set?
|
67
|
-
|
82
|
+
|
83
|
+
raise Errors::InvalidProcessCredentialsPayload.new(
|
84
|
+
'Invalid payload for JSON credentials version 1'
|
85
|
+
)
|
68
86
|
end
|
69
87
|
|
70
88
|
def refresh
|
71
|
-
@credentials = credentials_from_process
|
89
|
+
@credentials = credentials_from_process
|
72
90
|
end
|
73
91
|
|
74
92
|
def near_expiration?(expiration_length)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
# @api private
|
5
|
+
module Query
|
6
|
+
class EC2Handler < Aws::Query::Handler
|
7
|
+
|
8
|
+
def apply_params(param_list, params, rules)
|
9
|
+
Aws::Query::EC2ParamBuilder.new(param_list).apply(rules, params)
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse_xml(context)
|
13
|
+
if (rules = context.operation.output)
|
14
|
+
parser = Xml::Parser.new(rules)
|
15
|
+
parser.parse(xml(context)) do |path, value|
|
16
|
+
if path.size == 2 && path.last == 'requestId'
|
17
|
+
context.metadata[:request_id] = value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
else
|
21
|
+
EmptyStructure.new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -31,13 +31,11 @@ module Aws
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def list(ref, values, prefix)
|
34
|
-
if values.empty?
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
format(member_ref, value, "#{prefix}.#{n+1}")
|
40
|
-
end
|
34
|
+
return if values.empty?
|
35
|
+
|
36
|
+
member_ref = ref.shape.member
|
37
|
+
values.each.with_index do |value, n|
|
38
|
+
format(member_ref, value, "#{prefix}.#{n + 1}")
|
41
39
|
end
|
42
40
|
end
|
43
41
|
|
@@ -27,13 +27,13 @@ module Aws
|
|
27
27
|
# @return [Seahorse::Client::Response]
|
28
28
|
def call(context)
|
29
29
|
build_request(context)
|
30
|
-
@handler.call(context).on_success do |
|
31
|
-
|
30
|
+
@handler.call(context).on_success do |resp|
|
31
|
+
resp.error = nil
|
32
32
|
parsed = parse_xml(context)
|
33
33
|
if parsed.nil? || parsed == EmptyStructure
|
34
|
-
|
34
|
+
resp.data = EmptyStructure.new
|
35
35
|
else
|
36
|
-
|
36
|
+
resp.data = parsed
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -36,7 +36,7 @@ module Aws
|
|
36
36
|
return
|
37
37
|
end
|
38
38
|
if flat?(ref)
|
39
|
-
if name = query_name(
|
39
|
+
if (name = query_name(ref))
|
40
40
|
parts = prefix.split('.')
|
41
41
|
parts.pop
|
42
42
|
parts.push(name)
|
@@ -82,7 +82,7 @@ module Aws
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def flat?(ref)
|
85
|
-
ref.shape.flattened
|
85
|
+
ref[:flattened] || ref.shape.flattened
|
86
86
|
end
|
87
87
|
|
88
88
|
def timestamp(ref, value)
|
data/lib/aws-sdk-core/query.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'query/ec2_param_builder'
|
4
3
|
require_relative 'query/handler'
|
4
|
+
require_relative 'query/ec2_handler'
|
5
5
|
require_relative 'query/param'
|
6
6
|
require_relative 'query/param_builder'
|
7
|
+
require_relative 'query/ec2_param_builder'
|
7
8
|
require_relative 'query/param_list'
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'thread'
|
4
|
-
|
5
3
|
module Aws
|
6
4
|
|
7
5
|
# Base class used credential classes that can be refreshed. This
|
@@ -36,12 +34,6 @@ module Aws
|
|
36
34
|
@credentials
|
37
35
|
end
|
38
36
|
|
39
|
-
# @return [Time,nil]
|
40
|
-
def expiration
|
41
|
-
refresh_if_near_expiration!
|
42
|
-
@expiration
|
43
|
-
end
|
44
|
-
|
45
37
|
# Refresh credentials.
|
46
38
|
# @return [void]
|
47
39
|
def refresh!
|
@@ -54,6 +46,14 @@ module Aws
|
|
54
46
|
|
55
47
|
private
|
56
48
|
|
49
|
+
def sync_expiration_length
|
50
|
+
self.class::SYNC_EXPIRATION_LENGTH
|
51
|
+
end
|
52
|
+
|
53
|
+
def async_expiration_length
|
54
|
+
self.class::ASYNC_EXPIRATION_LENGTH
|
55
|
+
end
|
56
|
+
|
57
57
|
# Refreshes credentials asynchronously and synchronously.
|
58
58
|
# If we are near to expiration, block while getting new credentials.
|
59
59
|
# Otherwise, if we're approaching expiration, use the existing credentials
|
@@ -62,18 +62,18 @@ module Aws
|
|
62
62
|
# Note: This check is an optimization. Rather than acquire the mutex on every #refresh_if_near_expiration
|
63
63
|
# call, we check before doing so, and then we check within the mutex to avoid a race condition.
|
64
64
|
# See issue: https://github.com/aws/aws-sdk-ruby/issues/2641 for more info.
|
65
|
-
if near_expiration?(
|
65
|
+
if near_expiration?(sync_expiration_length)
|
66
66
|
@mutex.synchronize do
|
67
|
-
if near_expiration?(
|
67
|
+
if near_expiration?(sync_expiration_length)
|
68
68
|
@before_refresh.call(self) if @before_refresh
|
69
69
|
refresh
|
70
70
|
end
|
71
71
|
end
|
72
|
-
elsif @async_refresh && near_expiration?(
|
72
|
+
elsif @async_refresh && near_expiration?(async_expiration_length)
|
73
73
|
unless @mutex.locked?
|
74
74
|
Thread.new do
|
75
75
|
@mutex.synchronize do
|
76
|
-
if near_expiration?(
|
76
|
+
if near_expiration?(async_expiration_length)
|
77
77
|
@before_refresh.call(self) if @before_refresh
|
78
78
|
refresh
|
79
79
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Rest
|
5
|
+
# NOTE: headers could be already populated if specified on input shape
|
6
|
+
class ContentTypeHandler < Seahorse::Client::Handler
|
7
|
+
def call(context)
|
8
|
+
if eventstream?(context)
|
9
|
+
context.http_request.headers['Content-Type'] ||=
|
10
|
+
'application/vnd.amazon.eventstream'
|
11
|
+
elsif (payload = context.operation.input[:payload_member])
|
12
|
+
case payload.shape
|
13
|
+
when Seahorse::Model::Shapes::BlobShape
|
14
|
+
context.http_request.headers['Content-Type'] ||=
|
15
|
+
'application/octet-stream'
|
16
|
+
when Seahorse::Model::Shapes::StringShape
|
17
|
+
context.http_request.headers['Content-Type'] ||=
|
18
|
+
'text/plain'
|
19
|
+
else
|
20
|
+
apply_default_content_type(context)
|
21
|
+
end
|
22
|
+
elsif (body = context.http_request.body) &&
|
23
|
+
(!body.respond_to?(:size) || non_empty_body?(body))
|
24
|
+
apply_default_content_type(context)
|
25
|
+
end
|
26
|
+
|
27
|
+
@handler.call(context)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def non_empty_body?(body)
|
33
|
+
body.respond_to?(:size) && body.size.positive?
|
34
|
+
end
|
35
|
+
|
36
|
+
def eventstream?(context)
|
37
|
+
context.operation.input.shape.members.each do |_, ref|
|
38
|
+
return true if ref.eventstream
|
39
|
+
end
|
40
|
+
false
|
41
|
+
end
|
42
|
+
|
43
|
+
# content-type defaults as noted here:
|
44
|
+
# rest-json: https://smithy.io/2.0/aws/protocols/aws-restxml-protocol.html#content-type
|
45
|
+
# rest-xml: https://smithy.io/2.0/aws/protocols/aws-restxml-protocol.html#content-type
|
46
|
+
def apply_default_content_type(context)
|
47
|
+
protocol = context.config.api.metadata['protocol']
|
48
|
+
case protocol
|
49
|
+
when 'rest-json'
|
50
|
+
context.http_request.headers['Content-Type'] ||=
|
51
|
+
'application/json'
|
52
|
+
when 'rest-xml'
|
53
|
+
context.http_request.headers['Content-Type'] ||=
|
54
|
+
'application/xml'
|
55
|
+
else raise "Unsupported protocol #{protocol}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -7,10 +7,9 @@ module Aws
|
|
7
7
|
|
8
8
|
def call(context)
|
9
9
|
Rest::Request::Builder.new.apply(context)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
resp
|
10
|
+
response = @handler.call(context)
|
11
|
+
response.on(200..299) { |resp| Response::Parser.new.apply(resp) }
|
12
|
+
response.on(200..599) { |_resp| apply_request_id(context) }
|
14
13
|
end
|
15
14
|
|
16
15
|
private
|
@@ -18,10 +18,13 @@ module Aws
|
|
18
18
|
# @param [Hash] params
|
19
19
|
def apply(http_req, params)
|
20
20
|
body = build_body(params)
|
21
|
+
|
21
22
|
# for rest-json, ensure we send at least an empty object
|
22
23
|
# don't send an empty object for streaming? case.
|
23
|
-
if body.nil? &&
|
24
|
-
|
24
|
+
if body.nil? &&
|
25
|
+
json_builder? &&
|
26
|
+
modeled_body? &&
|
27
|
+
!streaming?
|
25
28
|
body = '{}'
|
26
29
|
end
|
27
30
|
http_req.body = body
|
@@ -45,13 +48,29 @@ module Aws
|
|
45
48
|
params[@rules[:payload]]
|
46
49
|
elsif @rules[:payload]
|
47
50
|
params = params[@rules[:payload]]
|
48
|
-
|
51
|
+
if params
|
52
|
+
if xml_builder? &&
|
53
|
+
@rules.shape.member?(@rules[:payload_member].location_name)
|
54
|
+
# serializing payload member name for rest-xml is as follows:
|
55
|
+
# 1. Use the member locationName if the member value doesn't match the member's name (default)
|
56
|
+
# 2. Use the value of the locationName on the member's target if present
|
57
|
+
# 3. Use the shape name of the member's target
|
58
|
+
serialize(@rules[:payload_member], params, location_name: payload_location_name)
|
59
|
+
else
|
60
|
+
serialize(@rules[:payload_member], params)
|
61
|
+
end
|
62
|
+
end
|
49
63
|
else
|
50
64
|
params = body_params(params)
|
51
65
|
serialize(@rules, params) unless params.empty?
|
52
66
|
end
|
53
67
|
end
|
54
68
|
|
69
|
+
def payload_location_name
|
70
|
+
@rules[:payload_member].shape['locationName'] ||
|
71
|
+
@rules[:payload_member].shape.name
|
72
|
+
end
|
73
|
+
|
55
74
|
def streaming?
|
56
75
|
@rules[:payload] && (
|
57
76
|
BlobShape === @rules[:payload_member].shape ||
|
@@ -59,8 +78,16 @@ module Aws
|
|
59
78
|
)
|
60
79
|
end
|
61
80
|
|
62
|
-
def
|
63
|
-
@serializer_class
|
81
|
+
def xml_builder?
|
82
|
+
@serializer_class == Xml::Builder
|
83
|
+
end
|
84
|
+
|
85
|
+
def json_builder?
|
86
|
+
@serializer_class == Json::Builder
|
87
|
+
end
|
88
|
+
|
89
|
+
def serialize(rules, params, location_name: nil)
|
90
|
+
@serializer_class.new(rules, location_name: location_name).serialize(params)
|
64
91
|
end
|
65
92
|
|
66
93
|
def body_params(params)
|