aws-sdk-core 3.209.1 → 3.220.1

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +119 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +1 -2
  5. data/lib/aws-sdk-core/arn.rb +1 -3
  6. data/lib/aws-sdk-core/cbor/decoder.rb +0 -2
  7. data/lib/aws-sdk-core/cbor/encoder.rb +2 -2
  8. data/lib/aws-sdk-core/cbor.rb +3 -56
  9. data/lib/aws-sdk-core/client_stubs.rb +29 -55
  10. data/lib/aws-sdk-core/endpoints/matchers.rb +1 -8
  11. data/lib/aws-sdk-core/json/error_handler.rb +2 -1
  12. data/lib/aws-sdk-core/json/handler.rb +1 -0
  13. data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
  14. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +332 -170
  15. data/lib/aws-sdk-core/plugins/http_checksum.rb +2 -8
  16. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +44 -25
  17. data/lib/aws-sdk-core/plugins/sign.rb +1 -1
  18. data/lib/aws-sdk-core/plugins/stub_responses.rb +24 -8
  19. data/lib/aws-sdk-core/plugins/user_agent.rb +10 -1
  20. data/lib/aws-sdk-core/rest/request/headers.rb +2 -2
  21. data/lib/aws-sdk-core/rpc_v2/builder.rb +1 -1
  22. data/lib/aws-sdk-core/{cbor → rpc_v2}/cbor_engine.rb +4 -5
  23. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +3 -1
  24. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +3 -2
  25. data/lib/aws-sdk-core/rpc_v2/handler.rb +2 -1
  26. data/lib/aws-sdk-core/rpc_v2/parser.rb +1 -1
  27. data/lib/aws-sdk-core/rpc_v2.rb +65 -2
  28. data/lib/aws-sdk-core/shared_config.rb +2 -0
  29. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
  30. data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
  31. data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
  32. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
  33. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
  34. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
  35. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +13 -15
  36. data/lib/aws-sdk-core/stubbing.rb +2 -2
  37. data/lib/aws-sdk-sso/client.rb +52 -29
  38. data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
  39. data/lib/aws-sdk-sso/endpoint_provider.rb +14 -18
  40. data/lib/aws-sdk-sso/endpoints.rb +2 -42
  41. data/lib/aws-sdk-sso/plugins/endpoints.rb +1 -14
  42. data/lib/aws-sdk-sso.rb +1 -1
  43. data/lib/aws-sdk-ssooidc/client.rb +76 -47
  44. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
  45. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +14 -18
  46. data/lib/aws-sdk-ssooidc/endpoints.rb +2 -42
  47. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +1 -14
  48. data/lib/aws-sdk-ssooidc/types.rb +20 -15
  49. data/lib/aws-sdk-ssooidc.rb +1 -1
  50. data/lib/aws-sdk-sts/client.rb +260 -81
  51. data/lib/aws-sdk-sts/client_api.rb +23 -0
  52. data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
  53. data/lib/aws-sdk-sts/endpoint_provider.rb +33 -38
  54. data/lib/aws-sdk-sts/endpoints.rb +2 -94
  55. data/lib/aws-sdk-sts/errors.rb +16 -0
  56. data/lib/aws-sdk-sts/plugins/endpoints.rb +1 -22
  57. data/lib/aws-sdk-sts/types.rb +170 -28
  58. data/lib/aws-sdk-sts.rb +1 -1
  59. data/lib/seahorse/client/net_http/connection_pool.rb +2 -0
  60. data/lib/seahorse/client/response.rb +2 -0
  61. metadata +25 -11
@@ -20,7 +20,7 @@ a default `:region` is searched for in the following locations:
20
20
  * `ENV['AWS_DEFAULT_REGION']`
21
21
  * `~/.aws/credentials`
22
22
  * `~/.aws/config`
23
- DOCS
23
+ DOCS
24
24
  resolve_region(cfg)
25
25
  end
26
26
 
@@ -35,7 +35,7 @@ in the following locations:
35
35
  * `Aws.config[:sigv4a_signing_region_set]`
36
36
  * `ENV['AWS_SIGV4A_SIGNING_REGION_SET']`
37
37
  * `~/.aws/config`
38
- DOCS
38
+ DOCS
39
39
  resolve_sigv4a_signing_region_set(cfg)
40
40
  end
41
41
 
@@ -44,7 +44,7 @@ in the following locations:
44
44
  docstring: <<-DOCS) do |cfg|
45
45
  When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
46
46
  will be used if available.
47
- DOCS
47
+ DOCS
48
48
  resolve_use_dualstack_endpoint(cfg)
49
49
  end
50
50
 
@@ -54,7 +54,7 @@ will be used if available.
54
54
  When set to `true`, fips compatible endpoints will be used if available.
55
55
  When a `fips` region is used, the region is normalized and this config
56
56
  is set to `true`.
57
- DOCS
57
+ DOCS
58
58
  resolve_use_fips_endpoint(cfg)
59
59
  end
60
60
 
@@ -67,7 +67,7 @@ is set to `true`.
67
67
  docstring: <<-DOCS) do |cfg|
68
68
  Setting to true disables use of endpoint URLs provided via environment
69
69
  variables and the shared configuration file.
70
- DOCS
70
+ DOCS
71
71
  resolve_ignore_configured_endpoint_urls(cfg)
72
72
  end
73
73
 
@@ -75,7 +75,7 @@ variables and the shared configuration file.
75
75
  The client endpoint is normally constructed from the `:region`
76
76
  option. You should only configure an `:endpoint` when connecting
77
77
  to test or custom endpoints. This should be a valid HTTP(S) URI.
78
- DOCS
78
+ DOCS
79
79
  resolve_endpoint(cfg)
80
80
  end
81
81
 
@@ -83,6 +83,9 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
83
83
  region = client.config.region
84
84
  raise Errors::MissingRegionError if region.nil? || region == ''
85
85
 
86
+ # resolve a default endpoint to preserve legacy behavior
87
+ initialize_default_endpoint(client) if client.config.endpoint.nil?
88
+
86
89
  region_set = client.config.sigv4a_signing_region_set
87
90
  return if region_set.nil?
88
91
  raise Errors::InvalidRegionSetError unless region_set.is_a?(Array)
@@ -93,6 +96,39 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
93
96
  client.config.sigv4a_signing_region_set = region_set
94
97
  end
95
98
 
99
+ private
100
+
101
+ def initialize_default_endpoint(client)
102
+ client_module = Object.const_get(client.class.name.rpartition('::').first)
103
+ param_class = client_module.const_get(:EndpointParameters)
104
+ endpoint_provider = client.config.endpoint_provider
105
+ params = param_class.create(client.config)
106
+ endpoint = endpoint_provider.resolve_endpoint(params)
107
+ client.config.endpoint = endpoint.url
108
+ rescue ArgumentError, NameError
109
+ # fallback to legacy
110
+ client.config.endpoint = resolve_legacy_endpoint(client.config)
111
+ end
112
+
113
+ # set a default endpoint in config using legacy (endpoints.json) resolver
114
+ def resolve_legacy_endpoint(cfg)
115
+ endpoint_prefix = cfg.api.metadata['endpointPrefix']
116
+ if cfg.respond_to?(:sts_regional_endpoints)
117
+ sts_regional = cfg.sts_regional_endpoints
118
+ end
119
+
120
+ endpoint = Aws::Partitions::EndpointProvider.resolve(
121
+ cfg.region,
122
+ endpoint_prefix,
123
+ sts_regional,
124
+ {
125
+ dualstack: cfg.use_dualstack_endpoint,
126
+ fips: cfg.use_fips_endpoint
127
+ }
128
+ )
129
+ URI(endpoint)
130
+ end
131
+
96
132
  class << self
97
133
  private
98
134
 
@@ -150,7 +186,8 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
150
186
  # that a custom endpoint has NOT been configured by the user
151
187
  cfg.override_config(:regional_endpoint, true)
152
188
 
153
- resolve_legacy_endpoint(cfg)
189
+ # a default endpoint is resolved in after_initialize
190
+ nil
154
191
  end
155
192
 
156
193
  # get a custom configured endpoint from ENV or configuration
@@ -205,24 +242,6 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
205
242
  cfg.override_config(:region, new_region)
206
243
  end
207
244
  end
208
-
209
- # set a default endpoint in config using legacy (endpoints.json) resolver
210
- def resolve_legacy_endpoint(cfg)
211
- endpoint_prefix = cfg.api.metadata['endpointPrefix']
212
- if cfg.respond_to?(:sts_regional_endpoints)
213
- sts_regional = cfg.sts_regional_endpoints
214
- end
215
-
216
- Aws::Partitions::EndpointProvider.resolve(
217
- cfg.region,
218
- endpoint_prefix,
219
- sts_regional,
220
- {
221
- dualstack: cfg.use_dualstack_endpoint,
222
- fips: cfg.use_fips_endpoint
223
- }
224
- )
225
- end
226
245
  end
227
246
  end
228
247
  end
@@ -113,7 +113,7 @@ module Aws
113
113
  signing_algorithm: scheme_name.to_sym,
114
114
  uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
115
115
  normalize_path: !!!auth_scheme['disableNormalizePath'],
116
- unsigned_headers: %w[content-length user-agent x-amzn-trace-id]
116
+ unsigned_headers: %w[content-length user-agent x-amzn-trace-id expect transfer-encoding connection]
117
117
  )
118
118
  rescue Aws::Sigv4::Errors::MissingCredentialsError
119
119
  raise Aws::Errors::MissingCredentialsError
@@ -29,8 +29,16 @@ requests are made, and retries are disabled.
29
29
  end
30
30
  end
31
31
 
32
+ option(:stubs) { {} }
33
+ option(:stubs_mutex) { Mutex.new }
34
+ option(:api_requests) { [] }
35
+ option(:api_requests_mutex) { Mutex.new }
36
+
32
37
  def add_handlers(handlers, config)
33
- handlers.add(Handler, step: :send) if config.stub_responses
38
+ return unless config.stub_responses
39
+
40
+ handlers.add(ApiRequestsHandler)
41
+ handlers.add(StubbingHandler, step: :send)
34
42
  end
35
43
 
36
44
  def after_initialize(client)
@@ -46,8 +54,20 @@ requests are made, and retries are disabled.
46
54
  end
47
55
  end
48
56
 
49
- class Handler < Seahorse::Client::Handler
57
+ class ApiRequestsHandler < Seahorse::Client::Handler
58
+ def call(context)
59
+ context.config.api_requests_mutex.synchronize do
60
+ context.config.api_requests << {
61
+ operation_name: context.operation_name,
62
+ params: context.params,
63
+ context: context
64
+ }
65
+ end
66
+ @handler.call(context)
67
+ end
68
+ end
50
69
 
70
+ class StubbingHandler < Seahorse::Client::Handler
51
71
  def call(context)
52
72
  span_wrapper(context) do
53
73
  stub_responses(context)
@@ -57,14 +77,10 @@ requests are made, and retries are disabled.
57
77
  private
58
78
 
59
79
  def stub_responses(context)
60
- stub = context.client.next_stub(context)
61
80
  resp = Seahorse::Client::Response.new(context: context)
62
81
  async_mode = context.client.is_a? Seahorse::Client::AsyncBase
63
- if Hash === stub && stub[:mutex]
64
- stub[:mutex].synchronize { apply_stub(stub, resp, async_mode) }
65
- else
66
- apply_stub(stub, resp, async_mode)
67
- end
82
+ stub = context.client.next_stub(context)
83
+ stub[:mutex].synchronize { apply_stub(stub, resp, async_mode) }
68
84
 
69
85
  if async_mode
70
86
  Seahorse::Client::AsyncResponse.new(
@@ -25,7 +25,16 @@ module Aws
25
25
  "ACCOUNT_ID_MODE_DISABLED": "Q",
26
26
  "ACCOUNT_ID_MODE_REQUIRED": "R",
27
27
  "SIGV4A_SIGNING": "S",
28
- "RESOLVED_ACCOUNT_ID": "T"
28
+ "RESOLVED_ACCOUNT_ID": "T",
29
+ "FLEXIBLE_CHECKSUMS_REQ_CRC32" : "U",
30
+ "FLEXIBLE_CHECKSUMS_REQ_CRC32C" : "V",
31
+ "FLEXIBLE_CHECKSUMS_REQ_CRC64" : "W",
32
+ "FLEXIBLE_CHECKSUMS_REQ_SHA1" : "X",
33
+ "FLEXIBLE_CHECKSUMS_REQ_SHA256" : "Y",
34
+ "FLEXIBLE_CHECKSUMS_REQ_WHEN_SUPPORTED" : "Z",
35
+ "FLEXIBLE_CHECKSUMS_REQ_WHEN_REQUIRED" : "a",
36
+ "FLEXIBLE_CHECKSUMS_RES_WHEN_SUPPORTED" : "b",
37
+ "FLEXIBLE_CHECKSUMS_RES_WHEN_REQUIRED" : "c"
29
38
  }
30
39
  METRICS
31
40
 
@@ -20,7 +20,7 @@ module Aws
20
20
  def apply(http_req, params)
21
21
  @rules.shape.members.each do |name, ref|
22
22
  value = params[name]
23
- next if value.nil? || ((ref.shape).is_a?(StringShape) && value.empty?)
23
+ next if value.nil?
24
24
 
25
25
  case ref.location
26
26
  when 'header' then apply_header_value(http_req.headers, ref, value)
@@ -51,7 +51,7 @@ module Aws
51
51
  end
52
52
 
53
53
  def list(headers, ref, values)
54
- return if !values || values.empty?
54
+ return if values.nil?
55
55
 
56
56
  member_ref = ref.shape.member
57
57
  values = values.collect do |value|
@@ -16,7 +16,7 @@ module Aws
16
16
  # different than if the input shape is a structure with no members.
17
17
  return nil if @rules.shape.struct_class == EmptyStructure
18
18
 
19
- Cbor.encode(format(@rules, params))
19
+ RpcV2.encode(format(@rules, params))
20
20
  end
21
21
 
22
22
  private
@@ -1,18 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'encoder'
4
- require_relative 'decoder'
3
+ require_relative '../cbor'
5
4
 
6
5
  module Aws
7
- module Cbor
6
+ module RpcV2
8
7
  # Pure Ruby implementation of CBOR encode and decode
9
8
  module CborEngine
10
9
  def self.encode(data)
11
- Encoder.new.add(data).bytes
10
+ Cbor::Encoder.new.add(data).bytes
12
11
  end
13
12
 
14
13
  def self.decode(bytes)
15
- Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
14
+ Cbor::Decoder.new(bytes.force_encoding(Encoding::BINARY)).decode
16
15
  end
17
16
  end
18
17
  end
@@ -13,11 +13,13 @@ module Aws
13
13
  accept =
14
14
  if eventstream_output?(context)
15
15
  'application/vnd.amazon.eventstream'
16
+ else
17
+ 'application/cbor'
16
18
  end
17
19
 
18
20
  headers = context.http_request.headers
19
21
  headers['Content-Type'] ||= content_type if content_type
20
- headers['Accept'] ||= accept if accept
22
+ headers['Accept'] ||= accept
21
23
  @handler.call(context)
22
24
  end
23
25
 
@@ -27,7 +27,7 @@ module Aws
27
27
  end
28
28
 
29
29
  def extract_error(body, context)
30
- data = Cbor.decode(body)
30
+ data = RpcV2.decode(body)
31
31
  code = error_code(data, context)
32
32
  message = data['message']
33
33
  data = parse_error_data(context, body, code)
@@ -39,7 +39,8 @@ module Aws
39
39
  def error_code(data, context)
40
40
  code =
41
41
  if aws_query_error?(context)
42
- error = context.http_response.headers['x-amzn-query-error'].split(';')[0]
42
+ query_header = context.http_response.headers['x-amzn-query-error']
43
+ error, _type = query_header.split(';') # type not supported
43
44
  remove_prefix(error, context)
44
45
  else
45
46
  data['__type']
@@ -20,7 +20,8 @@ module Aws
20
20
  end
21
21
 
22
22
  def build_request(context)
23
- context.http_request.headers['smithy-protocol'] = 'rpc-v2-cbor'
23
+ context.http_request.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
24
+ context.http_request.headers['X-Amzn-Query-Mode'] = 'true' if query_compatible?(context)
24
25
  context.http_request.http_method = 'POST'
25
26
  context.http_request.body = build_body(context)
26
27
  build_url(context)
@@ -16,7 +16,7 @@ module Aws
16
16
  def parse(cbor, target = nil)
17
17
  return {} if cbor.empty?
18
18
 
19
- parse_ref(@rules, Cbor.decode(cbor), target)
19
+ parse_ref(@rules, RpcV2.decode(cbor), target)
20
20
  end
21
21
 
22
22
  private
@@ -1,6 +1,69 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'cbor'
2
- require_relative 'rpc_v2/handler'
4
+ require_relative 'rpc_v2/builder'
3
5
  require_relative 'rpc_v2/content_type_handler'
4
6
  require_relative 'rpc_v2/error_handler'
5
- require_relative 'rpc_v2/builder'
7
+ require_relative 'rpc_v2/handler'
6
8
  require_relative 'rpc_v2/parser'
9
+
10
+ module Aws
11
+ # @api private
12
+ module RpcV2
13
+ class << self
14
+ # @param [Symbol,Class] engine
15
+ # Must be one of the following values:
16
+ #
17
+ # * :cbor
18
+ #
19
+ def engine=(engine)
20
+ @engine = Class === engine ? engine : load_engine(engine)
21
+ end
22
+
23
+ # @return [Class] Returns the default engine.
24
+ # One of:
25
+ #
26
+ # * {CborEngine}
27
+ #
28
+ def engine
29
+ set_default_engine unless @engine
30
+ @engine
31
+ end
32
+
33
+ def encode(data)
34
+ @engine.encode(data)
35
+ end
36
+
37
+ def decode(bytes)
38
+ bytes.force_encoding(Encoding::BINARY)
39
+ @engine.decode(bytes)
40
+ end
41
+
42
+ def set_default_engine
43
+ [:cbor].each do |name|
44
+ @engine ||= try_load_engine(name)
45
+ end
46
+
47
+ unless @engine
48
+ raise 'Unable to find a compatible cbor library.'
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def load_engine(name)
55
+ require "aws-sdk-core/rpc_v2/#{name}_engine"
56
+ const_name = name[0].upcase + name[1..-1] + 'Engine'
57
+ const_get(const_name)
58
+ end
59
+
60
+ def try_load_engine(name)
61
+ load_engine(name)
62
+ rescue LoadError
63
+ false
64
+ end
65
+ end
66
+
67
+ set_default_engine
68
+ end
69
+ end
@@ -212,6 +212,8 @@ module Aws
212
212
  :retry_mode,
213
213
  :adaptive_retry_wait_to_fill,
214
214
  :correct_clock_skew,
215
+ :request_checksum_calculation,
216
+ :response_checksum_validation,
215
217
  :csm_client_id,
216
218
  :csm_enabled,
217
219
  :csm_host,
@@ -3,6 +3,7 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class EC2
7
8
 
8
9
  def stub_data(api, operation, data)
@@ -16,17 +17,17 @@ module Aws
16
17
  end
17
18
 
18
19
  def stub_error(error_code)
19
- http_resp = Seahorse::Client::Http::Response.new
20
- http_resp.status_code = 400
21
- http_resp.body = <<-XML.strip
22
- <ErrorResponse>
23
- <Error>
24
- <Code>#{error_code}</Code>
25
- <Message>stubbed-response-error-message</Message>
26
- </Error>
27
- </ErrorResponse>
20
+ resp = Seahorse::Client::Http::Response.new
21
+ resp.status_code = 400
22
+ resp.body = <<~XML.strip
23
+ <ErrorResponse>
24
+ <Error>
25
+ <Code>#{error_code}</Code>
26
+ <Message>stubbed-response-error-message</Message>
27
+ </Error>
28
+ </ErrorResponse>
28
29
  XML
29
- http_resp
30
+ resp
30
31
  end
31
32
 
32
33
  private
@@ -37,7 +38,7 @@ module Aws
37
38
  xml.shift
38
39
  xml.pop
39
40
  xmlns = "http://ec2.amazonaws.com/doc/#{api.version}/".inspect
40
- xml.unshift(" <requestId>stubbed-request-id</requestId>")
41
+ xml.unshift(' <requestId>stubbed-request-id</requestId>')
41
42
  xml.unshift("<#{operation.name}Response xmlns=#{xmlns}>\n")
42
43
  xml.push("</#{operation.name}Response>\n")
43
44
  xml.join
@@ -3,27 +3,28 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class Json
7
8
 
8
9
  def stub_data(api, operation, data)
9
10
  resp = Seahorse::Client::Http::Response.new
10
11
  resp.status_code = 200
11
- resp.headers["Content-Type"] = content_type(api)
12
- resp.headers["x-amzn-RequestId"] = "stubbed-request-id"
12
+ resp.headers['Content-Type'] = content_type(api)
13
+ resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
13
14
  resp.body = build_body(operation, data)
14
15
  resp
15
16
  end
16
17
 
17
18
  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
- }
19
+ resp = Seahorse::Client::Http::Response.new
20
+ resp.status_code = 400
21
+ resp.body = <<~JSON.strip
22
+ {
23
+ "code": #{error_code.inspect},
24
+ "message": "stubbed-response-error-message"
25
+ }
25
26
  JSON
26
- http_resp
27
+ resp
27
28
  end
28
29
 
29
30
  private
@@ -3,6 +3,7 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class Query
7
8
 
8
9
  def stub_data(api, operation, data)
@@ -13,10 +14,10 @@ module Aws
13
14
  end
14
15
 
15
16
  def stub_error(error_code)
16
- http_resp = Seahorse::Client::Http::Response.new
17
- http_resp.status_code = 400
18
- http_resp.body = XmlError.new(error_code).to_xml
19
- http_resp
17
+ resp = Seahorse::Client::Http::Response.new
18
+ resp.status_code = 400
19
+ resp.body = XmlError.new(error_code).to_xml
20
+ resp
20
21
  end
21
22
 
22
23
  private
@@ -24,9 +25,9 @@ module Aws
24
25
  def build_body(api, operation, data)
25
26
  xml = []
26
27
  builder = Aws::Xml::DocBuilder.new(target: xml, indent: ' ')
27
- builder.node(operation.name + 'Response', xmlns: xmlns(api)) do
28
+ builder.node("#{operation.name}Response", xmlns: xmlns(api)) do
28
29
  if (rules = operation.output)
29
- rules.location_name = operation.name + 'Result'
30
+ rules.location_name = "#{operation.name}Result"
30
31
  Xml::Builder.new(rules, target: xml, pad:' ').to_xml(data)
31
32
  end
32
33
  builder.node('ResponseMetadata') do
@@ -5,6 +5,7 @@ require 'aws-eventstream'
5
5
  module Aws
6
6
  module Stubbing
7
7
  module Protocols
8
+ # @api private
8
9
  class Rest
9
10
 
10
11
  include Seahorse::Model::Shapes
@@ -22,7 +23,7 @@ module Aws
22
23
  def new_http_response
23
24
  resp = Seahorse::Client::Http::Response.new
24
25
  resp.status_code = 200
25
- resp.headers["x-amzn-RequestId"] = "stubbed-request-id"
26
+ resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
26
27
  resp
27
28
  end
28
29
 
@@ -3,6 +3,7 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class RestJson < Rest
7
8
 
8
9
  def body_for(_a, _b, rules, data)
@@ -14,15 +15,15 @@ module Aws
14
15
  end
15
16
 
16
17
  def stub_error(error_code)
17
- http_resp = Seahorse::Client::Http::Response.new
18
- http_resp.status_code = 400
19
- http_resp.body = <<-JSON.strip
20
- {
21
- "code": #{error_code.inspect},
22
- "message": "stubbed-response-error-message"
23
- }
18
+ resp = Seahorse::Client::Http::Response.new
19
+ resp.status_code = 400
20
+ resp.body = <<~JSON.strip
21
+ {
22
+ "code": #{error_code.inspect},
23
+ "message": "stubbed-response-error-message"
24
+ }
24
25
  JSON
25
- http_resp
26
+ resp
26
27
  end
27
28
 
28
29
  end
@@ -3,6 +3,7 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class RestXml < Rest
7
8
 
8
9
  def body_for(api, operation, rules, data)
@@ -10,7 +11,7 @@ module Aws
10
11
  encode_eventstream_response(rules, data, Xml::Builder)
11
12
  else
12
13
  xml = []
13
- rules.location_name = operation.name + 'Result'
14
+ rules.location_name = "#{operation.name}Result"
14
15
  rules['xmlNamespace'] = { 'uri' => api.metadata['xmlNamespace'] }
15
16
  Xml::Builder.new(rules, target:xml).to_xml(data)
16
17
  xml.join
@@ -18,10 +19,10 @@ module Aws
18
19
  end
19
20
 
20
21
  def stub_error(error_code)
21
- http_resp = Seahorse::Client::Http::Response.new
22
- http_resp.status_code = 400
23
- http_resp.body = XmlError.new(error_code).to_xml
24
- http_resp
22
+ resp = Seahorse::Client::Http::Response.new
23
+ resp.status_code = 400
24
+ resp.body = XmlError.new(error_code).to_xml
25
+ resp
25
26
  end
26
27
 
27
28
  def xmlns(api)
@@ -3,35 +3,33 @@
3
3
  module Aws
4
4
  module Stubbing
5
5
  module Protocols
6
+ # @api private
6
7
  class RpcV2
7
8
 
8
- def stub_data(api, operation, data)
9
+ def stub_data(_api, operation, data)
9
10
  resp = Seahorse::Client::Http::Response.new
10
11
  resp.status_code = 200
11
- resp.headers['Content-Type'] = content_type(api)
12
+ resp.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
13
+ resp.headers['Content-Type'] = 'application/cbor'
12
14
  resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
13
15
  resp.body = build_body(operation, data)
14
16
  resp
15
17
  end
16
18
 
17
19
  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
20
+ resp = Seahorse::Client::Http::Response.new
21
+ resp.status_code = 400
22
+ resp.body = Aws::RpcV2.encode(
23
+ {
24
+ 'code' => error_code,
25
+ 'message' => 'stubbed-response-error-message'
26
+ }
27
+ )
28
+ resp
27
29
  end
28
30
 
29
31
  private
30
32
 
31
- def content_type(api)
32
- 'application/cbor'
33
- end
34
-
35
33
  def build_body(operation, data)
36
34
  Aws::RpcV2::Builder.new(operation.output).serialize(data)
37
35
  end