aws-sdk-s3 1.61.1 → 1.166.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 (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1255 -0
  3. data/LICENSE.txt +202 -0
  4. data/VERSION +1 -0
  5. data/lib/aws-sdk-s3/access_grants_credentials.rb +57 -0
  6. data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +250 -0
  7. data/lib/aws-sdk-s3/bucket.rb +814 -112
  8. data/lib/aws-sdk-s3/bucket_acl.rb +54 -17
  9. data/lib/aws-sdk-s3/bucket_cors.rb +63 -20
  10. data/lib/aws-sdk-s3/bucket_lifecycle.rb +63 -19
  11. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +64 -19
  12. data/lib/aws-sdk-s3/bucket_logging.rb +58 -17
  13. data/lib/aws-sdk-s3/bucket_notification.rb +47 -20
  14. data/lib/aws-sdk-s3/bucket_policy.rb +104 -17
  15. data/lib/aws-sdk-s3/bucket_region_cache.rb +11 -5
  16. data/lib/aws-sdk-s3/bucket_request_payment.rb +53 -19
  17. data/lib/aws-sdk-s3/bucket_tagging.rb +60 -17
  18. data/lib/aws-sdk-s3/bucket_versioning.rb +106 -17
  19. data/lib/aws-sdk-s3/bucket_website.rb +64 -19
  20. data/lib/aws-sdk-s3/client.rb +11280 -3232
  21. data/lib/aws-sdk-s3/client_api.rb +1078 -197
  22. data/lib/aws-sdk-s3/customizations/bucket.rb +33 -45
  23. data/lib/aws-sdk-s3/customizations/errors.rb +40 -0
  24. data/lib/aws-sdk-s3/customizations/multipart_upload.rb +2 -0
  25. data/lib/aws-sdk-s3/customizations/object.rb +237 -39
  26. data/lib/aws-sdk-s3/customizations/object_summary.rb +10 -0
  27. data/lib/aws-sdk-s3/customizations/object_version.rb +13 -0
  28. data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +2 -0
  29. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  30. data/lib/aws-sdk-s3/customizations.rb +27 -28
  31. data/lib/aws-sdk-s3/encryption/client.rb +25 -8
  32. data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +71 -29
  33. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +43 -5
  34. data/lib/aws-sdk-s3/encryption/default_key_provider.rb +2 -0
  35. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +13 -2
  36. data/lib/aws-sdk-s3/encryption/errors.rb +2 -0
  37. data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +2 -0
  38. data/lib/aws-sdk-s3/encryption/io_decrypter.rb +11 -3
  39. data/lib/aws-sdk-s3/encryption/io_encrypter.rb +2 -0
  40. data/lib/aws-sdk-s3/encryption/key_provider.rb +2 -0
  41. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +46 -11
  42. data/lib/aws-sdk-s3/encryption/materials.rb +8 -6
  43. data/lib/aws-sdk-s3/encryption/utils.rb +25 -0
  44. data/lib/aws-sdk-s3/encryption.rb +4 -0
  45. data/lib/aws-sdk-s3/encryptionV2/client.rb +570 -0
  46. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +223 -0
  47. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +170 -0
  48. data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +40 -0
  49. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +65 -0
  50. data/lib/aws-sdk-s3/encryptionV2/errors.rb +37 -0
  51. data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +58 -0
  52. data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +37 -0
  53. data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +73 -0
  54. data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +31 -0
  55. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +173 -0
  56. data/lib/aws-sdk-s3/encryptionV2/materials.rb +60 -0
  57. data/lib/aws-sdk-s3/encryptionV2/utils.rb +103 -0
  58. data/lib/aws-sdk-s3/encryption_v2.rb +23 -0
  59. data/lib/aws-sdk-s3/endpoint_parameters.rb +186 -0
  60. data/lib/aws-sdk-s3/endpoint_provider.rb +592 -0
  61. data/lib/aws-sdk-s3/endpoints.rb +2392 -0
  62. data/lib/aws-sdk-s3/errors.rb +27 -1
  63. data/lib/aws-sdk-s3/event_streams.rb +8 -1
  64. data/lib/aws-sdk-s3/express_credentials.rb +55 -0
  65. data/lib/aws-sdk-s3/express_credentials_provider.rb +59 -0
  66. data/lib/aws-sdk-s3/file_downloader.rb +176 -44
  67. data/lib/aws-sdk-s3/file_part.rb +2 -0
  68. data/lib/aws-sdk-s3/file_uploader.rb +28 -8
  69. data/lib/aws-sdk-s3/legacy_signer.rb +17 -25
  70. data/lib/aws-sdk-s3/multipart_file_uploader.rb +69 -13
  71. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +49 -18
  72. data/lib/aws-sdk-s3/multipart_upload.rb +242 -25
  73. data/lib/aws-sdk-s3/multipart_upload_error.rb +2 -0
  74. data/lib/aws-sdk-s3/multipart_upload_part.rb +343 -31
  75. data/lib/aws-sdk-s3/object.rb +2240 -218
  76. data/lib/aws-sdk-s3/object_acl.rb +80 -21
  77. data/lib/aws-sdk-s3/object_copier.rb +9 -5
  78. data/lib/aws-sdk-s3/object_multipart_copier.rb +48 -22
  79. data/lib/aws-sdk-s3/object_summary.rb +1900 -178
  80. data/lib/aws-sdk-s3/object_version.rb +449 -59
  81. data/lib/aws-sdk-s3/plugins/accelerate.rb +17 -64
  82. data/lib/aws-sdk-s3/plugins/access_grants.rb +178 -0
  83. data/lib/aws-sdk-s3/plugins/arn.rb +70 -0
  84. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +5 -41
  85. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +3 -6
  86. data/lib/aws-sdk-s3/plugins/dualstack.rb +7 -50
  87. data/lib/aws-sdk-s3/plugins/endpoints.rb +289 -0
  88. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +5 -4
  89. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +97 -0
  90. data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +3 -1
  91. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +60 -15
  92. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +11 -27
  93. data/lib/aws-sdk-s3/plugins/location_constraint.rb +5 -1
  94. data/lib/aws-sdk-s3/plugins/md5s.rb +32 -26
  95. data/lib/aws-sdk-s3/plugins/redirects.rb +2 -0
  96. data/lib/aws-sdk-s3/plugins/s3_host_id.rb +2 -0
  97. data/lib/aws-sdk-s3/plugins/s3_signer.rb +50 -88
  98. data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +31 -0
  99. data/lib/aws-sdk-s3/plugins/sse_cpk.rb +3 -1
  100. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +139 -0
  101. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +2 -0
  102. data/lib/aws-sdk-s3/presigned_post.rb +160 -103
  103. data/lib/aws-sdk-s3/presigner.rb +136 -61
  104. data/lib/aws-sdk-s3/resource.rb +120 -15
  105. data/lib/aws-sdk-s3/types.rb +9683 -4358
  106. data/lib/aws-sdk-s3/waiters.rb +67 -1
  107. data/lib/aws-sdk-s3.rb +40 -29
  108. data/sig/bucket.rbs +213 -0
  109. data/sig/bucket_acl.rbs +78 -0
  110. data/sig/bucket_cors.rbs +69 -0
  111. data/sig/bucket_lifecycle.rbs +88 -0
  112. data/sig/bucket_lifecycle_configuration.rbs +111 -0
  113. data/sig/bucket_logging.rbs +76 -0
  114. data/sig/bucket_notification.rbs +114 -0
  115. data/sig/bucket_policy.rbs +59 -0
  116. data/sig/bucket_request_payment.rbs +54 -0
  117. data/sig/bucket_tagging.rbs +65 -0
  118. data/sig/bucket_versioning.rbs +77 -0
  119. data/sig/bucket_website.rbs +93 -0
  120. data/sig/client.rbs +2397 -0
  121. data/sig/customizations/bucket.rbs +19 -0
  122. data/sig/customizations/object.rbs +38 -0
  123. data/sig/customizations/object_summary.rbs +35 -0
  124. data/sig/errors.rbs +34 -0
  125. data/sig/multipart_upload.rbs +111 -0
  126. data/sig/multipart_upload_part.rbs +105 -0
  127. data/sig/object.rbs +443 -0
  128. data/sig/object_acl.rbs +86 -0
  129. data/sig/object_summary.rbs +335 -0
  130. data/sig/object_version.rbs +137 -0
  131. data/sig/resource.rbs +130 -0
  132. data/sig/types.rbs +2585 -0
  133. data/sig/waiters.rbs +95 -0
  134. metadata +73 -15
  135. data/lib/aws-sdk-s3/plugins/bucket_arn.rb +0 -211
@@ -1,23 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module S3
3
-
4
- # Allows you to create presigned URLs for S3 operations.
5
- #
6
- # Example Use:
7
- #
8
- # signer = Aws::S3::Presigner.new
9
- # url = signer.presigned_url(:get_object, bucket: "bucket", key: "key")
10
- #
11
5
  class Presigner
12
-
13
6
  # @api private
14
7
  ONE_WEEK = 60 * 60 * 24 * 7
15
8
 
16
9
  # @api private
17
10
  FIFTEEN_MINUTES = 60 * 15
18
11
 
12
+ # @api private
19
13
  BLACKLISTED_HEADERS = [
20
14
  'accept',
15
+ 'amz-sdk-request',
21
16
  'cache-control',
22
17
  'content-length', # due to a ELB bug
23
18
  'expect',
@@ -41,6 +36,12 @@ module Aws
41
36
  @client = options[:client] || Aws::S3::Client.new
42
37
  end
43
38
 
39
+ # Create presigned URLs for S3 operations.
40
+ #
41
+ # @example
42
+ # signer = Aws::S3::Presigner.new
43
+ # url = signer.presigned_url(:get_object, bucket: "bucket", key: "key")
44
+ #
44
45
  # @param [Symbol] method Symbolized method name of the operation you want
45
46
  # to presign.
46
47
  #
@@ -48,7 +49,56 @@ module Aws
48
49
  # before the presigned URL expires. Defaults to 15 minutes. As signature
49
50
  # version 4 has a maximum expiry time of one week for presigned URLs,
50
51
  # attempts to set this value to greater than one week (604800) will
51
- # raise an exception.
52
+ # raise an exception. The min value of this option and the credentials
53
+ # expiration time is used in the presigned URL.
54
+ #
55
+ # @option params [Time] :time (Time.now) The starting time for when the
56
+ # presigned url becomes active.
57
+ #
58
+ # @option params [Boolean] :secure (true) When `false`, a HTTP URL
59
+ # is returned instead of the default HTTPS URL.
60
+ #
61
+ # @option params [Boolean] :virtual_host (false) When `true`, the
62
+ # bucket name will be used as the hostname.
63
+ #
64
+ # @option params [Boolean] :use_accelerate_endpoint (false) When `true`,
65
+ # Presigner will attempt to use accelerated endpoint.
66
+ #
67
+ # @option params [Array<String>] :whitelist_headers ([]) Additional
68
+ # headers to be included for the signed request. Certain headers beyond
69
+ # the authorization header could, in theory, be changed for various
70
+ # reasons (including but not limited to proxies) while in transit and
71
+ # after signing. This would lead to signature errors being returned,
72
+ # despite no actual problems with signing. (see BLACKLISTED_HEADERS)
73
+ #
74
+ # @raise [ArgumentError] Raises an ArgumentError if `:expires_in`
75
+ # exceeds one week.
76
+ #
77
+ # @return [String] a presigned url
78
+ def presigned_url(method, params = {})
79
+ url, _headers = _presigned_request(method, params)
80
+ url
81
+ end
82
+
83
+ # Allows you to create presigned URL requests for S3 operations. This
84
+ # method returns a tuple containing the URL and the signed X-amz-* headers
85
+ # to be used with the presigned url.
86
+ #
87
+ # @example
88
+ # signer = Aws::S3::Presigner.new
89
+ # url, headers = signer.presigned_request(
90
+ # :get_object, bucket: "bucket", key: "key"
91
+ # )
92
+ #
93
+ # @param [Symbol] method Symbolized method name of the operation you want
94
+ # to presign.
95
+ #
96
+ # @option params [Integer] :expires_in (900) The number of seconds
97
+ # before the presigned URL expires. Defaults to 15 minutes. As signature
98
+ # version 4 has a maximum expiry time of one week for presigned URLs,
99
+ # attempts to set this value to greater than one week (604800) will
100
+ # raise an exception. The min value of this option and the credentials
101
+ # expiration time is used in the presigned URL.
52
102
  #
53
103
  # @option params [Time] :time (Time.now) The starting time for when the
54
104
  # presigned url becomes active.
@@ -73,43 +123,45 @@ module Aws
73
123
  # @raise [ArgumentError] Raises an ArgumentError if `:expires_in`
74
124
  # exceeds one week.
75
125
  #
76
- def presigned_url(method, params = {})
77
- if params[:key].nil? or params[:key] == ''
78
- raise ArgumentError, ":key must not be blank"
79
- end
80
- virtual_host = !!params.delete(:virtual_host)
126
+ # @return [String, Hash] A tuple with a presigned URL and headers that
127
+ # should be included with the request.
128
+ def presigned_request(method, params = {})
129
+ _presigned_request(method, params, false)
130
+ end
131
+
132
+ private
133
+
134
+ def _presigned_request(method, params, hoist = true)
135
+ virtual_host = params.delete(:virtual_host)
81
136
  time = params.delete(:time)
82
- whitelisted_headers = params.delete(:whitelist_headers) || []
83
- unsigned_headers = BLACKLISTED_HEADERS - whitelisted_headers
84
- scheme = http_scheme(params, virtual_host)
137
+ unsigned_headers = unsigned_headers(params)
138
+ secure = params.delete(:secure) != false
139
+ expires_in = expires_in(params)
85
140
 
86
141
  req = @client.build_request(method, params)
87
142
  use_bucket_as_hostname(req) if virtual_host
143
+ handle_presigned_url_context(req)
88
144
 
89
- sign_but_dont_send(req, expires_in(params), scheme, time, unsigned_headers)
90
- req.send_request.data
145
+ x_amz_headers = sign_but_dont_send(
146
+ req, expires_in, secure, time, unsigned_headers, hoist
147
+ )
148
+ [req.send_request.data, x_amz_headers]
91
149
  end
92
150
 
93
- private
94
-
95
- def http_scheme(params, virtual_host)
96
- if params.delete(:secure) == false || virtual_host
97
- 'http'
98
- else
99
- @client.config.endpoint.scheme
100
- end
151
+ def unsigned_headers(params)
152
+ whitelist_headers = params.delete(:whitelist_headers) || []
153
+ BLACKLISTED_HEADERS - whitelist_headers
101
154
  end
102
155
 
103
156
  def expires_in(params)
104
157
  if (expires_in = params.delete(:expires_in))
105
158
  if expires_in > ONE_WEEK
106
159
  raise ArgumentError,
107
- "expires_in value of #{expires_in} exceeds one-week maximum"
108
- elsif expires_in <= 0
160
+ "expires_in value of #{expires_in} exceeds one-week maximum."
161
+ elsif expires_in <= 0
109
162
  raise ArgumentError,
110
- "expires_in value of #{expires_in} cannot be 0 or less"
163
+ "expires_in value of #{expires_in} cannot be 0 or less."
111
164
  end
112
-
113
165
  expires_in
114
166
  else
115
167
  FIFTEEN_MINUTES
@@ -117,48 +169,79 @@ module Aws
117
169
  end
118
170
 
119
171
  def use_bucket_as_hostname(req)
120
- req.handlers.remove(Plugins::BucketDns::Handler)
121
- req.handle do |context|
172
+ req.handle(priority: 35) do |context|
122
173
  uri = context.http_request.endpoint
123
174
  uri.host = context.params[:bucket]
124
175
  uri.path.sub!("/#{context.params[:bucket]}", '')
125
- uri.scheme = 'http'
126
- uri.port = 80
176
+ @handler.call(context)
177
+ end
178
+ end
179
+
180
+ # Used for excluding presigned_urls from API request count.
181
+ #
182
+ # Store context information as early as possible, to allow
183
+ # handlers to perform decisions based on this flag if need.
184
+ def handle_presigned_url_context(req)
185
+ req.handle(step: :initialize, priority: 98) do |context|
186
+ context[:presigned_url] = true
127
187
  @handler.call(context)
128
188
  end
129
189
  end
130
190
 
131
191
  # @param [Seahorse::Client::Request] req
132
- def sign_but_dont_send(req, expires_in, scheme, time, unsigned_headers)
192
+ def sign_but_dont_send(
193
+ req, expires_in, secure, time, unsigned_headers, hoist = true
194
+ )
195
+ x_amz_headers = {}
196
+
133
197
  http_req = req.context.http_request
134
198
 
135
199
  req.handlers.remove(Aws::S3::Plugins::S3Signer::LegacyHandler)
136
- req.handlers.remove(Aws::S3::Plugins::S3Signer::V4Handler)
200
+ req.handlers.remove(Aws::Plugins::Sign::Handler)
137
201
  req.handlers.remove(Seahorse::Client::Plugins::ContentLength::Handler)
202
+ req.handlers.remove(Aws::Rest::ContentTypeHandler)
203
+ req.handlers.remove(Aws::Plugins::InvocationId::Handler)
138
204
 
139
- signer = build_signer(req.context.config, unsigned_headers)
140
-
141
- req.context[:presigned_url] = true
142
205
  req.handle(step: :send) do |context|
143
-
144
- if scheme != http_req.endpoint.scheme
145
- endpoint = http_req.endpoint.dup
146
- endpoint.scheme = scheme
147
- endpoint.port = (scheme == 'http' ? 80 : 443)
148
- http_req.endpoint = URI.parse(endpoint.to_s)
206
+ # if an endpoint was not provided, force secure or insecure
207
+ if context.config.regional_endpoint
208
+ http_req.endpoint.scheme = secure ? 'https' : 'http'
209
+ http_req.endpoint.port = secure ? 443 : 80
149
210
  end
150
211
 
151
- # hoist x-amz-* headers to the querystring
152
212
  query = http_req.endpoint.query ? http_req.endpoint.query.split('&') : []
153
- http_req.headers.keys.each do |key|
154
- if key.match(/^x-amz/i)
155
- value = Aws::Sigv4::Signer.uri_escape(http_req.headers.delete(key))
213
+ http_req.headers.each do |key, value|
214
+ next unless key =~ /^x-amz/i
215
+
216
+ if hoist
217
+ value = Aws::Sigv4::Signer.uri_escape(value)
156
218
  key = Aws::Sigv4::Signer.uri_escape(key)
219
+ # hoist x-amz-* headers to the querystring
220
+ http_req.headers.delete(key)
157
221
  query << "#{key}=#{value}"
222
+ else
223
+ x_amz_headers[key] = value
158
224
  end
159
225
  end
160
226
  http_req.endpoint.query = query.join('&') unless query.empty?
161
227
 
228
+ auth_scheme = context[:auth_scheme]
229
+ scheme_name = auth_scheme['name']
230
+ region = if scheme_name == 'sigv4a'
231
+ auth_scheme['signingRegionSet'].first
232
+ else
233
+ auth_scheme['signingRegion']
234
+ end
235
+ signer = Aws::Sigv4::Signer.new(
236
+ service: auth_scheme['signingName'] || 's3',
237
+ region: context[:sigv4_region] || region || context.config.region,
238
+ credentials_provider: context[:sigv4_credentials] || context.config.credentials,
239
+ signing_algorithm: scheme_name.to_sym,
240
+ uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
241
+ unsigned_headers: unsigned_headers,
242
+ apply_checksum_header: false
243
+ )
244
+
162
245
  url = signer.presign_url(
163
246
  http_method: http_req.http_method,
164
247
  url: http_req.endpoint,
@@ -170,16 +253,8 @@ module Aws
170
253
 
171
254
  Seahorse::Client::Response.new(context: context, data: url)
172
255
  end
173
- end
174
-
175
- def build_signer(cfg, unsigned_headers)
176
- Aws::Sigv4::Signer.new(
177
- service: 's3',
178
- region: cfg.region,
179
- credentials_provider: cfg.credentials,
180
- unsigned_headers: unsigned_headers,
181
- uri_escape_path: false
182
- )
256
+ # Return the headers
257
+ x_amz_headers
183
258
  end
184
259
  end
185
260
  end
@@ -1,18 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # WARNING ABOUT GENERATED CODE
2
4
  #
3
5
  # This file is generated. See the contributing guide for more information:
4
- # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
5
7
  #
6
8
  # WARNING ABOUT GENERATED CODE
7
9
 
8
10
  module Aws::S3
11
+
9
12
  # This class provides a resource oriented interface for S3.
10
13
  # To create a resource object:
14
+ #
11
15
  # resource = Aws::S3::Resource.new(region: 'us-west-2')
16
+ #
12
17
  # You can supply a client object with custom configuration that will be used for all resource operations.
13
- # If you do not pass +:client+, a default client will be constructed.
18
+ # If you do not pass `:client`, a default client will be constructed.
19
+ #
14
20
  # client = Aws::S3::Client.new(region: 'us-west-2')
15
21
  # resource = Aws::S3::Resource.new(client: client)
22
+ #
16
23
  class Resource
17
24
 
18
25
  # @param options ({})
@@ -34,7 +41,15 @@ module Aws::S3
34
41
  # acl: "private", # accepts private, public-read, public-read-write, authenticated-read
35
42
  # bucket: "BucketName", # required
36
43
  # create_bucket_configuration: {
37
- # location_constraint: "EU", # accepts EU, eu-west-1, us-west-1, us-west-2, ap-south-1, ap-southeast-1, ap-southeast-2, ap-northeast-1, sa-east-1, cn-north-1, eu-central-1
44
+ # location_constraint: "af-south-1", # accepts af-south-1, ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-south-2, ap-southeast-1, ap-southeast-2, ap-southeast-3, ca-central-1, cn-north-1, cn-northwest-1, EU, eu-central-1, eu-north-1, eu-south-1, eu-south-2, eu-west-1, eu-west-2, eu-west-3, me-south-1, sa-east-1, us-east-2, us-gov-east-1, us-gov-west-1, us-west-1, us-west-2
45
+ # location: {
46
+ # type: "AvailabilityZone", # accepts AvailabilityZone
47
+ # name: "LocationNameAsString",
48
+ # },
49
+ # bucket: {
50
+ # data_redundancy: "SingleAvailabilityZone", # accepts SingleAvailabilityZone
51
+ # type: "Directory", # accepts Directory
52
+ # },
38
53
  # },
39
54
  # grant_full_control: "GrantFullControl",
40
55
  # grant_read: "GrantRead",
@@ -42,32 +57,118 @@ module Aws::S3
42
57
  # grant_write: "GrantWrite",
43
58
  # grant_write_acp: "GrantWriteACP",
44
59
  # object_lock_enabled_for_bucket: false,
60
+ # object_ownership: "BucketOwnerPreferred", # accepts BucketOwnerPreferred, ObjectWriter, BucketOwnerEnforced
45
61
  # })
46
62
  # @param [Hash] options ({})
47
63
  # @option options [String] :acl
48
64
  # The canned ACL to apply to the bucket.
65
+ #
66
+ # <note markdown="1"> This functionality is not supported for directory buckets.
67
+ #
68
+ # </note>
49
69
  # @option options [required, String] :bucket
50
70
  # The name of the bucket to create.
71
+ #
72
+ # **General purpose buckets** - For information about bucket naming
73
+ # restrictions, see [Bucket naming rules][1] in the *Amazon S3 User
74
+ # Guide*.
75
+ #
76
+ # <b>Directory buckets </b> - When you use this operation with a
77
+ # directory bucket, you must use path-style requests in the format
78
+ # `https://s3express-control.region_code.amazonaws.com/bucket-name `.
79
+ # Virtual-hosted-style requests aren't supported. Directory bucket
80
+ # names must be unique in the chosen Availability Zone. Bucket names
81
+ # must also follow the format ` bucket_base_name--az_id--x-s3` (for
82
+ # example, ` DOC-EXAMPLE-BUCKET--usw2-az1--x-s3`). For information about
83
+ # bucket naming restrictions, see [Directory bucket naming rules][2] in
84
+ # the *Amazon S3 User Guide*
85
+ #
86
+ #
87
+ #
88
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
89
+ # [2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html
51
90
  # @option options [Types::CreateBucketConfiguration] :create_bucket_configuration
52
91
  # The configuration information for the bucket.
53
92
  # @option options [String] :grant_full_control
54
93
  # Allows grantee the read, write, read ACP, and write ACP permissions on
55
94
  # the bucket.
95
+ #
96
+ # <note markdown="1"> This functionality is not supported for directory buckets.
97
+ #
98
+ # </note>
56
99
  # @option options [String] :grant_read
57
100
  # Allows grantee to list the objects in the bucket.
101
+ #
102
+ # <note markdown="1"> This functionality is not supported for directory buckets.
103
+ #
104
+ # </note>
58
105
  # @option options [String] :grant_read_acp
59
106
  # Allows grantee to read the bucket ACL.
107
+ #
108
+ # <note markdown="1"> This functionality is not supported for directory buckets.
109
+ #
110
+ # </note>
60
111
  # @option options [String] :grant_write
61
- # Allows grantee to create, overwrite, and delete any object in the
62
- # bucket.
112
+ # Allows grantee to create new objects in the bucket.
113
+ #
114
+ # For the bucket and object owners of existing objects, also allows
115
+ # deletions and overwrites of those objects.
116
+ #
117
+ # <note markdown="1"> This functionality is not supported for directory buckets.
118
+ #
119
+ # </note>
63
120
  # @option options [String] :grant_write_acp
64
121
  # Allows grantee to write the ACL for the applicable bucket.
122
+ #
123
+ # <note markdown="1"> This functionality is not supported for directory buckets.
124
+ #
125
+ # </note>
65
126
  # @option options [Boolean] :object_lock_enabled_for_bucket
66
127
  # Specifies whether you want S3 Object Lock to be enabled for the new
67
128
  # bucket.
129
+ #
130
+ # <note markdown="1"> This functionality is not supported for directory buckets.
131
+ #
132
+ # </note>
133
+ # @option options [String] :object_ownership
134
+ # The container element for object ownership for a bucket's ownership
135
+ # controls.
136
+ #
137
+ # `BucketOwnerPreferred` - Objects uploaded to the bucket change
138
+ # ownership to the bucket owner if the objects are uploaded with the
139
+ # `bucket-owner-full-control` canned ACL.
140
+ #
141
+ # `ObjectWriter` - The uploading account will own the object if the
142
+ # object is uploaded with the `bucket-owner-full-control` canned ACL.
143
+ #
144
+ # `BucketOwnerEnforced` - Access control lists (ACLs) are disabled and
145
+ # no longer affect permissions. The bucket owner automatically owns and
146
+ # has full control over every object in the bucket. The bucket only
147
+ # accepts PUT requests that don't specify an ACL or specify bucket
148
+ # owner full control ACLs (such as the predefined
149
+ # `bucket-owner-full-control` canned ACL or a custom ACL in XML format
150
+ # that grants the same permissions).
151
+ #
152
+ # By default, `ObjectOwnership` is set to `BucketOwnerEnforced` and ACLs
153
+ # are disabled. We recommend keeping ACLs disabled, except in uncommon
154
+ # use cases where you must control access for each object individually.
155
+ # For more information about S3 Object Ownership, see [Controlling
156
+ # ownership of objects and disabling ACLs for your bucket][1] in the
157
+ # *Amazon S3 User Guide*.
158
+ #
159
+ # <note markdown="1"> This functionality is not supported for directory buckets. Directory
160
+ # buckets use the bucket owner enforced setting for S3 Object Ownership.
161
+ #
162
+ # </note>
163
+ #
164
+ #
165
+ #
166
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html
68
167
  # @return [Bucket]
69
168
  def create_bucket(options = {})
70
- resp = @client.create_bucket(options)
169
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
170
+ @client.create_bucket(options)
171
+ end
71
172
  Bucket.new(
72
173
  name: options[:bucket],
73
174
  client: @client
@@ -92,16 +193,20 @@ module Aws::S3
92
193
  # @return [Bucket::Collection]
93
194
  def buckets(options = {})
94
195
  batches = Enumerator.new do |y|
95
- batch = []
96
- resp = @client.list_buckets(options)
97
- resp.data.buckets.each do |b|
98
- batch << Bucket.new(
99
- name: b.name,
100
- data: b,
101
- client: @client
102
- )
196
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
197
+ @client.list_buckets(options)
198
+ end
199
+ resp.each_page do |page|
200
+ batch = []
201
+ page.data.buckets.each do |b|
202
+ batch << Bucket.new(
203
+ name: b.name,
204
+ data: b,
205
+ client: @client
206
+ )
207
+ end
208
+ y.yield(batch)
103
209
  end
104
- y.yield(batch)
105
210
  end
106
211
  Bucket::Collection.new(batches)
107
212
  end