aws-sdk-s3 1.48.0 → 1.169.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1270 -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 +959 -106
  8. data/lib/aws-sdk-s3/bucket_acl.rb +64 -18
  9. data/lib/aws-sdk-s3/bucket_cors.rb +79 -18
  10. data/lib/aws-sdk-s3/bucket_lifecycle.rb +66 -20
  11. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +106 -21
  12. data/lib/aws-sdk-s3/bucket_logging.rb +68 -16
  13. data/lib/aws-sdk-s3/bucket_notification.rb +52 -20
  14. data/lib/aws-sdk-s3/bucket_policy.rb +107 -17
  15. data/lib/aws-sdk-s3/bucket_region_cache.rb +11 -5
  16. data/lib/aws-sdk-s3/bucket_request_payment.rb +60 -15
  17. data/lib/aws-sdk-s3/bucket_tagging.rb +71 -18
  18. data/lib/aws-sdk-s3/bucket_versioning.rb +133 -17
  19. data/lib/aws-sdk-s3/bucket_website.rb +78 -21
  20. data/lib/aws-sdk-s3/client.rb +13765 -1019
  21. data/lib/aws-sdk-s3/client_api.rb +1137 -197
  22. data/lib/aws-sdk-s3/customizations/bucket.rb +56 -37
  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 +288 -68
  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 +28 -7
  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 +181 -0
  60. data/lib/aws-sdk-s3/endpoint_provider.rb +592 -0
  61. data/lib/aws-sdk-s3/endpoints.rb +1392 -0
  62. data/lib/aws-sdk-s3/errors.rb +126 -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 +11 -6
  68. data/lib/aws-sdk-s3/file_uploader.rb +39 -18
  69. data/lib/aws-sdk-s3/legacy_signer.rb +17 -25
  70. data/lib/aws-sdk-s3/multipart_file_uploader.rb +82 -23
  71. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +61 -21
  72. data/lib/aws-sdk-s3/multipart_upload.rb +265 -32
  73. data/lib/aws-sdk-s3/multipart_upload_error.rb +2 -0
  74. data/lib/aws-sdk-s3/multipart_upload_part.rb +367 -45
  75. data/lib/aws-sdk-s3/object.rb +2475 -228
  76. data/lib/aws-sdk-s3/object_acl.rb +103 -25
  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 +2075 -203
  80. data/lib/aws-sdk-s3/object_version.rb +492 -80
  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 +7 -43
  85. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +20 -3
  86. data/lib/aws-sdk-s3/plugins/dualstack.rb +7 -50
  87. data/lib/aws-sdk-s3/plugins/endpoints.rb +86 -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 +44 -0
  93. data/lib/aws-sdk-s3/plugins/location_constraint.rb +5 -1
  94. data/lib/aws-sdk-s3/plugins/md5s.rb +35 -30
  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 +63 -94
  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 -99
  103. data/lib/aws-sdk-s3/presigner.rb +138 -59
  104. data/lib/aws-sdk-s3/resource.rb +155 -17
  105. data/lib/aws-sdk-s3/types.rb +12229 -4377
  106. data/lib/aws-sdk-s3/waiters.rb +67 -1
  107. data/lib/aws-sdk-s3.rb +46 -32
  108. data/sig/bucket.rbs +216 -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 +115 -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 +2406 -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 +132 -0
  132. data/sig/types.rbs +2596 -0
  133. data/sig/waiters.rbs +95 -0
  134. metadata +74 -15
@@ -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,60 @@ 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
+ #
45
+ # @param [Symbol] method Symbolized method name of the operation you want
46
+ # to presign.
47
+ #
48
+ # @option params [Integer] :expires_in (900) The number of seconds
49
+ # before the presigned URL expires. Defaults to 15 minutes. As signature
50
+ # version 4 has a maximum expiry time of one week for presigned URLs,
51
+ # attempts to set this value to greater than one week (604800) will
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
+ #
44
93
  # @param [Symbol] method Symbolized method name of the operation you want
45
94
  # to presign.
46
95
  #
@@ -48,7 +97,8 @@ module Aws
48
97
  # before the presigned URL expires. Defaults to 15 minutes. As signature
49
98
  # version 4 has a maximum expiry time of one week for presigned URLs,
50
99
  # attempts to set this value to greater than one week (604800) will
51
- # raise an exception.
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,38 +123,44 @@ 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
- msg = "expires_in value of #{expires_in} exceeds one-week maximum"
107
- raise ArgumentError, msg
159
+ raise ArgumentError,
160
+ "expires_in value of #{expires_in} exceeds one-week maximum."
161
+ elsif expires_in <= 0
162
+ raise ArgumentError,
163
+ "expires_in value of #{expires_in} cannot be 0 or less."
108
164
  end
109
165
  expires_in
110
166
  else
@@ -113,48 +169,79 @@ module Aws
113
169
  end
114
170
 
115
171
  def use_bucket_as_hostname(req)
116
- req.handlers.remove(Plugins::BucketDns::Handler)
117
- req.handle do |context|
172
+ req.handle(priority: 35) do |context|
118
173
  uri = context.http_request.endpoint
119
174
  uri.host = context.params[:bucket]
120
175
  uri.path.sub!("/#{context.params[:bucket]}", '')
121
- uri.scheme = 'http'
122
- 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
123
187
  @handler.call(context)
124
188
  end
125
189
  end
126
190
 
127
191
  # @param [Seahorse::Client::Request] req
128
- 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
+
129
197
  http_req = req.context.http_request
130
198
 
131
199
  req.handlers.remove(Aws::S3::Plugins::S3Signer::LegacyHandler)
132
- req.handlers.remove(Aws::S3::Plugins::S3Signer::V4Handler)
200
+ req.handlers.remove(Aws::Plugins::Sign::Handler)
133
201
  req.handlers.remove(Seahorse::Client::Plugins::ContentLength::Handler)
202
+ req.handlers.remove(Aws::Rest::ContentTypeHandler)
203
+ req.handlers.remove(Aws::Plugins::InvocationId::Handler)
134
204
 
135
- signer = build_signer(req.context.config, unsigned_headers)
136
-
137
- req.context[:presigned_url] = true
138
205
  req.handle(step: :send) do |context|
139
-
140
- if scheme != http_req.endpoint.scheme
141
- endpoint = http_req.endpoint.dup
142
- endpoint.scheme = scheme
143
- endpoint.port = (scheme == 'http' ? 80 : 443)
144
- 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
145
210
  end
146
211
 
147
- # hoist x-amz-* headers to the querystring
148
212
  query = http_req.endpoint.query ? http_req.endpoint.query.split('&') : []
149
- http_req.headers.keys.each do |key|
150
- if key.match(/^x-amz/i)
151
- 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)
152
218
  key = Aws::Sigv4::Signer.uri_escape(key)
219
+ # hoist x-amz-* headers to the querystring
220
+ http_req.headers.delete(key)
153
221
  query << "#{key}=#{value}"
222
+ else
223
+ x_amz_headers[key] = value
154
224
  end
155
225
  end
156
226
  http_req.endpoint.query = query.join('&') unless query.empty?
157
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
+
158
245
  url = signer.presign_url(
159
246
  http_method: http_req.http_method,
160
247
  url: http_req.endpoint,
@@ -166,16 +253,8 @@ module Aws
166
253
 
167
254
  Seahorse::Client::Response.new(context: context, data: url)
168
255
  end
169
- end
170
-
171
- def build_signer(cfg, unsigned_headers)
172
- Aws::Sigv4::Signer.new(
173
- service: 's3',
174
- region: cfg.region,
175
- credentials_provider: cfg.credentials,
176
- unsigned_headers: unsigned_headers,
177
- uri_escape_path: false
178
- )
256
+ # Return the headers
257
+ x_amz_headers
179
258
  end
180
259
  end
181
260
  end
@@ -1,11 +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
+
12
+ # This class provides a resource oriented interface for S3.
13
+ # To create a resource object:
14
+ #
15
+ # resource = Aws::S3::Resource.new(region: 'us-west-2')
16
+ #
17
+ # You can supply a client object with custom configuration that will be used for all resource operations.
18
+ # If you do not pass `:client`, a default client will be constructed.
19
+ #
20
+ # client = Aws::S3::Client.new(region: 'us-west-2')
21
+ # resource = Aws::S3::Resource.new(client: client)
22
+ #
9
23
  class Resource
10
24
 
11
25
  # @param options ({})
@@ -27,7 +41,15 @@ module Aws::S3
27
41
  # acl: "private", # accepts private, public-read, public-read-write, authenticated-read
28
42
  # bucket: "BucketName", # required
29
43
  # create_bucket_configuration: {
30
- # 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
+ # },
31
53
  # },
32
54
  # grant_full_control: "GrantFullControl",
33
55
  # grant_read: "GrantRead",
@@ -35,30 +57,118 @@ module Aws::S3
35
57
  # grant_write: "GrantWrite",
36
58
  # grant_write_acp: "GrantWriteACP",
37
59
  # object_lock_enabled_for_bucket: false,
60
+ # object_ownership: "BucketOwnerPreferred", # accepts BucketOwnerPreferred, ObjectWriter, BucketOwnerEnforced
38
61
  # })
39
62
  # @param [Hash] options ({})
40
63
  # @option options [String] :acl
41
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>
42
69
  # @option options [required, String] :bucket
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
43
90
  # @option options [Types::CreateBucketConfiguration] :create_bucket_configuration
91
+ # The configuration information for the bucket.
44
92
  # @option options [String] :grant_full_control
45
93
  # Allows grantee the read, write, read ACP, and write ACP permissions on
46
94
  # the bucket.
95
+ #
96
+ # <note markdown="1"> This functionality is not supported for directory buckets.
97
+ #
98
+ # </note>
47
99
  # @option options [String] :grant_read
48
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>
49
105
  # @option options [String] :grant_read_acp
50
106
  # Allows grantee to read the bucket ACL.
107
+ #
108
+ # <note markdown="1"> This functionality is not supported for directory buckets.
109
+ #
110
+ # </note>
51
111
  # @option options [String] :grant_write
52
- # Allows grantee to create, overwrite, and delete any object in the
53
- # 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>
54
120
  # @option options [String] :grant_write_acp
55
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>
56
126
  # @option options [Boolean] :object_lock_enabled_for_bucket
57
- # Specifies whether you want Amazon S3 object lock to be enabled for the
58
- # new bucket.
127
+ # Specifies whether you want S3 Object Lock to be enabled for the new
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
59
167
  # @return [Bucket]
60
168
  def create_bucket(options = {})
61
- resp = @client.create_bucket(options)
169
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
170
+ @client.create_bucket(options)
171
+ end
62
172
  Bucket.new(
63
173
  name: options[:bucket],
64
174
  client: @client
@@ -78,21 +188,49 @@ module Aws::S3
78
188
 
79
189
  # @example Request syntax with placeholder values
80
190
  #
81
- # s3.buckets()
191
+ # buckets = s3.buckets({
192
+ # prefix: "Prefix",
193
+ # bucket_region: "BucketRegion",
194
+ # })
82
195
  # @param [Hash] options ({})
196
+ # @option options [String] :prefix
197
+ # Limits the response to bucket names that begin with the specified
198
+ # bucket name prefix.
199
+ # @option options [String] :bucket_region
200
+ # Limits the response to buckets that are located in the specified
201
+ # Amazon Web Services Region. The Amazon Web Services Region must be
202
+ # expressed according to the Amazon Web Services Region code, such as
203
+ # `us-west-2` for the US West (Oregon) Region. For a list of the valid
204
+ # values for all of the Amazon Web Services Regions, see [Regions and
205
+ # Endpoints][1].
206
+ #
207
+ # <note markdown="1"> Requests made to a Regional endpoint that is different from the
208
+ # `bucket-region` parameter are not supported. For example, if you want
209
+ # to limit the response to your buckets in Region `us-west-2`, the
210
+ # request must be made to an endpoint in Region `us-west-2`.
211
+ #
212
+ # </note>
213
+ #
214
+ #
215
+ #
216
+ # [1]: https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
83
217
  # @return [Bucket::Collection]
84
218
  def buckets(options = {})
85
219
  batches = Enumerator.new do |y|
86
- batch = []
87
- resp = @client.list_buckets(options)
88
- resp.data.buckets.each do |b|
89
- batch << Bucket.new(
90
- name: b.name,
91
- data: b,
92
- client: @client
93
- )
220
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
221
+ @client.list_buckets(options)
222
+ end
223
+ resp.each_page do |page|
224
+ batch = []
225
+ page.data.buckets.each do |b|
226
+ batch << Bucket.new(
227
+ name: b.name,
228
+ data: b,
229
+ client: @client
230
+ )
231
+ end
232
+ y.yield(batch)
94
233
  end
95
- y.yield(batch)
96
234
  end
97
235
  Bucket::Collection.new(batches)
98
236
  end