aws-sdk-core 3.31.0 → 3.168.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1573 -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 +105 -0
  9. data/lib/aws-sdk-core/arn_parser.rb +40 -0
  10. data/lib/aws-sdk-core/assume_role_credentials.rb +23 -7
  11. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +108 -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 +45 -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 +71 -9
  22. data/lib/aws-sdk-core/client_stubs.rb +21 -14
  23. data/lib/aws-sdk-core/credential_provider.rb +1 -30
  24. data/lib/aws-sdk-core/credential_provider_chain.rb +107 -43
  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 +24 -9
  30. data/lib/aws-sdk-core/endpoint_cache.rb +193 -0
  31. data/lib/aws-sdk-core/endpoints/condition.rb +36 -0
  32. data/lib/aws-sdk-core/endpoints/endpoint.rb +17 -0
  33. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +71 -0
  34. data/lib/aws-sdk-core/endpoints/error_rule.rb +37 -0
  35. data/lib/aws-sdk-core/endpoints/function.rb +75 -0
  36. data/lib/aws-sdk-core/endpoints/matchers.rb +127 -0
  37. data/lib/aws-sdk-core/endpoints/reference.rb +26 -0
  38. data/lib/aws-sdk-core/endpoints/rule.rb +20 -0
  39. data/lib/aws-sdk-core/endpoints/rule_set.rb +47 -0
  40. data/lib/aws-sdk-core/endpoints/rules_provider.rb +32 -0
  41. data/lib/aws-sdk-core/endpoints/templater.rb +52 -0
  42. data/lib/aws-sdk-core/endpoints/tree_rule.rb +40 -0
  43. data/lib/aws-sdk-core/endpoints/url.rb +59 -0
  44. data/lib/aws-sdk-core/endpoints.rb +74 -0
  45. data/lib/aws-sdk-core/errors.rb +172 -12
  46. data/lib/aws-sdk-core/event_emitter.rb +44 -0
  47. data/lib/aws-sdk-core/ini_parser.rb +2 -0
  48. data/lib/aws-sdk-core/instance_profile_credentials.rb +231 -42
  49. data/lib/aws-sdk-core/json/builder.rb +2 -0
  50. data/lib/aws-sdk-core/json/error_handler.rb +31 -3
  51. data/lib/aws-sdk-core/json/handler.rb +21 -1
  52. data/lib/aws-sdk-core/json/json_engine.rb +12 -8
  53. data/lib/aws-sdk-core/json/oj_engine.rb +35 -6
  54. data/lib/aws-sdk-core/json/parser.rb +10 -0
  55. data/lib/aws-sdk-core/json.rb +11 -28
  56. data/lib/aws-sdk-core/log/formatter.rb +16 -4
  57. data/lib/aws-sdk-core/log/handler.rb +2 -0
  58. data/lib/aws-sdk-core/log/param_filter.rb +38 -13
  59. data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
  60. data/lib/aws-sdk-core/pageable_response.rb +118 -47
  61. data/lib/aws-sdk-core/pager.rb +5 -0
  62. data/lib/aws-sdk-core/param_converter.rb +2 -0
  63. data/lib/aws-sdk-core/param_validator.rb +63 -7
  64. data/lib/aws-sdk-core/plugins/api_key.rb +5 -1
  65. data/lib/aws-sdk-core/plugins/apig_authorizer_token.rb +2 -0
  66. data/lib/aws-sdk-core/plugins/apig_credentials_configuration.rb +2 -0
  67. data/lib/aws-sdk-core/plugins/apig_user_agent.rb +2 -0
  68. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +67 -0
  69. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +340 -0
  70. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +65 -6
  71. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +10 -4
  72. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +50 -7
  73. data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
  74. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +172 -0
  75. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +65 -0
  76. data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +16 -0
  77. data/lib/aws-sdk-core/plugins/global_configuration.rb +2 -0
  78. data/lib/aws-sdk-core/plugins/helpful_socket_errors.rb +2 -0
  79. data/lib/aws-sdk-core/plugins/http_checksum.rb +64 -0
  80. data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
  81. data/lib/aws-sdk-core/plugins/invocation_id.rb +35 -0
  82. data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +36 -6
  83. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  84. data/lib/aws-sdk-core/plugins/param_converter.rb +2 -0
  85. data/lib/aws-sdk-core/plugins/param_validator.rb +2 -0
  86. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +19 -0
  87. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -0
  88. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +2 -0
  89. data/lib/aws-sdk-core/plugins/protocols/query.rb +2 -0
  90. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +18 -1
  91. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +2 -0
  92. data/lib/aws-sdk-core/plugins/recursion_detection.rb +38 -0
  93. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +81 -16
  94. data/lib/aws-sdk-core/plugins/response_paging.rb +3 -1
  95. data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +139 -0
  96. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +100 -0
  97. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +147 -0
  98. data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +59 -0
  99. data/lib/aws-sdk-core/plugins/retry_errors.rb +312 -92
  100. data/lib/aws-sdk-core/plugins/sign.rb +200 -0
  101. data/lib/aws-sdk-core/plugins/signature_v2.rb +3 -0
  102. data/lib/aws-sdk-core/plugins/signature_v4.rb +42 -32
  103. data/lib/aws-sdk-core/plugins/stub_responses.rb +28 -7
  104. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +53 -0
  105. data/lib/aws-sdk-core/plugins/user_agent.rb +9 -5
  106. data/lib/aws-sdk-core/process_credentials.rb +20 -15
  107. data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
  108. data/lib/aws-sdk-core/query/handler.rb +8 -1
  109. data/lib/aws-sdk-core/query/param.rb +2 -0
  110. data/lib/aws-sdk-core/query/param_builder.rb +2 -0
  111. data/lib/aws-sdk-core/query/param_list.rb +2 -0
  112. data/lib/aws-sdk-core/query.rb +2 -0
  113. data/lib/aws-sdk-core/refreshing_credentials.rb +45 -12
  114. data/lib/aws-sdk-core/refreshing_token.rb +71 -0
  115. data/lib/aws-sdk-core/resources/collection.rb +3 -1
  116. data/lib/aws-sdk-core/rest/handler.rb +3 -1
  117. data/lib/aws-sdk-core/rest/request/body.rb +21 -1
  118. data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
  119. data/lib/aws-sdk-core/rest/request/endpoint.rb +10 -3
  120. data/lib/aws-sdk-core/rest/request/headers.rb +16 -6
  121. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +4 -2
  122. data/lib/aws-sdk-core/rest/response/body.rb +2 -0
  123. data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
  124. data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
  125. data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
  126. data/lib/aws-sdk-core/rest.rb +2 -0
  127. data/lib/aws-sdk-core/shared_config.rb +222 -118
  128. data/lib/aws-sdk-core/shared_credentials.rb +9 -1
  129. data/lib/aws-sdk-core/sso_credentials.rb +172 -0
  130. data/lib/aws-sdk-core/sso_token_provider.rb +135 -0
  131. data/lib/aws-sdk-core/static_token_provider.rb +14 -0
  132. data/lib/aws-sdk-core/structure.rb +24 -7
  133. data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
  134. data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
  135. data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
  136. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
  137. data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
  138. data/lib/aws-sdk-core/stubbing/protocols/query.rb +4 -2
  139. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +52 -7
  140. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
  141. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
  142. data/lib/aws-sdk-core/stubbing/stub_data.rb +15 -4
  143. data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
  144. data/lib/aws-sdk-core/token.rb +31 -0
  145. data/lib/aws-sdk-core/token_provider.rb +15 -0
  146. data/lib/aws-sdk-core/token_provider_chain.rb +51 -0
  147. data/lib/aws-sdk-core/type_builder.rb +2 -0
  148. data/lib/aws-sdk-core/util.rb +24 -0
  149. data/lib/aws-sdk-core/waiters/errors.rb +2 -0
  150. data/lib/aws-sdk-core/waiters/poller.rb +2 -0
  151. data/lib/aws-sdk-core/waiters/waiter.rb +4 -2
  152. data/lib/aws-sdk-core/waiters.rb +2 -0
  153. data/lib/aws-sdk-core/xml/builder.rb +5 -3
  154. data/lib/aws-sdk-core/xml/default_list.rb +2 -0
  155. data/lib/aws-sdk-core/xml/default_map.rb +2 -0
  156. data/lib/aws-sdk-core/xml/doc_builder.rb +15 -4
  157. data/lib/aws-sdk-core/xml/error_handler.rb +36 -4
  158. data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
  159. data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
  160. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
  161. data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
  162. data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +4 -1
  163. data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
  164. data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
  165. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  166. data/lib/aws-sdk-core/xml/parser.rb +7 -0
  167. data/lib/aws-sdk-core/xml.rb +2 -0
  168. data/lib/aws-sdk-core.rb +42 -4
  169. data/lib/aws-sdk-sso/client.rb +610 -0
  170. data/lib/aws-sdk-sso/client_api.rb +190 -0
  171. data/lib/aws-sdk-sso/customizations.rb +1 -0
  172. data/lib/aws-sdk-sso/endpoint_parameters.rb +66 -0
  173. data/lib/aws-sdk-sso/endpoint_provider.rb +112 -0
  174. data/lib/aws-sdk-sso/endpoints.rb +71 -0
  175. data/lib/aws-sdk-sso/errors.rb +102 -0
  176. data/lib/aws-sdk-sso/plugins/endpoints.rb +76 -0
  177. data/lib/aws-sdk-sso/resource.rb +26 -0
  178. data/lib/aws-sdk-sso/types.rb +317 -0
  179. data/lib/aws-sdk-sso.rb +59 -0
  180. data/lib/aws-sdk-ssooidc/client.rb +606 -0
  181. data/lib/aws-sdk-ssooidc/client_api.rb +216 -0
  182. data/lib/aws-sdk-ssooidc/customizations.rb +1 -0
  183. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +66 -0
  184. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +111 -0
  185. data/lib/aws-sdk-ssooidc/endpoints.rb +57 -0
  186. data/lib/aws-sdk-ssooidc/errors.rb +290 -0
  187. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +74 -0
  188. data/lib/aws-sdk-ssooidc/resource.rb +26 -0
  189. data/lib/aws-sdk-ssooidc/types.rb +502 -0
  190. data/lib/aws-sdk-ssooidc.rb +59 -0
  191. data/lib/aws-sdk-sts/client.rb +1426 -616
  192. data/lib/aws-sdk-sts/client_api.rb +76 -1
  193. data/lib/aws-sdk-sts/customizations.rb +4 -0
  194. data/lib/aws-sdk-sts/endpoint_parameters.rb +78 -0
  195. data/lib/aws-sdk-sts/endpoint_provider.rb +229 -0
  196. data/lib/aws-sdk-sts/endpoints.rb +135 -0
  197. data/lib/aws-sdk-sts/errors.rb +153 -1
  198. data/lib/aws-sdk-sts/plugins/endpoints.rb +84 -0
  199. data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +38 -0
  200. data/lib/aws-sdk-sts/presigner.rb +73 -0
  201. data/lib/aws-sdk-sts/resource.rb +4 -1
  202. data/lib/aws-sdk-sts/types.rb +918 -296
  203. data/lib/aws-sdk-sts.rb +20 -6
  204. data/lib/seahorse/client/async_base.rb +51 -0
  205. data/lib/seahorse/client/async_response.rb +64 -0
  206. data/lib/seahorse/client/base.rb +7 -2
  207. data/lib/seahorse/client/block_io.rb +6 -2
  208. data/lib/seahorse/client/configuration.rb +17 -3
  209. data/lib/seahorse/client/events.rb +3 -1
  210. data/lib/seahorse/client/h2/connection.rb +247 -0
  211. data/lib/seahorse/client/h2/handler.rb +152 -0
  212. data/lib/seahorse/client/handler.rb +2 -0
  213. data/lib/seahorse/client/handler_builder.rb +2 -0
  214. data/lib/seahorse/client/handler_list.rb +2 -0
  215. data/lib/seahorse/client/handler_list_entry.rb +6 -4
  216. data/lib/seahorse/client/http/async_response.rb +44 -0
  217. data/lib/seahorse/client/http/headers.rb +2 -0
  218. data/lib/seahorse/client/http/request.rb +5 -3
  219. data/lib/seahorse/client/http/response.rb +18 -11
  220. data/lib/seahorse/client/logging/formatter.rb +6 -2
  221. data/lib/seahorse/client/logging/handler.rb +2 -0
  222. data/lib/seahorse/client/managed_file.rb +2 -0
  223. data/lib/seahorse/client/net_http/connection_pool.rb +30 -23
  224. data/lib/seahorse/client/net_http/handler.rb +24 -7
  225. data/lib/seahorse/client/net_http/patches.rb +16 -79
  226. data/lib/seahorse/client/networking_error.rb +30 -0
  227. data/lib/seahorse/client/plugin.rb +10 -7
  228. data/lib/seahorse/client/plugin_list.rb +2 -0
  229. data/lib/seahorse/client/plugins/content_length.rb +14 -3
  230. data/lib/seahorse/client/plugins/endpoint.rb +4 -2
  231. data/lib/seahorse/client/plugins/h2.rb +69 -0
  232. data/lib/seahorse/client/plugins/logging.rb +2 -0
  233. data/lib/seahorse/client/plugins/net_http.rb +39 -3
  234. data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
  235. data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
  236. data/lib/seahorse/client/plugins/request_callback.rb +110 -0
  237. data/lib/seahorse/client/plugins/response_target.rb +23 -14
  238. data/lib/seahorse/client/request.rb +2 -0
  239. data/lib/seahorse/client/request_context.rb +2 -0
  240. data/lib/seahorse/client/response.rb +5 -5
  241. data/lib/seahorse/model/api.rb +14 -0
  242. data/lib/seahorse/model/authorizer.rb +2 -0
  243. data/lib/seahorse/model/operation.rb +21 -0
  244. data/lib/seahorse/model/shapes.rb +29 -2
  245. data/lib/seahorse/util.rb +12 -1
  246. data/lib/seahorse/version.rb +2 -0
  247. data/lib/seahorse.rb +12 -0
  248. metadata +117 -16
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
 
3
5
  module Aws
@@ -83,6 +85,9 @@ module Aws
83
85
  # The default list of filtered parameters is documented on the
84
86
  # {ParamFilter} class.
85
87
  #
88
+ # @option options [Boolean] :filter_sensitive_params (true) Set to false
89
+ # to disable the sensitive parameter filtering when logging
90
+ # `:request_params`.
86
91
  def initialize(pattern, options = {})
87
92
  @pattern = pattern
88
93
  @param_formatter = ParamFormatter.new(options)
@@ -92,12 +97,12 @@ module Aws
92
97
  # @return [String]
93
98
  attr_reader :pattern
94
99
 
95
- # Given a resopnse, this will format a log message and return it as a
100
+ # Given a response, this will format a log message and return it as a
96
101
  # string according to {#pattern}.
97
102
  # @param [Seahorse::Client::Response] response
98
103
  # @return [String]
99
104
  def format(response)
100
- pattern.gsub(/:(\w+)/) {|sym| send("_#{sym[1..-1]}", response) }
105
+ pattern.gsub(/:(\w+)/) { |sym| send("_#{sym[1..-1]}", response) }
101
106
  end
102
107
 
103
108
  # @api private
@@ -121,7 +126,8 @@ module Aws
121
126
 
122
127
  def _request_params(response)
123
128
  params = response.context.params
124
- @param_formatter.summarize(@param_filter.filter(params))
129
+ type = response.context.operation.input.shape.struct_class
130
+ @param_formatter.summarize(@param_filter.filter(params, type))
125
131
  end
126
132
 
127
133
  def _time(response)
@@ -171,7 +177,13 @@ module Aws
171
177
  end
172
178
 
173
179
  def _http_response_body(response)
174
- @param_formatter.summarize(response.context.http_response.body_contents)
180
+ if response.context.http_response.body.respond_to?(:rewind)
181
+ @param_formatter.summarize(
182
+ response.context.http_response.body_contents
183
+ )
184
+ else
185
+ ''
186
+ end
175
187
  end
176
188
 
177
189
  def _error_class(response)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seahorse
2
4
  module Client
3
5
  module Logging
@@ -1,43 +1,68 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
  require 'set'
3
5
 
4
6
  module Aws
5
7
  module Log
6
8
  class ParamFilter
7
-
9
+ # DEPRECATED - This must exist for backwards compatibility. Sensitive
10
+ # members are now computed for each request/response type. This can be
11
+ # removed in a new major version. This list is no longer updated.
12
+ #
8
13
  # A managed list of sensitive parameters that should be filtered from
9
14
  # logs. This is updated automatically as part of each release. See the
10
- # `tasks/sensitive.rake` for more information.
15
+ # `tasks/update-sensitive-params.rake` for more information.
11
16
  #
12
17
  # @api private
13
18
  # begin
14
- SENSITIVE = [:access_token, :account_name, :account_password, :admin_contact, :artifact_credentials, :auth_code, :authentication_token, :base_32_string_seed, :body, :bot_configuration, :client_id, :client_secret, :configuration, :copy_source_sse_customer_key, :credentials, :custom_attributes, :db_password, :description, :display_name, :email, :email_address, :email_message, :feedback_token, :id, :id_token, :input, :input_text, :key_id, :kms_key_id, :kms_master_key_id, :local_console_password, :master_account_email, :master_user_password, :message, :name, :new_password, :notes, :old_password, :owner_information, :parameters, :passphrase, :password, :payload, :plaintext, :previous_password, :private_key, :proposed_password, :public_key, :qr_code_png, :query, :refresh_token, :registrant_contact, :request_attributes, :search_query, :secret_access_key, :secret_binary, :secret_code, :secret_hash, :secret_string, :service_password, :session_attributes, :share_notes, :shared_secret, :slots, :sse_customer_key, :ssekms_key_id, :status_message, :task_parameters, :tech_contact, :temporary_password, :text, :trust_password, :upload_credentials, :upload_url, :username, :value, :values, :variables, :zip_file]
19
+ SENSITIVE = [:access_token, :account_name, :account_password, :address, :admin_contact, :admin_password, :alexa_for_business_room_arn, :artifact_credentials, :auth_code, :auth_parameters, :authentication_token, :authorization_result, :backup_plan_tags, :backup_vault_tags, :base_32_string_seed, :basic_auth_credentials, :block, :block_address, :block_data, :blocks, :body, :bot_configuration, :bot_email, :calling_name, :cause, :client_id, :client_request_token, :client_secret, :comment, :configuration, :content, :copy_source_sse_customer_key, :credentials, :current_password, :custom_attributes, :custom_private_key, :db_password, :default_phone_number, :definition, :description, :destination_access_token, :digest_tip_address, :display_name, :domain_signing_private_key, :e164_phone_number, :email, :email_address, :email_message, :embed_url, :emergency_phone_number, :error, :external_meeting_id, :external_model_endpoint_data_blobs, :external_user_id, :fall_back_phone_number, :feedback_token, :file, :filter_expression, :first_name, :full_name, :host_key, :id, :id_token, :input, :input_text, :ion_text, :join_token, :key, :key_id, :key_material, :key_store_password, :kms_key_id, :kms_master_key_id, :lambda_function_arn, :last_name, :local_console_password, :master_account_email, :master_user_name, :master_user_password, :meeting_host_id, :message, :metadata, :name, :new_password, :next_password, :notes, :number, :oauth_token, :old_password, :outbound_events_https_endpoint, :output, :owner_information, :parameters, :passphrase, :password, :payload, :phone_number, :plaintext, :previous_password, :primary_email, :primary_provisioned_number, :private_key, :private_key_plaintext, :proof, :proposed_password, :proxy_phone_number, :public_key, :qr_code_png, :query, :random_password, :recovery_point_tags, :refresh_token, :registrant_contact, :request_attributes, :resource_arn, :restore_metadata, :revision, :saml_assertion, :search_query, :secret_access_key, :secret_binary, :secret_code, :secret_hash, :secret_string, :secret_to_authenticate_initiator, :secret_to_authenticate_target, :security_token, :service_password, :session_attributes, :session_token, :share_notes, :shared_secret, :slots, :sns_topic_arn, :source_access_token, :sqs_queue_arn, :sse_customer_key, :ssekms_encryption_context, :ssekms_key_id, :status_message, :tag_key_list, :tags, :target_address, :task_parameters, :tech_contact, :temporary_password, :test_phone_number, :text, :token, :trust_password, :type, :upload_credentials, :upload_url, :uri, :user_data, :user_email, :user_name, :user_password, :username, :value, :values, :variables, :vpn_psk, :web_identity_token, :zip_file]
15
20
  # end
16
21
 
17
22
  def initialize(options = {})
18
- @filters = Set.new(SENSITIVE + Array(options[:filter]))
23
+ @enabled = options[:filter_sensitive_params] != false
24
+ @additional_filters = options[:filter] || []
19
25
  end
20
26
 
21
- def filter(value)
22
- case value
23
- when Struct, Hash then filter_hash(value)
24
- when Array then filter_array(value)
25
- else value
27
+ def filter(values, type)
28
+ case values
29
+ when Struct then filter_struct(values, type)
30
+ when Hash then filter_hash(values, type)
31
+ when Array then filter_array(values, type)
32
+ else values
26
33
  end
27
34
  end
28
35
 
29
36
  private
30
37
 
31
- def filter_hash(values)
38
+ def filter_struct(values, type)
39
+ if values.class.include? Aws::Structure::Union
40
+ values = { values.member => values.value }
41
+ end
42
+ filter_hash(values, type)
43
+ end
44
+
45
+ def filter_hash(values, type)
46
+ if type.const_defined?('SENSITIVE')
47
+ filters = type::SENSITIVE + @additional_filters
48
+ else
49
+ # Support backwards compatibility (new core + old service)
50
+ filters = SENSITIVE + @additional_filters
51
+ end
52
+
32
53
  filtered = {}
33
54
  values.each_pair do |key, value|
34
- filtered[key] = @filters.include?(key) ? '[FILTERED]' : filter(value)
55
+ filtered[key] = if @enabled && filters.include?(key)
56
+ '[FILTERED]'
57
+ else
58
+ filter(value, type)
59
+ end
35
60
  end
36
61
  filtered
37
62
  end
38
63
 
39
- def filter_array(values)
40
- values.map { |value| filter(value) }
64
+ def filter_array(values, type)
65
+ values.map { |value| filter(value, type) }
41
66
  end
42
67
 
43
68
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
 
3
5
  module Aws
@@ -1,40 +1,58 @@
1
- module Aws
1
+ # frozen_string_literal: true
2
2
 
3
- # Decorates a {Seahorse::Client::Response} with paging methods:
4
- #
5
- # resp = s3.list_objects(params)
6
- # resp.last_page?
7
- # #=> false
3
+ module Aws
4
+ # Decorates a {Seahorse::Client::Response} with paging convenience methods.
5
+ # Some AWS calls provide paged responses to limit the amount of data returned
6
+ # with each response. To optimize for latency, some APIs may return an
7
+ # inconsistent number of responses per page. You should rely on the values of
8
+ # the `next_page?` method or using enumerable methods such as `each` rather
9
+ # than the number of items returned to iterate through results. See below for
10
+ # examples.
8
11
  #
9
- # # sends a request to receive the next response page
10
- # resp = resp.next_page
11
- # resp.last_page?
12
- # #=> true
12
+ # @note Methods such as `to_json` will enumerate all of the responses before
13
+ # returning the full response as JSON.
13
14
  #
14
- # resp.next_page
15
- # #=> raises PageableResponse::LastPageError
15
+ # # Paged Responses Are Enumerable
16
+ # The simplest way to handle paged response data is to use the built-in
17
+ # enumerator in the response object, as shown in the following example.
16
18
  #
17
- # You can enumerate all response pages with a block
19
+ # s3 = Aws::S3::Client.new
18
20
  #
19
- # ec2.describe_instances(params).each do |page|
20
- # # yields once per page
21
- # page.reservations.each do |r|
22
- # # ...
23
- # end
21
+ # s3.list_objects(bucket:'aws-sdk').each do |response|
22
+ # puts response.contents.map(&:key)
24
23
  # end
25
24
  #
26
- # Or using {#next_page} and {#last_page?}:
25
+ # This yields one response object per API call made, and enumerates objects
26
+ # in the named bucket. The SDK retrieves additional pages of data to
27
+ # complete the request.
28
+ #
29
+ # # Handling Paged Responses Manually
30
+ # To handle paging yourself, use the response’s `next_page?` method to verify
31
+ # there are more pages to retrieve, or use the last_page? method to verify
32
+ # there are no more pages to retrieve.
33
+ #
34
+ # If there are more pages, use the `next_page` method to retrieve the
35
+ # next page of results, as shown in the following example.
27
36
  #
28
- # resp.last_page?
29
- # resp = resp.next_page until resp.last_page?
37
+ # s3 = Aws::S3::Client.new
38
+ #
39
+ # # Get the first page of data
40
+ # response = s3.list_objects(bucket:'aws-sdk')
41
+ #
42
+ # # Get additional pages
43
+ # while response.next_page? do
44
+ # response = response.next_page
45
+ # # Use the response data here...
46
+ # puts response.contents.map(&:key)
47
+ # end
30
48
  #
31
49
  module PageableResponse
32
50
 
33
- def self.extended(base)
34
- base.send(:extend, Enumerable)
35
- base.send(:extend, UnsafeEnumerableMethods)
36
- base.instance_variable_set("@last_page", nil)
37
- base.instance_variable_set("@more_results", nil)
51
+ def self.apply(base)
52
+ base.extend Extension
53
+ base.instance_variable_set(:@last_page, nil)
54
+ base.instance_variable_set(:@more_results, nil)
55
+ base
38
56
  end
39
57
 
40
58
  # @return [Paging::Pager]
@@ -44,39 +62,26 @@ module Aws
44
62
  # when this method returns `false` will raise an error.
45
63
  # @return [Boolean]
46
64
  def last_page?
47
- if @last_page.nil?
48
- @last_page = !@pager.truncated?(self)
49
- end
50
- @last_page
65
+ # Actual implementation is in PageableResponse::Extension
51
66
  end
52
67
 
53
68
  # Returns `true` if there are more results. Calling {#next_page} will
54
69
  # return the next response.
55
70
  # @return [Boolean]
56
71
  def next_page?
57
- !last_page?
72
+ # Actual implementation is in PageableResponse::Extension
58
73
  end
59
74
 
60
75
  # @return [Seahorse::Client::Response]
61
76
  def next_page(params = {})
62
- if last_page?
63
- raise LastPageError.new(self)
64
- else
65
- next_response(params)
66
- end
77
+ # Actual implementation is in PageableResponse::Extension
67
78
  end
68
79
 
69
80
  # Yields the current and each following response to the given block.
70
81
  # @yieldparam [Response] response
71
82
  # @return [Enumerable,nil] Returns a new Enumerable if no block is given.
72
83
  def each(&block)
73
- return enum_for(:each_page) unless block_given?
74
- response = self
75
- yield(response)
76
- until response.last_page?
77
- response = response.next_page
78
- yield(response)
79
- end
84
+ # Actual implementation is in PageableResponse::Extension
80
85
  end
81
86
  alias each_page each
82
87
 
@@ -87,9 +92,7 @@ module Aws
87
92
  # @return [Seahorse::Client::Response] Returns the next page of
88
93
  # results.
89
94
  def next_response(params)
90
- params = next_page_params(params)
91
- request = context.client.build_request(context.operation_name, params)
92
- request.send_request
95
+ # Actual implementation is in PageableResponse::Extension
93
96
  end
94
97
 
95
98
  # @param [Hash] params A hash of additional request params to
@@ -97,7 +100,7 @@ module Aws
97
100
  # @return [Hash] Returns the hash of request parameters for the
98
101
  # next page, merging any given params.
99
102
  def next_page_params(params)
100
- context[:original_params].merge(@pager.next_tokens(self).merge(params))
103
+ # Actual implementation is in PageableResponse::Extension
101
104
  end
102
105
 
103
106
  # Raised when calling {PageableResponse#next_page} on a pager that
@@ -143,6 +146,74 @@ module Aws
143
146
  data.to_h
144
147
  end
145
148
 
149
+ def as_json(_options = {})
150
+ data.to_h(data, as_json: true)
151
+ end
152
+
153
+ def to_json(options = {})
154
+ as_json.to_json(options)
155
+ end
156
+ end
157
+
158
+ # The actual decorator module implementation. It is in a distinct module
159
+ # so that it can be used to extend objects without busting Ruby's constant cache.
160
+ # object.extend(mod) bust the constant cache only if `mod` contains constants of its own.
161
+ # @api private
162
+ module Extension
163
+
164
+ include Enumerable
165
+ include UnsafeEnumerableMethods
166
+
167
+ attr_accessor :pager
168
+
169
+ def last_page?
170
+ if @last_page.nil?
171
+ @last_page = !@pager.truncated?(self)
172
+ end
173
+ @last_page
174
+ end
175
+
176
+ def next_page?
177
+ !last_page?
178
+ end
179
+
180
+ def next_page(params = {})
181
+ if last_page?
182
+ raise LastPageError.new(self)
183
+ else
184
+ next_response(params)
185
+ end
186
+ end
187
+
188
+ def each(&block)
189
+ return enum_for(:each_page) unless block_given?
190
+ response = self
191
+ yield(response)
192
+ until response.last_page?
193
+ response = response.next_page
194
+ yield(response)
195
+ end
196
+ end
197
+ alias each_page each
198
+
199
+ private
200
+
201
+ def next_response(params)
202
+ params = next_page_params(params)
203
+ request = context.client.build_request(context.operation_name, params)
204
+ request.send_request
205
+ end
206
+
207
+ def next_page_params(params)
208
+ # Remove all previous tokens from original params
209
+ # Sometimes a token can be nil and merge would not include it.
210
+ tokens = @pager.tokens.values.map(&:to_sym)
211
+
212
+ params_without_tokens = context[:original_params].reject { |k, _v| tokens.include?(k) }
213
+ params_without_tokens.merge!(@pager.next_tokens(self).merge(params))
214
+ params_without_tokens
215
+ end
216
+
146
217
  end
147
218
  end
148
219
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jmespath'
2
4
 
3
5
  module Aws
@@ -16,6 +18,9 @@ module Aws
16
18
  # @return [Symbol, nil]
17
19
  attr_reader :limit_key
18
20
 
21
+ # @return [Hash, nil]
22
+ attr_reader :tokens
23
+
19
24
  # @param [Seahorse::Client::Response] response
20
25
  # @return [Hash]
21
26
  def next_tokens(response)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stringio'
2
4
  require 'date'
3
5
  require 'time'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  # @api private
3
5
  class ParamValidator
@@ -22,6 +24,7 @@ module Aws
22
24
  ShapeRef.new(shape: shape)
23
25
  end
24
26
  @validate_required = options[:validate_required] != false
27
+ @input = options[:input].nil? ? true : !!options[:input]
25
28
  end
26
29
 
27
30
  # @param [Hash] params
@@ -39,6 +42,7 @@ module Aws
39
42
  return unless correct_type?(ref, values, errors, context)
40
43
 
41
44
  if ref.eventstream
45
+ # input eventstream is provided from event signals
42
46
  values.each do |value|
43
47
  # each event is structure type
44
48
  case value[:message_type]
@@ -58,13 +62,22 @@ module Aws
58
62
  # ensure required members are present
59
63
  if @validate_required
60
64
  shape.required.each do |member_name|
61
- if values[member_name].nil?
65
+ input_eventstream = ref.shape.member(member_name).eventstream && @input
66
+ if values[member_name].nil? && !input_eventstream
62
67
  param = "#{context}[#{member_name.inspect}]"
63
68
  errors << "missing required parameter #{param}"
64
69
  end
65
70
  end
66
71
  end
67
72
 
73
+ if @validate_required && shape.union
74
+ if values.length > 1
75
+ errors << "multiple values provided to union at #{context} - must contain exactly one of the supported types: #{shape.member_names.join(', ')}"
76
+ elsif values.length == 0
77
+ errors << "No values provided to union at #{context} - must contain exactly one of the supported types: #{shape.member_names.join(', ')}"
78
+ end
79
+ end
80
+
68
81
  # validate non-nil members
69
82
  values.each_pair do |name, value|
70
83
  unless value.nil?
@@ -112,11 +125,32 @@ module Aws
112
125
  end
113
126
  end
114
127
 
128
+ def document(ref, value, errors, context)
129
+ document_types = [Hash, Array, Numeric, String, TrueClass, FalseClass, NilClass]
130
+ unless document_types.any? { |t| value.is_a?(t) }
131
+ errors << expected_got(context, "one of #{document_types.join(', ')}", value)
132
+ end
133
+
134
+ # recursively validate types for aggregated types
135
+ case value
136
+ when Hash
137
+ value.each do |k, v|
138
+ document(ref, v, errors, context + "[#{k}]")
139
+ end
140
+ when Array
141
+ value.each do |v|
142
+ document(ref, v, errors, context)
143
+ end
144
+ end
145
+
146
+ end
147
+
115
148
  def shape(ref, value, errors, context)
116
149
  case ref.shape
117
150
  when StructureShape then structure(ref, value, errors, context)
118
151
  when ListShape then list(ref, value, errors, context)
119
152
  when MapShape then map(ref, value, errors, context)
153
+ when DocumentShape then document(ref, value, errors, context)
120
154
  when StringShape
121
155
  unless value.is_a?(String)
122
156
  errors << expected_got(context, "a String", value)
@@ -138,8 +172,22 @@ module Aws
138
172
  errors << expected_got(context, "true or false", value)
139
173
  end
140
174
  when BlobShape
141
- unless io_like?(value) or value.is_a?(String)
142
- errors << expected_got(context, "a String or IO object", value)
175
+ unless value.is_a?(String)
176
+ if streaming_input?(ref)
177
+ unless io_like?(value, _require_size = false)
178
+ errors << expected_got(
179
+ context,
180
+ "a String or IO like object that supports read and rewind",
181
+ value
182
+ )
183
+ end
184
+ elsif !io_like?(value, _require_size = true)
185
+ errors << expected_got(
186
+ context,
187
+ "a String or IO like object that supports read, rewind, and size",
188
+ value
189
+ )
190
+ end
143
191
  end
144
192
  else
145
193
  raise "unhandled shape type: #{ref.shape.class.name}"
@@ -147,6 +195,11 @@ module Aws
147
195
  end
148
196
 
149
197
  def correct_type?(ref, value, errors, context)
198
+ if ref.eventstream && @input
199
+ errors << "instead of providing value directly for eventstreams at input,"\
200
+ " expected to use #signal events per stream"
201
+ return false
202
+ end
150
203
  case value
151
204
  when Hash then true
152
205
  when ref.shape.struct_class then true
@@ -157,10 +210,13 @@ module Aws
157
210
  end
158
211
  end
159
212
 
160
- def io_like?(value)
161
- value.respond_to?(:read) &&
162
- value.respond_to?(:rewind) &&
163
- value.respond_to?(:size)
213
+ def io_like?(value, require_size = true)
214
+ value.respond_to?(:read) && value.respond_to?(:rewind) &&
215
+ (!require_size || value.respond_to?(:size))
216
+ end
217
+
218
+ def streaming_input?(ref)
219
+ (ref["streaming"] || ref.shape["streaming"])
164
220
  end
165
221
 
166
222
  def error_messages(errors)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
 
@@ -21,7 +23,9 @@ When provided, `x-api-key` header will be injected with the value provided.
21
23
  class OptionHandler < Seahorse::Client::Handler
22
24
  def call(context)
23
25
  if context.operation.require_apikey
24
- api_key = context.params.delete(:api_key)
26
+ if context.params.is_a?(Hash) && context.params[:api_key]
27
+ api_key = context.params.delete(:api_key)
28
+ end
25
29
  api_key = context.config.api_key if api_key.nil?
26
30
  context[:api_key] = api_key
27
31
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  # @api private
3
5
  module Plugins
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module Plugins
3
5
  # @api private
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # @api private
5
+ module Plugins
6
+ # @api private
7
+ class BearerAuthorization < Seahorse::Client::Plugin
8
+
9
+ option(:token_provider,
10
+ required: false,
11
+ doc_type: 'Aws::TokenProvider',
12
+ docstring: <<-DOCS
13
+ A Bearer Token Provider. This can be an instance of any one of the
14
+ following classes:
15
+
16
+ * `Aws::StaticTokenProvider` - Used for configuring static, non-refreshing
17
+ tokens.
18
+
19
+ * `Aws::SSOTokenProvider` - Used for loading tokens from AWS SSO using an
20
+ access token generated from `aws login`.
21
+
22
+ When `:token_provider` is not configured directly, the `Aws::TokenProviderChain`
23
+ will be used to search for tokens configured for your profile in shared configuration files.
24
+ DOCS
25
+ ) do |config|
26
+ if config.stub_responses
27
+ StaticTokenProvider.new('token')
28
+ else
29
+ TokenProviderChain.new(config).resolve
30
+ end
31
+ end
32
+
33
+
34
+ def add_handlers(handlers, cfg)
35
+ bearer_operations =
36
+ if cfg.api.metadata['signatureVersion'] == 'bearer'
37
+ # select operations where authtype is either not set or is bearer
38
+ cfg.api.operation_names.select do |o|
39
+ !cfg.api.operation(o)['authtype'] || cfg.api.operation(o)['authtype'] == 'bearer'
40
+ end
41
+ else # service is not bearer auth
42
+ # select only operations where authtype is explicitly bearer
43
+ cfg.api.operation_names.select do |o|
44
+ cfg.api.operation(o)['authtype'] == 'bearer'
45
+ end
46
+ end
47
+ handlers.add(Handler, step: :sign, operations: bearer_operations)
48
+ end
49
+
50
+ class Handler < Seahorse::Client::Handler
51
+ def call(context)
52
+ if context.http_request.endpoint.scheme != 'https'
53
+ raise ArgumentError, 'Unable to use bearer authorization on non https endpoint.'
54
+ end
55
+
56
+ token_provider = context.config.token_provider
57
+ if token_provider && token_provider.set?
58
+ context.http_request.headers['Authorization'] = "Bearer #{token_provider.token.token}"
59
+ else
60
+ raise Errors::MissingBearerTokenError
61
+ end
62
+ @handler.call(context)
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end