aws-sdk-core 3.197.0 → 3.201.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -4
  5. data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
  6. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  7. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  8. data/lib/aws-sdk-core/cbor/cbor_engine.rb +19 -0
  9. data/lib/aws-sdk-core/cbor/decoder.rb +310 -0
  10. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  11. data/lib/aws-sdk-core/cbor.rb +106 -0
  12. data/lib/aws-sdk-core/client_stubs.rb +3 -2
  13. data/lib/aws-sdk-core/endpoints/matchers.rb +5 -1
  14. data/lib/aws-sdk-core/endpoints.rb +64 -18
  15. data/lib/aws-sdk-core/error_handler.rb +41 -0
  16. data/lib/aws-sdk-core/errors.rb +9 -0
  17. data/lib/aws-sdk-core/json/error_handler.rb +6 -8
  18. data/lib/aws-sdk-core/json/handler.rb +5 -6
  19. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  20. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  21. data/lib/aws-sdk-core/json/parser.rb +2 -0
  22. data/lib/aws-sdk-core/json.rb +43 -14
  23. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  24. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +2 -1
  25. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  26. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  27. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  28. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  29. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  30. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +4 -3
  31. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +5 -1
  32. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  33. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +32 -3
  34. data/lib/aws-sdk-core/plugins/retry_errors.rb +0 -1
  35. data/lib/aws-sdk-core/plugins/sign.rb +10 -7
  36. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
  37. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
  38. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  39. data/lib/aws-sdk-core/process_credentials.rb +45 -27
  40. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  41. data/lib/aws-sdk-core/query/handler.rb +4 -4
  42. data/lib/aws-sdk-core/query.rb +2 -1
  43. data/lib/aws-sdk-core/rest/{request/content_type.rb → content_type_handler.rb} +1 -1
  44. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  45. data/lib/aws-sdk-core/rest/request/endpoint.rb +3 -1
  46. data/lib/aws-sdk-core/rest.rb +1 -1
  47. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  48. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +45 -0
  49. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +84 -0
  50. data/lib/aws-sdk-core/rpc_v2/handler.rb +74 -0
  51. data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
  52. data/lib/aws-sdk-core/rpc_v2.rb +6 -0
  53. data/lib/aws-sdk-core/shared_config.rb +1 -0
  54. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +41 -0
  55. data/lib/aws-sdk-core/xml/error_handler.rb +11 -37
  56. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  57. data/lib/aws-sdk-core.rb +6 -2
  58. data/lib/aws-sdk-sso/client.rb +15 -3
  59. data/lib/aws-sdk-sso/client_api.rb +6 -0
  60. data/lib/aws-sdk-sso.rb +1 -1
  61. data/lib/aws-sdk-ssooidc/client.rb +15 -3
  62. data/lib/aws-sdk-ssooidc/client_api.rb +4 -0
  63. data/lib/aws-sdk-ssooidc.rb +1 -1
  64. data/lib/aws-sdk-sts/client.rb +15 -3
  65. data/lib/aws-sdk-sts/client_api.rb +4 -2
  66. data/lib/aws-sdk-sts.rb +1 -1
  67. data/lib/seahorse/client/base.rb +17 -7
  68. data/lib/seahorse/client/handler.rb +1 -1
  69. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  70. metadata +22 -8
  71. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  72. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  73. /data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +0 -0
  74. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  75. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # @api private
5
+ module Cbor
6
+
7
+ # CBOR Tagged data (Major type 6).
8
+ # A Tag consists of a tag number and a value.
9
+ # In the extended generic data model, a tag number's definition
10
+ # describes the additional semantics conveyed with the tag number.
11
+ # # @!method initialize(*args)
12
+ # @option args [Integer] :tag The tag number.
13
+ # @option args [Object] :value The tag's content.
14
+ # @!attribute tag
15
+ # The tag number.
16
+ # @return [Integer]
17
+ # @!attribute value
18
+ # The tag's content.
19
+ # @return [Object]
20
+ Tagged = Struct.new(:tag, :value)
21
+
22
+ class Error < StandardError; end
23
+
24
+ class OutOfBytesError < Error
25
+ def initialize(n, left)
26
+ super("Out of bytes. Trying to read #{n} bytes but buffer contains only #{left}")
27
+ end
28
+ end
29
+
30
+ class UnknownTypeError < Error
31
+ def initialize(type)
32
+ super("Unable to encode #{type}")
33
+ end
34
+ end
35
+
36
+ class ExtraBytesError < Error
37
+ def initialize(pos, size)
38
+ super("Extra bytes follow after decoding item. Read #{pos} / #{size} bytes")
39
+ end
40
+ end
41
+
42
+ class UnexpectedBreakCodeError < Error; end
43
+
44
+ class UnexpectedAdditionalInformationError < Error
45
+ def initialize(add_info)
46
+ super("Unexpected additional information: #{add_info}")
47
+ end
48
+ end
49
+
50
+ class << self
51
+ # @param [Symbol,Class] engine
52
+ # Must be one of the following values:
53
+ #
54
+ # * :cbor
55
+ #
56
+ def engine=(engine)
57
+ @engine = Class === engine ? engine : load_engine(engine)
58
+ end
59
+
60
+ # @return [Class] Returns the default engine.
61
+ # One of:
62
+ #
63
+ # * {CborEngine}
64
+ #
65
+ def engine
66
+ set_default_engine unless @engine
67
+ @engine
68
+ end
69
+
70
+ def encode(data)
71
+ @engine.encode(data)
72
+ end
73
+
74
+ def decode(bytes)
75
+ bytes.force_encoding(Encoding::BINARY)
76
+ @engine.decode(bytes)
77
+ end
78
+
79
+ def set_default_engine
80
+ [:cbor].each do |name|
81
+ @engine ||= try_load_engine(name)
82
+ end
83
+
84
+ unless @engine
85
+ raise 'Unable to find a compatible cbor library.'
86
+ end
87
+ end
88
+
89
+ private
90
+
91
+ def load_engine(name)
92
+ require "aws-sdk-core/cbor/#{name}_engine"
93
+ const_name = name[0].upcase + name[1..-1] + 'Engine'
94
+ const_get(const_name)
95
+ end
96
+
97
+ def try_load_engine(name)
98
+ load_engine(name)
99
+ rescue LoadError
100
+ false
101
+ end
102
+ end
103
+
104
+ set_default_engine
105
+ end
106
+ end
@@ -308,10 +308,11 @@ module Aws
308
308
  def protocol_helper
309
309
  case config.api.metadata['protocol']
310
310
  when 'json' then Stubbing::Protocols::Json
311
- when 'query' then Stubbing::Protocols::Query
312
- when 'ec2' then Stubbing::Protocols::EC2
313
311
  when 'rest-json' then Stubbing::Protocols::RestJson
314
312
  when 'rest-xml' then Stubbing::Protocols::RestXml
313
+ when 'query' then Stubbing::Protocols::Query
314
+ when 'ec2' then Stubbing::Protocols::EC2
315
+ when 'smithy-rpc-v2-cbor' then Stubbing::Protocols::RpcV2
315
316
  when 'api-gateway' then Stubbing::Protocols::ApiGateway
316
317
  else raise "unsupported protocol"
317
318
  end.new
@@ -28,7 +28,11 @@ module Aws
28
28
 
29
29
  val = if (index = parts.first[BRACKET_REGEX, 1])
30
30
  # remove brackets and index from part before indexing
31
- value[parts.first.gsub(BRACKET_REGEX, '')][index.to_i]
31
+ if (base = parts.first.gsub(BRACKET_REGEX, '')) && !base.empty?
32
+ value[base][index.to_i]
33
+ else
34
+ value[index.to_i]
35
+ end
32
36
  else
33
37
  value[parts.first]
34
38
  end
@@ -14,9 +14,15 @@ require_relative 'endpoints/templater'
14
14
  require_relative 'endpoints/tree_rule'
15
15
  require_relative 'endpoints/url'
16
16
 
17
+ require 'aws-sigv4'
18
+
17
19
  module Aws
18
20
  # @api private
19
21
  module Endpoints
22
+ supported_auth_traits = %w[aws.auth#sigv4 smithy.api#httpBearerAuth smithy.api#noAuth]
23
+ supported_auth_traits += ['aws.auth#sigv4a'] if Aws::Sigv4::Signer.use_crt?
24
+ SUPPORTED_AUTH_TRAITS = supported_auth_traits.freeze
25
+
20
26
  class << self
21
27
  def resolve_auth_scheme(context, endpoint)
22
28
  if endpoint && (auth_schemes = endpoint.properties['authSchemes'])
@@ -33,8 +39,64 @@ module Aws
33
39
 
34
40
  private
35
41
 
42
+ def merge_signing_defaults(auth_scheme, config)
43
+ if %w[sigv4 sigv4a sigv4-s3express].include?(auth_scheme['name'])
44
+ auth_scheme['signingName'] ||= sigv4_name(config)
45
+ if auth_scheme['name'] == 'sigv4a'
46
+ # config option supersedes endpoint properties
47
+ auth_scheme['signingRegionSet'] =
48
+ config.sigv4a_signing_region_set || auth_scheme['signingRegionSet'] || [config.region]
49
+ else
50
+ auth_scheme['signingRegion'] ||= config.region
51
+ end
52
+ end
53
+ auth_scheme
54
+ end
55
+
56
+ def sigv4_name(config)
57
+ config.api.metadata['signingName'] ||
58
+ config.api.metadata['endpointPrefix']
59
+ end
60
+
36
61
  def default_auth_scheme(context)
37
- case default_api_authtype(context)
62
+ if (auth_list = default_api_auth(context))
63
+ auth = auth_list.find { |a| SUPPORTED_AUTH_TRAITS.include?(a) }
64
+ case auth
65
+ when 'aws.auth#sigv4', 'aws.auth#sigv4a'
66
+ auth_scheme = { 'name' => auth.split('#').last }
67
+ if s3_or_s3v4_signature_version?(context)
68
+ auth_scheme = auth_scheme.merge(
69
+ 'disableDoubleEncoding' => true,
70
+ 'disableNormalizePath' => true
71
+ )
72
+ end
73
+ merge_signing_defaults(auth_scheme, context.config)
74
+ when 'smithy.api#httpBearerAuth'
75
+ { 'name' => 'bearer' }
76
+ when 'smithy.api#noAuth'
77
+ { 'name' => 'none' }
78
+ else
79
+ raise 'No supported auth trait for this endpoint.'
80
+ end
81
+ else
82
+ legacy_default_auth_scheme(context)
83
+ end
84
+ end
85
+
86
+ def default_api_auth(context)
87
+ context.config.api.operation(context.operation_name)['auth'] ||
88
+ context.config.api.metadata['auth']
89
+ end
90
+
91
+ def s3_or_s3v4_signature_version?(context)
92
+ %w[s3 s3v4].include?(context.config.api.metadata['signatureVersion'])
93
+ end
94
+
95
+ # Legacy auth resolution - looks for deprecated signatureVersion
96
+ # and authType traits.
97
+
98
+ def legacy_default_auth_scheme(context)
99
+ case legacy_default_api_authtype(context)
38
100
  when 'v4', 'v4-unsigned-body'
39
101
  auth_scheme = { 'name' => 'sigv4' }
40
102
  merge_signing_defaults(auth_scheme, context.config)
@@ -52,27 +114,11 @@ module Aws
52
114
  end
53
115
  end
54
116
 
55
- def merge_signing_defaults(auth_scheme, config)
56
- if %w[sigv4 sigv4a sigv4-s3express].include?(auth_scheme['name'])
57
- auth_scheme['signingName'] ||= sigv4_name(config)
58
- if auth_scheme['name'] == 'sigv4a'
59
- auth_scheme['signingRegionSet'] ||= ['*']
60
- else
61
- auth_scheme['signingRegion'] ||= config.region
62
- end
63
- end
64
- auth_scheme
65
- end
66
-
67
- def default_api_authtype(context)
117
+ def legacy_default_api_authtype(context)
68
118
  context.config.api.operation(context.operation_name)['authtype'] ||
69
119
  context.config.api.metadata['signatureVersion']
70
120
  end
71
121
 
72
- def sigv4_name(config)
73
- config.api.metadata['signingName'] ||
74
- config.api.metadata['endpointPrefix']
75
- end
76
122
  end
77
123
  end
78
124
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ class ErrorHandler < Seahorse::Client::Handler
5
+
6
+ private
7
+
8
+ def error(context)
9
+ body = context.http_response.body_contents
10
+ if body.empty?
11
+ code, message, data = http_status_error(context)
12
+ else
13
+ code, message, data = extract_error(body, context)
14
+ end
15
+ build_error(context, code, message, data)
16
+ end
17
+
18
+ def build_error(context, code, message, data)
19
+ errors_module = context.client.class.errors_module
20
+ errors_module.error_class(code).new(context, message, data)
21
+ end
22
+
23
+ def http_status_error(context)
24
+ [http_status_error_code(context), '', EmptyStructure.new]
25
+ end
26
+
27
+ def http_status_error_code(context)
28
+ status_code = context.http_response.status_code
29
+ {
30
+ 302 => 'MovedTemporarily',
31
+ 304 => 'NotModified',
32
+ 400 => 'BadRequest',
33
+ 403 => 'Forbidden',
34
+ 404 => 'NotFound',
35
+ 412 => 'PreconditionFailed',
36
+ 413 => 'RequestEntityTooLarge',
37
+ }[status_code] || "Http#{status_code}Error"
38
+ end
39
+
40
+ end
41
+ end
@@ -236,6 +236,15 @@ module Aws
236
236
  end
237
237
  end
238
238
 
239
+ # Raised when a client is constructed and the sigv4a region set is invalid.
240
+ # It is invalid when it is empty and/or contains empty strings.
241
+ class InvalidRegionSetError < ArgumentError
242
+ def initialize(*args)
243
+ msg = 'The provided sigv4a region set was empty or invalid.'
244
+ super(msg)
245
+ end
246
+ end
247
+
239
248
  # Raised when a client is contsructed and the region is not valid.
240
249
  class InvalidRegionError < ArgumentError
241
250
  def initialize(*args)
@@ -2,10 +2,8 @@
2
2
 
3
3
  module Aws
4
4
  module Json
5
- class ErrorHandler < Xml::ErrorHandler
5
+ class ErrorHandler < Aws::ErrorHandler
6
6
 
7
- # @param [Seahorse::Client::RequestContext] context
8
- # @return [Seahorse::Client::Response]
9
7
  def call(context)
10
8
  @handler.call(context).on(300..599) do |response|
11
9
  response.error = error(context)
@@ -19,7 +17,7 @@ module Aws
19
17
  json = Json.load(body)
20
18
  code = error_code(json, context)
21
19
  message = error_message(code, json)
22
- data = parse_error_data(context, code)
20
+ data = parse_error_data(context, body, code)
23
21
  [code, message, data]
24
22
  rescue Json::ParseError
25
23
  [http_status_error_code(context), '', EmptyStructure.new]
@@ -48,7 +46,7 @@ module Aws
48
46
  end
49
47
 
50
48
  def remove_prefix(error_code, context)
51
- if prefix = context.config.api.metadata['errorPrefix']
49
+ if (prefix = context.config.api.metadata['errorPrefix'])
52
50
  error_code.sub(/^#{prefix}/, '')
53
51
  else
54
52
  error_code
@@ -63,9 +61,9 @@ module Aws
63
61
  end
64
62
  end
65
63
 
66
- def parse_error_data(context, code)
64
+ def parse_error_data(context, body, code)
67
65
  data = EmptyStructure.new
68
- if error_rules = context.operation.errors
66
+ if (error_rules = context.operation.errors)
69
67
  error_rules.each do |rule|
70
68
  # match modeled shape name with the type(code) only
71
69
  # some type(code) might contains invalid characters
@@ -73,7 +71,7 @@ module Aws
73
71
  match = rule.shape.name == code.gsub(/[^^a-zA-Z0-9]/, '')
74
72
  next unless match && rule.shape.members.any?
75
73
 
76
- data = Parser.new(rule).parse(context.http_response.body_contents)
74
+ data = Parser.new(rule).parse(body)
77
75
  # errors support HTTP bindings
78
76
  apply_error_headers(rule, context, data)
79
77
  end
@@ -12,8 +12,7 @@ module Aws
12
12
  build_request(context)
13
13
  response = @handler.call(context)
14
14
  response.on(200..299) { |resp| parse_response(resp) }
15
- response.on(200..599) { |resp| apply_request_id(context) }
16
- response
15
+ response.on(200..599) { |_resp| apply_request_id(context) }
17
16
  end
18
17
 
19
18
  private
@@ -38,10 +37,10 @@ module Aws
38
37
  end
39
38
 
40
39
  def parse_body(context)
40
+ json = context.http_response.body_contents
41
41
  if simple_json?(context)
42
- Json.load(context.http_response.body_contents)
43
- elsif rules = context.operation.output
44
- json = context.http_response.body_contents
42
+ Json.load(json)
43
+ elsif (rules = context.operation.output)
45
44
  if json.is_a?(Array)
46
45
  # an array of emitted events
47
46
  if json[0].respond_to?(:response)
@@ -62,7 +61,7 @@ module Aws
62
61
  Parser.new(
63
62
  rules,
64
63
  query_compatible: query_compatible?(context)
65
- ).parse(json == '' ? '{}' : json)
64
+ ).parse(json)
66
65
  end
67
66
  else
68
67
  EmptyStructure.new
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
4
+
3
5
  module Aws
4
6
  module Json
5
- module JSONEngine
7
+ module JsonEngine
6
8
  class << self
7
9
  def load(json)
8
10
  JSON.parse(json)
@@ -1,10 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'oj'
4
+
3
5
  module Aws
4
6
  module Json
5
7
  module OjEngine
6
8
  # @api private
7
- LOAD_OPTIONS = { mode: :compat, symbol_keys: false, empty_string: false }.freeze
9
+ LOAD_OPTIONS = {
10
+ mode: :compat,
11
+ symbol_keys: false,
12
+ empty_string: false
13
+ }.freeze
8
14
 
9
15
  # @api private
10
16
  DUMP_OPTIONS = { mode: :compat }.freeze
@@ -17,6 +17,8 @@ module Aws
17
17
 
18
18
  # @param [String<JSON>] json
19
19
  def parse(json, target = nil)
20
+ json = '{}' if json.empty?
21
+
20
22
  parse_ref(@rules, Json.load(json), target)
21
23
  end
22
24
 
@@ -1,12 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'json'
4
3
  require_relative 'json/builder'
5
4
  require_relative 'json/error_handler'
6
5
  require_relative 'json/handler'
7
6
  require_relative 'json/parser'
8
- require_relative 'json/json_engine'
9
- require_relative 'json/oj_engine'
10
7
 
11
8
  module Aws
12
9
  # @api private
@@ -21,29 +18,61 @@ module Aws
21
18
  end
22
19
 
23
20
  class << self
24
- def load(json)
25
- ENGINE.load(json)
21
+ # @param [Symbol,Class] engine
22
+ # Must be one of the following values:
23
+ #
24
+ # * :oj
25
+ # * :json
26
+ #
27
+ def engine=(engine)
28
+ @engine = Class === engine ? engine : load_engine(engine)
29
+ end
30
+
31
+ # @return [Class] Returns the default engine.
32
+ # One of:
33
+ #
34
+ # * {OjEngine}
35
+ # * {JsonEngine}
36
+ #
37
+ def engine
38
+ set_default_engine unless @engine
39
+ @engine
26
40
  end
27
41
 
28
- def load_file(path)
29
- load(File.open(path, 'r', encoding: 'UTF-8', &:read))
42
+ def load(json)
43
+ @engine.load(json)
30
44
  end
31
45
 
32
46
  def dump(value)
33
- ENGINE.dump(value)
47
+ @engine.dump(value)
48
+ end
49
+
50
+ def set_default_engine
51
+ [:oj, :json].each do |name|
52
+ @engine ||= try_load_engine(name)
53
+ end
54
+ unless @engine
55
+ raise 'Unable to find a compatible json library. ' \
56
+ 'Ensure that you have installed or added to your Gemfile one of ' \
57
+ 'oj or json'
58
+ end
34
59
  end
35
60
 
36
61
  private
37
62
 
38
- def select_engine
39
- require 'oj'
40
- OjEngine
63
+ def load_engine(name)
64
+ require "aws-sdk-core/json/#{name}_engine"
65
+ const_name = name[0].upcase + name[1..-1] + 'Engine'
66
+ const_get(const_name)
67
+ end
68
+
69
+ def try_load_engine(name)
70
+ load_engine(name)
41
71
  rescue LoadError
42
- JSONEngine
72
+ false
43
73
  end
44
74
  end
45
75
 
46
- # @api private
47
- ENGINE = select_engine
76
+ set_default_engine
48
77
  end
49
78
  end
@@ -4,6 +4,8 @@ module Aws
4
4
  # @api private
5
5
  module Plugins
6
6
  # @api private
7
+ # Deprecated - does not look at new traits like `auth` and `unsignedPayload`
8
+ # Necessary to exist after endpoints 2.0 for old service clients + new core
7
9
  class BearerAuthorization < Seahorse::Client::Plugin
8
10
 
9
11
  option(:token_provider,
@@ -238,7 +238,8 @@ module Aws
238
238
 
239
239
  # determine where (header vs trailer) a request checksum should be added
240
240
  def checksum_request_in(context)
241
- if context.operation['authtype'].eql?('v4-unsigned-body')
241
+ if context.operation['unsignedPayload'] ||
242
+ context.operation['authtype'] == 'v4-unsigned-body'
242
243
  'trailer'
243
244
  else
244
245
  'header'
@@ -43,7 +43,7 @@ module Aws
43
43
  # @api private
44
44
  class GlobalConfiguration < Seahorse::Client::Plugin
45
45
 
46
- @identifiers = Set.new()
46
+ @identifiers = Set.new
47
47
 
48
48
  # @api private
49
49
  def before_initialize(client_class, options)
@@ -55,17 +55,18 @@ module Aws
55
55
  private
56
56
 
57
57
  def apply_service_defaults(client_class, options)
58
- if defaults = Aws.config[client_class.identifier]
59
- defaults.each do |option_name, default|
60
- options[option_name] = default unless options.key?(option_name)
61
- end
58
+ return unless (defaults = Aws.config[client_class.identifier])
59
+
60
+ defaults.each do |option_name, default|
61
+ options[option_name] = default unless options.key?(option_name)
62
62
  end
63
63
  end
64
64
 
65
- def apply_aws_defaults(client_class, options)
65
+ def apply_aws_defaults(_client_class, options)
66
66
  Aws.config.each do |option_name, default|
67
67
  next if self.class.identifiers.include?(option_name)
68
68
  next if options.key?(option_name)
69
+
69
70
  options[option_name] = default
70
71
  end
71
72
  end
@@ -80,9 +81,7 @@ module Aws
80
81
 
81
82
  # @return [Set<String>]
82
83
  # @api private
83
- def identifiers
84
- @identifiers
85
- end
84
+ attr_reader :identifiers
86
85
 
87
86
  end
88
87
  end
@@ -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