aws-sdk-s3 1.48.0 → 1.183.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 (134) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1352 -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 +1005 -106
  8. data/lib/aws-sdk-s3/bucket_acl.rb +65 -18
  9. data/lib/aws-sdk-s3/bucket_cors.rb +80 -18
  10. data/lib/aws-sdk-s3/bucket_lifecycle.rb +71 -20
  11. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +126 -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 +108 -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 +14517 -941
  21. data/lib/aws-sdk-s3/client_api.rb +1296 -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 +716 -0
  61. data/lib/aws-sdk-s3/endpoints.rb +1434 -0
  62. data/lib/aws-sdk-s3/errors.rb +170 -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 +161 -46
  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 +104 -27
  71. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +61 -21
  72. data/lib/aws-sdk-s3/multipart_upload.rb +342 -32
  73. data/lib/aws-sdk-s3/multipart_upload_error.rb +2 -0
  74. data/lib/aws-sdk-s3/multipart_upload_part.rb +384 -46
  75. data/lib/aws-sdk-s3/object.rb +2600 -231
  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 +2174 -204
  80. data/lib/aws-sdk-s3/object_version.rb +539 -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/checksum_algorithm.rb +31 -0
  87. data/lib/aws-sdk-s3/plugins/dualstack.rb +7 -50
  88. data/lib/aws-sdk-s3/plugins/endpoints.rb +86 -0
  89. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +5 -4
  90. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +88 -0
  91. data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +3 -1
  92. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +62 -17
  93. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +44 -0
  94. data/lib/aws-sdk-s3/plugins/location_constraint.rb +5 -1
  95. data/lib/aws-sdk-s3/plugins/md5s.rb +14 -70
  96. data/lib/aws-sdk-s3/plugins/redirects.rb +2 -0
  97. data/lib/aws-sdk-s3/plugins/s3_host_id.rb +2 -0
  98. data/lib/aws-sdk-s3/plugins/s3_signer.rb +63 -94
  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 +141 -62
  104. data/lib/aws-sdk-s3/resource.rb +156 -17
  105. data/lib/aws-sdk-s3/types.rb +13021 -4106
  106. data/lib/aws-sdk-s3/waiters.rb +67 -1
  107. data/lib/aws-sdk-s3.rb +46 -32
  108. data/sig/bucket.rbs +222 -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 +2472 -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 +42 -0
  125. data/sig/multipart_upload.rbs +120 -0
  126. data/sig/multipart_upload_part.rbs +109 -0
  127. data/sig/object.rbs +459 -0
  128. data/sig/object_acl.rbs +86 -0
  129. data/sig/object_summary.rbs +345 -0
  130. data/sig/object_version.rbs +143 -0
  131. data/sig/resource.rbs +134 -0
  132. data/sig/types.rbs +2712 -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,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,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 = {}
129
196
  http_req = req.context.http_request
130
-
131
- req.handlers.remove(Aws::S3::Plugins::S3Signer::LegacyHandler)
132
- req.handlers.remove(Aws::S3::Plugins::S3Signer::V4Handler)
133
197
  req.handlers.remove(Seahorse::Client::Plugins::ContentLength::Handler)
134
-
135
- signer = build_signer(req.context.config, unsigned_headers)
136
-
137
- req.context[:presigned_url] = true
198
+ req.handlers.remove(Aws::Rest::ContentTypeHandler)
199
+ req.handlers.remove(Aws::Plugins::ChecksumAlgorithm::OptionHandler)
200
+ req.handlers.remove(Aws::Plugins::ChecksumAlgorithm::ChecksumHandler)
201
+ req.handlers.remove(Aws::Plugins::InvocationId::Handler)
202
+ req.handlers.remove(Aws::Plugins::Sign::Handler)
203
+ req.handlers.remove(Aws::S3::Plugins::S3Signer::LegacyHandler)
138
204
  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)
205
+ # if an endpoint was not provided, force secure or insecure
206
+ if context.config.regional_endpoint
207
+ http_req.endpoint.scheme = secure ? 'https' : 'http'
208
+ http_req.endpoint.port = secure ? 443 : 80
145
209
  end
146
210
 
147
- # hoist x-amz-* headers to the querystring
148
211
  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))
212
+ http_req.headers.each do |key, value|
213
+ next unless key =~ /^x-amz/i
214
+
215
+ if hoist
216
+ value = Aws::Sigv4::Signer.uri_escape(value)
152
217
  key = Aws::Sigv4::Signer.uri_escape(key)
218
+ # hoist x-amz-* headers to the querystring
219
+ http_req.headers.delete(key)
153
220
  query << "#{key}=#{value}"
221
+ else
222
+ x_amz_headers[key] = value
154
223
  end
155
224
  end
156
225
  http_req.endpoint.query = query.join('&') unless query.empty?
157
226
 
227
+ auth_scheme = context[:auth_scheme]
228
+ scheme_name = auth_scheme['name']
229
+ region = if scheme_name == 'sigv4a'
230
+ auth_scheme['signingRegionSet'].first
231
+ else
232
+ auth_scheme['signingRegion']
233
+ end
234
+ signer = Aws::Sigv4::Signer.new(
235
+ service: auth_scheme['signingName'] || 's3',
236
+ region: context[:sigv4_region] || region || context.config.region,
237
+ credentials_provider: context[:sigv4_credentials] || context.config.credentials,
238
+ signing_algorithm: scheme_name.to_sym,
239
+ uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
240
+ normalize_path: !!!auth_scheme['disableNormalizePath'],
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, ap-southeast-4, ap-southeast-5, ca-central-1, cn-north-1, cn-northwest-1, EU, eu-central-1, eu-central-2, eu-north-1, eu-south-1, eu-south-2, eu-west-1, eu-west-2, eu-west-3, il-central-1, me-central-1, 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, LocalZone
47
+ # name: "LocationNameAsString",
48
+ # },
49
+ # bucket: {
50
+ # data_redundancy: "SingleAvailabilityZone", # accepts SingleAvailabilityZone, SingleLocalZone
51
+ # type: "Directory", # accepts Directory
52
+ # },
31
53
  # },
32
54
  # grant_full_control: "GrantFullControl",
33
55
  # grant_read: "GrantRead",
@@ -35,30 +57,119 @@ 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 Zone (Availability Zone or Local
81
+ # Zone). Bucket names must also follow the format `
82
+ # bucket-base-name--zone-id--x-s3` (for example, `
83
+ # DOC-EXAMPLE-BUCKET--usw2-az1--x-s3`). For information about bucket
84
+ # naming restrictions, see [Directory bucket naming rules][2] in the
85
+ # *Amazon S3 User Guide*
86
+ #
87
+ #
88
+ #
89
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
90
+ # [2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html
43
91
  # @option options [Types::CreateBucketConfiguration] :create_bucket_configuration
92
+ # The configuration information for the bucket.
44
93
  # @option options [String] :grant_full_control
45
94
  # Allows grantee the read, write, read ACP, and write ACP permissions on
46
95
  # the bucket.
96
+ #
97
+ # <note markdown="1"> This functionality is not supported for directory buckets.
98
+ #
99
+ # </note>
47
100
  # @option options [String] :grant_read
48
101
  # Allows grantee to list the objects in the bucket.
102
+ #
103
+ # <note markdown="1"> This functionality is not supported for directory buckets.
104
+ #
105
+ # </note>
49
106
  # @option options [String] :grant_read_acp
50
107
  # Allows grantee to read the bucket ACL.
108
+ #
109
+ # <note markdown="1"> This functionality is not supported for directory buckets.
110
+ #
111
+ # </note>
51
112
  # @option options [String] :grant_write
52
- # Allows grantee to create, overwrite, and delete any object in the
53
- # bucket.
113
+ # Allows grantee to create new objects in the bucket.
114
+ #
115
+ # For the bucket and object owners of existing objects, also allows
116
+ # deletions and overwrites of those objects.
117
+ #
118
+ # <note markdown="1"> This functionality is not supported for directory buckets.
119
+ #
120
+ # </note>
54
121
  # @option options [String] :grant_write_acp
55
122
  # Allows grantee to write the ACL for the applicable bucket.
123
+ #
124
+ # <note markdown="1"> This functionality is not supported for directory buckets.
125
+ #
126
+ # </note>
56
127
  # @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.
128
+ # Specifies whether you want S3 Object Lock to be enabled for the new
129
+ # bucket.
130
+ #
131
+ # <note markdown="1"> This functionality is not supported for directory buckets.
132
+ #
133
+ # </note>
134
+ # @option options [String] :object_ownership
135
+ # The container element for object ownership for a bucket's ownership
136
+ # controls.
137
+ #
138
+ # `BucketOwnerPreferred` - Objects uploaded to the bucket change
139
+ # ownership to the bucket owner if the objects are uploaded with the
140
+ # `bucket-owner-full-control` canned ACL.
141
+ #
142
+ # `ObjectWriter` - The uploading account will own the object if the
143
+ # object is uploaded with the `bucket-owner-full-control` canned ACL.
144
+ #
145
+ # `BucketOwnerEnforced` - Access control lists (ACLs) are disabled and
146
+ # no longer affect permissions. The bucket owner automatically owns and
147
+ # has full control over every object in the bucket. The bucket only
148
+ # accepts PUT requests that don't specify an ACL or specify bucket
149
+ # owner full control ACLs (such as the predefined
150
+ # `bucket-owner-full-control` canned ACL or a custom ACL in XML format
151
+ # that grants the same permissions).
152
+ #
153
+ # By default, `ObjectOwnership` is set to `BucketOwnerEnforced` and ACLs
154
+ # are disabled. We recommend keeping ACLs disabled, except in uncommon
155
+ # use cases where you must control access for each object individually.
156
+ # For more information about S3 Object Ownership, see [Controlling
157
+ # ownership of objects and disabling ACLs for your bucket][1] in the
158
+ # *Amazon S3 User Guide*.
159
+ #
160
+ # <note markdown="1"> This functionality is not supported for directory buckets. Directory
161
+ # buckets use the bucket owner enforced setting for S3 Object Ownership.
162
+ #
163
+ # </note>
164
+ #
165
+ #
166
+ #
167
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html
59
168
  # @return [Bucket]
60
169
  def create_bucket(options = {})
61
- resp = @client.create_bucket(options)
170
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
171
+ @client.create_bucket(options)
172
+ end
62
173
  Bucket.new(
63
174
  name: options[:bucket],
64
175
  client: @client
@@ -78,21 +189,49 @@ module Aws::S3
78
189
 
79
190
  # @example Request syntax with placeholder values
80
191
  #
81
- # s3.buckets()
192
+ # buckets = s3.buckets({
193
+ # prefix: "Prefix",
194
+ # bucket_region: "BucketRegion",
195
+ # })
82
196
  # @param [Hash] options ({})
197
+ # @option options [String] :prefix
198
+ # Limits the response to bucket names that begin with the specified
199
+ # bucket name prefix.
200
+ # @option options [String] :bucket_region
201
+ # Limits the response to buckets that are located in the specified
202
+ # Amazon Web Services Region. The Amazon Web Services Region must be
203
+ # expressed according to the Amazon Web Services Region code, such as
204
+ # `us-west-2` for the US West (Oregon) Region. For a list of the valid
205
+ # values for all of the Amazon Web Services Regions, see [Regions and
206
+ # Endpoints][1].
207
+ #
208
+ # <note markdown="1"> Requests made to a Regional endpoint that is different from the
209
+ # `bucket-region` parameter are not supported. For example, if you want
210
+ # to limit the response to your buckets in Region `us-west-2`, the
211
+ # request must be made to an endpoint in Region `us-west-2`.
212
+ #
213
+ # </note>
214
+ #
215
+ #
216
+ #
217
+ # [1]: https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
83
218
  # @return [Bucket::Collection]
84
219
  def buckets(options = {})
85
220
  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
- )
221
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
222
+ @client.list_buckets(options)
223
+ end
224
+ resp.each_page do |page|
225
+ batch = []
226
+ page.data.buckets.each do |b|
227
+ batch << Bucket.new(
228
+ name: b.name,
229
+ data: b,
230
+ client: @client
231
+ )
232
+ end
233
+ y.yield(batch)
94
234
  end
95
- y.yield(batch)
96
235
  end
97
236
  Bucket::Collection.new(batches)
98
237
  end