aws-sdk-core 3.117.0 → 3.122.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +79 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/json/json_engine.rb +10 -8
  5. data/lib/aws-sdk-core/json/oj_engine.rb +33 -6
  6. data/lib/aws-sdk-core/json/parser.rb +8 -0
  7. data/lib/aws-sdk-core/json.rb +8 -26
  8. data/lib/aws-sdk-core/log/param_filter.rb +9 -1
  9. data/lib/aws-sdk-core/param_validator.rb +29 -0
  10. data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +17 -0
  11. data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +16 -1
  12. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +47 -1
  13. data/lib/aws-sdk-core/plugins/signature_v4.rb +13 -23
  14. data/lib/aws-sdk-core/rest/request/body.rb +19 -1
  15. data/lib/aws-sdk-core/rest/request/headers.rb +6 -1
  16. data/lib/aws-sdk-core/rest/response/headers.rb +3 -1
  17. data/lib/aws-sdk-core/shared_config.rb +4 -1
  18. data/lib/aws-sdk-core/sso_credentials.rb +1 -1
  19. data/lib/aws-sdk-core/structure.rb +10 -1
  20. data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +0 -8
  21. data/lib/aws-sdk-core/xml/parser/frame.rb +23 -0
  22. data/lib/aws-sdk-core.rb +3 -0
  23. data/lib/aws-sdk-sso/client.rb +10 -3
  24. data/lib/aws-sdk-sso.rb +1 -1
  25. data/lib/aws-sdk-sts/client.rb +10 -1
  26. data/lib/aws-sdk-sts/presigner.rb +7 -1
  27. data/lib/aws-sdk-sts.rb +1 -1
  28. data/lib/seahorse/client/configuration.rb +4 -0
  29. data/lib/seahorse/client/h2/connection.rb +3 -5
  30. data/lib/seahorse/client/h2/handler.rb +4 -5
  31. data/lib/seahorse/client/net_http/handler.rb +15 -7
  32. data/lib/seahorse/client/net_http/patches.rb +13 -84
  33. data/lib/seahorse/client/plugins/content_length.rb +11 -5
  34. data/lib/seahorse/model/shapes.rb +25 -0
  35. metadata +5 -6
  36. data/lib/aws-sdk-sso/plugins/content_type.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87480a79b026cd9f4a732927079633d67b5fa7cb0150c3cef3c7eedd954d179d
4
- data.tar.gz: 42e118b53803b2d5bb5514059852fe684f4f64a22fadee010541851eca299fc5
3
+ metadata.gz: 537c37ff87364e7db7df2b499b7e82544a3912b817b32d4b43ae81a32c511f7b
4
+ data.tar.gz: 7deac3f2493760b46f54ae0f54022878641023f54566af10d56e270ea7590935
5
5
  SHA512:
6
- metadata.gz: 71053f9fca038e4fb57084f29d972034e845d58c45a973ac3e9690717689ba74228d6b1d25c2b1e473e8f2358091916875dfd3ffb90ed4ece0b36aaa38d9e81e
7
- data.tar.gz: 6e353f5356d8a61a4cfc70dce05f176859e5180e53b7de74c09bf1da7e57d0a5ac9f7cc58a584880b98b95d8518da62ed22adac942cf8d37a596300ea9caa102
6
+ metadata.gz: 63aa35b1adf4d9f660f35af4f174922fe417b9f1124602d493d4fcc90c256e8ffb472489c606746f8c06f72f71c9faa33a8a1746d7496e1fc76a2a8d138a5b7e
7
+ data.tar.gz: 113f6de79f057dd502327550b44566f52f291f1358817778dc915849c4838b29f9724f1cd4ad5f75b2df153675e058982b26a47ffbc585d008b280fb87744417
data/CHANGELOG.md CHANGED
@@ -1,6 +1,85 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.122.1 (2021-11-09)
5
+ ------------------
6
+
7
+ * Issue - Correctly serialize/deserialize header lists.
8
+
9
+ 3.122.0 (2021-11-04)
10
+ ------------------
11
+
12
+ * Feature - Updated Aws::STS::Client with the latest API changes.
13
+
14
+ * Feature - Updated Aws::SSO::Client with the latest API changes.
15
+
16
+ * Issue - Fix parsing of ISO8601 timestamps with millisecond precision in headers.
17
+
18
+ * Feature - Support modeled dualstack endpoints. It can be configured with shared configuration (`use_dualstack_endpoint`), an ENV variable (`AWS_USE_DUALSTACK_ENDPOINT`), and a constructor option (`:use_dualstack_endpoint`). Requests made to services without a dualstack endpoint will fail.
19
+
20
+ * Feature - Support modeled fips endpoints. It can be configured with shared configuration (`use_fips_endpoint`), an ENV variable (`AWS_USE_FIPS_ENDPOINT`), and a constructor option (`:use_fips_endpoint`). Requests made to services without a fips endpoint will fail.
21
+
22
+ 3.121.6 (2021-11-02)
23
+ ------------------
24
+
25
+ * Issue - Improve `SSOCredentials` error handling when profile file does not exist (#2605)
26
+
27
+ 3.121.5 (2021-10-29)
28
+ ------------------
29
+
30
+ * Issue - bump minimum version of `aws-partitions` (#2603).
31
+
32
+ 3.121.4 (2021-10-28)
33
+ ------------------
34
+
35
+ * Issue - This version has been yanked. (#2603).
36
+
37
+ * Issue - use the `EndpointProvider` to lookup signing region and name.
38
+
39
+ 3.121.3 (2021-10-20)
40
+ ------------------
41
+
42
+ * Issue - Use endpointPrefix when looking up the `signing_region` from the `EndpointProvider`.
43
+
44
+ 3.121.2 (2021-10-18)
45
+ ------------------
46
+
47
+ * Issue - Fix an issue where Rest JSON services do not have a `Content-Type` header.
48
+
49
+ * Issue - Remove blank `Content-Type` header from Net::HTTP handler, and prevent a default from being set.
50
+
51
+ * Issue - Set `Content-Length` only for HTTP methods that take a body.
52
+
53
+ 3.121.1 (2021-09-24)
54
+ ------------------
55
+
56
+ * Issue - Fix error in finding union member for boolean shapes with `false` values.
57
+
58
+ 3.121.0 (2021-09-02)
59
+ ------------------
60
+
61
+ * Feature - Add support for S3 Multi-region access point configuration.
62
+
63
+ 3.120.0 (2021-09-01)
64
+ ------------------
65
+
66
+ * Feature - AWS SDK for Ruby no longer supports Ruby runtime versions 1.9, 2.0, 2.1, and 2.2.
67
+
68
+ 3.119.1 (2021-08-20)
69
+ ------------------
70
+
71
+ * Issue - Refactored `Aws::Json::Engine` to remove dead code and replaced usage of `JSON.load` with `JSON.parse`.
72
+
73
+ 3.119.0 (2021-07-30)
74
+ ------------------
75
+
76
+ * Feature - Support Document Types. Document types are used to carry open content. A document type value is serialized using the same format as its surroundings and requires no additional encoding or escaping.(#2523)
77
+
78
+ 3.118.0 (2021-07-28)
79
+ ------------------
80
+
81
+ * Feature - Add support for Tagged Unions using a "sealed" classes like approach where each union member has a corresponding subclass.
82
+
4
83
  3.117.0 (2021-07-12)
5
84
  ------------------
6
85
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.117.0
1
+ 3.122.1
@@ -2,16 +2,18 @@
2
2
 
3
3
  module Aws
4
4
  module Json
5
- class JSONEngine
5
+ module JSONEngine
6
+ class << self
7
+ def load(json)
8
+ JSON.parse(json)
9
+ rescue JSON::ParserError => e
10
+ raise ParseError.new(e)
11
+ end
6
12
 
7
- def self.load(json)
8
- JSON.load(json)
13
+ def dump(value)
14
+ JSON.dump(value)
15
+ end
9
16
  end
10
-
11
- def self.dump(value)
12
- JSON.dump(value)
13
- end
14
-
15
17
  end
16
18
  end
17
19
  end
@@ -2,16 +2,43 @@
2
2
 
3
3
  module Aws
4
4
  module Json
5
- class OjEngine
5
+ module OjEngine
6
+ # @api private
7
+ LOAD_OPTIONS = { mode: :compat, symbol_keys: false, empty_string: false }.freeze
6
8
 
7
- def self.load(json)
8
- Oj.load(json)
9
- end
9
+ # @api private
10
+ DUMP_OPTIONS = { mode: :compat }.freeze
11
+
12
+ class << self
13
+ def load(json)
14
+ Oj.load(json, LOAD_OPTIONS)
15
+ rescue *PARSE_ERRORS => e
16
+ raise ParseError.new(e)
17
+ end
18
+
19
+ def dump(value)
20
+ Oj.dump(value, DUMP_OPTIONS)
21
+ end
22
+
23
+ private
24
+
25
+ # Oj before 1.4.0 does not define Oj::ParseError and instead raises
26
+ # SyntaxError on failure
27
+ def detect_oj_parse_errors
28
+ require 'oj'
10
29
 
11
- def self.dump(value)
12
- Oj.dump(value)
30
+ if Oj.const_defined?(:ParseError)
31
+ [Oj::ParseError, EncodingError, JSON::ParserError]
32
+ else
33
+ [SyntaxError]
34
+ end
35
+ rescue LoadError
36
+ nil
37
+ end
13
38
  end
14
39
 
40
+ # @api private
41
+ PARSE_ERRORS = detect_oj_parse_errors
15
42
  end
16
43
  end
17
44
  end
@@ -28,8 +28,16 @@ module Aws
28
28
  member_name, member_ref = shape.member_by_location_name(key)
29
29
  if member_ref
30
30
  target[member_name] = parse_ref(member_ref, value)
31
+ elsif shape.union
32
+ target[:unknown] = { 'name' => key, 'value' => value }
31
33
  end
32
34
  end
35
+ if shape.union
36
+ # convert to subclass
37
+ member_subclass = shape.member_subclass(target.member).new
38
+ member_subclass[target.member] = target.value
39
+ target = member_subclass
40
+ end
33
41
  target
34
42
  end
35
43
 
@@ -5,6 +5,8 @@ require_relative 'json/builder'
5
5
  require_relative 'json/error_handler'
6
6
  require_relative 'json/handler'
7
7
  require_relative 'json/parser'
8
+ require_relative 'json/json_engine'
9
+ require_relative 'json/oj_engine'
8
10
 
9
11
  module Aws
10
12
  # @api private
@@ -20,9 +22,7 @@ module Aws
20
22
 
21
23
  class << self
22
24
  def load(json)
23
- ENGINE.load(json, *ENGINE_LOAD_OPTIONS)
24
- rescue *ENGINE_ERRORS => e
25
- raise ParseError, e
25
+ ENGINE.load(json)
26
26
  end
27
27
 
28
28
  def load_file(path)
@@ -30,38 +30,20 @@ module Aws
30
30
  end
31
31
 
32
32
  def dump(value)
33
- ENGINE.dump(value, *ENGINE_DUMP_OPTIONS)
33
+ ENGINE.dump(value)
34
34
  end
35
35
 
36
36
  private
37
37
 
38
- def oj_engine
38
+ def select_engine
39
39
  require 'oj'
40
- [
41
- Oj,
42
- [{ mode: :compat, symbol_keys: false, empty_string: false }],
43
- [{ mode: :compat }],
44
- oj_parse_error
45
- ]
40
+ OjEngine
46
41
  rescue LoadError
47
- false
48
- end
49
-
50
- def json_engine
51
- [JSON, [], [], [JSON::ParserError]]
52
- end
53
-
54
- def oj_parse_error
55
- if Oj.const_defined?('ParseError')
56
- [Oj::ParseError, EncodingError, JSON::ParserError]
57
- else
58
- [SyntaxError]
59
- end
42
+ JSONEngine
60
43
  end
61
44
  end
62
45
 
63
46
  # @api private
64
- ENGINE, ENGINE_LOAD_OPTIONS, ENGINE_DUMP_OPTIONS, ENGINE_ERRORS =
65
- oj_engine || json_engine
47
+ ENGINE = select_engine
66
48
  end
67
49
  end
@@ -26,7 +26,8 @@ module Aws
26
26
 
27
27
  def filter(values, type)
28
28
  case values
29
- when Struct, Hash then filter_hash(values, type)
29
+ when Struct then filter_struct(values, type)
30
+ when Hash then filter_hash(values, type)
30
31
  when Array then filter_array(values, type)
31
32
  else values
32
33
  end
@@ -34,6 +35,13 @@ module Aws
34
35
 
35
36
  private
36
37
 
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
+
37
45
  def filter_hash(values, type)
38
46
  if type.const_defined?('SENSITIVE')
39
47
  filters = type::SENSITIVE + @additional_filters
@@ -70,6 +70,14 @@ module Aws
70
70
  end
71
71
  end
72
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
+
73
81
  # validate non-nil members
74
82
  values.each_pair do |name, value|
75
83
  unless value.nil?
@@ -117,11 +125,32 @@ module Aws
117
125
  end
118
126
  end
119
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
+
120
148
  def shape(ref, value, errors, context)
121
149
  case ref.shape
122
150
  when StructureShape then structure(ref, value, errors, context)
123
151
  when ListShape then list(ref, value, errors, context)
124
152
  when MapShape then map(ref, value, errors, context)
153
+ when DocumentShape then document(ref, value, errors, context)
125
154
  when StringShape
126
155
  unless value.is_a?(String)
127
156
  errors << expected_got(context, "a String", value)
@@ -4,9 +4,26 @@ module Aws
4
4
  module Plugins
5
5
  module Protocols
6
6
  class ApiGateway < Seahorse::Client::Plugin
7
+
8
+ class ContentTypeHandler < Seahorse::Client::Handler
9
+ def call(context)
10
+ body = context.http_request.body
11
+ # Rest::Handler will set a default JSON body, so size can be checked
12
+ # if this handler is run after serialization.
13
+ if !body.respond_to?(:size) ||
14
+ (body.respond_to?(:size) && body.size > 0)
15
+ context.http_request.headers['Content-Type'] ||=
16
+ 'application/json'
17
+ end
18
+ @handler.call(context)
19
+ end
20
+ end
21
+
7
22
  handler(Rest::Handler)
23
+ handler(ContentTypeHandler, priority: 30)
8
24
  handler(Json::ErrorHandler, step: :sign)
9
25
  end
26
+
10
27
  end
11
28
  end
12
29
  end
@@ -5,10 +5,25 @@ module Aws
5
5
  module Protocols
6
6
  class RestJson < Seahorse::Client::Plugin
7
7
 
8
+ class ContentTypeHandler < Seahorse::Client::Handler
9
+ def call(context)
10
+ body = context.http_request.body
11
+ # Rest::Handler will set a default JSON body, so size can be checked
12
+ # if this handler is run after serialization.
13
+ if !body.respond_to?(:size) ||
14
+ (body.respond_to?(:size) && body.size > 0)
15
+ context.http_request.headers['Content-Type'] ||=
16
+ 'application/json'
17
+ end
18
+ @handler.call(context)
19
+ end
20
+ end
21
+
8
22
  handler(Rest::Handler)
23
+ handler(ContentTypeHandler, priority: 30)
9
24
  handler(Json::ErrorHandler, step: :sign)
10
-
11
25
  end
26
+
12
27
  end
13
28
  end
14
29
  end
@@ -24,6 +24,25 @@ a default `:region` is searched for in the following locations:
24
24
  resolve_region(cfg)
25
25
  end
26
26
 
27
+ option(:use_dualstack_endpoint,
28
+ doc_type: 'Boolean',
29
+ docstring: <<-DOCS) do |cfg|
30
+ When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
31
+ will be used if available.
32
+ DOCS
33
+ resolve_use_dualstack_endpoint(cfg)
34
+ end
35
+
36
+ option(:use_fips_endpoint,
37
+ doc_type: 'Boolean',
38
+ docstring: <<-DOCS) do |cfg|
39
+ When set to `true`, fips compatible endpoints will be used if available.
40
+ When a `fips` region is used, the region is normalized and this config
41
+ is set to `true`.
42
+ DOCS
43
+ resolve_use_fips_endpoint(cfg)
44
+ end
45
+
27
46
  option(:regional_endpoint, false)
28
47
 
29
48
  option(:endpoint, doc_type: String, docstring: <<-DOCS) do |cfg|
@@ -42,10 +61,23 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
42
61
  raise Errors::InvalidRegionError
43
62
  end
44
63
 
64
+ region = cfg.region
65
+ new_region = region.gsub('fips-', '').gsub('-fips', '')
66
+ if region != new_region
67
+ warn("Legacy region #{region} was transformed to #{new_region}."\
68
+ '`use_fips_endpoint` config was set to true.')
69
+ cfg.override_config(:use_fips_endpoint, true)
70
+ cfg.override_config(:region, new_region)
71
+ end
72
+
45
73
  Aws::Partitions::EndpointProvider.resolve(
46
74
  cfg.region,
47
75
  endpoint_prefix,
48
- sts_regional
76
+ sts_regional,
77
+ {
78
+ dualstack: cfg.use_dualstack_endpoint,
79
+ fips: cfg.use_fips_endpoint
80
+ }
49
81
  )
50
82
  end
51
83
  end
@@ -66,6 +98,20 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
66
98
  cfg_region = Aws.shared_config.region(profile: cfg.profile)
67
99
  env_region || cfg_region
68
100
  end
101
+
102
+ def resolve_use_dualstack_endpoint(cfg)
103
+ value = ENV['AWS_USE_DUALSTACK_ENDPOINT']
104
+ value ||= Aws.shared_config.use_dualstack_endpoint(
105
+ profile: cfg.profile
106
+ )
107
+ Aws::Util.str_2_bool(value) || false
108
+ end
109
+
110
+ def resolve_use_fips_endpoint(cfg)
111
+ value = ENV['AWS_USE_FIPS_ENDPOINT']
112
+ value ||= Aws.shared_config.use_fips_endpoint(profile: cfg.profile)
113
+ Aws::Util.str_2_bool(value) || false
114
+ end
69
115
  end
70
116
  end
71
117
  end
@@ -12,32 +12,22 @@ module Aws
12
12
  end
13
13
 
14
14
  option(:sigv4_name) do |cfg|
15
- cfg.api.metadata['signingName'] || cfg.api.metadata['endpointPrefix']
15
+ signingName = if cfg.region
16
+ Aws::Partitions::EndpointProvider.signing_service(
17
+ cfg.region, cfg.api.metadata['endpointPrefix']
18
+ )
19
+ end
20
+ signingName || cfg.api.metadata['signingName'] || cfg.api.metadata['endpointPrefix']
16
21
  end
17
22
 
18
23
  option(:sigv4_region) do |cfg|
19
-
20
- # The signature version 4 signing region is most
21
- # commonly the configured region. There are a few
22
- # notable exceptions:
23
- #
24
- # * Some services have a global endpoint to the entire
25
- # partition. For example, when constructing a route53
26
- # client for a region like "us-west-2", we will
27
- # always use "route53.amazonaws.com". This endpoint
28
- # is actually global to the entire partition,
29
- # and must be signed as "us-east-1".
30
- #
31
- # * When the region is configured, but it is configured
32
- # to a non region, such as "aws-global". This is similar
33
- # to the previous case. We use the Aws::Partitions::EndpointProvider
34
- # to resolve to the actual signing region.
35
- #
36
- prefix = cfg.api.metadata['endpointPrefix']
37
- if prefix && cfg.endpoint.to_s.match(/#{prefix}\.amazonaws\.com/)
38
- 'us-east-1'
39
- elsif cfg.region
40
- Aws::Partitions::EndpointProvider.signing_region(cfg.region, cfg.sigv4_name)
24
+ if cfg.region
25
+ if cfg.respond_to?(:sts_regional_endpoints)
26
+ sts_regional = cfg.sts_regional_endpoints
27
+ end
28
+ Aws::Partitions::EndpointProvider.signing_region(
29
+ cfg.region, cfg.api.metadata['endpointPrefix'], sts_regional
30
+ )
41
31
  end
42
32
  end
43
33
 
@@ -17,11 +17,29 @@ module Aws
17
17
  # @param [Seahorse::Client::Http::Request] http_req
18
18
  # @param [Hash] params
19
19
  def apply(http_req, params)
20
- 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
21
28
  end
22
29
 
23
30
  private
24
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
+
25
43
  def build_body(params)
26
44
  if streaming?
27
45
  params[@rules[:payload]]
@@ -35,6 +35,7 @@ module Aws
35
35
  headers[ref.location_name] =
36
36
  case ref.shape
37
37
  when TimestampShape then timestamp(ref, value)
38
+ when ListShape then list(ref, value)
38
39
  else value.to_s
39
40
  end
40
41
  end
@@ -49,6 +50,10 @@ module Aws
49
50
  end
50
51
  end
51
52
 
53
+ def list(_ref, value)
54
+ value.compact.join(",")
55
+ end
56
+
52
57
  def apply_header_map(headers, ref, values)
53
58
  prefix = ref.location_name || ''
54
59
  values.each_pair do |name, value|
@@ -57,7 +62,7 @@ module Aws
57
62
  end
58
63
 
59
64
  # With complex headers value in json syntax,
60
- # base64 encodes value to aviod weird characters
65
+ # base64 encodes value to avoid weird characters
61
66
  # causing potential issues in headers
62
67
  def apply_json_trait(value)
63
68
  Base64.strict_encode64(value)
@@ -40,8 +40,10 @@ module Aws
40
40
  when IntegerShape then value.to_i
41
41
  when FloatShape then value.to_f
42
42
  when BooleanShape then value == 'true'
43
+ when ListShape then
44
+ value.split(",").map { |v| cast_value(ref.shape.member, v) }
43
45
  when TimestampShape
44
- if value =~ /\d+(\.\d*)/
46
+ if value =~ /^\d+(\.\d*)/
45
47
  Time.at(value.to_f)
46
48
  elsif value =~ /^\d+$/
47
49
  Time.at(value.to_i)
@@ -163,6 +163,8 @@ module Aws
163
163
  :ca_bundle,
164
164
  :credential_process,
165
165
  :endpoint_discovery_enabled,
166
+ :use_dualstack_endpoint,
167
+ :use_fips_endpoint,
166
168
  :ec2_metadata_service_endpoint,
167
169
  :ec2_metadata_service_endpoint_mode,
168
170
  :max_attempts,
@@ -175,7 +177,8 @@ module Aws
175
177
  :csm_port,
176
178
  :sts_regional_endpoints,
177
179
  :s3_use_arn_region,
178
- :s3_us_east_1_regional_endpoint
180
+ :s3_us_east_1_regional_endpoint,
181
+ :s3_disable_multiregion_access_points
179
182
  )
180
183
 
181
184
  private
@@ -100,7 +100,7 @@ module Aws
100
100
  raise ArgumentError, 'Cached SSO Token is expired.'
101
101
  end
102
102
  cached_token
103
- rescue Aws::Json::ParseError, ArgumentError
103
+ rescue Errno::ENOENT, Aws::Json::ParseError, ArgumentError
104
104
  raise Errors::InvalidSSOCredentials, SSO_LOGIN_GUIDANCE
105
105
  end
106
106
 
@@ -70,11 +70,20 @@ module Aws
70
70
  end
71
71
 
72
72
  end
73
+
74
+ module Union
75
+ def member
76
+ self.members.select { |k| self[k] != nil }.first
77
+ end
78
+
79
+ def value
80
+ self[member] if member
81
+ end
82
+ end
73
83
  end
74
84
 
75
85
  # @api private
76
86
  class EmptyStructure < Struct.new('AwsEmptyStructure')
77
87
  include(Aws::Structure)
78
88
  end
79
-
80
89
  end
@@ -1,16 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- use_system_rexml = ((RUBY_VERSION <=> "2.0.0") < 0)
4
- if use_system_rexml
5
- require "rbconfig"
6
- $LOAD_PATH.unshift(RbConfig::CONFIG["rubylibdir"])
7
- end
8
-
9
3
  require 'rexml/document'
10
4
  require 'rexml/streamlistener'
11
5
 
12
- $LOAD_PATH.shift if use_system_rexml
13
-
14
6
  module Aws
15
7
  module Xml
16
8
  class Parser
@@ -95,6 +95,8 @@ module Aws
95
95
  def child_frame(xml_name)
96
96
  if @member = @members[xml_name]
97
97
  Frame.new(xml_name, self, @member[:ref])
98
+ elsif @ref.shape.union
99
+ UnknownMemberFrame.new(xml_name, self, nil, @result)
98
100
  else
99
101
  NullFrame.new(xml_name, self)
100
102
  end
@@ -106,10 +108,24 @@ module Aws
106
108
  @result[@member[:name]][child.key.result] = child.value.result
107
109
  when FlatListFrame
108
110
  @result[@member[:name]] << child.result
111
+ when UnknownMemberFrame
112
+ @result[:unknown] = { 'name' => child.path.last, 'value' => child.result }
109
113
  when NullFrame
110
114
  else
111
115
  @result[@member[:name]] = child.result
112
116
  end
117
+
118
+ if @ref.shape.union
119
+ # a union may only have one member set
120
+ # convert to the union subclass
121
+ # The default Struct created will have defaults set for all values
122
+ # This also sets only one of the values leaving everything else nil
123
+ # as required for unions
124
+ set_member_name = @member ? @member[:name] : :unknown
125
+ member_subclass = @ref.shape.member_subclass(set_member_name).new # shape.member_subclass(target.member).new
126
+ member_subclass[set_member_name] = @result[set_member_name]
127
+ @result = member_subclass
128
+ end
113
129
  end
114
130
 
115
131
  private
@@ -242,6 +258,12 @@ module Aws
242
258
  end
243
259
  end
244
260
 
261
+ class UnknownMemberFrame < Frame
262
+ def result
263
+ @text.join
264
+ end
265
+ end
266
+
245
267
  class BlobFrame < Frame
246
268
  def result
247
269
  @text.empty? ? nil : Base64.decode64(@text.join)
@@ -302,6 +324,7 @@ module Aws
302
324
  MapShape => MapFrame,
303
325
  StringShape => StringFrame,
304
326
  StructureShape => StructureFrame,
327
+ UnionShape => StructureFrame,
305
328
  TimestampShape => TimestampFrame,
306
329
  }
307
330
 
data/lib/aws-sdk-core.rb CHANGED
@@ -88,6 +88,9 @@ require_relative 'aws-sdk-core/arn'
88
88
  require_relative 'aws-sdk-core/arn_parser'
89
89
  require_relative 'aws-sdk-core/ec2_metadata'
90
90
 
91
+ # plugins
92
+ # loaded through building STS or SSO ..
93
+
91
94
  # aws-sdk-sts is included to support Aws::AssumeRoleCredentials
92
95
  require_relative 'aws-sdk-sts'
93
96
 
@@ -29,7 +29,6 @@ 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/signature_v4.rb'
31
31
  require 'aws-sdk-core/plugins/protocols/rest_json.rb'
32
- require 'aws-sdk-sso/plugins/content_type.rb'
33
32
 
34
33
  Aws::Plugins::GlobalConfiguration.add_identifier(:sso)
35
34
 
@@ -76,7 +75,6 @@ module Aws::SSO
76
75
  add_plugin(Aws::Plugins::HttpChecksum)
77
76
  add_plugin(Aws::Plugins::SignatureV4)
78
77
  add_plugin(Aws::Plugins::Protocols::RestJson)
79
- add_plugin(Aws::SSO::Plugins::ContentType)
80
78
 
81
79
  # @overload initialize(options)
82
80
  # @param [Hash] options
@@ -277,6 +275,15 @@ module Aws::SSO
277
275
  # ** Please note ** When response stubbing is enabled, no HTTP
278
276
  # requests are made, and retries are disabled.
279
277
  #
278
+ # @option options [Boolean] :use_dualstack_endpoint
279
+ # When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
280
+ # will be used if available.
281
+ #
282
+ # @option options [Boolean] :use_fips_endpoint
283
+ # When set to `true`, fips compatible endpoints will be used if available.
284
+ # When a `fips` region is used, the region is normalized and this config
285
+ # is set to `true`.
286
+ #
280
287
  # @option options [Boolean] :validate_params (true)
281
288
  # When `true`, request parameters are validated before
282
289
  # sending the request.
@@ -523,7 +530,7 @@ module Aws::SSO
523
530
  params: params,
524
531
  config: config)
525
532
  context[:gem_name] = 'aws-sdk-core'
526
- context[:gem_version] = '3.117.0'
533
+ context[:gem_version] = '3.122.1'
527
534
  Seahorse::Client::Request.new(handlers, context)
528
535
  end
529
536
 
data/lib/aws-sdk-sso.rb CHANGED
@@ -50,6 +50,6 @@ require_relative 'aws-sdk-sso/customizations'
50
50
  # @!group service
51
51
  module Aws::SSO
52
52
 
53
- GEM_VERSION = '3.117.0'
53
+ GEM_VERSION = '3.122.1'
54
54
 
55
55
  end
@@ -282,6 +282,15 @@ module Aws::STS
282
282
  # ** Please note ** When response stubbing is enabled, no HTTP
283
283
  # requests are made, and retries are disabled.
284
284
  #
285
+ # @option options [Boolean] :use_dualstack_endpoint
286
+ # When set to `true`, dualstack enabled endpoints (with `.aws` TLD)
287
+ # will be used if available.
288
+ #
289
+ # @option options [Boolean] :use_fips_endpoint
290
+ # When set to `true`, fips compatible endpoints will be used if available.
291
+ # When a `fips` region is used, the region is normalized and this config
292
+ # is set to `true`.
293
+ #
285
294
  # @option options [Boolean] :validate_params (true)
286
295
  # When `true`, request parameters are validated before
287
296
  # sending the request.
@@ -2303,7 +2312,7 @@ module Aws::STS
2303
2312
  params: params,
2304
2313
  config: config)
2305
2314
  context[:gem_name] = 'aws-sdk-core'
2306
- context[:gem_version] = '3.117.0'
2315
+ context[:gem_version] = '3.122.1'
2307
2316
  Seahorse::Client::Request.new(handlers, context)
2308
2317
  end
2309
2318
 
@@ -53,7 +53,13 @@ module Aws
53
53
  )
54
54
 
55
55
  url = Aws::Partitions::EndpointProvider.resolve(
56
- req.context.config.region, 'sts', 'regional'
56
+ req.context.config.region,
57
+ 'sts',
58
+ req.context.config.sts_regional_endpoints,
59
+ {
60
+ dualstack: req.context.config.use_dualstack_endpoint,
61
+ fips: req.context.config.use_fips_endpoint
62
+ }
57
63
  )
58
64
  url += "/?#{param_list}"
59
65
 
data/lib/aws-sdk-sts.rb CHANGED
@@ -50,6 +50,6 @@ require_relative 'aws-sdk-sts/customizations'
50
50
  # @!group service
51
51
  module Aws::STS
52
52
 
53
- GEM_VERSION = '3.117.0'
53
+ GEM_VERSION = '3.122.1'
54
54
 
55
55
  end
@@ -195,6 +195,10 @@ module Seahorse
195
195
  @members.include?(method_name) or super
196
196
  end
197
197
 
198
+ def override_config(k, v)
199
+ @struct[k] = v
200
+ end
201
+
198
202
  private
199
203
 
200
204
  def value_at(opt_name)
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if RUBY_VERSION >= '2.1'
4
- begin
5
- require 'http/2'
6
- rescue LoadError; end
7
- end
3
+ begin
4
+ require 'http/2'
5
+ rescue LoadError; end
8
6
  require 'openssl'
9
7
  require 'socket'
10
8
 
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if RUBY_VERSION >= '2.1'
4
- begin
5
- require 'http/2'
6
- rescue LoadError; end
7
- end
3
+ begin
4
+ require 'http/2'
5
+ rescue LoadError; end
6
+
8
7
  require 'securerandom'
9
8
 
10
9
  module Seahorse
@@ -74,8 +74,9 @@ module Seahorse
74
74
  # @return [void]
75
75
  def transmit(config, req, resp)
76
76
  session(config, req) do |http|
77
+ # Monkey patch default content-type set by Net::HTTP
78
+ Thread.current[:net_http_skip_default_content_type] = true
77
79
  http.request(build_net_request(req)) do |net_resp|
78
-
79
80
  status_code = net_resp.code.to_i
80
81
  headers = extract_headers(net_resp)
81
82
 
@@ -96,6 +97,9 @@ module Seahorse
96
97
  rescue => error
97
98
  # not retryable
98
99
  resp.signal_error(error)
100
+ ensure
101
+ # ensure we turn off monkey patch in case of error
102
+ Thread.current[:net_http_skip_default_content_type] = nil
99
103
  end
100
104
 
101
105
  def complete_response(req, resp, bytes_received)
@@ -147,7 +151,12 @@ module Seahorse
147
151
  def build_net_request(request)
148
152
  request_class = net_http_request_class(request)
149
153
  req = request_class.new(request.endpoint.request_uri, headers(request))
150
- req.body_stream = request.body
154
+ # Net::HTTP adds a default Content-Type when a body is present.
155
+ # Set the body stream when it has an unknown size or when it is > 0.
156
+ if !request.body.respond_to?(:size) ||
157
+ (request.body.respond_to?(:size) && request.body.size > 0)
158
+ req.body_stream = request.body
159
+ end
151
160
  req
152
161
  end
153
162
 
@@ -166,14 +175,13 @@ module Seahorse
166
175
  # @return [Hash] Returns a vanilla hash of headers to send with the
167
176
  # HTTP request.
168
177
  def headers(request)
169
- # Net::HTTP adds default headers for content-type to POSTs (1.8.7+)
170
- # and accept-encoding (2.0.0+). Setting a default empty value defeats
171
- # this.
178
+ # Net::HTTP adds a default header for accept-encoding (2.0.0+).
179
+ # Setting a default empty value defeats this.
172
180
  #
173
- # Removing these are necessary for most services to not break request
181
+ # Removing this is necessary for most services to not break request
174
182
  # signatures as well as dynamodb crc32 checks (these fail if the
175
183
  # response is gzipped).
176
- headers = { 'content-type' => '', 'accept-encoding' => '' }
184
+ headers = { 'accept-encoding' => '' }
177
185
  request.headers.each_pair do |key, value|
178
186
  headers[key] = value
179
187
  end
@@ -11,97 +11,26 @@ module Seahorse
11
11
  module Patches
12
12
 
13
13
  def self.apply!
14
+ Net::HTTPGenericRequest.prepend(PatchDefaultContentType)
14
15
  return unless RUBY_VERSION < '2.5'
15
- if RUBY_VERSION >= '2.3'
16
- Net::HTTP::IDEMPOTENT_METHODS_.clear
17
- return
18
- end
19
- # no further patches needed for above versions
20
16
 
21
- if RUBY_VERSION >= '2.0'
22
- Net::HTTP.send(:include, Ruby_2)
23
- Net::HTTP::IDEMPOTENT_METHODS_.clear
24
- elsif RUBY_VERSION >= '1.9.3'
25
- Net::HTTP.send(:include, Ruby_1_9_3)
26
- end
27
- Net::HTTP.send(:alias_method, :old_transport_request, :transport_request)
28
- Net::HTTP.send(:alias_method, :transport_request, :new_transport_request)
17
+ Net::HTTP::IDEMPOTENT_METHODS_.clear
29
18
  end
30
19
 
31
- module Ruby_2
32
- def new_transport_request(req)
33
- count = 0
34
- begin
35
- begin_transport req
36
- res = catch(:response) {
37
- req.exec @socket, @curr_http_version, edit_path(req.path)
38
- begin
39
- res = Net::HTTPResponse.read_new(@socket)
40
- res.decode_content = req.decode_content
41
- end while res.kind_of?(Net::HTTPInformation)
42
-
43
- res.uri = req.uri
44
-
45
- res
46
- }
47
- res.reading_body(@socket, req.response_body_permitted?) {
48
- yield res if block_given?
49
- }
50
- rescue Net::OpenTimeout
51
- raise
52
- rescue Net::ReadTimeout, IOError, EOFError,
53
- Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE,
54
- # avoid a dependency on OpenSSL
55
- defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : IOError,
56
- Timeout::Error => exception
57
- if count == 0 && Net::HTTP::IDEMPOTENT_METHODS_.include?(req.method)
58
- count += 1
59
- @socket.close if @socket and not @socket.closed?
60
- D "Conn close because of error #{exception}, and retry"
61
- if req.body_stream
62
- if req.body_stream.respond_to?(:rewind)
63
- req.body_stream.rewind
64
- else
65
- raise
66
- end
67
- end
68
- retry
69
- end
70
- D "Conn close because of error #{exception}"
71
- @socket.close if @socket and not @socket.closed?
72
- raise
73
- end
74
-
75
- end_transport req, res
76
- res
77
- rescue => exception
78
- D "Conn close because of error #{exception}"
79
- @socket.close if @socket and not @socket.closed?
80
- raise exception
20
+ # For requests with bodys, Net::HTTP sets a default content type of:
21
+ # 'application/x-www-form-urlencoded'
22
+ # There are cases where we should not send content type at all.
23
+ # Even when no body is supplied, Net::HTTP uses a default empty body
24
+ # and sets it anyway. This patch disables the behavior when a Thread
25
+ # local variable is set.
26
+ module PatchDefaultContentType
27
+ def supply_default_content_type
28
+ return if Thread.current[:net_http_skip_default_content_type]
29
+
30
+ super
81
31
  end
82
32
  end
83
33
 
84
- module Ruby_1_9_3
85
- def new_transport_request(req)
86
- begin_transport req
87
- res = catch(:response) {
88
- req.exec @socket, @curr_http_version, edit_path(req.path)
89
- begin
90
- res = Net::HTTPResponse.read_new(@socket)
91
- end while res.kind_of?(Net::HTTPContinue)
92
- res
93
- }
94
- res.reading_body(@socket, req.response_body_permitted?) {
95
- yield res if block_given?
96
- }
97
- end_transport req, res
98
- res
99
- rescue => exception
100
- D "Conn close because of error #{exception}"
101
- @socket.close if @socket and not @socket.closed?
102
- raise exception
103
- end
104
- end
105
34
  end
106
35
  end
107
36
  end
@@ -7,16 +7,22 @@ module Seahorse
7
7
 
8
8
  # @api private
9
9
  class Handler < Client::Handler
10
+ # https://github.com/ruby/net-http/blob/master/lib/net/http/requests.rb
11
+ # Methods without body are forwards compatible, because content-length
12
+ # may be set for requests without body but is technically incorrect.
13
+ METHODS_WITHOUT_BODY = Set.new(
14
+ %w[GET HEAD DELETE OPTIONS TRACE COPY MOVE]
15
+ )
10
16
 
11
17
  def call(context)
12
- # If it's an IO object and not a File / String / String IO
13
- if context.http_request.body.respond_to?(:size)
14
- length = context.http_request.body.size
15
- context.http_request.headers['Content-Length'] = length
18
+ body = context.http_request.body
19
+ method = context.http_request.http_method
20
+ # We use Net::HTTP with body_stream which doesn't do this by default
21
+ if body.respond_to?(:size) && !METHODS_WITHOUT_BODY.include?(method)
22
+ context.http_request.headers['Content-Length'] = body.size
16
23
  end
17
24
  @handler.call(context)
18
25
  end
19
-
20
26
  end
21
27
 
22
28
  handler(Handler, step: :sign, priority: 0)
@@ -61,6 +61,9 @@ module Seahorse
61
61
  # @return [Boolean]
62
62
  attr_accessor :eventheader_type
63
63
 
64
+ # @return [Boolean]
65
+ attr_accessor :document
66
+
64
67
  # @return [String, nil]
65
68
  def location
66
69
  @location || (shape && shape[:location])
@@ -114,6 +117,9 @@ module Seahorse
114
117
  # @return [String, nil]
115
118
  attr_accessor :documentation
116
119
 
120
+ # @return [Boolean]
121
+ attr_accessor :union
122
+
117
123
  # Gets metadata for the given `key`.
118
124
  def [](key)
119
125
  @metadata[key.to_s]
@@ -264,8 +270,27 @@ module Seahorse
264
270
 
265
271
  end
266
272
 
273
+ class UnionShape < StructureShape
274
+ def initialize(options = {})
275
+ @member_subclasses = {}
276
+ super options.merge(union: true)
277
+ end
278
+
279
+ # @api private
280
+ def member_subclass(member)
281
+ @member_subclasses[member]
282
+ end
283
+
284
+ # @api private
285
+ def add_member_subclass(member, subclass)
286
+ @member_subclasses[member] = subclass
287
+ end
288
+ end
289
+
267
290
  class TimestampShape < Shape; end
268
291
 
292
+ class DocumentShape < Shape; end
293
+
269
294
  end
270
295
  end
271
296
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.117.0
4
+ version: 3.122.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-12 00:00:00.000000000 Z
11
+ date: 2021-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jmespath
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '1'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 1.239.0
36
+ version: 1.525.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '1'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.239.0
46
+ version: 1.525.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: aws-sigv4
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -230,7 +230,6 @@ files:
230
230
  - lib/aws-sdk-sso/client_api.rb
231
231
  - lib/aws-sdk-sso/customizations.rb
232
232
  - lib/aws-sdk-sso/errors.rb
233
- - lib/aws-sdk-sso/plugins/content_type.rb
234
233
  - lib/aws-sdk-sso/resource.rb
235
234
  - lib/aws-sdk-sso/types.rb
236
235
  - lib/aws-sdk-sts.rb
@@ -300,7 +299,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
300
299
  requirements:
301
300
  - - ">="
302
301
  - !ruby/object:Gem::Version
303
- version: '0'
302
+ version: '2.3'
304
303
  required_rubygems_version: !ruby/object:Gem::Requirement
305
304
  requirements:
306
305
  - - ">="
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Aws
4
- module SSO
5
- module Plugins
6
- class ContentType < Seahorse::Client::Plugin
7
-
8
- def add_handlers(handlers, config)
9
- handlers.add(Handler)
10
- end
11
-
12
- class Handler < Seahorse::Client::Handler
13
- def call(context)
14
- # Some operations break when given an empty content-type header.
15
- # The SDK adds this blank content-type header
16
- # since Net::HTTP provides a default that can break services.
17
- # We're setting one here even though it's not used or necessary.
18
- context.http_request.headers['content-type'] = 'application/json'
19
- @handler.call(context)
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end