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
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module RpcV2
5
+ class Handler < Seahorse::Client::Handler
6
+ # @param [Seahorse::Client::RequestContext] context
7
+ # @return [Seahorse::Client::Response]
8
+ def call(context)
9
+ build_request(context)
10
+ response = @handler.call(context)
11
+ response.on(200..299) { |resp| resp.data = parse_body(context) }
12
+ response.on(200..599) { |_resp| apply_request_id(context) }
13
+ response
14
+ end
15
+
16
+ private
17
+
18
+ def build_request(context)
19
+ context.http_request.headers['smithy-protocol'] = 'rpc-v2-cbor'
20
+ context.http_request.http_method = 'POST'
21
+ context.http_request.body = build_body(context)
22
+ build_url(context)
23
+ end
24
+
25
+ def build_url(context)
26
+ base = context.http_request.endpoint
27
+ service_name = context.config.api.metadata['targetPrefix']
28
+ base.path += "/service/#{service_name}/operation/#{context.operation.name}"
29
+ end
30
+
31
+ def build_body(context)
32
+ Builder.new(context.operation.input).serialize(context.params)
33
+ end
34
+
35
+ def parse_body(context)
36
+ cbor = context.http_response.body_contents
37
+ if (rules = context.operation.output)
38
+ if cbor.is_a?(Array)
39
+ # an array of emitted events
40
+ if cbor[0].respond_to?(:response)
41
+ # initial response exists
42
+ # it must be the first event arrived
43
+ resp_struct = cbor.shift.response
44
+ else
45
+ resp_struct = context.operation.output.shape.struct_class.new
46
+ end
47
+
48
+ rules.shape.members.each do |name, ref|
49
+ if ref.eventstream
50
+ resp_struct.send("#{name}=", cbor.to_enum)
51
+ end
52
+ end
53
+ resp_struct
54
+ else
55
+ Parser.new(
56
+ rules,
57
+ query_compatible: query_compatible?(context)
58
+ ).parse(cbor)
59
+ end
60
+ else
61
+ EmptyStructure.new
62
+ end
63
+ end
64
+
65
+ def apply_request_id(context)
66
+ context[:request_id] = context.http_response.headers['x-amzn-requestid']
67
+ end
68
+
69
+ def query_compatible?(context)
70
+ context.config.api.metadata.key?('awsQueryCompatible')
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+
5
+ module Aws
6
+ module RpcV2
7
+ class Parser
8
+ include Seahorse::Model::Shapes
9
+
10
+ # @param [Seahorse::Model::ShapeRef] rules
11
+ def initialize(rules, query_compatible: false)
12
+ @rules = rules
13
+ @query_compatible = query_compatible
14
+ end
15
+
16
+ def parse(cbor, target = nil)
17
+ return {} if cbor.empty?
18
+
19
+ parse_ref(@rules, Cbor.decode(cbor), target)
20
+ end
21
+
22
+ private
23
+
24
+ def structure(ref, values, target = nil)
25
+ shape = ref.shape
26
+ target = ref.shape.struct_class.new if target.nil?
27
+ values.each do |key, value|
28
+ member_name, member_ref = shape.member_by_location_name(key)
29
+ if member_ref
30
+ target[member_name] = parse_ref(member_ref, value)
31
+ elsif shape.union && key != '__type'
32
+ target[:unknown] = { 'name' => key, 'value' => value }
33
+ end
34
+ end
35
+ # In services that were previously Query/XML, members that were
36
+ # "flattened" defaulted to empty lists. In JSON, these values are nil,
37
+ # which is backwards incompatible. To preserve backwards compatibility,
38
+ # we set a default value of [] for these members.
39
+ if @query_compatible
40
+ ref.shape.members.each do |member_name, member_target|
41
+ next unless target[member_name].nil?
42
+
43
+ if flattened_list?(member_target.shape)
44
+ target[member_name] = []
45
+ elsif flattened_map?(member_target.shape)
46
+ target[member_name] = {}
47
+ end
48
+ end
49
+ end
50
+
51
+ if shape.union
52
+ # convert to subclass
53
+ member_subclass = shape.member_subclass(target.member).new
54
+ member_subclass[target.member] = target.value
55
+ target = member_subclass
56
+ end
57
+ target
58
+ end
59
+
60
+ def list(ref, values, target = nil)
61
+ target = [] if target.nil?
62
+ values.each do |value|
63
+ target << parse_ref(ref.shape.member, value)
64
+ end
65
+ target
66
+ end
67
+
68
+ def map(ref, values, target = nil)
69
+ target = {} if target.nil?
70
+ values.each do |key, value|
71
+ target[key] = parse_ref(ref.shape.value, value) unless value.nil?
72
+ end
73
+ target
74
+ end
75
+
76
+ def parse_ref(ref, value, target = nil)
77
+ if value.nil?
78
+ nil
79
+ else
80
+ case ref.shape
81
+ when StructureShape then structure(ref, value, target)
82
+ when ListShape then list(ref, value, target)
83
+ when MapShape then map(ref, value, target)
84
+ else value
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'cbor'
2
+ require_relative 'rpc_v2/handler'
3
+ require_relative 'rpc_v2/content_type_handler'
4
+ require_relative 'rpc_v2/error_handler'
5
+ require_relative 'rpc_v2/builder'
6
+ require_relative 'rpc_v2/parser'
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Stubbing
5
+ module Protocols
6
+ class RpcV2
7
+
8
+ def stub_data(api, operation, data)
9
+ resp = Seahorse::Client::Http::Response.new
10
+ resp.status_code = 200
11
+ resp.headers['Content-Type'] = content_type(api)
12
+ resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
13
+ resp.body = build_body(operation, data)
14
+ resp
15
+ end
16
+
17
+ def stub_error(error_code)
18
+ http_resp = Seahorse::Client::Http::Response.new
19
+ http_resp.status_code = 400
20
+ http_resp.body = <<-JSON.strip
21
+ {
22
+ "code": #{error_code.inspect},
23
+ "message": "stubbed-response-error-message"
24
+ }
25
+ JSON
26
+ http_resp
27
+ end
28
+
29
+ private
30
+
31
+ def content_type(api)
32
+ 'application/cbor'
33
+ end
34
+
35
+ def build_body(operation, data)
36
+ Aws::RpcV2::Builder.new(operation.output).serialize(data)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -67,6 +67,45 @@ module Aws
67
67
  end
68
68
  end
69
69
 
70
+ # @param [Number] input
71
+ # @return [Number, String] The serialized number
72
+ def serialize_number(input)
73
+ if input == ::Float::INFINITY then 'Infinity'
74
+ elsif input == -::Float::INFINITY then '-Infinity'
75
+ elsif input&.nan? then 'NaN'
76
+ else
77
+ input
78
+ end
79
+ end
80
+
81
+ # @param [String] str
82
+ # @return [Number] The input as a number
83
+ def deserialize_number(str)
84
+ case str
85
+ when 'Infinity' then ::Float::INFINITY
86
+ when '-Infinity' then -::Float::INFINITY
87
+ when 'NaN' then ::Float::NAN
88
+ when nil then nil
89
+ else str.to_f
90
+ end
91
+ end
92
+
93
+ # @param [String] value
94
+ # @return [Time]
95
+ def deserialize_time(value)
96
+ case value
97
+ when nil then nil
98
+ when /^[\d.]+$/ then Time.at(value.to_f).utc
99
+ else
100
+ begin
101
+ fractional_time = Time.parse(value).to_f
102
+ Time.at(fractional_time).utc
103
+ rescue ArgumentError
104
+ raise "unhandled timestamp format `#{value}'"
105
+ end
106
+ end
107
+ end
108
+
70
109
  end
71
110
  end
72
111
  end
@@ -62,7 +62,7 @@ module Aws
62
62
  def send_request(options)
63
63
  req = options[:client].build_request(@operation_name, options[:params])
64
64
  req.handlers.remove(RAISE_HANDLER)
65
- Aws::Plugins::UserAgent.feature('waiter') do
65
+ Aws::Plugins::UserAgent.metric('WAITER') do
66
66
  req.send_request
67
67
  end
68
68
  end
@@ -97,7 +97,7 @@ module Aws
97
97
 
98
98
  def matches_error?(acceptor, response)
99
99
  Aws::Errors::ServiceError === response.error &&
100
- response.error.code == acceptor['expected'].gsub('.', '')
100
+ response.error.code == acceptor['expected'].delete('.')
101
101
  end
102
102
 
103
103
  def path(acceptor)
@@ -10,6 +10,8 @@ module Aws
10
10
 
11
11
  def initialize(rules, options = {})
12
12
  @rules = rules
13
+ @location_name =
14
+ options[:location_name].nil? ? @rules.location_name : options[:location_name]
13
15
  @xml = options[:target] || []
14
16
  indent = options[:indent] || ''
15
17
  pad = options[:pad] || ''
@@ -17,7 +19,7 @@ module Aws
17
19
  end
18
20
 
19
21
  def to_xml(params)
20
- structure(@rules.location_name, @rules, params)
22
+ structure(@location_name, @rules, params)
21
23
  @xml.join
22
24
  end
23
25
  alias serialize to_xml
@@ -50,7 +52,7 @@ module Aws
50
52
  def list(name, ref, values)
51
53
  if ref[:flattened] || ref.shape.flattened
52
54
  values.each do |value|
53
- member(ref.shape.member.location_name || name, ref.shape.member, value)
55
+ member(name, ref.shape.member, value)
54
56
  end
55
57
  else
56
58
  node(name, ref) do
@@ -65,7 +67,7 @@ module Aws
65
67
  def map(name, ref, hash)
66
68
  key_ref = ref.shape.key
67
69
  value_ref = ref.shape.value
68
- if ref.shape.flattened
70
+ if ref[:flattened] || ref.shape.flattened
69
71
  hash.each do |key, value|
70
72
  node(name, ref) do
71
73
  member(key_ref.location_name || 'key', key_ref, key)
@@ -75,7 +77,8 @@ module Aws
75
77
  else
76
78
  node(name, ref) do
77
79
  hash.each do |key, value|
78
- node('entry', ref) do
80
+ # Pass in a new ShapeRef to create an entry node
81
+ node('entry', ShapeRef.new) do
79
82
  member(key_ref.location_name || 'key', key_ref, key)
80
83
  member(value_ref.location_name || 'value', value_ref, value)
81
84
  end
@@ -129,11 +132,16 @@ module Aws
129
132
  end
130
133
 
131
134
  def shape_attrs(ref)
132
- if xmlns = ref['xmlNamespace']
133
- if prefix = xmlns['prefix']
134
- { 'xmlns:' + prefix => xmlns['uri'] }
135
- else
136
- { 'xmlns' => xmlns['uri'] }
135
+ if (xmlns = ref['xmlNamespace'])
136
+ case xmlns
137
+ when String
138
+ { 'xmlns' => xmlns }
139
+ when Hash
140
+ if (prefix = xmlns['prefix'])
141
+ { "xmlns:#{prefix}" => xmlns['uri'] }
142
+ else
143
+ { 'xmlns' => xmlns['uri'] }
144
+ end
137
145
  end
138
146
  else
139
147
  {}
@@ -4,7 +4,7 @@ require 'cgi'
4
4
 
5
5
  module Aws
6
6
  module Xml
7
- class ErrorHandler < Seahorse::Client::Handler
7
+ class ErrorHandler < Aws::ErrorHandler
8
8
 
9
9
  def call(context)
10
10
  @handler.call(context).on(300..599) do |response|
@@ -15,42 +15,29 @@ module Aws
15
15
 
16
16
  private
17
17
 
18
- def error(context)
19
- body = context.http_response.body_contents
20
- if body.empty?
21
- code = http_status_error_code(context)
22
- message = ''
23
- data = EmptyStructure.new
24
- else
25
- code, message, data = extract_error(body, context)
26
- end
27
- context[:request_id] = request_id(body)
28
- errors_module = context.client.class.errors_module
29
- error_class = errors_module.error_class(code).new(context, message, data)
30
- error_class
31
- end
32
-
33
18
  def extract_error(body, context)
19
+ context[:request_id] = request_id(body)
34
20
  code = error_code(body, context)
35
21
  [
36
22
  code,
37
23
  error_message(body),
38
- error_data(context, code)
24
+ error_data(context, body, code)
39
25
  ]
40
26
  end
41
27
 
42
- def error_data(context, code)
28
+ def error_data(context, body, code)
43
29
  data = EmptyStructure.new
44
- if error_rules = context.operation.errors
30
+ if (error_rules = context.operation.errors)
45
31
  error_rules.each do |rule|
46
- # for modeled shape with error trait
47
- # match `code` in the error trait before
48
- # match modeled shape name
32
+ # query protocol may have custom error code
33
+ # reference: https://smithy.io/2.0/aws/protocols/aws-query-protocol.html#error-code-resolution
49
34
  error_shape_code = rule.shape['error']['code'] if rule.shape['error']
50
35
  match = (code == error_shape_code || code == rule.shape.name)
51
- if match && rule.shape.members.any?
52
- data = Parser.new(rule).parse(context.http_response.body_contents)
53
- end
36
+ next unless match && rule.shape.members.any?
37
+
38
+ data = parse_error_data(rule, body)
39
+ # supporting HTTP bindings
40
+ apply_error_headers(rule, context, data)
54
41
  end
55
42
  end
56
43
  data
@@ -58,29 +45,32 @@ module Aws
58
45
  EmptyStructure.new
59
46
  end
60
47
 
48
+ def parse_error_data(rule, body)
49
+ # errors may nested under <Errors><Error>structure_data</Error></Errors>
50
+ # Or may be flat and under <Error>structure_data</Error>
51
+ body = body.tr("\n", '')
52
+ if (matches = body.match(/<Error>(.+?)<\/Error>/))
53
+ Parser.new(rule).parse("<#{rule.shape.name}>#{matches[1]}</#{rule.shape.name}>")
54
+ else
55
+ EmptyStructure.new
56
+ end
57
+ end
58
+
59
+ def apply_error_headers(rule, context, data)
60
+ headers = Aws::Rest::Response::Headers.new(rule)
61
+ headers.apply(context.http_response, data)
62
+ end
63
+
61
64
  def error_code(body, context)
62
- if matches = body.match(/<Code>(.+?)<\/Code>/)
65
+ if (matches = body.match(/<Code>(.+?)<\/Code>/))
63
66
  remove_prefix(unescape(matches[1]), context)
64
67
  else
65
68
  http_status_error_code(context)
66
69
  end
67
70
  end
68
71
 
69
- def http_status_error_code(context)
70
- status_code = context.http_response.status_code
71
- {
72
- 302 => 'MovedTemporarily',
73
- 304 => 'NotModified',
74
- 400 => 'BadRequest',
75
- 403 => 'Forbidden',
76
- 404 => 'NotFound',
77
- 412 => 'PreconditionFailed',
78
- 413 => 'RequestEntityTooLarge',
79
- }[status_code] || "Http#{status_code}Error"
80
- end
81
-
82
72
  def remove_prefix(error_code, context)
83
- if prefix = context.config.api.metadata['errorPrefix']
73
+ if (prefix = context.config.api.metadata['errorPrefix'])
84
74
  error_code.sub(/^#{prefix}/, '')
85
75
  else
86
76
  error_code
@@ -88,7 +78,7 @@ module Aws
88
78
  end
89
79
 
90
80
  def error_message(body)
91
- if matches = body.match(/<Message>(.+?)<\/Message>/m)
81
+ if (matches = body.match(/<Message>(.+?)<\/Message>/m))
92
82
  unescape(matches[1])
93
83
  else
94
84
  ''
@@ -96,7 +86,7 @@ module Aws
96
86
  end
97
87
 
98
88
  def request_id(body)
99
- if matches = body.match(/<RequestId>(.+?)<\/RequestId>/m)
89
+ if (matches = body.match(/<RequestId>(.+?)<\/RequestId>/m))
100
90
  matches[1]
101
91
  end
102
92
  end
@@ -138,11 +138,7 @@ module Aws
138
138
  end
139
139
 
140
140
  def xml_name(ref)
141
- if flattened_list?(ref)
142
- ref.shape.member.location_name || ref.location_name
143
- else
144
- ref.location_name
145
- end
141
+ ref.location_name
146
142
  end
147
143
 
148
144
  def flattened_list?(ref)
@@ -266,7 +262,7 @@ module Aws
266
262
 
267
263
  class BlobFrame < Frame
268
264
  def result
269
- @text.empty? ? nil : Base64.decode64(@text.join)
265
+ @text.empty? ? '' : Base64.decode64(@text.join)
270
266
  end
271
267
  end
272
268
 
@@ -278,7 +274,7 @@ module Aws
278
274
 
279
275
  class FloatFrame < Frame
280
276
  def result
281
- @text.empty? ? nil : @text.join.to_f
277
+ @text.empty? ? nil : Aws::Util.deserialize_number(@text.join)
282
278
  end
283
279
  end
284
280
 
@@ -296,19 +292,7 @@ module Aws
296
292
 
297
293
  class TimestampFrame < Frame
298
294
  def result
299
- @text.empty? ? nil : parse(@text.join)
300
- end
301
- def parse(value)
302
- case value
303
- when nil then nil
304
- when /^\d+$/ then Time.at(value.to_i)
305
- else
306
- begin
307
- Time.parse(value).utc
308
- rescue ArgumentError
309
- raise "unhandled timestamp format `#{value}'"
310
- end
311
- end
295
+ @text.empty? ? nil : Aws::Util.deserialize_time(@text.join)
312
296
  end
313
297
  end
314
298
 
@@ -24,6 +24,8 @@ module Aws
24
24
  if name.to_s == 'encoding' && value.to_s == 'base64'
25
25
  @frame = BlobFrame.new(name, @frame.parent, @frame.ref)
26
26
  else
27
+ # don't try to parse shapes from xml namespace
28
+ return if name.to_s == 'xmlns'
27
29
  start_element(name)
28
30
  text(value)
29
31
  end_element(name)
@@ -5,7 +5,6 @@ module Aws
5
5
  module Xml
6
6
  # A SAX-style XML parser that uses a shape context to handle types.
7
7
  class Parser
8
-
9
8
  # @param [Seahorse::Model::ShapeRef] rules
10
9
  def initialize(rules, options = {})
11
10
  @rules = rules
@@ -47,8 +46,7 @@ module Aws
47
46
  # * :libxml
48
47
  # * :nokogiri
49
48
  # * :rexml
50
- #
51
- def engine= engine
49
+ def engine=(engine)
52
50
  @engine = Class === engine ? engine : load_engine(engine)
53
51
  end
54
52
 
@@ -60,7 +58,6 @@ module Aws
60
58
  # * {LibxmlEngine}
61
59
  # * {NokogiriEngine}
62
60
  # * {RexmlEngine}
63
- #
64
61
  def engine
65
62
  set_default_engine unless @engine
66
63
  @engine
@@ -80,7 +77,7 @@ module Aws
80
77
  private
81
78
 
82
79
  def load_engine(name)
83
- require "aws-sdk-core/xml/parser/engines/#{name}"
80
+ require "aws-sdk-core/xml/parser/#{name}_engine"
84
81
  const_name = name[0].upcase + name[1..-1] + 'Engine'
85
82
  const_get(const_name)
86
83
  end
@@ -94,7 +91,6 @@ module Aws
94
91
  end
95
92
 
96
93
  set_default_engine
97
-
98
94
  end
99
95
  end
100
96
  end
data/lib/aws-sdk-core.rb CHANGED
@@ -63,19 +63,23 @@ require_relative 'aws-sdk-core/stubbing/xml_error'
63
63
 
64
64
  # stubbing protocols
65
65
 
66
- require_relative 'aws-sdk-core/stubbing/protocols/ec2'
67
66
  require_relative 'aws-sdk-core/stubbing/protocols/json'
68
- require_relative 'aws-sdk-core/stubbing/protocols/query'
69
67
  require_relative 'aws-sdk-core/stubbing/protocols/rest'
70
68
  require_relative 'aws-sdk-core/stubbing/protocols/rest_json'
71
69
  require_relative 'aws-sdk-core/stubbing/protocols/rest_xml'
70
+ require_relative 'aws-sdk-core/stubbing/protocols/query'
71
+ require_relative 'aws-sdk-core/stubbing/protocols/ec2'
72
+ require_relative 'aws-sdk-core/stubbing/protocols/rpc_v2'
72
73
  require_relative 'aws-sdk-core/stubbing/protocols/api_gateway'
73
74
 
74
75
  # protocols
75
76
 
77
+ require_relative 'aws-sdk-core/error_handler'
76
78
  require_relative 'aws-sdk-core/rest'
77
79
  require_relative 'aws-sdk-core/xml'
78
80
  require_relative 'aws-sdk-core/json'
81
+ require_relative 'aws-sdk-core/query'
82
+ require_relative 'aws-sdk-core/rpc_v2'
79
83
 
80
84
  # event stream
81
85
 
@@ -96,6 +100,7 @@ require_relative 'aws-sdk-core/client_side_monitoring/publisher'
96
100
  require_relative 'aws-sdk-core/arn'
97
101
  require_relative 'aws-sdk-core/arn_parser'
98
102
  require_relative 'aws-sdk-core/ec2_metadata'
103
+ require_relative 'aws-sdk-core/lru_cache'
99
104
 
100
105
  # dynamic endpoints
101
106
  require_relative 'aws-sdk-core/endpoints'