aws-sdk-core 3.189.0 → 3.199.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.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +183 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
  5. data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
  6. data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
  7. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  8. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  9. data/lib/aws-sdk-core/cbor/cbor_engine.rb +19 -0
  10. data/lib/aws-sdk-core/cbor/decoder.rb +310 -0
  11. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  12. data/lib/aws-sdk-core/cbor.rb +106 -0
  13. data/lib/aws-sdk-core/client_stubs.rb +18 -14
  14. data/lib/aws-sdk-core/credential_provider.rb +1 -1
  15. data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
  16. data/lib/aws-sdk-core/ecs_credentials.rb +2 -1
  17. data/lib/aws-sdk-core/endpoints/matchers.rb +5 -1
  18. data/lib/aws-sdk-core/error_handler.rb +41 -0
  19. data/lib/aws-sdk-core/errors.rb +2 -2
  20. data/lib/aws-sdk-core/event_emitter.rb +0 -16
  21. data/lib/aws-sdk-core/instance_profile_credentials.rb +3 -2
  22. data/lib/aws-sdk-core/json/builder.rb +8 -1
  23. data/lib/aws-sdk-core/json/error_handler.rb +15 -10
  24. data/lib/aws-sdk-core/json/handler.rb +5 -6
  25. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  26. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  27. data/lib/aws-sdk-core/json/parser.rb +6 -1
  28. data/lib/aws-sdk-core/json.rb +43 -14
  29. data/lib/aws-sdk-core/lru_cache.rb +75 -0
  30. data/lib/aws-sdk-core/pageable_response.rb +1 -1
  31. data/lib/aws-sdk-core/param_validator.rb +7 -2
  32. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -0
  33. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
  34. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +2 -0
  35. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  36. data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
  37. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  38. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  39. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  40. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  41. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  42. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
  43. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
  44. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  45. data/lib/aws-sdk-core/plugins/request_compression.rb +11 -2
  46. data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
  47. data/lib/aws-sdk-core/plugins/sign.rb +8 -3
  48. data/lib/aws-sdk-core/plugins/stub_responses.rb +1 -0
  49. data/lib/aws-sdk-core/plugins/user_agent.rb +61 -26
  50. data/lib/aws-sdk-core/process_credentials.rb +45 -27
  51. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  52. data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
  53. data/lib/aws-sdk-core/query/handler.rb +4 -4
  54. data/lib/aws-sdk-core/query/param_builder.rb +2 -2
  55. data/lib/aws-sdk-core/query.rb +2 -1
  56. data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
  57. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  58. data/lib/aws-sdk-core/rest/request/body.rb +32 -5
  59. data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
  60. data/lib/aws-sdk-core/rest/request/headers.rb +15 -7
  61. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +23 -11
  62. data/lib/aws-sdk-core/rest/response/body.rb +15 -1
  63. data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
  64. data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
  65. data/lib/aws-sdk-core/rest.rb +1 -0
  66. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  67. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +45 -0
  68. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +84 -0
  69. data/lib/aws-sdk-core/rpc_v2/handler.rb +74 -0
  70. data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
  71. data/lib/aws-sdk-core/rpc_v2.rb +6 -0
  72. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +41 -0
  73. data/lib/aws-sdk-core/util.rb +39 -0
  74. data/lib/aws-sdk-core/waiters/poller.rb +2 -2
  75. data/lib/aws-sdk-core/xml/builder.rb +17 -9
  76. data/lib/aws-sdk-core/xml/error_handler.rb +32 -42
  77. data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
  78. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  79. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  80. data/lib/aws-sdk-core.rb +7 -2
  81. data/lib/aws-sdk-sso/client.rb +77 -49
  82. data/lib/aws-sdk-sso/plugins/endpoints.rb +1 -0
  83. data/lib/aws-sdk-sso.rb +1 -1
  84. data/lib/aws-sdk-ssooidc/client.rb +127 -51
  85. data/lib/aws-sdk-ssooidc/client_api.rb +22 -0
  86. data/lib/aws-sdk-ssooidc/errors.rb +21 -0
  87. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +1 -0
  88. data/lib/aws-sdk-ssooidc/types.rb +77 -9
  89. data/lib/aws-sdk-ssooidc.rb +1 -1
  90. data/lib/aws-sdk-sts/client.rb +78 -50
  91. data/lib/aws-sdk-sts/client_api.rb +8 -8
  92. data/lib/aws-sdk-sts/plugins/endpoints.rb +1 -0
  93. data/lib/aws-sdk-sts/types.rb +1 -1
  94. data/lib/aws-sdk-sts.rb +1 -1
  95. data/lib/seahorse/client/async_base.rb +1 -1
  96. data/lib/seahorse/client/async_response.rb +19 -0
  97. data/lib/seahorse/client/base.rb +18 -7
  98. data/lib/seahorse/client/h2/handler.rb +1 -0
  99. data/lib/seahorse/client/handler.rb +1 -1
  100. data/lib/seahorse/client/net_http/connection_pool.rb +3 -9
  101. data/lib/seahorse/client/plugin.rb +9 -0
  102. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  103. data/lib/seahorse/client/plugins/net_http.rb +48 -16
  104. data/lib/seahorse/model/shapes.rb +2 -2
  105. data/sig/aws-sdk-core/client_stubs.rbs +10 -0
  106. data/sig/aws-sdk-core/errors.rbs +22 -0
  107. data/sig/aws-sdk-core/resources/collection.rbs +21 -0
  108. data/sig/aws-sdk-core/structure.rbs +4 -0
  109. data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
  110. data/sig/aws-sdk-core.rbs +7 -0
  111. data/sig/seahorse/client/base.rbs +25 -0
  112. data/sig/seahorse/client/handler_builder.rbs +16 -0
  113. data/sig/seahorse/client/response.rbs +61 -0
  114. metadata +38 -12
  115. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  116. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  117. /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
  118. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  119. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -12,18 +12,8 @@ module Aws
12
12
  class Handler < Seahorse::Client::Handler
13
13
 
14
14
  def call(context)
15
- apply_invocation_id(context)
16
- @handler.call(context)
17
- end
18
-
19
- private
20
-
21
- def apply_invocation_id(context)
22
15
  context.http_request.headers['amz-sdk-invocation-id'] = SecureRandom.uuid
23
- if context[:input_event_emitter]
24
- # only used for eventstreaming at input
25
- context.http_request.headers['x-amz-content-sha256'] = 'STREAMING-AWS4-HMAC-SHA256-EVENTS'
26
- end
16
+ @handler.call(context)
27
17
  end
28
18
 
29
19
  end
@@ -8,6 +8,7 @@ module Aws
8
8
 
9
9
  option(:logger,
10
10
  doc_type: 'Logger',
11
+ rbs_type: 'untyped',
11
12
  docstring: <<-DOCS
12
13
  The Logger instance to send log messages to. If this option
13
14
  is not set, logging will be disabled.
@@ -22,6 +23,7 @@ is not set, logging will be disabled.
22
23
 
23
24
  option(:log_formatter,
24
25
  doc_type: 'Aws::Log::Formatter',
26
+ rbs_type: 'untyped',
25
27
  doc_default: literal('Aws::Log::Formatter.default'),
26
28
  docstring: 'The log formatter.'
27
29
  ) do |config|
@@ -5,6 +5,8 @@ module Aws
5
5
  module Protocols
6
6
  class ApiGateway < Seahorse::Client::Plugin
7
7
 
8
+ option(:protocol, 'api-gateway')
9
+
8
10
  class ContentTypeHandler < Seahorse::Client::Handler
9
11
  def call(context)
10
12
  body = context.http_request.body
@@ -22,8 +24,8 @@ module Aws
22
24
  handler(Rest::Handler)
23
25
  handler(ContentTypeHandler, priority: 30)
24
26
  handler(Json::ErrorHandler, step: :sign)
25
- end
26
27
 
28
+ end
27
29
  end
28
30
  end
29
31
  end
@@ -1,35 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../query'
4
-
5
3
  module Aws
6
4
  module Plugins
7
5
  module Protocols
8
6
  class EC2 < Seahorse::Client::Plugin
9
7
 
10
- class Handler < Aws::Query::Handler
11
-
12
- def apply_params(param_list, params, rules)
13
- Aws::Query::EC2ParamBuilder.new(param_list).apply(rules, params)
14
- end
15
-
16
- def parse_xml(context)
17
- if rules = context.operation.output
18
- parser = Xml::Parser.new(rules)
19
- data = parser.parse(xml(context)) do |path, value|
20
- if path.size == 2 && path.last == 'requestId'
21
- context.metadata[:request_id] = value
22
- end
23
- end
24
- data
25
- else
26
- EmptyStructure.new
27
- end
28
- end
29
-
30
- end
8
+ option(:protocol, 'ec2')
31
9
 
32
- handler(Handler)
10
+ handler(Aws::Query::EC2Handler)
33
11
  handler(Xml::ErrorHandler, step: :sign)
34
12
 
35
13
  end
@@ -5,18 +5,17 @@ module Aws
5
5
  module Protocols
6
6
  class JsonRpc < Seahorse::Client::Plugin
7
7
 
8
+ option(:protocol, 'json')
9
+
8
10
  option(:simple_json,
9
11
  default: false,
10
12
  doc_type: 'Boolean',
11
13
  docstring: <<-DOCS)
12
14
  Disables request parameter conversion, validation, and formatting.
13
- Also disable response data type conversions. This option is useful
14
- when you want to ensure the highest level of performance by
15
- avoiding overhead of walking request parameters and response data
16
- structures.
17
-
18
- When `:simple_json` is enabled, the request parameters hash must
19
- be formatted exactly as the DynamoDB API expects.
15
+ Also disables response data type conversions. The request parameters
16
+ hash must be formatted exactly as the API expects.This option is useful
17
+ when you want to ensure the highest level of performance by avoiding
18
+ overhead of walking request parameters and response data structures.
20
19
  DOCS
21
20
 
22
21
  option(:validate_params) { |config| !config.simple_json }
@@ -24,7 +23,6 @@ be formatted exactly as the DynamoDB API expects.
24
23
  option(:convert_params) { |config| !config.simple_json }
25
24
 
26
25
  handler(Json::Handler)
27
-
28
26
  handler(Json::ErrorHandler, step: :sign)
29
27
 
30
28
  end
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../query'
4
-
5
3
  module Aws
6
4
  module Plugins
7
5
  module Protocols
8
6
  class Query < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'query')
9
+
9
10
  handler(Aws::Query::Handler)
10
11
  handler(Xml::ErrorHandler, step: :sign)
12
+
11
13
  end
12
14
  end
13
15
  end
@@ -5,25 +5,13 @@ module Aws
5
5
  module Protocols
6
6
  class RestJson < Seahorse::Client::Plugin
7
7
 
8
- class ContentTypeHandler < Seahorse::Client::Handler
9
- def call(context)
10
- body = context.http_request.body
11
- # Rest::Handler will set a default JSON body, so size can be checked
12
- # if this handler is run after serialization.
13
- if !body.respond_to?(:size) ||
14
- (body.respond_to?(:size) && body.size > 0)
15
- context.http_request.headers['Content-Type'] ||=
16
- 'application/json'
17
- end
18
- @handler.call(context)
19
- end
20
- end
8
+ option(:protocol, 'rest-json')
21
9
 
22
10
  handler(Rest::Handler)
23
- handler(ContentTypeHandler, priority: 30)
11
+ handler(Rest::ContentTypeHandler, priority: 30)
24
12
  handler(Json::ErrorHandler, step: :sign)
25
- end
26
13
 
14
+ end
27
15
  end
28
16
  end
29
17
  end
@@ -5,7 +5,10 @@ module Aws
5
5
  module Protocols
6
6
  class RestXml < Seahorse::Client::Plugin
7
7
 
8
+ option(:protocol, 'rest-xml')
9
+
8
10
  handler(Rest::Handler)
11
+ handler(Rest::ContentTypeHandler, priority: 30)
9
12
  handler(Xml::ErrorHandler, step: :sign)
10
13
 
11
14
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Plugins
5
+ module Protocols
6
+ class RpcV2 < Seahorse::Client::Plugin
7
+
8
+ option(:protocol, 'smithy-rpc-v2-cbor')
9
+
10
+ handler(Aws::RpcV2::Handler)
11
+ handler(Aws::RpcV2::ContentTypeHandler, priority: 30)
12
+ handler(Aws::RpcV2::ErrorHandler, step: :sign)
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -91,11 +91,20 @@ and 10485780 bytes inclusive.
91
91
  end
92
92
  end
93
93
  end
94
- @handler.call(context)
94
+ with_metric(selected_encoding) { @handler.call(context) }
95
95
  end
96
96
 
97
97
  private
98
98
 
99
+ def with_metric(encoding, &block)
100
+ case encoding
101
+ when 'gzip'
102
+ Aws::Plugins::UserAgent.metric('GZIP_REQUEST_COMPRESSION', &block)
103
+ else
104
+ block.call
105
+ end
106
+ end
107
+
99
108
  def request_encoding_selection(context)
100
109
  encoding_list = context.operation.request_compression['encodings']
101
110
  encoding_list.find { |encoding| RequestCompression::SUPPORTED_ENCODINGS.include?(encoding) }
@@ -104,7 +113,7 @@ and 10485780 bytes inclusive.
104
113
  def update_content_encoding(encoding, context)
105
114
  headers = context.http_request.headers
106
115
  if headers['Content-Encoding']
107
- headers['Content-Encoding'] += ',' + encoding
116
+ headers['Content-Encoding'] += ", #{encoding}"
108
117
  else
109
118
  headers['Content-Encoding'] = encoding
110
119
  end
@@ -73,6 +73,7 @@ is only used in the `legacy` retry mode.
73
73
  :retry_jitter,
74
74
  default: :none,
75
75
  doc_type: Symbol,
76
+ rbs_type: '(:none | :equal | :full | ^(Integer) -> Integer)',
76
77
  docstring: <<-DOCS)
77
78
  A delay randomiser function used by the default backoff function.
78
79
  Some predefined functions can be referenced by name - :none, :equal, :full,
@@ -97,6 +98,7 @@ This option is only used in the `legacy` retry mode.
97
98
  :retry_mode,
98
99
  default: 'legacy',
99
100
  doc_type: String,
101
+ rbs_type: '("legacy" | "standard" | "adaptive")',
100
102
  docstring: <<-DOCS) do |cfg|
101
103
  Specifies which retry algorithm to use. Values are:
102
104
 
@@ -111,7 +113,6 @@ Specifies which retry algorithm to use. Values are:
111
113
  functionality of `standard` mode along with automatic client side
112
114
  throttling. This is a provisional mode that may change behavior
113
115
  in the future.
114
-
115
116
  DOCS
116
117
  resolve_retry_mode(cfg)
117
118
  end
@@ -233,7 +234,7 @@ a clock skew correction and retry requests with skewed client clocks.
233
234
 
234
235
  get_send_token(config)
235
236
  add_retry_headers(context)
236
- response = @handler.call(context)
237
+ response = with_metric(config.retry_mode) { @handler.call(context) }
237
238
  error_inspector = Retries::ErrorInspector.new(
238
239
  response.error, response.context.http_response.status_code
239
240
  )
@@ -270,6 +271,10 @@ a clock skew correction and retry requests with skewed client clocks.
270
271
 
271
272
  private
272
273
 
274
+ def with_metric(retry_mode, &block)
275
+ Aws::Plugins::UserAgent.metric("RETRY_MODE_#{retry_mode.upcase}", &block)
276
+ end
277
+
273
278
  def get_send_token(config)
274
279
  # either fail fast or block until a token becomes available
275
280
  # must be configurable
@@ -357,7 +362,7 @@ a clock skew correction and retry requests with skewed client clocks.
357
362
  class LegacyHandler < Seahorse::Client::Handler
358
363
 
359
364
  def call(context)
360
- response = @handler.call(context)
365
+ response = with_metric { @handler.call(context) }
361
366
  if response.error
362
367
  error_inspector = Retries::ErrorInspector.new(
363
368
  response.error, response.context.http_response.status_code
@@ -376,6 +381,10 @@ a clock skew correction and retry requests with skewed client clocks.
376
381
 
377
382
  private
378
383
 
384
+ def with_metric(&block)
385
+ Aws::Plugins::UserAgent.metric('RETRY_MODE_LEGACY', &block)
386
+ end
387
+
379
388
  def retry_if_possible(response, error_inspector)
380
389
  context = response.context
381
390
  if should_retry?(context, error_inspector)
@@ -159,9 +159,14 @@ module Aws
159
159
  private
160
160
 
161
161
  def apply_authtype(context, req)
162
- if context.operation['authtype'].eql?('v4-unsigned-body') &&
163
- req.endpoint.scheme.eql?('https')
164
- req.headers['X-Amz-Content-Sha256'] ||= 'UNSIGNED-PAYLOAD'
162
+ # only used for eventstreaming at input
163
+ if context[:input_event_emitter]
164
+ req.headers['X-Amz-Content-Sha256'] = 'STREAMING-AWS4-HMAC-SHA256-EVENTS'
165
+ else
166
+ if context.operation['authtype'].eql?('v4-unsigned-body') &&
167
+ req.endpoint.scheme.eql?('https')
168
+ req.headers['X-Amz-Content-Sha256'] ||= 'UNSIGNED-PAYLOAD'
169
+ end
165
170
  end
166
171
  end
167
172
 
@@ -8,6 +8,7 @@ module Aws
8
8
  option(:stub_responses,
9
9
  default: false,
10
10
  doc_type: 'Boolean',
11
+ rbs_type: 'untyped',
11
12
  docstring: <<-DOCS)
12
13
  Causes the client to return stubbed responses. By default
13
14
  fake responses are generated and returned. You can specify
@@ -4,6 +4,23 @@ 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
+
7
24
  # @api private
8
25
  option(:user_agent_suffix)
9
26
  # @api private
@@ -14,20 +31,29 @@ module Aws
14
31
  doc_type: 'String',
15
32
  docstring: <<-DOCS) do |cfg|
16
33
  A unique and opaque application ID that is appended to the
17
- User-Agent header as app/<sdk_ua_app_id>. It should have a
18
- maximum length of 50.
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.
19
37
  DOCS
20
38
  app_id = ENV['AWS_SDK_UA_APP_ID']
21
39
  app_id ||= Aws.shared_config.sdk_ua_app_id(profile: cfg.profile)
22
40
  app_id
23
41
  end
24
42
 
25
- def self.feature(feature, &block)
26
- Thread.current[:aws_sdk_core_user_agent_feature] ||= []
27
- Thread.current[:aws_sdk_core_user_agent_feature] << "ft/#{feature}"
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]
28
51
  block.call
29
52
  ensure
30
- Thread.current[:aws_sdk_core_user_agent_feature].pop
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
31
57
  end
32
58
 
33
59
  # @api private
@@ -48,15 +74,24 @@ maximum length of 50.
48
74
 
49
75
  def to_s
50
76
  ua = "aws-sdk-ruby3/#{CORE_GEM_VERSION}"
51
- ua += ' ua/2.0'
52
- ua += " #{api_metadata}" if api_metadata
77
+ ua += ' ua/2.1'
78
+ if (api_m = api_metadata)
79
+ ua += " #{api_m}"
80
+ end
53
81
  ua += " #{os_metadata}"
54
82
  ua += " #{language_metadata}"
55
- ua += " #{env_metadata}" if env_metadata
56
- ua += " #{config_metadata}" if config_metadata
57
- ua += " #{app_id}" if app_id
58
- ua += " #{feature_metadata}" if feature_metadata
59
- ua += " #{framework_metadata}" if framework_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
60
95
  if @context.config.user_agent_suffix
61
96
  ua += " #{@context.config.user_agent_suffix}"
62
97
  end
@@ -92,7 +127,6 @@ maximum length of 50.
92
127
  local_version = Gem::Platform.local.version
93
128
  metadata += "##{local_version}" if local_version
94
129
  metadata += " md/#{RbConfig::CONFIG['host_cpu']}"
95
- metadata
96
130
  end
97
131
 
98
132
  # Used to be RUBY_ENGINE/RUBY_VERSION
@@ -106,11 +140,7 @@ maximum length of 50.
106
140
  "exec-env/#{execution_env}"
107
141
  end
108
142
 
109
- def config_metadata
110
- "cfg/retry-mode##{@context.config.retry_mode}"
111
- end
112
-
113
- def app_id
143
+ def app_id_metadata
114
144
  return unless (app_id = @context.config.sdk_ua_app_id)
115
145
 
116
146
  # Sanitize and only allow these characters
@@ -118,12 +148,6 @@ maximum length of 50.
118
148
  "app/#{app_id}"
119
149
  end
120
150
 
121
- def feature_metadata
122
- return unless Thread.current[:aws_sdk_core_user_agent_feature]
123
-
124
- Thread.current[:aws_sdk_core_user_agent_feature].join(' ')
125
- end
126
-
127
151
  def framework_metadata
128
152
  if (frameworks_cfg = @context.config.user_agent_frameworks).empty?
129
153
  return
@@ -140,10 +164,21 @@ maximum length of 50.
140
164
  end
141
165
  frameworks.map { |n, v| "lib/#{n}##{v}" }.join(' ')
142
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
143
178
  end
144
179
  end
145
180
 
146
- handler(Handler, priority: 1)
181
+ handler(Handler, step: :sign, priority: 97)
147
182
  end
148
183
  end
149
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 recieve a JSON payload containing the credentials.
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 Invocation string for process
23
- # credentials provider.
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(@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
- def credentials_from_process(proc_invocation)
34
- begin
35
- raw_out = `#{proc_invocation}`
36
- process_status = $?
37
- rescue Errno::ENOENT
38
- raise Errors::InvalidProcessCredentialsPayload.new("Could not find process #{proc_invocation}")
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
- if process_status.success?
42
- begin
43
- creds_json = Aws::Json.load(raw_out)
44
- rescue Aws::Json::ParseError
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
- raise Errors::InvalidProcessCredentialsPayload.new("Invalid payload for JSON credentials version 1")
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(@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
- set(prefix, '')
36
- else
37
- member_ref = ref.shape.member
38
- values.each.with_index do |value, n|
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 |response|
31
- response.error = nil
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
- response.data = EmptyStructure.new
34
+ resp.data = EmptyStructure.new
35
35
  else
36
- response.data = parsed
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(member_ref)
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)