aws-sdk-core 3.152.0 → 3.234.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 (213) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +942 -1
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +5 -6
  5. data/lib/aws-defaults.rb +4 -1
  6. data/lib/aws-sdk-core/arn.rb +14 -3
  7. data/lib/aws-sdk-core/assume_role_credentials.rb +21 -13
  8. data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +16 -9
  9. data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
  10. data/lib/aws-sdk-core/binary/encode_handler.rb +13 -2
  11. data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
  12. data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
  13. data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
  14. data/lib/aws-sdk-core/cbor/decoder.rb +308 -0
  15. data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
  16. data/lib/aws-sdk-core/cbor.rb +53 -0
  17. data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
  18. data/lib/aws-sdk-core/client_stubs.rb +33 -55
  19. data/lib/aws-sdk-core/credential_provider.rb +8 -1
  20. data/lib/aws-sdk-core/credential_provider_chain.rb +81 -29
  21. data/lib/aws-sdk-core/credentials.rb +19 -6
  22. data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
  23. data/lib/aws-sdk-core/ecs_credentials.rb +186 -60
  24. data/lib/aws-sdk-core/endpoints/condition.rb +41 -0
  25. data/lib/aws-sdk-core/endpoints/endpoint.rb +19 -0
  26. data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +75 -0
  27. data/lib/aws-sdk-core/endpoints/error_rule.rb +42 -0
  28. data/lib/aws-sdk-core/endpoints/function.rb +80 -0
  29. data/lib/aws-sdk-core/endpoints/matchers.rb +129 -0
  30. data/lib/aws-sdk-core/endpoints/reference.rb +31 -0
  31. data/lib/aws-sdk-core/endpoints/rule.rb +25 -0
  32. data/lib/aws-sdk-core/endpoints/rule_set.rb +52 -0
  33. data/lib/aws-sdk-core/endpoints/rules_provider.rb +37 -0
  34. data/lib/aws-sdk-core/endpoints/templater.rb +58 -0
  35. data/lib/aws-sdk-core/endpoints/tree_rule.rb +45 -0
  36. data/lib/aws-sdk-core/endpoints/url.rb +60 -0
  37. data/lib/aws-sdk-core/endpoints.rb +158 -0
  38. data/lib/aws-sdk-core/error_handler.rb +46 -0
  39. data/lib/aws-sdk-core/errors.rb +14 -5
  40. data/lib/aws-sdk-core/event_emitter.rb +1 -17
  41. data/lib/aws-sdk-core/ini_parser.rb +7 -0
  42. data/lib/aws-sdk-core/instance_profile_credentials.rb +168 -155
  43. data/lib/aws-sdk-core/json/builder.rb +8 -1
  44. data/lib/aws-sdk-core/json/error_handler.rb +46 -11
  45. data/lib/aws-sdk-core/json/handler.rb +13 -6
  46. data/lib/aws-sdk-core/json/json_engine.rb +3 -1
  47. data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
  48. data/lib/aws-sdk-core/json/parser.rb +33 -3
  49. data/lib/aws-sdk-core/json.rb +43 -14
  50. data/lib/aws-sdk-core/log/formatter.rb +6 -0
  51. data/lib/aws-sdk-core/log/param_filter.rb +2 -2
  52. data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
  53. data/lib/aws-sdk-core/log.rb +10 -0
  54. data/lib/aws-sdk-core/lru_cache.rb +75 -0
  55. data/lib/aws-sdk-core/pageable_response.rb +3 -1
  56. data/lib/aws-sdk-core/param_validator.rb +9 -4
  57. data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
  58. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +348 -169
  59. data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -1
  60. data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
  61. data/lib/aws-sdk-core/plugins/credentials_configuration.rb +84 -38
  62. data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +6 -2
  63. data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
  64. data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
  65. data/lib/aws-sdk-core/plugins/http_checksum.rb +3 -8
  66. data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
  67. data/lib/aws-sdk-core/plugins/logging.rb +2 -0
  68. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
  69. data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
  70. data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
  71. data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
  72. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
  73. data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
  74. data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
  75. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +164 -34
  76. data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
  77. data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +2 -1
  78. data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
  79. data/lib/aws-sdk-core/plugins/sign.rb +222 -0
  80. data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -0
  81. data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -0
  82. data/lib/aws-sdk-core/plugins/stub_responses.rb +59 -9
  83. data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
  84. data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
  85. data/lib/aws-sdk-core/plugins/user_agent.rb +192 -14
  86. data/lib/aws-sdk-core/plugins.rb +39 -0
  87. data/lib/aws-sdk-core/process_credentials.rb +48 -29
  88. data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
  89. data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
  90. data/lib/aws-sdk-core/query/handler.rb +4 -4
  91. data/lib/aws-sdk-core/query/param_builder.rb +2 -2
  92. data/lib/aws-sdk-core/query.rb +2 -1
  93. data/lib/aws-sdk-core/refreshing_credentials.rb +20 -23
  94. data/lib/aws-sdk-core/resources.rb +8 -0
  95. data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
  96. data/lib/aws-sdk-core/rest/handler.rb +3 -4
  97. data/lib/aws-sdk-core/rest/request/body.rb +32 -5
  98. data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
  99. data/lib/aws-sdk-core/rest/request/headers.rb +14 -10
  100. data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
  101. data/lib/aws-sdk-core/rest/response/body.rb +15 -1
  102. data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
  103. data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
  104. data/lib/aws-sdk-core/rest.rb +1 -0
  105. data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
  106. data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
  107. data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
  108. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +95 -0
  109. data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
  110. data/lib/aws-sdk-core/rpc_v2/parser.rb +98 -0
  111. data/lib/aws-sdk-core/rpc_v2.rb +69 -0
  112. data/lib/aws-sdk-core/shared_config.rb +160 -36
  113. data/lib/aws-sdk-core/shared_credentials.rb +1 -7
  114. data/lib/aws-sdk-core/sso_credentials.rb +84 -46
  115. data/lib/aws-sdk-core/sso_token_provider.rb +3 -2
  116. data/lib/aws-sdk-core/static_token_provider.rb +1 -2
  117. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
  118. data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
  119. data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
  120. data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
  121. data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
  122. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
  123. data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +39 -0
  124. data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
  125. data/lib/aws-sdk-core/stubbing.rb +22 -0
  126. data/lib/aws-sdk-core/telemetry/base.rb +177 -0
  127. data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
  128. data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
  129. data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
  130. data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
  131. data/lib/aws-sdk-core/telemetry.rb +78 -0
  132. data/lib/aws-sdk-core/token.rb +3 -3
  133. data/lib/aws-sdk-core/token_provider.rb +4 -0
  134. data/lib/aws-sdk-core/token_provider_chain.rb +2 -6
  135. data/lib/aws-sdk-core/util.rb +41 -1
  136. data/lib/aws-sdk-core/waiters/poller.rb +12 -5
  137. data/lib/aws-sdk-core/xml/builder.rb +17 -9
  138. data/lib/aws-sdk-core/xml/error_handler.rb +35 -43
  139. data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
  140. data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +2 -0
  141. data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
  142. data/lib/aws-sdk-core/xml/parser.rb +2 -6
  143. data/lib/aws-sdk-core.rb +82 -103
  144. data/lib/aws-sdk-sso/client.rb +219 -89
  145. data/lib/aws-sdk-sso/client_api.rb +7 -0
  146. data/lib/aws-sdk-sso/endpoint_parameters.rb +69 -0
  147. data/lib/aws-sdk-sso/endpoint_provider.rb +53 -0
  148. data/lib/aws-sdk-sso/endpoints.rb +20 -0
  149. data/lib/aws-sdk-sso/plugins/endpoints.rb +77 -0
  150. data/lib/aws-sdk-sso/types.rb +1 -35
  151. data/lib/aws-sdk-sso.rb +15 -7
  152. data/lib/aws-sdk-ssooidc/client.rb +650 -118
  153. data/lib/aws-sdk-ssooidc/client_api.rb +94 -1
  154. data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +69 -0
  155. data/lib/aws-sdk-ssooidc/endpoint_provider.rb +53 -0
  156. data/lib/aws-sdk-ssooidc/endpoints.rb +20 -0
  157. data/lib/aws-sdk-ssooidc/errors.rb +62 -0
  158. data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +77 -0
  159. data/lib/aws-sdk-ssooidc/types.rb +437 -67
  160. data/lib/aws-sdk-ssooidc.rb +15 -7
  161. data/lib/aws-sdk-sts/client.rb +670 -368
  162. data/lib/aws-sdk-sts/client_api.rb +48 -9
  163. data/lib/aws-sdk-sts/customizations.rb +5 -2
  164. data/lib/aws-sdk-sts/endpoint_parameters.rb +79 -0
  165. data/lib/aws-sdk-sts/endpoint_provider.rb +107 -0
  166. data/lib/aws-sdk-sts/endpoints.rb +20 -0
  167. data/lib/aws-sdk-sts/errors.rb +15 -0
  168. data/lib/aws-sdk-sts/plugins/endpoints.rb +77 -0
  169. data/lib/aws-sdk-sts/presigner.rb +12 -18
  170. data/lib/aws-sdk-sts/types.rb +296 -222
  171. data/lib/aws-sdk-sts.rb +15 -7
  172. data/lib/seahorse/client/async_base.rb +4 -6
  173. data/lib/seahorse/client/async_response.rb +19 -0
  174. data/lib/seahorse/client/base.rb +18 -21
  175. data/lib/seahorse/client/configuration.rb +1 -5
  176. data/lib/seahorse/client/h2/connection.rb +27 -36
  177. data/lib/seahorse/client/h2/handler.rb +14 -3
  178. data/lib/seahorse/client/handler.rb +1 -1
  179. data/lib/seahorse/client/http/response.rb +1 -1
  180. data/lib/seahorse/client/net_http/connection_pool.rb +15 -12
  181. data/lib/seahorse/client/net_http/handler.rb +21 -9
  182. data/lib/seahorse/client/net_http/patches.rb +1 -4
  183. data/lib/seahorse/client/networking_error.rb +1 -1
  184. data/lib/seahorse/client/plugin.rb +9 -0
  185. data/lib/seahorse/client/plugins/endpoint.rb +0 -1
  186. data/lib/seahorse/client/plugins/h2.rb +4 -4
  187. data/lib/seahorse/client/plugins/net_http.rb +57 -16
  188. data/lib/seahorse/client/plugins/request_callback.rb +40 -9
  189. data/lib/seahorse/client/request_context.rb +9 -2
  190. data/lib/seahorse/client/response.rb +8 -0
  191. data/lib/seahorse/model/operation.rb +3 -0
  192. data/lib/seahorse/model/shapes.rb +2 -2
  193. data/lib/seahorse/util.rb +6 -1
  194. data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
  195. data/sig/aws-sdk-core/client_stubs.rbs +10 -0
  196. data/sig/aws-sdk-core/errors.rbs +22 -0
  197. data/sig/aws-sdk-core/resources/collection.rbs +21 -0
  198. data/sig/aws-sdk-core/structure.rbs +4 -0
  199. data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
  200. data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
  201. data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
  202. data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
  203. data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
  204. data/sig/aws-sdk-core.rbs +7 -0
  205. data/sig/seahorse/client/async_base.rbs +18 -0
  206. data/sig/seahorse/client/base.rbs +25 -0
  207. data/sig/seahorse/client/handler_builder.rbs +16 -0
  208. data/sig/seahorse/client/response.rbs +61 -0
  209. metadata +133 -23
  210. /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
  211. /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
  212. /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
  213. /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
@@ -3,24 +3,19 @@
3
3
  module Aws
4
4
  # An auto-refreshing credential provider that assumes a role via
5
5
  # {Aws::SSO::Client#get_role_credentials} using a cached access
6
- # token. This class does NOT implement the SSO login token flow - tokens
7
- # must generated and refreshed separately by running `aws login` from the
8
- # AWS CLI with the correct profile.
9
- #
10
- # The `SSOCredentials` will auto-refresh the AWS credentials from SSO. In
11
- # addition to AWS credentials expiring after a given amount of time, the
12
- # access token generated and cached from `aws login` will also expire.
13
- # Once this token expires, it will not be usable to refresh AWS credentials,
14
- # and another token will be needed. The SDK does not manage refreshing of
15
- # the token value, but this can be done by running `aws login` with the
16
- # correct profile.
6
+ # token. When `sso_session` is specified, token refresh logic from
7
+ # {Aws::SSOTokenProvider} will be used to refresh the token if possible.
8
+ # This class does NOT implement the SSO login token flow - tokens
9
+ # must generated separately by running `aws login` from the
10
+ # AWS CLI with the correct profile. The {SSOCredentials} will
11
+ # auto-refresh the AWS credentials from SSO.
17
12
  #
18
13
  # # You must first run aws sso login --profile your-sso-profile
19
14
  # sso_credentials = Aws::SSOCredentials.new(
20
15
  # sso_account_id: '123456789',
21
16
  # sso_role_name: "role_name",
22
17
  # sso_region: "us-east-1",
23
- # sso_start_url: 'https://your-start-url.awsapps.com/start'
18
+ # sso_session: 'my_sso_session'
24
19
  # )
25
20
  # ec2 = Aws::EC2::Client.new(credentials: sso_credentials)
26
21
  #
@@ -35,7 +30,8 @@ module Aws
35
30
  include RefreshingCredentials
36
31
 
37
32
  # @api private
38
- SSO_REQUIRED_OPTS = [:sso_account_id, :sso_region, :sso_role_name, :sso_start_url].freeze
33
+ LEGACY_REQUIRED_OPTS = [:sso_start_url, :sso_account_id, :sso_region, :sso_role_name].freeze
34
+ TOKEN_PROVIDER_REQUIRED_OPTS = [:sso_session, :sso_account_id, :sso_region, :sso_role_name].freeze
39
35
 
40
36
  # @api private
41
37
  SSO_LOGIN_GUIDANCE = 'The SSO session associated with this profile has '\
@@ -45,17 +41,23 @@ module Aws
45
41
  # @option options [required, String] :sso_account_id The AWS account ID
46
42
  # that temporary AWS credentials will be resolved for
47
43
  #
48
- # @option options [required, String] :sso_region The AWS region where the
49
- # SSO directory for the given sso_start_url is hosted.
50
- #
51
44
  # @option options [required, String] :sso_role_name The corresponding
52
45
  # IAM role in the AWS account that temporary AWS credentials
53
46
  # will be resolved for.
54
47
  #
55
- # @option options [required, String] :sso_start_url The start URL is
56
- # provided by the SSO service via the console and is the URL used to
48
+ # @option options [required, String] :sso_region The AWS region where the
49
+ # SSO directory for the given sso_start_url is hosted.
50
+ #
51
+ # @option options [String] :sso_session The SSO Token used for fetching
52
+ # the token. If provided, refresh logic from the {Aws::SSOTokenProvider}
53
+ # will be used.
54
+ #
55
+ # @option options [String] :sso_start_url (legacy profiles) If provided,
56
+ # legacy token fetch behavior will be used, which does not support
57
+ # token refreshing. The start URL is provided by the SSO
58
+ # service via the console and is the URL used to
57
59
  # login to the SSO directory. This is also sometimes referred to as
58
- # the "User Portal URL"
60
+ # the "User Portal URL".
59
61
  #
60
62
  # @option options [SSO::Client] :client Optional `SSO::Client`. If not
61
63
  # provided, a client will be constructed.
@@ -65,27 +67,54 @@ module Aws
65
67
  # with an instance of this object when
66
68
  # AWS credentials are required and need to be refreshed.
67
69
  def initialize(options = {})
68
-
69
- missing_keys = SSO_REQUIRED_OPTS.select { |k| options[k].nil? }
70
- unless missing_keys.empty?
71
- raise ArgumentError, "Missing required keys: #{missing_keys}"
70
+ options = options.select {|k, v| !v.nil? }
71
+ if (options[:sso_session])
72
+ missing_keys = TOKEN_PROVIDER_REQUIRED_OPTS.select { |k| options[k].nil? }
73
+ unless missing_keys.empty?
74
+ raise ArgumentError, "Missing required keys: #{missing_keys}"
75
+ end
76
+ @legacy = false
77
+ @sso_role_name = options.delete(:sso_role_name)
78
+ @sso_account_id = options.delete(:sso_account_id)
79
+
80
+ # if client has been passed, don't pass through to SSOTokenProvider
81
+ @client = options.delete(:client)
82
+ options.delete(:sso_start_url)
83
+ @token_provider = Aws::SSOTokenProvider.new(options.dup)
84
+ @sso_session = options.delete(:sso_session)
85
+ @sso_region = options.delete(:sso_region)
86
+
87
+ unless @client
88
+ client_opts = {}
89
+ options.each_pair { |k,v| client_opts[k] = v unless CLIENT_EXCLUDE_OPTIONS.include?(k) }
90
+ client_opts[:region] = @sso_region
91
+ client_opts[:credentials] = nil
92
+ @client = Aws::SSO::Client.new(client_opts)
93
+ end
94
+ @metrics = ['CREDENTIALS_SSO']
95
+ else # legacy behavior
96
+ missing_keys = LEGACY_REQUIRED_OPTS.select { |k| options[k].nil? }
97
+ unless missing_keys.empty?
98
+ raise ArgumentError, "Missing required keys: #{missing_keys}"
99
+ end
100
+ @legacy = true
101
+ @sso_start_url = options.delete(:sso_start_url)
102
+ @sso_region = options.delete(:sso_region)
103
+ @sso_role_name = options.delete(:sso_role_name)
104
+ @sso_account_id = options.delete(:sso_account_id)
105
+
106
+ # validate we can read the token file
107
+ read_cached_token
108
+
109
+ client_opts = {}
110
+ options.each_pair { |k,v| client_opts[k] = v unless CLIENT_EXCLUDE_OPTIONS.include?(k) }
111
+ client_opts[:region] = @sso_region
112
+ client_opts[:credentials] = nil
113
+
114
+ @client = options[:client] || Aws::SSO::Client.new(client_opts)
115
+ @metrics = ['CREDENTIALS_SSO_LEGACY']
72
116
  end
73
117
 
74
- @sso_start_url = options.delete(:sso_start_url)
75
- @sso_region = options.delete(:sso_region)
76
- @sso_role_name = options.delete(:sso_role_name)
77
- @sso_account_id = options.delete(:sso_account_id)
78
-
79
- # validate we can read the token file
80
- read_cached_token
81
-
82
-
83
- client_opts = {}
84
- options.each_pair { |k,v| client_opts[k] = v unless CLIENT_EXCLUDE_OPTIONS.include?(k) }
85
- client_opts[:region] = @sso_region
86
- client_opts[:credentials] = nil
87
-
88
- @client = options[:client] || Aws::SSO::Client.new(client_opts)
89
118
  @async_refresh = true
90
119
  super
91
120
  end
@@ -111,19 +140,28 @@ module Aws
111
140
  end
112
141
 
113
142
  def refresh
114
- cached_token = read_cached_token
115
- c = @client.get_role_credentials(
116
- account_id: @sso_account_id,
117
- role_name: @sso_role_name,
118
- access_token: cached_token['accessToken']
119
- ).role_credentials
143
+ c = if @legacy
144
+ cached_token = read_cached_token
145
+ @client.get_role_credentials(
146
+ account_id: @sso_account_id,
147
+ role_name: @sso_role_name,
148
+ access_token: cached_token['accessToken']
149
+ ).role_credentials
150
+ else
151
+ @client.get_role_credentials(
152
+ account_id: @sso_account_id,
153
+ role_name: @sso_role_name,
154
+ access_token: @token_provider.token.token
155
+ ).role_credentials
156
+ end
120
157
 
121
158
  @credentials = Credentials.new(
122
159
  c.access_key_id,
123
160
  c.secret_access_key,
124
- c.session_token
161
+ c.session_token,
162
+ account_id: @sso_account_id
125
163
  )
126
- @expiration = c.expiration
164
+ @expiration = Time.at(c.expiration / 1000.0)
127
165
  end
128
166
 
129
167
  def sso_cache_file
@@ -39,12 +39,13 @@ module Aws
39
39
 
40
40
  options[:region] = @sso_region
41
41
  options[:credentials] = nil
42
+ options[:token_provider] = nil
42
43
  @client = options[:client] || Aws::SSOOIDC::Client.new(options)
43
44
 
44
45
  super
45
46
  end
46
47
 
47
- # @return [SSO::Client]
48
+ # @return [SSOOIDC::Client]
48
49
  attr_reader :client
49
50
 
50
51
  private
@@ -66,7 +67,7 @@ module Aws
66
67
  resp = @client.create_token(
67
68
  grant_type: 'refresh_token',
68
69
  client_id: token_json['clientId'],
69
- client_secret: token_json['client_secret'],
70
+ client_secret: token_json['clientSecret'],
70
71
  refresh_token: token_json['refreshToken']
71
72
  )
72
73
  token_json['accessToken'] = resp.access_token
@@ -2,12 +2,11 @@
2
2
 
3
3
  module Aws
4
4
  class StaticTokenProvider
5
-
6
5
  include TokenProvider
7
6
 
8
7
  # @param [String] token
9
8
  # @param [Time] expiration
10
- def initialize(token, expiration=nil)
9
+ def initialize(token, expiration = nil)
11
10
  @token = Token.new(token, expiration)
12
11
  end
13
12
  end
@@ -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)
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Stubbing
5
+ module Protocols
6
+ # @api private
7
+ class RpcV2
8
+
9
+ def stub_data(_api, operation, data)
10
+ resp = Seahorse::Client::Http::Response.new
11
+ resp.status_code = 200
12
+ resp.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
13
+ resp.headers['Content-Type'] = 'application/cbor'
14
+ resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
15
+ resp.body = build_body(operation, data)
16
+ resp
17
+ end
18
+
19
+ def stub_error(error_code)
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
29
+ end
30
+
31
+ private
32
+
33
+ def build_body(operation, data)
34
+ Aws::RpcV2::Builder.new(operation.output).serialize(data)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -13,12 +13,23 @@ module Aws
13
13
  def stub(data = {})
14
14
  stub = EmptyStub.new(@rules).stub
15
15
  remove_paging_tokens(stub)
16
+ remove_checksums(stub)
16
17
  apply_data(data, stub)
17
18
  stub
18
19
  end
19
20
 
20
21
  private
21
22
 
23
+ def remove_checksums(stub)
24
+ if @rules && @rules.shape.is_a?(Seahorse::Model::Shapes::StructureShape)
25
+ @rules.shape.members.each do |key, member|
26
+ if member.location == 'header' && member.location_name.start_with?('x-amz-checksum-')
27
+ stub[key] = nil
28
+ end
29
+ end
30
+ end
31
+ end
32
+
22
33
  def remove_paging_tokens(stub)
23
34
  if @pager
24
35
  @pager.instance_variable_get("@tokens").keys.each do |path|
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ # @api private
5
+ module Stubbing
6
+ autoload :EmptyStub, 'aws-sdk-core/stubbing/empty_stub'
7
+ autoload :DataApplicator, 'aws-sdk-core/stubbing/data_applicator'
8
+ autoload :StubData, 'aws-sdk-core/stubbing/stub_data'
9
+ autoload :XmlError, 'aws-sdk-core/stubbing/xml_error'
10
+
11
+ module Protocols
12
+ autoload :Json, 'aws-sdk-core/stubbing/protocols/json'
13
+ autoload :Rest, 'aws-sdk-core/stubbing/protocols/rest'
14
+ autoload :RestJson, 'aws-sdk-core/stubbing/protocols/rest_json'
15
+ autoload :RestXml, 'aws-sdk-core/stubbing/protocols/rest_xml'
16
+ autoload :Query, 'aws-sdk-core/stubbing/protocols/query'
17
+ autoload :EC2, 'aws-sdk-core/stubbing/protocols/ec2'
18
+ autoload :RpcV2, 'aws-sdk-core/stubbing/protocols/rpc_v2'
19
+ autoload :ApiGateway, 'aws-sdk-core/stubbing/protocols/api_gateway'
20
+ end
21
+ end
22
+ end