aws-sdk-core 3.171.0 → 3.181.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +106 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-defaults/default_configuration.rb +4 -4
  5. data/lib/aws-sdk-core/credential_provider.rb +3 -0
  6. data/lib/aws-sdk-core/endpoints.rb +5 -1
  7. data/lib/aws-sdk-core/ini_parser.rb +7 -0
  8. data/lib/aws-sdk-core/json/error_handler.rb +15 -5
  9. data/lib/aws-sdk-core/log/formatter.rb +6 -0
  10. data/lib/aws-sdk-core/pageable_response.rb +3 -1
  11. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +1 -1
  12. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +109 -33
  13. data/lib/aws-sdk-core/plugins/request_compression.rb +217 -0
  14. data/lib/aws-sdk-core/plugins/sign.rb +1 -0
  15. data/lib/aws-sdk-core/plugins/user_agent.rb +117 -14
  16. data/lib/aws-sdk-core/refreshing_credentials.rb +0 -6
  17. data/lib/aws-sdk-core/shared_config.rb +46 -18
  18. data/lib/aws-sdk-core/sso_credentials.rb +1 -1
  19. data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
  20. data/lib/aws-sdk-core/waiters/poller.rb +3 -1
  21. data/lib/aws-sdk-sso/client.rb +21 -1
  22. data/lib/aws-sdk-sso/endpoints.rb +1 -0
  23. data/lib/aws-sdk-sso.rb +1 -1
  24. data/lib/aws-sdk-ssooidc/client.rb +21 -1
  25. data/lib/aws-sdk-ssooidc/endpoints.rb +1 -0
  26. data/lib/aws-sdk-ssooidc.rb +1 -1
  27. data/lib/aws-sdk-sts/client.rb +137 -111
  28. data/lib/aws-sdk-sts/client_api.rb +10 -0
  29. data/lib/aws-sdk-sts/endpoint_provider.rb +81 -78
  30. data/lib/aws-sdk-sts/endpoints.rb +1 -0
  31. data/lib/aws-sdk-sts/types.rb +35 -11
  32. data/lib/aws-sdk-sts.rb +1 -1
  33. data/lib/seahorse/client/configuration.rb +0 -4
  34. data/lib/seahorse/client/plugins/request_callback.rb +31 -0
  35. data/lib/seahorse/client/response.rb +6 -0
  36. data/lib/seahorse/model/operation.rb +3 -0
  37. metadata +3 -2
@@ -4,7 +4,31 @@ module Aws
4
4
  module Plugins
5
5
  # @api private
6
6
  class UserAgent < Seahorse::Client::Plugin
7
+ # @api private
7
8
  option(:user_agent_suffix)
9
+ # @api private
10
+ option(:user_agent_frameworks, default: [])
11
+
12
+ option(
13
+ :sdk_ua_app_id,
14
+ doc_type: 'String',
15
+ docstring: <<-DOCS) do |cfg|
16
+ A unique and opaque application ID that is appended to the
17
+ User-Agent header as app/<sdk_ua_app_id>. It should have a
18
+ maximum length of 50.
19
+ DOCS
20
+ app_id = ENV['AWS_SDK_UA_APP_ID']
21
+ app_id ||= Aws.shared_config.sdk_ua_app_id(profile: cfg.profile)
22
+ app_id
23
+ end
24
+
25
+ def self.feature(feature, &block)
26
+ Thread.current[:aws_sdk_core_user_agent_feature] ||= []
27
+ Thread.current[:aws_sdk_core_user_agent_feature] << "ft/#{feature}"
28
+ block.call
29
+ ensure
30
+ Thread.current[:aws_sdk_core_user_agent_feature].pop
31
+ end
8
32
 
9
33
  # @api private
10
34
  class Handler < Seahorse::Client::Handler
@@ -14,33 +38,112 @@ module Aws
14
38
  end
15
39
 
16
40
  def set_user_agent(context)
17
- ua = "aws-sdk-ruby3/#{CORE_GEM_VERSION}"
41
+ context.http_request.headers['User-Agent'] = UserAgent.new(context).to_s
42
+ end
43
+
44
+ class UserAgent
45
+ def initialize(context)
46
+ @context = context
47
+ end
48
+
49
+ def to_s
50
+ ua = "aws-sdk-ruby3/#{CORE_GEM_VERSION}"
51
+ ua += ' ua/2.0'
52
+ ua += " #{api_metadata}" if api_metadata
53
+ ua += " #{os_metadata}"
54
+ ua += " #{language_metadata}"
55
+ ua += " #{env_metadata}" if env_metadata
56
+ ua += " #{config_metadata}" if config_metadata
57
+ ua += " #{app_id}" if app_id
58
+ ua += " #{feature_metadata}" if feature_metadata
59
+ ua += " #{framework_metadata}" if framework_metadata
60
+ if @context.config.user_agent_suffix
61
+ ua += " #{@context.config.user_agent_suffix}"
62
+ end
63
+ ua.strip
64
+ end
65
+
66
+ private
18
67
 
19
- begin
20
- ua += " #{RUBY_ENGINE}/#{RUBY_VERSION}"
21
- rescue
22
- ua += " RUBY_ENGINE_NA/#{RUBY_VERSION}"
68
+ # Used to be gem_name/gem_version
69
+ def api_metadata
70
+ service_id = @context.config.api.metadata['serviceId']
71
+ return unless service_id
72
+
73
+ service_id = service_id.gsub(' ', '_').downcase
74
+ gem_version = @context[:gem_version]
75
+ "api/#{service_id}##{gem_version}"
76
+ end
77
+
78
+ # Used to be RUBY_PLATFORM
79
+ def os_metadata
80
+ os =
81
+ case RbConfig::CONFIG['host_os']
82
+ when /mac|darwin/
83
+ 'macos'
84
+ when /linux|cygwin/
85
+ 'linux'
86
+ when /mingw|mswin/
87
+ 'windows'
88
+ else
89
+ 'other'
90
+ end
91
+ metadata = "os/#{os}"
92
+ local_version = Gem::Platform.local.version
93
+ metadata += "##{local_version}" if local_version
94
+ metadata += " md/#{RbConfig::CONFIG['host_cpu']}"
95
+ metadata
23
96
  end
24
97
 
25
- ua += " #{RUBY_PLATFORM}"
98
+ # Used to be RUBY_ENGINE/RUBY_VERSION
99
+ def language_metadata
100
+ "lang/#{RUBY_ENGINE}##{RUBY_ENGINE_VERSION} md/#{RUBY_VERSION}"
101
+ end
102
+
103
+ def env_metadata
104
+ return unless (execution_env = ENV['AWS_EXECUTION_ENV'])
105
+
106
+ "exec-env/#{execution_env}"
107
+ end
26
108
 
27
- if context[:gem_name] && context[:gem_version]
28
- ua += " #{context[:gem_name]}/#{context[:gem_version]}"
109
+ def config_metadata
110
+ "cfg/retry-mode##{@context.config.retry_mode}"
29
111
  end
30
112
 
31
- if (execution_env = ENV['AWS_EXECUTION_ENV'])
32
- ua += " exec-env/#{execution_env}"
113
+ def app_id
114
+ return unless (app_id = @context.config.sdk_ua_app_id)
115
+
116
+ # Sanitize and only allow these characters
117
+ app_id = app_id.gsub(/[^!#$%&'*+\-.^_`|~0-9A-Za-z]/, '-')
118
+ "app/#{app_id}"
33
119
  end
34
120
 
35
- if context.config.user_agent_suffix
36
- ua += " #{context.config.user_agent_suffix}"
121
+ def feature_metadata
122
+ return unless Thread.current[:aws_sdk_core_user_agent_feature]
123
+
124
+ Thread.current[:aws_sdk_core_user_agent_feature].join(' ')
37
125
  end
38
126
 
39
- context.http_request.headers['User-Agent'] = ua.strip
127
+ def framework_metadata
128
+ if (frameworks_cfg = @context.config.user_agent_frameworks).empty?
129
+ return
130
+ end
131
+
132
+ # Frameworks may be aws-record, aws-sdk-rails, etc.
133
+ regex = /gems\/(?<name>#{frameworks_cfg.join('|')})-(?<version>\d+\.\d+\.\d+)/.freeze
134
+ frameworks = {}
135
+ Kernel.caller.each do |line|
136
+ match = line.match(regex)
137
+ next unless match
138
+
139
+ frameworks[match[:name]] = match[:version]
140
+ end
141
+ frameworks.map { |n, v| "lib/#{n}##{v}" }.join(' ')
142
+ end
40
143
  end
41
144
  end
42
145
 
43
- handler(Handler)
146
+ handler(Handler, priority: 1)
44
147
  end
45
148
  end
46
149
  end
@@ -36,12 +36,6 @@ module Aws
36
36
  @credentials
37
37
  end
38
38
 
39
- # @return [Time,nil]
40
- def expiration
41
- refresh_if_near_expiration!
42
- @expiration
43
- end
44
-
45
39
  # Refresh credentials.
46
40
  # @return [void]
47
41
  def refresh!
@@ -167,6 +167,26 @@ module Aws
167
167
  token
168
168
  end
169
169
 
170
+ # Source a custom configured endpoint from the shared configuration file
171
+ #
172
+ # @param [Hash] opts
173
+ # @option opts [String] :profile
174
+ # @option opts [String] :service_id
175
+ def configured_endpoint(opts = {})
176
+ # services section is only allowed in the shared config file (not credentials)
177
+ profile = opts[:profile] || @profile_name
178
+ service_id = opts[:service_id]&.gsub(" ", "_")&.downcase
179
+ if @parsed_config && (prof_config = @parsed_config[profile])
180
+ services_section_name = prof_config['services']
181
+ if (services_config = @parsed_config["services #{services_section_name}"]) &&
182
+ (service_config = services_config[service_id])
183
+ return service_config['endpoint_url'] if service_config['endpoint_url']
184
+ end
185
+ return prof_config['endpoint_url']
186
+ end
187
+ nil
188
+ end
189
+
170
190
  # Add an accessor method (similar to attr_reader) to return a configuration value
171
191
  # Uses the get_config_value below to control where
172
192
  # values are loaded from
@@ -197,7 +217,11 @@ module Aws
197
217
  :s3_use_arn_region,
198
218
  :s3_us_east_1_regional_endpoint,
199
219
  :s3_disable_multiregion_access_points,
200
- :defaults_mode
220
+ :defaults_mode,
221
+ :sdk_ua_app_id,
222
+ :disable_request_compression,
223
+ :request_min_compression_size_bytes,
224
+ :ignore_configured_endpoint_urls
201
225
  )
202
226
 
203
227
  private
@@ -335,12 +359,8 @@ module Aws
335
359
  !(prof_config.keys & SSO_CREDENTIAL_PROFILE_KEYS).empty?
336
360
 
337
361
  if sso_session_name = prof_config['sso_session']
338
- sso_session = cfg["sso-session #{sso_session_name}"]
339
- unless sso_session
340
- raise ArgumentError,
341
- "sso-session #{sso_session_name} must be defined in the config file. " \
342
- "Referenced by profile #{profile}"
343
- end
362
+ sso_session = sso_session(cfg, profile, sso_session_name)
363
+
344
364
  sso_region = sso_session['sso_region']
345
365
  sso_start_url = sso_session['sso_start_url']
346
366
 
@@ -365,7 +385,7 @@ module Aws
365
385
  sso_role_name: prof_config['sso_role_name'],
366
386
  sso_session: prof_config['sso_session'],
367
387
  sso_region: sso_region,
368
- sso_start_url: prof_config['sso_start_url']
388
+ sso_start_url: sso_start_url
369
389
  )
370
390
  end
371
391
  end
@@ -378,16 +398,7 @@ module Aws
378
398
  !(prof_config.keys & SSO_TOKEN_PROFILE_KEYS).empty?
379
399
 
380
400
  sso_session_name = prof_config['sso_session']
381
- sso_session = cfg["sso-session #{sso_session_name}"]
382
- unless sso_session
383
- raise ArgumentError,
384
- "sso-session #{sso_session_name} must be defined in the config file." \
385
- "Referenced by profile #{profile}"
386
- end
387
-
388
- unless sso_session['sso_region']
389
- raise ArgumentError, "sso-session #{sso_session_name} missing required parameter: sso_region"
390
- end
401
+ sso_session = sso_session(cfg, profile, sso_session_name)
391
402
 
392
403
  SSOTokenProvider.new(
393
404
  sso_session: sso_session_name,
@@ -445,5 +456,22 @@ module Aws
445
456
  ret ||= 'default'
446
457
  ret
447
458
  end
459
+
460
+ def sso_session(cfg, profile, sso_session_name)
461
+ # aws sso-configure may add quotes around sso session names with whitespace
462
+ sso_session = cfg["sso-session #{sso_session_name}"] || cfg["sso-session '#{sso_session_name}'"]
463
+
464
+ unless sso_session
465
+ raise ArgumentError,
466
+ "sso-session #{sso_session_name} must be defined in the config file. " \
467
+ "Referenced by profile #{profile}"
468
+ end
469
+
470
+ unless sso_session['sso_region']
471
+ raise ArgumentError, "sso-session #{sso_session_name} missing required parameter: sso_region"
472
+ end
473
+
474
+ sso_session
475
+ end
448
476
  end
449
477
  end
@@ -158,7 +158,7 @@ module Aws
158
158
  c.secret_access_key,
159
159
  c.session_token
160
160
  )
161
- @expiration = c.expiration
161
+ @expiration = Time.at(c.expiration / 1000.0)
162
162
  end
163
163
 
164
164
  def sso_cache_file
@@ -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|
@@ -62,7 +62,9 @@ module Aws
62
62
  def send_request(options)
63
63
  req = options[:client].build_request(@operation_name, options[:params])
64
64
  req.handlers.remove(RAISE_HANDLER)
65
- req.send_request
65
+ Aws::Plugins::UserAgent.feature('waiter') do
66
+ req.send_request
67
+ end
66
68
  end
67
69
 
68
70
  def acceptor_matches?(acceptor, response)
@@ -28,6 +28,7 @@ require 'aws-sdk-core/plugins/client_metrics_send_plugin.rb'
28
28
  require 'aws-sdk-core/plugins/transfer_encoding.rb'
29
29
  require 'aws-sdk-core/plugins/http_checksum.rb'
30
30
  require 'aws-sdk-core/plugins/checksum_algorithm.rb'
31
+ require 'aws-sdk-core/plugins/request_compression.rb'
31
32
  require 'aws-sdk-core/plugins/defaults_mode.rb'
32
33
  require 'aws-sdk-core/plugins/recursion_detection.rb'
33
34
  require 'aws-sdk-core/plugins/sign.rb'
@@ -77,6 +78,7 @@ module Aws::SSO
77
78
  add_plugin(Aws::Plugins::TransferEncoding)
78
79
  add_plugin(Aws::Plugins::HttpChecksum)
79
80
  add_plugin(Aws::Plugins::ChecksumAlgorithm)
81
+ add_plugin(Aws::Plugins::RequestCompression)
80
82
  add_plugin(Aws::Plugins::DefaultsMode)
81
83
  add_plugin(Aws::Plugins::RecursionDetection)
82
84
  add_plugin(Aws::Plugins::Sign)
@@ -190,6 +192,10 @@ module Aws::SSO
190
192
  # Set to true to disable SDK automatically adding host prefix
191
193
  # to default service endpoint when available.
192
194
  #
195
+ # @option options [Boolean] :disable_request_compression (false)
196
+ # When set to 'true' the request body will not be compressed
197
+ # for supported operations.
198
+ #
193
199
  # @option options [String] :endpoint
194
200
  # The client endpoint is normally constructed from the `:region`
195
201
  # option. You should only configure an `:endpoint` when connecting
@@ -210,6 +216,10 @@ module Aws::SSO
210
216
  # @option options [Boolean] :endpoint_discovery (false)
211
217
  # When set to `true`, endpoint discovery will be enabled for operations when available.
212
218
  #
219
+ # @option options [Boolean] :ignore_configured_endpoint_urls
220
+ # Setting to true disables use of endpoint URLs provided via environment
221
+ # variables and the shared configuration file.
222
+ #
213
223
  # @option options [Aws::Log::Formatter] :log_formatter (Aws::Log::Formatter.default)
214
224
  # The log formatter.
215
225
  #
@@ -230,6 +240,11 @@ module Aws::SSO
230
240
  # Used when loading credentials from the shared credentials file
231
241
  # at HOME/.aws/credentials. When not specified, 'default' is used.
232
242
  #
243
+ # @option options [Integer] :request_min_compression_size_bytes (10240)
244
+ # The minimum size in bytes that triggers compression for request
245
+ # bodies. The value must be non-negative integer value between 0
246
+ # and 10485780 bytes inclusive.
247
+ #
233
248
  # @option options [Proc] :retry_backoff
234
249
  # A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
235
250
  # This option is only used in the `legacy` retry mode.
@@ -275,6 +290,11 @@ module Aws::SSO
275
290
  # in the future.
276
291
  #
277
292
  #
293
+ # @option options [String] :sdk_ua_app_id
294
+ # A unique and opaque application ID that is appended to the
295
+ # User-Agent header as app/<sdk_ua_app_id>. It should have a
296
+ # maximum length of 50.
297
+ #
278
298
  # @option options [String] :secret_access_key
279
299
  #
280
300
  # @option options [String] :session_token
@@ -585,7 +605,7 @@ module Aws::SSO
585
605
  params: params,
586
606
  config: config)
587
607
  context[:gem_name] = 'aws-sdk-core'
588
- context[:gem_version] = '3.171.0'
608
+ context[:gem_version] = '3.181.0'
589
609
  Seahorse::Client::Request.new(handlers, context)
590
610
  end
591
611
 
@@ -9,6 +9,7 @@
9
9
 
10
10
 
11
11
  module Aws::SSO
12
+ # @api private
12
13
  module Endpoints
13
14
 
14
15
  class GetRoleCredentials
data/lib/aws-sdk-sso.rb CHANGED
@@ -54,6 +54,6 @@ require_relative 'aws-sdk-sso/customizations'
54
54
  # @!group service
55
55
  module Aws::SSO
56
56
 
57
- GEM_VERSION = '3.171.0'
57
+ GEM_VERSION = '3.181.0'
58
58
 
59
59
  end
@@ -28,6 +28,7 @@ require 'aws-sdk-core/plugins/client_metrics_send_plugin.rb'
28
28
  require 'aws-sdk-core/plugins/transfer_encoding.rb'
29
29
  require 'aws-sdk-core/plugins/http_checksum.rb'
30
30
  require 'aws-sdk-core/plugins/checksum_algorithm.rb'
31
+ require 'aws-sdk-core/plugins/request_compression.rb'
31
32
  require 'aws-sdk-core/plugins/defaults_mode.rb'
32
33
  require 'aws-sdk-core/plugins/recursion_detection.rb'
33
34
  require 'aws-sdk-core/plugins/sign.rb'
@@ -77,6 +78,7 @@ module Aws::SSOOIDC
77
78
  add_plugin(Aws::Plugins::TransferEncoding)
78
79
  add_plugin(Aws::Plugins::HttpChecksum)
79
80
  add_plugin(Aws::Plugins::ChecksumAlgorithm)
81
+ add_plugin(Aws::Plugins::RequestCompression)
80
82
  add_plugin(Aws::Plugins::DefaultsMode)
81
83
  add_plugin(Aws::Plugins::RecursionDetection)
82
84
  add_plugin(Aws::Plugins::Sign)
@@ -190,6 +192,10 @@ module Aws::SSOOIDC
190
192
  # Set to true to disable SDK automatically adding host prefix
191
193
  # to default service endpoint when available.
192
194
  #
195
+ # @option options [Boolean] :disable_request_compression (false)
196
+ # When set to 'true' the request body will not be compressed
197
+ # for supported operations.
198
+ #
193
199
  # @option options [String] :endpoint
194
200
  # The client endpoint is normally constructed from the `:region`
195
201
  # option. You should only configure an `:endpoint` when connecting
@@ -210,6 +216,10 @@ module Aws::SSOOIDC
210
216
  # @option options [Boolean] :endpoint_discovery (false)
211
217
  # When set to `true`, endpoint discovery will be enabled for operations when available.
212
218
  #
219
+ # @option options [Boolean] :ignore_configured_endpoint_urls
220
+ # Setting to true disables use of endpoint URLs provided via environment
221
+ # variables and the shared configuration file.
222
+ #
213
223
  # @option options [Aws::Log::Formatter] :log_formatter (Aws::Log::Formatter.default)
214
224
  # The log formatter.
215
225
  #
@@ -230,6 +240,11 @@ module Aws::SSOOIDC
230
240
  # Used when loading credentials from the shared credentials file
231
241
  # at HOME/.aws/credentials. When not specified, 'default' is used.
232
242
  #
243
+ # @option options [Integer] :request_min_compression_size_bytes (10240)
244
+ # The minimum size in bytes that triggers compression for request
245
+ # bodies. The value must be non-negative integer value between 0
246
+ # and 10485780 bytes inclusive.
247
+ #
233
248
  # @option options [Proc] :retry_backoff
234
249
  # A proc or lambda used for backoff. Defaults to 2**retries * retry_base_delay.
235
250
  # This option is only used in the `legacy` retry mode.
@@ -275,6 +290,11 @@ module Aws::SSOOIDC
275
290
  # in the future.
276
291
  #
277
292
  #
293
+ # @option options [String] :sdk_ua_app_id
294
+ # A unique and opaque application ID that is appended to the
295
+ # User-Agent header as app/<sdk_ua_app_id>. It should have a
296
+ # maximum length of 50.
297
+ #
278
298
  # @option options [String] :secret_access_key
279
299
  #
280
300
  # @option options [String] :session_token
@@ -581,7 +601,7 @@ module Aws::SSOOIDC
581
601
  params: params,
582
602
  config: config)
583
603
  context[:gem_name] = 'aws-sdk-core'
584
- context[:gem_version] = '3.171.0'
604
+ context[:gem_version] = '3.181.0'
585
605
  Seahorse::Client::Request.new(handlers, context)
586
606
  end
587
607
 
@@ -9,6 +9,7 @@
9
9
 
10
10
 
11
11
  module Aws::SSOOIDC
12
+ # @api private
12
13
  module Endpoints
13
14
 
14
15
  class CreateToken
@@ -54,6 +54,6 @@ require_relative 'aws-sdk-ssooidc/customizations'
54
54
  # @!group service
55
55
  module Aws::SSOOIDC
56
56
 
57
- GEM_VERSION = '3.171.0'
57
+ GEM_VERSION = '3.181.0'
58
58
 
59
59
  end