aws-sdk-s3 1.45.0 → 1.143.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1106 -0
  3. data/LICENSE.txt +202 -0
  4. data/VERSION +1 -0
  5. data/lib/aws-sdk-s3/bucket.rb +784 -98
  6. data/lib/aws-sdk-s3/bucket_acl.rb +64 -18
  7. data/lib/aws-sdk-s3/bucket_cors.rb +79 -18
  8. data/lib/aws-sdk-s3/bucket_lifecycle.rb +66 -20
  9. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +68 -20
  10. data/lib/aws-sdk-s3/bucket_logging.rb +68 -16
  11. data/lib/aws-sdk-s3/bucket_notification.rb +52 -20
  12. data/lib/aws-sdk-s3/bucket_policy.rb +107 -17
  13. data/lib/aws-sdk-s3/bucket_region_cache.rb +2 -0
  14. data/lib/aws-sdk-s3/bucket_request_payment.rb +60 -15
  15. data/lib/aws-sdk-s3/bucket_tagging.rb +71 -18
  16. data/lib/aws-sdk-s3/bucket_versioning.rb +133 -17
  17. data/lib/aws-sdk-s3/bucket_website.rb +78 -21
  18. data/lib/aws-sdk-s3/client.rb +12610 -902
  19. data/lib/aws-sdk-s3/client_api.rb +1086 -191
  20. data/lib/aws-sdk-s3/customizations/bucket.rb +56 -37
  21. data/lib/aws-sdk-s3/customizations/errors.rb +27 -0
  22. data/lib/aws-sdk-s3/customizations/multipart_upload.rb +2 -0
  23. data/lib/aws-sdk-s3/customizations/object.rb +282 -68
  24. data/lib/aws-sdk-s3/customizations/object_summary.rb +5 -0
  25. data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +2 -0
  26. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  27. data/lib/aws-sdk-s3/customizations.rb +11 -1
  28. data/lib/aws-sdk-s3/encryption/client.rb +28 -7
  29. data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +71 -29
  30. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +43 -5
  31. data/lib/aws-sdk-s3/encryption/default_key_provider.rb +2 -0
  32. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +13 -2
  33. data/lib/aws-sdk-s3/encryption/errors.rb +2 -0
  34. data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +2 -0
  35. data/lib/aws-sdk-s3/encryption/io_decrypter.rb +11 -3
  36. data/lib/aws-sdk-s3/encryption/io_encrypter.rb +2 -0
  37. data/lib/aws-sdk-s3/encryption/key_provider.rb +2 -0
  38. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +46 -11
  39. data/lib/aws-sdk-s3/encryption/materials.rb +8 -6
  40. data/lib/aws-sdk-s3/encryption/utils.rb +25 -0
  41. data/lib/aws-sdk-s3/encryption.rb +4 -0
  42. data/lib/aws-sdk-s3/encryptionV2/client.rb +570 -0
  43. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +223 -0
  44. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +170 -0
  45. data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +40 -0
  46. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +65 -0
  47. data/lib/aws-sdk-s3/encryptionV2/errors.rb +37 -0
  48. data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +58 -0
  49. data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +37 -0
  50. data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +73 -0
  51. data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +31 -0
  52. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +173 -0
  53. data/lib/aws-sdk-s3/encryptionV2/materials.rb +60 -0
  54. data/lib/aws-sdk-s3/encryptionV2/utils.rb +103 -0
  55. data/lib/aws-sdk-s3/encryption_v2.rb +23 -0
  56. data/lib/aws-sdk-s3/endpoint_parameters.rb +178 -0
  57. data/lib/aws-sdk-s3/endpoint_provider.rb +591 -0
  58. data/lib/aws-sdk-s3/endpoints.rb +2590 -0
  59. data/lib/aws-sdk-s3/errors.rb +123 -1
  60. data/lib/aws-sdk-s3/event_streams.rb +8 -1
  61. data/lib/aws-sdk-s3/express_credentials.rb +55 -0
  62. data/lib/aws-sdk-s3/express_credentials_cache.rb +30 -0
  63. data/lib/aws-sdk-s3/express_credentials_provider.rb +36 -0
  64. data/lib/aws-sdk-s3/file_downloader.rb +176 -44
  65. data/lib/aws-sdk-s3/file_part.rb +11 -6
  66. data/lib/aws-sdk-s3/file_uploader.rb +39 -18
  67. data/lib/aws-sdk-s3/legacy_signer.rb +17 -25
  68. data/lib/aws-sdk-s3/multipart_file_uploader.rb +78 -20
  69. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +56 -18
  70. data/lib/aws-sdk-s3/multipart_upload.rb +242 -32
  71. data/lib/aws-sdk-s3/multipart_upload_error.rb +2 -0
  72. data/lib/aws-sdk-s3/multipart_upload_part.rb +367 -45
  73. data/lib/aws-sdk-s3/object.rb +2191 -227
  74. data/lib/aws-sdk-s3/object_acl.rb +103 -25
  75. data/lib/aws-sdk-s3/object_copier.rb +9 -5
  76. data/lib/aws-sdk-s3/object_multipart_copier.rb +43 -19
  77. data/lib/aws-sdk-s3/object_summary.rb +1811 -208
  78. data/lib/aws-sdk-s3/object_version.rb +452 -80
  79. data/lib/aws-sdk-s3/plugins/accelerate.rb +17 -64
  80. data/lib/aws-sdk-s3/plugins/arn.rb +70 -0
  81. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +7 -43
  82. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +20 -3
  83. data/lib/aws-sdk-s3/plugins/dualstack.rb +7 -50
  84. data/lib/aws-sdk-s3/plugins/endpoints.rb +274 -0
  85. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +5 -4
  86. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +91 -0
  87. data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +3 -1
  88. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +11 -3
  89. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +44 -0
  90. data/lib/aws-sdk-s3/plugins/location_constraint.rb +5 -1
  91. data/lib/aws-sdk-s3/plugins/md5s.rb +35 -30
  92. data/lib/aws-sdk-s3/plugins/redirects.rb +2 -0
  93. data/lib/aws-sdk-s3/plugins/s3_host_id.rb +2 -0
  94. data/lib/aws-sdk-s3/plugins/s3_signer.rb +56 -92
  95. data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +31 -0
  96. data/lib/aws-sdk-s3/plugins/sse_cpk.rb +3 -1
  97. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +139 -0
  98. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +2 -0
  99. data/lib/aws-sdk-s3/presigned_post.rb +160 -99
  100. data/lib/aws-sdk-s3/presigner.rb +171 -80
  101. data/lib/aws-sdk-s3/resource.rb +120 -8
  102. data/lib/aws-sdk-s3/types.rb +11353 -4225
  103. data/lib/aws-sdk-s3/waiters.rb +67 -1
  104. data/lib/aws-sdk-s3.rb +16 -6
  105. data/sig/bucket.rbs +212 -0
  106. data/sig/bucket_acl.rbs +78 -0
  107. data/sig/bucket_cors.rbs +69 -0
  108. data/sig/bucket_lifecycle.rbs +88 -0
  109. data/sig/bucket_lifecycle_configuration.rbs +111 -0
  110. data/sig/bucket_logging.rbs +76 -0
  111. data/sig/bucket_notification.rbs +114 -0
  112. data/sig/bucket_policy.rbs +59 -0
  113. data/sig/bucket_request_payment.rbs +54 -0
  114. data/sig/bucket_tagging.rbs +65 -0
  115. data/sig/bucket_versioning.rbs +77 -0
  116. data/sig/bucket_website.rbs +93 -0
  117. data/sig/client.rbs +2360 -0
  118. data/sig/errors.rbs +34 -0
  119. data/sig/multipart_upload.rbs +110 -0
  120. data/sig/multipart_upload_part.rbs +105 -0
  121. data/sig/object.rbs +436 -0
  122. data/sig/object_acl.rbs +86 -0
  123. data/sig/object_summary.rbs +334 -0
  124. data/sig/object_version.rbs +131 -0
  125. data/sig/resource.rbs +124 -0
  126. data/sig/types.rbs +2562 -0
  127. data/sig/waiters.rbs +83 -0
  128. metadata +68 -15
@@ -1,94 +1,47 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module S3
3
5
  module Plugins
4
-
5
6
  # Provides support for using `Aws::S3::Client` with Amazon S3 Transfer
6
7
  # Acceleration.
7
8
  #
8
9
  # Go here for more information about transfer acceleration:
9
10
  # [http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html](http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html)
10
11
  class Accelerate < Seahorse::Client::Plugin
11
-
12
- option(:use_accelerate_endpoint,
12
+ option(
13
+ :use_accelerate_endpoint,
13
14
  default: false,
14
15
  doc_type: 'Boolean',
15
16
  docstring: <<-DOCS)
16
17
  When set to `true`, accelerated bucket endpoints will be used
17
18
  for all object operations. You must first enable accelerate for
18
- each bucket. [Go here for more information](http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html).
19
+ each bucket. [Go here for more information](http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html).
19
20
  DOCS
20
21
 
21
22
  def add_handlers(handlers, config)
22
23
  operations = config.api.operation_names - [
23
- :create_bucket, :list_buckets, :delete_bucket,
24
+ :create_bucket, :list_buckets, :delete_bucket
24
25
  ]
25
- handlers.add(OptionHandler, step: :initialize, operations: operations)
26
- handlers.add(AccelerateHandler, step: :build, priority: 0, operations: operations)
26
+ handlers.add(
27
+ OptionHandler, step: :initialize, operations: operations
28
+ )
27
29
  end
28
30
 
29
31
  # @api private
30
32
  class OptionHandler < Seahorse::Client::Handler
31
33
  def call(context)
32
- accelerate = context.params.delete(:use_accelerate_endpoint)
33
- accelerate = context.config.use_accelerate_endpoint if accelerate.nil?
34
- context[:use_accelerate_endpoint] = accelerate
35
- @handler.call(context)
36
- end
37
- end
38
-
39
- # @api private
40
- class AccelerateHandler < Seahorse::Client::Handler
41
-
42
- def call(context)
43
- if context[:use_accelerate_endpoint]
44
- if context[:use_dualstack_endpoint]
45
- use_combined_accelerate_dualstack_endpoint(context)
46
- else
47
- use_accelerate_endpoint(context)
48
- end
34
+ # Support client configuration and per-operation configuration
35
+ # TODO: move this to an options hash and warn here.
36
+ if context.params.is_a?(Hash)
37
+ accelerate = context.params.delete(:use_accelerate_endpoint)
49
38
  end
50
- @handler.call(context)
51
- end
52
-
53
- private
54
-
55
- def use_accelerate_endpoint(context)
56
- bucket_name = context.params[:bucket]
57
- validate_bucket_name!(bucket_name)
58
- endpoint = URI.parse(context.http_request.endpoint.to_s)
59
- endpoint.scheme = 'https'
60
- endpoint.port = 443
61
- endpoint.host = "#{bucket_name}.s3-accelerate.amazonaws.com"
62
- context.http_request.endpoint = endpoint.to_s
63
- # s3 accelerate endpoint doesn't work with 'expect' header
64
- context.http_request.headers.delete('expect')
65
- end
66
-
67
- def use_combined_accelerate_dualstack_endpoint(context)
68
- bucket_name = context.params[:bucket]
69
- validate_bucket_name!(bucket_name)
70
- endpoint = URI.parse(context.http_request.endpoint.to_s)
71
- endpoint.scheme = 'https'
72
- endpoint.port = 443
73
- endpoint.host = "#{bucket_name}.s3-accelerate.dualstack.amazonaws.com"
74
- context.http_request.endpoint = endpoint.to_s
75
- # s3 accelerate endpoint doesn't work with 'expect' header
76
- context.http_request.headers.delete('expect')
77
- end
78
-
79
- def validate_bucket_name!(bucket_name)
80
- unless BucketDns.dns_compatible?(bucket_name, _ssl = true)
81
- msg = "unable to use `accelerate: true` on buckets with "
82
- msg << "non-DNS compatible names"
83
- raise ArgumentError, msg
84
- end
85
- if bucket_name.include?('.')
86
- msg = "unable to use `accelerate: true` on buckets with dots"
87
- msg << "in their name: #{bucket_name.inspect}"
88
- raise ArgumentError, msg
39
+ if accelerate.nil?
40
+ accelerate = context.config.use_accelerate_endpoint
89
41
  end
42
+ context[:use_accelerate_endpoint] = accelerate
43
+ @handler.call(context)
90
44
  end
91
-
92
45
  end
93
46
  end
94
47
  end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Plugins
6
+ # When an accesspoint ARN is provided for :bucket in S3 operations, this
7
+ # plugin resolves the request endpoint from the ARN when possible.
8
+ # @api private
9
+ class ARN < Seahorse::Client::Plugin
10
+ option(
11
+ :s3_use_arn_region,
12
+ default: true,
13
+ doc_type: 'Boolean',
14
+ docstring: <<-DOCS) do |cfg|
15
+ For S3 ARNs passed into the `:bucket` parameter, this option will
16
+ use the region in the ARN, allowing for cross-region requests to
17
+ be made. Set to `false` to use the client's region instead.
18
+ DOCS
19
+ resolve_s3_use_arn_region(cfg)
20
+ end
21
+
22
+ option(
23
+ :s3_disable_multiregion_access_points,
24
+ default: false,
25
+ doc_type: 'Boolean',
26
+ docstring: <<-DOCS) do |cfg|
27
+ When set to `false` this will option will raise errors when multi-region
28
+ access point ARNs are used. Multi-region access points can potentially
29
+ result in cross region requests.
30
+ DOCS
31
+ resolve_s3_disable_multiregion_access_points(cfg)
32
+ end
33
+
34
+ class << self
35
+ private
36
+
37
+ def resolve_s3_use_arn_region(cfg)
38
+ value = ENV['AWS_S3_USE_ARN_REGION'] ||
39
+ Aws.shared_config.s3_use_arn_region(profile: cfg.profile) ||
40
+ 'true'
41
+ value = Aws::Util.str_2_bool(value)
42
+ # Raise if provided value is not true or false
43
+ if value.nil?
44
+ raise ArgumentError,
45
+ 'Must provide either `true` or `false` for the '\
46
+ '`s3_use_arn_region` profile option or for '\
47
+ "ENV['AWS_S3_USE_ARN_REGION']."
48
+ end
49
+ value
50
+ end
51
+
52
+ def resolve_s3_disable_multiregion_access_points(cfg)
53
+ value = ENV['AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS'] ||
54
+ Aws.shared_config.s3_disable_multiregion_access_points(profile: cfg.profile) ||
55
+ 'false'
56
+ value = Aws::Util.str_2_bool(value)
57
+ # Raise if provided value is not true or false
58
+ if value.nil?
59
+ raise ArgumentError,
60
+ 'Must provide either `true` or `false` for '\
61
+ 's3_use_arn_region profile option or for '\
62
+ "ENV['AWS_S3_USE_ARN_REGION']"
63
+ end
64
+ value
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module S3
3
5
  module Plugins
@@ -21,47 +23,10 @@ When set to `true`, the bucket name is always left in the
21
23
  request URI and never moved to the host as a sub-domain.
22
24
  DOCS
23
25
 
24
- def add_handlers(handlers, config)
25
- handlers.add(Handler) unless config.force_path_style
26
- end
27
-
28
- # @api private
29
- class Handler < Seahorse::Client::Handler
30
-
31
- def call(context)
32
- move_dns_compat_bucket_to_subdomain(context)
33
- @handler.call(context)
34
- end
35
-
36
- private
37
-
38
- def move_dns_compat_bucket_to_subdomain(context)
39
- bucket_name = context.params[:bucket]
40
- endpoint = context.http_request.endpoint
41
- if
42
- bucket_name &&
43
- BucketDns.dns_compatible?(bucket_name, https?(endpoint)) &&
44
- context.operation_name.to_s != 'get_bucket_location'
45
- then
46
- move_bucket_to_subdomain(bucket_name, endpoint)
47
- end
48
- end
49
-
50
- def move_bucket_to_subdomain(bucket_name, endpoint)
51
- endpoint.host = "#{bucket_name}.#{endpoint.host}"
52
- path = endpoint.path.sub("/#{bucket_name}", '')
53
- path = "/#{path}" unless path.match(/^\//)
54
- endpoint.path = path
55
- end
56
-
57
- def https?(uri)
58
- uri.scheme == 'https'
59
- end
60
-
61
- end
62
-
26
+ # These class methods were originally used in a handler in this plugin.
27
+ # SigV2 legacy signer needs this logic so we keep it here as utility.
28
+ # New endpoint resolution will check this as a matcher.
63
29
  class << self
64
-
65
30
  # @param [String] bucket_name
66
31
  # @param [Boolean] ssl
67
32
  # @return [Boolean]
@@ -73,15 +38,14 @@ request URI and never moved to the host as a sub-domain.
73
38
  end
74
39
  end
75
40
 
76
- private
77
-
41
+ # @param [String] bucket_name
42
+ # @return [Boolean]
78
43
  def valid_subdomain?(bucket_name)
79
44
  bucket_name.size < 64 &&
80
45
  bucket_name =~ /^[a-z0-9][a-z0-9.-]+[a-z0-9]$/ &&
81
46
  bucket_name !~ /(\d+\.){3}\d+/ &&
82
47
  bucket_name !~ /[.-]{2}/
83
48
  end
84
-
85
49
  end
86
50
  end
87
51
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module S3
3
5
  module Plugins
@@ -5,14 +7,29 @@ module Aws
5
7
  class BucketNameRestrictions < Seahorse::Client::Plugin
6
8
  class Handler < Seahorse::Client::Handler
7
9
 
10
+ # Useful because Aws::S3::Errors::SignatureDoesNotMatch is thrown
11
+ # when passed a bucket with a forward slash. Instead provide a more
12
+ # helpful error. Ideally should not be a plugin?
8
13
  def call(context)
9
- if context.params.key?(:bucket) && context.params[:bucket].include?('/')
10
- msg = ":bucket option must not contain a forward-slash (/)"
11
- raise ArgumentError, msg
14
+ bucket_member = _bucket_member(context.operation.input.shape)
15
+ if bucket_member && (bucket = context.params[bucket_member])
16
+ if !Aws::ARNParser.arn?(bucket) && bucket.include?('/')
17
+ raise ArgumentError,
18
+ 'bucket name must not contain a forward-slash (/)'
19
+ end
12
20
  end
13
21
  @handler.call(context)
14
22
  end
15
23
 
24
+ private
25
+
26
+ def _bucket_member(input)
27
+ input.members.each do |member, ref|
28
+ return member if ref.shape.name == 'BucketName'
29
+ end
30
+ nil
31
+ end
32
+
16
33
  end
17
34
 
18
35
  handler(Handler)
@@ -1,69 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module S3
3
5
  module Plugins
4
6
  # @api private
5
7
  class Dualstack < Seahorse::Client::Plugin
6
-
7
- option(:use_dualstack_endpoint,
8
- default: false,
9
- doc_type: 'Boolean',
10
- docstring: <<-DOCS)
11
- When set to `true`, IPv6-compatible bucket endpoints will be used
12
- for all operations.
13
- DOCS
14
-
15
- def add_handlers(handlers, config)
8
+ def add_handlers(handlers, _config)
16
9
  handlers.add(OptionHandler, step: :initialize)
17
- handlers.add(DualstackHandler, step: :build, priority: 0)
18
10
  end
19
11
 
20
12
  # @api private
21
13
  class OptionHandler < Seahorse::Client::Handler
22
14
  def call(context)
23
- dualstack = context.params.delete(:use_dualstack_endpoint)
15
+ # Support client configuration and per-operation configuration
16
+ if context.params.is_a?(Hash)
17
+ dualstack = context.params.delete(:use_dualstack_endpoint)
18
+ end
24
19
  dualstack = context.config.use_dualstack_endpoint if dualstack.nil?
25
20
  context[:use_dualstack_endpoint] = dualstack
26
21
  @handler.call(context)
27
22
  end
28
23
  end
29
-
30
- # @api private
31
- class DualstackHandler < Seahorse::Client::Handler
32
- def call(context)
33
- apply_dualstack_endpoint(context) if use_dualstack_endpoint?(context)
34
- @handler.call(context)
35
- end
36
-
37
- private
38
- def apply_dualstack_endpoint(context)
39
- bucket_name = context.params[:bucket]
40
- region = context.config.region
41
- context.config.force_path_style
42
- dns_suffix = Aws::Partitions::EndpointProvider.dns_suffix_for(region)
43
-
44
- if use_bucket_dns?(bucket_name, context)
45
- host = "#{bucket_name}.s3.dualstack.#{region}.#{dns_suffix}"
46
- else
47
- host = "s3.dualstack.#{region}.#{dns_suffix}"
48
- end
49
- endpoint = URI.parse(context.http_request.endpoint.to_s)
50
- endpoint.scheme = context.http_request.endpoint.scheme
51
- endpoint.port = context.http_request.endpoint.port
52
- endpoint.host = host
53
- context.http_request.endpoint = endpoint.to_s
54
- end
55
-
56
- def use_bucket_dns?(bucket_name, context)
57
- ssl = context.http_request.endpoint.scheme == "https"
58
- bucket_name && BucketDns.dns_compatible?(bucket_name, ssl) &&
59
- !context.config.force_path_style
60
- end
61
-
62
- def use_dualstack_endpoint?(context)
63
- context[:use_dualstack_endpoint] && !context[:use_accelerate_endpoint]
64
- end
65
- end
66
-
67
24
  end
68
25
  end
69
26
  end
@@ -0,0 +1,274 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+
11
+ module Aws::S3
12
+ module Plugins
13
+ class Endpoints < Seahorse::Client::Plugin
14
+ option(
15
+ :endpoint_provider,
16
+ doc_type: 'Aws::S3::EndpointProvider',
17
+ rbs_type: 'untyped',
18
+ docstring: 'The endpoint provider used to resolve endpoints. Any '\
19
+ 'object that responds to `#resolve_endpoint(parameters)` '\
20
+ 'where `parameters` is a Struct similar to '\
21
+ '`Aws::S3::EndpointParameters`'
22
+ ) do |cfg|
23
+ Aws::S3::EndpointProvider.new
24
+ end
25
+
26
+ option(
27
+ :disable_s3_express_session_auth,
28
+ doc_type: 'Boolean',
29
+ default: nil,
30
+ docstring: "Parameter to indicate whether S3Express session auth should be disabled")
31
+
32
+ # @api private
33
+ class Handler < Seahorse::Client::Handler
34
+ def call(context)
35
+ unless context[:discovered_endpoint]
36
+ params = parameters_for_operation(context)
37
+ endpoint = context.config.endpoint_provider.resolve_endpoint(params)
38
+
39
+ context.http_request.endpoint = endpoint.url
40
+ apply_endpoint_headers(context, endpoint.headers)
41
+
42
+ context[:endpoint_params] = params
43
+ context[:endpoint_properties] = endpoint.properties
44
+ end
45
+
46
+ context[:auth_scheme] =
47
+ Aws::Endpoints.resolve_auth_scheme(context, endpoint)
48
+
49
+ @handler.call(context)
50
+ end
51
+
52
+ private
53
+
54
+ def apply_endpoint_headers(context, headers)
55
+ headers.each do |key, values|
56
+ value = values
57
+ .compact
58
+ .map { |s| Seahorse::Util.escape_header_list_string(s.to_s) }
59
+ .join(',')
60
+
61
+ context.http_request.headers[key] = value
62
+ end
63
+ end
64
+
65
+ def parameters_for_operation(context)
66
+ case context.operation_name
67
+ when :abort_multipart_upload
68
+ Aws::S3::Endpoints::AbortMultipartUpload.build(context)
69
+ when :complete_multipart_upload
70
+ Aws::S3::Endpoints::CompleteMultipartUpload.build(context)
71
+ when :copy_object
72
+ Aws::S3::Endpoints::CopyObject.build(context)
73
+ when :create_bucket
74
+ Aws::S3::Endpoints::CreateBucket.build(context)
75
+ when :create_multipart_upload
76
+ Aws::S3::Endpoints::CreateMultipartUpload.build(context)
77
+ when :create_session
78
+ Aws::S3::Endpoints::CreateSession.build(context)
79
+ when :delete_bucket
80
+ Aws::S3::Endpoints::DeleteBucket.build(context)
81
+ when :delete_bucket_analytics_configuration
82
+ Aws::S3::Endpoints::DeleteBucketAnalyticsConfiguration.build(context)
83
+ when :delete_bucket_cors
84
+ Aws::S3::Endpoints::DeleteBucketCors.build(context)
85
+ when :delete_bucket_encryption
86
+ Aws::S3::Endpoints::DeleteBucketEncryption.build(context)
87
+ when :delete_bucket_intelligent_tiering_configuration
88
+ Aws::S3::Endpoints::DeleteBucketIntelligentTieringConfiguration.build(context)
89
+ when :delete_bucket_inventory_configuration
90
+ Aws::S3::Endpoints::DeleteBucketInventoryConfiguration.build(context)
91
+ when :delete_bucket_lifecycle
92
+ Aws::S3::Endpoints::DeleteBucketLifecycle.build(context)
93
+ when :delete_bucket_metrics_configuration
94
+ Aws::S3::Endpoints::DeleteBucketMetricsConfiguration.build(context)
95
+ when :delete_bucket_ownership_controls
96
+ Aws::S3::Endpoints::DeleteBucketOwnershipControls.build(context)
97
+ when :delete_bucket_policy
98
+ Aws::S3::Endpoints::DeleteBucketPolicy.build(context)
99
+ when :delete_bucket_replication
100
+ Aws::S3::Endpoints::DeleteBucketReplication.build(context)
101
+ when :delete_bucket_tagging
102
+ Aws::S3::Endpoints::DeleteBucketTagging.build(context)
103
+ when :delete_bucket_website
104
+ Aws::S3::Endpoints::DeleteBucketWebsite.build(context)
105
+ when :delete_object
106
+ Aws::S3::Endpoints::DeleteObject.build(context)
107
+ when :delete_object_tagging
108
+ Aws::S3::Endpoints::DeleteObjectTagging.build(context)
109
+ when :delete_objects
110
+ Aws::S3::Endpoints::DeleteObjects.build(context)
111
+ when :delete_public_access_block
112
+ Aws::S3::Endpoints::DeletePublicAccessBlock.build(context)
113
+ when :get_bucket_accelerate_configuration
114
+ Aws::S3::Endpoints::GetBucketAccelerateConfiguration.build(context)
115
+ when :get_bucket_acl
116
+ Aws::S3::Endpoints::GetBucketAcl.build(context)
117
+ when :get_bucket_analytics_configuration
118
+ Aws::S3::Endpoints::GetBucketAnalyticsConfiguration.build(context)
119
+ when :get_bucket_cors
120
+ Aws::S3::Endpoints::GetBucketCors.build(context)
121
+ when :get_bucket_encryption
122
+ Aws::S3::Endpoints::GetBucketEncryption.build(context)
123
+ when :get_bucket_intelligent_tiering_configuration
124
+ Aws::S3::Endpoints::GetBucketIntelligentTieringConfiguration.build(context)
125
+ when :get_bucket_inventory_configuration
126
+ Aws::S3::Endpoints::GetBucketInventoryConfiguration.build(context)
127
+ when :get_bucket_lifecycle
128
+ Aws::S3::Endpoints::GetBucketLifecycle.build(context)
129
+ when :get_bucket_lifecycle_configuration
130
+ Aws::S3::Endpoints::GetBucketLifecycleConfiguration.build(context)
131
+ when :get_bucket_location
132
+ Aws::S3::Endpoints::GetBucketLocation.build(context)
133
+ when :get_bucket_logging
134
+ Aws::S3::Endpoints::GetBucketLogging.build(context)
135
+ when :get_bucket_metrics_configuration
136
+ Aws::S3::Endpoints::GetBucketMetricsConfiguration.build(context)
137
+ when :get_bucket_notification
138
+ Aws::S3::Endpoints::GetBucketNotification.build(context)
139
+ when :get_bucket_notification_configuration
140
+ Aws::S3::Endpoints::GetBucketNotificationConfiguration.build(context)
141
+ when :get_bucket_ownership_controls
142
+ Aws::S3::Endpoints::GetBucketOwnershipControls.build(context)
143
+ when :get_bucket_policy
144
+ Aws::S3::Endpoints::GetBucketPolicy.build(context)
145
+ when :get_bucket_policy_status
146
+ Aws::S3::Endpoints::GetBucketPolicyStatus.build(context)
147
+ when :get_bucket_replication
148
+ Aws::S3::Endpoints::GetBucketReplication.build(context)
149
+ when :get_bucket_request_payment
150
+ Aws::S3::Endpoints::GetBucketRequestPayment.build(context)
151
+ when :get_bucket_tagging
152
+ Aws::S3::Endpoints::GetBucketTagging.build(context)
153
+ when :get_bucket_versioning
154
+ Aws::S3::Endpoints::GetBucketVersioning.build(context)
155
+ when :get_bucket_website
156
+ Aws::S3::Endpoints::GetBucketWebsite.build(context)
157
+ when :get_object
158
+ Aws::S3::Endpoints::GetObject.build(context)
159
+ when :get_object_acl
160
+ Aws::S3::Endpoints::GetObjectAcl.build(context)
161
+ when :get_object_attributes
162
+ Aws::S3::Endpoints::GetObjectAttributes.build(context)
163
+ when :get_object_legal_hold
164
+ Aws::S3::Endpoints::GetObjectLegalHold.build(context)
165
+ when :get_object_lock_configuration
166
+ Aws::S3::Endpoints::GetObjectLockConfiguration.build(context)
167
+ when :get_object_retention
168
+ Aws::S3::Endpoints::GetObjectRetention.build(context)
169
+ when :get_object_tagging
170
+ Aws::S3::Endpoints::GetObjectTagging.build(context)
171
+ when :get_object_torrent
172
+ Aws::S3::Endpoints::GetObjectTorrent.build(context)
173
+ when :get_public_access_block
174
+ Aws::S3::Endpoints::GetPublicAccessBlock.build(context)
175
+ when :head_bucket
176
+ Aws::S3::Endpoints::HeadBucket.build(context)
177
+ when :head_object
178
+ Aws::S3::Endpoints::HeadObject.build(context)
179
+ when :list_bucket_analytics_configurations
180
+ Aws::S3::Endpoints::ListBucketAnalyticsConfigurations.build(context)
181
+ when :list_bucket_intelligent_tiering_configurations
182
+ Aws::S3::Endpoints::ListBucketIntelligentTieringConfigurations.build(context)
183
+ when :list_bucket_inventory_configurations
184
+ Aws::S3::Endpoints::ListBucketInventoryConfigurations.build(context)
185
+ when :list_bucket_metrics_configurations
186
+ Aws::S3::Endpoints::ListBucketMetricsConfigurations.build(context)
187
+ when :list_buckets
188
+ Aws::S3::Endpoints::ListBuckets.build(context)
189
+ when :list_directory_buckets
190
+ Aws::S3::Endpoints::ListDirectoryBuckets.build(context)
191
+ when :list_multipart_uploads
192
+ Aws::S3::Endpoints::ListMultipartUploads.build(context)
193
+ when :list_object_versions
194
+ Aws::S3::Endpoints::ListObjectVersions.build(context)
195
+ when :list_objects
196
+ Aws::S3::Endpoints::ListObjects.build(context)
197
+ when :list_objects_v2
198
+ Aws::S3::Endpoints::ListObjectsV2.build(context)
199
+ when :list_parts
200
+ Aws::S3::Endpoints::ListParts.build(context)
201
+ when :put_bucket_accelerate_configuration
202
+ Aws::S3::Endpoints::PutBucketAccelerateConfiguration.build(context)
203
+ when :put_bucket_acl
204
+ Aws::S3::Endpoints::PutBucketAcl.build(context)
205
+ when :put_bucket_analytics_configuration
206
+ Aws::S3::Endpoints::PutBucketAnalyticsConfiguration.build(context)
207
+ when :put_bucket_cors
208
+ Aws::S3::Endpoints::PutBucketCors.build(context)
209
+ when :put_bucket_encryption
210
+ Aws::S3::Endpoints::PutBucketEncryption.build(context)
211
+ when :put_bucket_intelligent_tiering_configuration
212
+ Aws::S3::Endpoints::PutBucketIntelligentTieringConfiguration.build(context)
213
+ when :put_bucket_inventory_configuration
214
+ Aws::S3::Endpoints::PutBucketInventoryConfiguration.build(context)
215
+ when :put_bucket_lifecycle
216
+ Aws::S3::Endpoints::PutBucketLifecycle.build(context)
217
+ when :put_bucket_lifecycle_configuration
218
+ Aws::S3::Endpoints::PutBucketLifecycleConfiguration.build(context)
219
+ when :put_bucket_logging
220
+ Aws::S3::Endpoints::PutBucketLogging.build(context)
221
+ when :put_bucket_metrics_configuration
222
+ Aws::S3::Endpoints::PutBucketMetricsConfiguration.build(context)
223
+ when :put_bucket_notification
224
+ Aws::S3::Endpoints::PutBucketNotification.build(context)
225
+ when :put_bucket_notification_configuration
226
+ Aws::S3::Endpoints::PutBucketNotificationConfiguration.build(context)
227
+ when :put_bucket_ownership_controls
228
+ Aws::S3::Endpoints::PutBucketOwnershipControls.build(context)
229
+ when :put_bucket_policy
230
+ Aws::S3::Endpoints::PutBucketPolicy.build(context)
231
+ when :put_bucket_replication
232
+ Aws::S3::Endpoints::PutBucketReplication.build(context)
233
+ when :put_bucket_request_payment
234
+ Aws::S3::Endpoints::PutBucketRequestPayment.build(context)
235
+ when :put_bucket_tagging
236
+ Aws::S3::Endpoints::PutBucketTagging.build(context)
237
+ when :put_bucket_versioning
238
+ Aws::S3::Endpoints::PutBucketVersioning.build(context)
239
+ when :put_bucket_website
240
+ Aws::S3::Endpoints::PutBucketWebsite.build(context)
241
+ when :put_object
242
+ Aws::S3::Endpoints::PutObject.build(context)
243
+ when :put_object_acl
244
+ Aws::S3::Endpoints::PutObjectAcl.build(context)
245
+ when :put_object_legal_hold
246
+ Aws::S3::Endpoints::PutObjectLegalHold.build(context)
247
+ when :put_object_lock_configuration
248
+ Aws::S3::Endpoints::PutObjectLockConfiguration.build(context)
249
+ when :put_object_retention
250
+ Aws::S3::Endpoints::PutObjectRetention.build(context)
251
+ when :put_object_tagging
252
+ Aws::S3::Endpoints::PutObjectTagging.build(context)
253
+ when :put_public_access_block
254
+ Aws::S3::Endpoints::PutPublicAccessBlock.build(context)
255
+ when :restore_object
256
+ Aws::S3::Endpoints::RestoreObject.build(context)
257
+ when :select_object_content
258
+ Aws::S3::Endpoints::SelectObjectContent.build(context)
259
+ when :upload_part
260
+ Aws::S3::Endpoints::UploadPart.build(context)
261
+ when :upload_part_copy
262
+ Aws::S3::Endpoints::UploadPartCopy.build(context)
263
+ when :write_get_object_response
264
+ Aws::S3::Endpoints::WriteGetObjectResponse.build(context)
265
+ end
266
+ end
267
+ end
268
+
269
+ def add_handlers(handlers, _config)
270
+ handlers.add(Handler, step: :build, priority: 75)
271
+ end
272
+ end
273
+ end
274
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module S3
3
5
  module Plugins
@@ -13,10 +15,9 @@ module Aws
13
15
  class Handler < Seahorse::Client::Handler
14
16
 
15
17
  def call(context)
16
- if
17
- context.http_request.body &&
18
- context.http_request.body.size > 0
19
- then
18
+ body = context.http_request.body
19
+ if body.respond_to?(:size) && body.size > 0 &&
20
+ !context[:use_accelerate_endpoint]
20
21
  context.http_request.headers['expect'] = '100-continue'
21
22
  end
22
23
  @handler.call(context)