aws-sdk-core 3.46.2 → 3.126.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1258 -0
  3. data/LICENSE.txt +202 -0
  4. data/VERSION +1 -1
  5. data/lib/aws-defaults/default_configuration.rb +153 -0
  6. data/lib/aws-defaults/defaults_mode_config_resolver.rb +107 -0
  7. data/lib/aws-defaults.rb +3 -0
  8. data/lib/aws-sdk-core/arn.rb +92 -0
  9. data/lib/aws-sdk-core/arn_parser.rb +40 -0
  10. data/lib/aws-sdk-core/assume_role_credentials.rb +20 -0
  11. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +109 -0
  12. data/lib/aws-sdk-core/async_client_stubs.rb +82 -0
  13. data/lib/aws-sdk-core/binary/decode_handler.rb +11 -1
  14. data/lib/aws-sdk-core/binary/encode_handler.rb +34 -0
  15. data/lib/aws-sdk-core/binary/event_builder.rb +124 -0
  16. data/lib/aws-sdk-core/binary/event_parser.rb +50 -18
  17. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +7 -2
  18. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +55 -0
  19. data/lib/aws-sdk-core/binary.rb +5 -0
  20. data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +11 -1
  21. data/lib/aws-sdk-core/client_side_monitoring/request_metrics.rb +2 -0
  22. data/lib/aws-sdk-core/client_stubs.rb +16 -13
  23. data/lib/aws-sdk-core/credential_provider.rb +1 -30
  24. data/lib/aws-sdk-core/credential_provider_chain.rb +102 -40
  25. data/lib/aws-sdk-core/credentials.rb +2 -0
  26. data/lib/aws-sdk-core/deprecations.rb +17 -11
  27. data/lib/aws-sdk-core/eager_loader.rb +2 -0
  28. data/lib/aws-sdk-core/ec2_metadata.rb +238 -0
  29. data/lib/aws-sdk-core/ecs_credentials.rb +18 -9
  30. data/lib/aws-sdk-core/endpoint_cache.rb +16 -11
  31. data/lib/aws-sdk-core/errors.rb +138 -15
  32. data/lib/aws-sdk-core/event_emitter.rb +44 -0
  33. data/lib/aws-sdk-core/ini_parser.rb +2 -0
  34. data/lib/aws-sdk-core/instance_profile_credentials.rb +179 -42
  35. data/lib/aws-sdk-core/json/builder.rb +2 -0
  36. data/lib/aws-sdk-core/json/error_handler.rb +21 -2
  37. data/lib/aws-sdk-core/json/handler.rb +21 -1
  38. data/lib/aws-sdk-core/json/json_engine.rb +12 -8
  39. data/lib/aws-sdk-core/json/oj_engine.rb +35 -6
  40. data/lib/aws-sdk-core/json/parser.rb +10 -0
  41. data/lib/aws-sdk-core/json.rb +11 -28
  42. data/lib/aws-sdk-core/log/formatter.rb +16 -4
  43. data/lib/aws-sdk-core/log/handler.rb +2 -0
  44. data/lib/aws-sdk-core/log/param_filter.rb +38 -13
  45. data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
  46. data/lib/aws-sdk-core/pageable_response.rb +48 -24
  47. data/lib/aws-sdk-core/pager.rb +5 -0
  48. data/lib/aws-sdk-core/param_converter.rb +2 -0
  49. data/lib/aws-sdk-core/param_validator.rb +63 -7
  50. data/lib/aws-sdk-core/plugins/api_key.rb +5 -1
  51. data/lib/aws-sdk-core/plugins/apig_authorizer_token.rb +2 -0
  52. data/lib/aws-sdk-core/plugins/apig_credentials_configuration.rb +2 -0
  53. data/lib/aws-sdk-core/plugins/apig_user_agent.rb +2 -0
  54. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +28 -1
  55. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +2 -0
  56. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +26 -7
  57. data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
  58. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +12 -4
  59. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +8 -6
  60. data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +16 -0
  61. data/lib/aws-sdk-core/plugins/global_configuration.rb +2 -0
  62. data/lib/aws-sdk-core/plugins/helpful_socket_errors.rb +2 -0
  63. data/lib/aws-sdk-core/plugins/http_checksum.rb +57 -0
  64. data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
  65. data/lib/aws-sdk-core/plugins/invocation_id.rb +35 -0
  66. data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +2 -0
  67. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  68. data/lib/aws-sdk-core/plugins/param_converter.rb +2 -0
  69. data/lib/aws-sdk-core/plugins/param_validator.rb +2 -0
  70. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +19 -0
  71. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -0
  72. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +2 -0
  73. data/lib/aws-sdk-core/plugins/protocols/query.rb +2 -0
  74. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +18 -1
  75. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +2 -0
  76. data/lib/aws-sdk-core/plugins/recursion_detection.rb +27 -0
  77. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +74 -16
  78. data/lib/aws-sdk-core/plugins/response_paging.rb +2 -0
  79. data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +139 -0
  80. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +100 -0
  81. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +146 -0
  82. data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +59 -0
  83. data/lib/aws-sdk-core/plugins/retry_errors.rb +295 -107
  84. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -0
  85. data/lib/aws-sdk-core/plugins/signature_v4.rb +28 -25
  86. data/lib/aws-sdk-core/plugins/stub_responses.rb +24 -7
  87. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +53 -0
  88. data/lib/aws-sdk-core/plugins/user_agent.rb +6 -8
  89. data/lib/aws-sdk-core/process_credentials.rb +12 -5
  90. data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
  91. data/lib/aws-sdk-core/query/handler.rb +2 -0
  92. data/lib/aws-sdk-core/query/param.rb +2 -0
  93. data/lib/aws-sdk-core/query/param_builder.rb +2 -0
  94. data/lib/aws-sdk-core/query/param_list.rb +2 -0
  95. data/lib/aws-sdk-core/query.rb +2 -0
  96. data/lib/aws-sdk-core/refreshing_credentials.rb +15 -2
  97. data/lib/aws-sdk-core/resources/collection.rb +2 -0
  98. data/lib/aws-sdk-core/rest/handler.rb +2 -0
  99. data/lib/aws-sdk-core/rest/request/body.rb +21 -1
  100. data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
  101. data/lib/aws-sdk-core/rest/request/endpoint.rb +10 -3
  102. data/lib/aws-sdk-core/rest/request/headers.rb +20 -6
  103. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +4 -2
  104. data/lib/aws-sdk-core/rest/response/body.rb +2 -0
  105. data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
  106. data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
  107. data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
  108. data/lib/aws-sdk-core/rest.rb +2 -0
  109. data/lib/aws-sdk-core/shared_config.rb +153 -127
  110. data/lib/aws-sdk-core/shared_credentials.rb +9 -1
  111. data/lib/aws-sdk-core/sso_credentials.rb +136 -0
  112. data/lib/aws-sdk-core/structure.rb +14 -4
  113. data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
  114. data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
  115. data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
  116. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
  117. data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
  118. data/lib/aws-sdk-core/stubbing/protocols/query.rb +4 -2
  119. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +52 -7
  120. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
  121. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
  122. data/lib/aws-sdk-core/stubbing/stub_data.rb +15 -4
  123. data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
  124. data/lib/aws-sdk-core/type_builder.rb +2 -0
  125. data/lib/aws-sdk-core/util.rb +6 -0
  126. data/lib/aws-sdk-core/waiters/errors.rb +2 -0
  127. data/lib/aws-sdk-core/waiters/poller.rb +2 -0
  128. data/lib/aws-sdk-core/waiters/waiter.rb +4 -2
  129. data/lib/aws-sdk-core/waiters.rb +2 -0
  130. data/lib/aws-sdk-core/xml/builder.rb +5 -3
  131. data/lib/aws-sdk-core/xml/default_list.rb +2 -0
  132. data/lib/aws-sdk-core/xml/default_map.rb +2 -0
  133. data/lib/aws-sdk-core/xml/doc_builder.rb +15 -4
  134. data/lib/aws-sdk-core/xml/error_handler.rb +29 -4
  135. data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
  136. data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
  137. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
  138. data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
  139. data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +4 -1
  140. data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
  141. data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
  142. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  143. data/lib/aws-sdk-core/xml/parser.rb +7 -0
  144. data/lib/aws-sdk-core/xml.rb +2 -0
  145. data/lib/aws-sdk-core.rb +23 -4
  146. data/lib/aws-sdk-sso/client.rb +568 -0
  147. data/lib/aws-sdk-sso/client_api.rb +190 -0
  148. data/lib/aws-sdk-sso/customizations.rb +1 -0
  149. data/lib/aws-sdk-sso/errors.rb +102 -0
  150. data/lib/aws-sdk-sso/resource.rb +26 -0
  151. data/lib/aws-sdk-sso/types.rb +352 -0
  152. data/lib/aws-sdk-sso.rb +55 -0
  153. data/lib/aws-sdk-sts/client.rb +1282 -531
  154. data/lib/aws-sdk-sts/client_api.rb +76 -1
  155. data/lib/aws-sdk-sts/customizations.rb +4 -0
  156. data/lib/aws-sdk-sts/errors.rb +153 -1
  157. data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +38 -0
  158. data/lib/aws-sdk-sts/presigner.rb +75 -0
  159. data/lib/aws-sdk-sts/resource.rb +4 -1
  160. data/lib/aws-sdk-sts/types.rb +958 -229
  161. data/lib/aws-sdk-sts.rb +16 -6
  162. data/lib/seahorse/client/async_base.rb +52 -0
  163. data/lib/seahorse/client/async_response.rb +64 -0
  164. data/lib/seahorse/client/base.rb +7 -2
  165. data/lib/seahorse/client/block_io.rb +6 -2
  166. data/lib/seahorse/client/configuration.rb +7 -1
  167. data/lib/seahorse/client/events.rb +3 -1
  168. data/lib/seahorse/client/h2/connection.rb +250 -0
  169. data/lib/seahorse/client/h2/handler.rb +152 -0
  170. data/lib/seahorse/client/handler.rb +2 -0
  171. data/lib/seahorse/client/handler_builder.rb +2 -0
  172. data/lib/seahorse/client/handler_list.rb +2 -0
  173. data/lib/seahorse/client/handler_list_entry.rb +6 -4
  174. data/lib/seahorse/client/http/async_response.rb +44 -0
  175. data/lib/seahorse/client/http/headers.rb +2 -0
  176. data/lib/seahorse/client/http/request.rb +5 -3
  177. data/lib/seahorse/client/http/response.rb +18 -11
  178. data/lib/seahorse/client/logging/formatter.rb +6 -2
  179. data/lib/seahorse/client/logging/handler.rb +2 -0
  180. data/lib/seahorse/client/managed_file.rb +2 -0
  181. data/lib/seahorse/client/net_http/connection_pool.rb +30 -23
  182. data/lib/seahorse/client/net_http/handler.rb +24 -7
  183. data/lib/seahorse/client/net_http/patches.rb +15 -84
  184. data/lib/seahorse/client/networking_error.rb +30 -0
  185. data/lib/seahorse/client/plugin.rb +10 -7
  186. data/lib/seahorse/client/plugin_list.rb +2 -0
  187. data/lib/seahorse/client/plugins/content_length.rb +14 -3
  188. data/lib/seahorse/client/plugins/endpoint.rb +4 -2
  189. data/lib/seahorse/client/plugins/h2.rb +69 -0
  190. data/lib/seahorse/client/plugins/logging.rb +2 -0
  191. data/lib/seahorse/client/plugins/net_http.rb +39 -3
  192. data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
  193. data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
  194. data/lib/seahorse/client/plugins/request_callback.rb +110 -0
  195. data/lib/seahorse/client/plugins/response_target.rb +23 -14
  196. data/lib/seahorse/client/request.rb +2 -0
  197. data/lib/seahorse/client/request_context.rb +2 -0
  198. data/lib/seahorse/client/response.rb +5 -5
  199. data/lib/seahorse/model/api.rb +10 -0
  200. data/lib/seahorse/model/authorizer.rb +2 -0
  201. data/lib/seahorse/model/operation.rb +9 -0
  202. data/lib/seahorse/model/shapes.rb +29 -2
  203. data/lib/seahorse/util.rb +8 -1
  204. data/lib/seahorse/version.rb +2 -0
  205. data/lib/seahorse.rb +12 -0
  206. metadata +64 -14
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Plugins
5
+
6
+ # For Streaming Input Operations, when `requiresLength` is enabled
7
+ # checking whether `Content-Length` header can be set,
8
+ # for `v4-unsigned-body` operations, set `Transfer-Encoding` header
9
+ class TransferEncoding < Seahorse::Client::Plugin
10
+
11
+ # @api private
12
+ class Handler < Seahorse::Client::Handler
13
+ def call(context)
14
+ if streaming?(context.operation.input)
15
+ # If it's an IO object and not a File / String / String IO
16
+ unless context.http_request.body.respond_to?(:size)
17
+ if requires_length?(context.operation.input)
18
+ # if size of the IO is not available but required
19
+ raise Aws::Errors::MissingContentLength.new
20
+ elsif context.operation['authtype'] == "v4-unsigned-body"
21
+ context.http_request.headers['Transfer-Encoding'] = 'chunked'
22
+ end
23
+ end
24
+ end
25
+
26
+ @handler.call(context)
27
+ end
28
+
29
+ private
30
+
31
+ def streaming?(ref)
32
+ if payload = ref[:payload_member]
33
+ payload["streaming"] || # checking ref and shape
34
+ payload.shape["streaming"]
35
+ else
36
+ false
37
+ end
38
+ end
39
+
40
+ def requires_length?(ref)
41
+ payload = ref[:payload_member]
42
+ payload["requiresLength"] || # checking ref and shape
43
+ payload.shape["requiresLength"]
44
+ end
45
+
46
+ end
47
+
48
+ handler(Handler, step: :sign)
49
+
50
+ end
51
+
52
+ end
53
+ end
@@ -1,21 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @api private
4
6
  class UserAgent < Seahorse::Client::Plugin
5
-
6
7
  option(:user_agent_suffix)
7
8
 
8
9
  # @api private
9
10
  class Handler < Seahorse::Client::Handler
10
-
11
11
  def call(context)
12
12
  set_user_agent(context)
13
13
  @handler.call(context)
14
14
  end
15
15
 
16
16
  def set_user_agent(context)
17
- execution_env = ENV["AWS_EXECUTION_ENV"]
18
-
19
17
  ua = "aws-sdk-ruby3/#{CORE_GEM_VERSION}"
20
18
 
21
19
  begin
@@ -30,19 +28,19 @@ module Aws
30
28
  ua += " #{context[:gem_name]}/#{context[:gem_version]}"
31
29
  end
32
30
 
33
- if execution_env
31
+ if (execution_env = ENV['AWS_EXECUTION_ENV'])
34
32
  ua += " exec-env/#{execution_env}"
35
33
  end
36
34
 
37
- ua += " #{context.config.user_agent_suffix}" if context.config.user_agent_suffix
35
+ if context.config.user_agent_suffix
36
+ ua += " #{context.config.user_agent_suffix}"
37
+ end
38
38
 
39
39
  context.http_request.headers['User-Agent'] = ua.strip
40
40
  end
41
-
42
41
  end
43
42
 
44
43
  handler(Handler)
45
-
46
44
  end
47
45
  end
48
46
  end
@@ -1,11 +1,11 @@
1
- require 'open3'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Aws
4
4
 
5
5
  # A credential provider that executes a given process and attempts
6
6
  # to read its stdout to recieve a JSON payload containing the credentials
7
7
  #
8
- # Automatically handles refreshing credentials if an Expiration time is
8
+ # Automatically handles refreshing credentials if an Expiration time is
9
9
  # provided in the credentials payload
10
10
  #
11
11
  # credentials = Aws::ProcessCredentials.new('/usr/bin/credential_proc').credentials
@@ -23,22 +23,29 @@ module Aws
23
23
  # external process to be used as a credential provider.
24
24
  #
25
25
  # @param [String] process Invocation string for process
26
- # credentials provider.
26
+ # credentials provider.
27
27
  def initialize(process)
28
28
  @process = process
29
29
  @credentials = credentials_from_process(@process)
30
+
31
+ super
30
32
  end
31
33
 
32
34
  private
33
35
  def credentials_from_process(proc_invocation)
34
36
  begin
35
- raw_out, process_status = Open3.capture2(proc_invocation)
37
+ raw_out = `#{proc_invocation}`
38
+ process_status = $?
36
39
  rescue Errno::ENOENT
37
40
  raise Errors::InvalidProcessCredentialsPayload.new("Could not find process #{proc_invocation}")
38
41
  end
39
42
 
40
43
  if process_status.success?
41
- creds_json = JSON.parse(raw_out)
44
+ begin
45
+ creds_json = Aws::Json.load(raw_out)
46
+ rescue Aws::Json::ParseError
47
+ raise Errors::InvalidProcessCredentialsPayload.new("Invalid JSON response")
48
+ end
42
49
  payload_version = creds_json['Version']
43
50
  if payload_version == 1
44
51
  _parse_payload_format_v1(creds_json)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'base64'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  # @api private
3
5
  module Query
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Query
3
5
  class Param
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'base64'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stringio'
2
4
 
3
5
  module Aws
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'query/ec2_param_builder'
2
4
  require_relative 'query/handler'
3
5
  require_relative 'query/param'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thread'
2
4
 
3
5
  module Aws
@@ -17,6 +19,9 @@ module Aws
17
19
 
18
20
  def initialize(options = {})
19
21
  @mutex = Mutex.new
22
+ @before_refresh = options.delete(:before_refresh) if Hash === options
23
+
24
+ @before_refresh.call(self) if @before_refresh
20
25
  refresh
21
26
  end
22
27
 
@@ -35,7 +40,11 @@ module Aws
35
40
  # Refresh credentials.
36
41
  # @return [void]
37
42
  def refresh!
38
- @mutex.synchronize { refresh }
43
+ @mutex.synchronize do
44
+ @before_refresh.call(self) if @before_refresh
45
+
46
+ refresh
47
+ end
39
48
  end
40
49
 
41
50
  private
@@ -45,7 +54,11 @@ module Aws
45
54
  def refresh_if_near_expiration
46
55
  if near_expiration?
47
56
  @mutex.synchronize do
48
- refresh if near_expiration?
57
+ if near_expiration?
58
+ @before_refresh.call(self) if @before_refresh
59
+
60
+ refresh
61
+ end
49
62
  end
50
63
  end
51
64
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Resources
3
5
  class Collection
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  # @api private
3
5
  module Rest
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Rest
3
5
  module Request
@@ -15,11 +17,29 @@ module Aws
15
17
  # @param [Seahorse::Client::Http::Request] http_req
16
18
  # @param [Hash] params
17
19
  def apply(http_req, params)
18
- http_req.body = build_body(params)
20
+ body = build_body(params)
21
+ # for rest-json, ensure we send at least an empty object
22
+ # don't send an empty object for streaming? case.
23
+ if body.nil? && @serializer_class == Json::Builder &&
24
+ modeled_body? && !streaming?
25
+ body = '{}'
26
+ end
27
+ http_req.body = body
19
28
  end
20
29
 
21
30
  private
22
31
 
32
+ # operation is modeled for body when it is modeled for a payload
33
+ # either with payload trait or normal members.
34
+ def modeled_body?
35
+ return true if @rules[:payload]
36
+ @rules.shape.members.each do |member|
37
+ _name, shape = member
38
+ return true if shape.location.nil?
39
+ end
40
+ false
41
+ end
42
+
23
43
  def build_body(params)
24
44
  if streaming?
25
45
  params[@rules[:payload]]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Rest
3
5
  module Request
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
 
3
5
  module Aws
@@ -35,10 +37,15 @@ module Aws
35
37
  end
36
38
 
37
39
  def param_value_for_placeholder(placeholder, params)
38
- value = params[param_name(placeholder)].to_s
39
- placeholder.include?('+') ?
40
- value.gsub(/[^\/]+/) { |v| escape(v) } :
40
+ name = param_name(placeholder)
41
+ value = params[name].to_s
42
+ raise ArgumentError, ":#{name} must not be blank" if value.empty?
43
+
44
+ if placeholder.include?('+')
45
+ value.gsub(/[^\/]+/) { |v| escape(v) }
46
+ else
41
47
  escape(value)
48
+ end
42
49
  end
43
50
 
44
51
  def param_name(placeholder)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'time'
2
4
  require 'base64'
3
5
 
@@ -30,11 +32,11 @@ module Aws
30
32
 
31
33
  def apply_header_value(headers, ref, value)
32
34
  value = apply_json_trait(value) if ref['jsonvalue']
33
- headers[ref.location_name] =
34
- case ref.shape
35
- when TimestampShape then timestamp(ref, value)
36
- else value.to_s
37
- end
35
+ case ref.shape
36
+ when TimestampShape then headers[ref.location_name] = timestamp(ref, value)
37
+ when ListShape then list(headers, ref, value)
38
+ else headers[ref.location_name] = value.to_s
39
+ end
38
40
  end
39
41
 
40
42
  def timestamp(ref, value)
@@ -47,6 +49,18 @@ module Aws
47
49
  end
48
50
  end
49
51
 
52
+ def list(headers, ref, value)
53
+ return if !value || value.empty?
54
+ headers[ref.location_name] = value
55
+ .compact
56
+ .map { |s| escape_header_list_string(s.to_s) }
57
+ .join(",")
58
+ end
59
+
60
+ def escape_header_list_string(s)
61
+ (s.include?('"') || s.include?(",")) ? "\"#{s.gsub('"', '\"')}\"" : s
62
+ end
63
+
50
64
  def apply_header_map(headers, ref, values)
51
65
  prefix = ref.location_name || ''
52
66
  values.each_pair do |name, value|
@@ -55,7 +69,7 @@ module Aws
55
69
  end
56
70
 
57
71
  # With complex headers value in json syntax,
58
- # base64 encodes value to aviod weird characters
72
+ # base64 encodes value to avoid weird characters
59
73
  # causing potential issues in headers
60
74
  def apply_json_trait(value)
61
75
  Base64.strict_encode64(value)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Rest
3
5
  module Request
@@ -50,8 +52,8 @@ module Aws
50
52
  if StringShape === shape_ref.shape.member.shape
51
53
  list_of_strings(shape_ref.location_name, param_value)
52
54
  else
53
- msg = "Only list of strings supported, got "
54
- msg << shape_ref.shape.member.shape.class.name
55
+ msg = "Only list of strings supported, got "\
56
+ "#{shape_ref.shape.member.shape.class.name}"
55
57
  raise NotImplementedError, msg
56
58
  end
57
59
  else
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Rest
3
5
  module Response
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'time'
2
4
  require 'base64'
3
- require 'json'
4
5
 
5
6
  module Aws
6
7
  module Rest
@@ -39,8 +40,10 @@ module Aws
39
40
  when IntegerShape then value.to_i
40
41
  when FloatShape then value.to_f
41
42
  when BooleanShape then value == 'true'
43
+ when ListShape then
44
+ value.split(",").map { |v| cast_value(ref.shape.member, v) }
42
45
  when TimestampShape
43
- if value =~ /\d+(\.\d*)/
46
+ if value =~ /^\d+(\.\d*)/
44
47
  Time.at(value.to_f)
45
48
  elsif value =~ /^\d+$/
46
49
  Time.at(value.to_i)
@@ -66,7 +69,7 @@ module Aws
66
69
  end
67
70
 
68
71
  def extract_json_trait(value)
69
- JSON.parse(Base64.decode64(value))
72
+ Aws::Json.load(Base64.decode64(value))
70
73
  end
71
74
 
72
75
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Rest
3
5
  module Response
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Rest
3
5
  module Response
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'rest/handler'
2
4
  require_relative 'rest/request/body'
3
5
  require_relative 'rest/request/builder'