aws-sdk-s3 1.75.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/lib/aws-sdk-s3.rb +73 -0
  3. data/lib/aws-sdk-s3/bucket.rb +861 -0
  4. data/lib/aws-sdk-s3/bucket_acl.rb +277 -0
  5. data/lib/aws-sdk-s3/bucket_cors.rb +262 -0
  6. data/lib/aws-sdk-s3/bucket_lifecycle.rb +264 -0
  7. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +283 -0
  8. data/lib/aws-sdk-s3/bucket_logging.rb +251 -0
  9. data/lib/aws-sdk-s3/bucket_notification.rb +293 -0
  10. data/lib/aws-sdk-s3/bucket_policy.rb +242 -0
  11. data/lib/aws-sdk-s3/bucket_region_cache.rb +81 -0
  12. data/lib/aws-sdk-s3/bucket_request_payment.rb +236 -0
  13. data/lib/aws-sdk-s3/bucket_tagging.rb +251 -0
  14. data/lib/aws-sdk-s3/bucket_versioning.rb +312 -0
  15. data/lib/aws-sdk-s3/bucket_website.rb +292 -0
  16. data/lib/aws-sdk-s3/client.rb +11818 -0
  17. data/lib/aws-sdk-s3/client_api.rb +3014 -0
  18. data/lib/aws-sdk-s3/customizations.rb +34 -0
  19. data/lib/aws-sdk-s3/customizations/bucket.rb +162 -0
  20. data/lib/aws-sdk-s3/customizations/multipart_upload.rb +44 -0
  21. data/lib/aws-sdk-s3/customizations/object.rb +389 -0
  22. data/lib/aws-sdk-s3/customizations/object_summary.rb +85 -0
  23. data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +13 -0
  24. data/lib/aws-sdk-s3/encryption.rb +21 -0
  25. data/lib/aws-sdk-s3/encryption/client.rb +375 -0
  26. data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +190 -0
  27. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +65 -0
  28. data/lib/aws-sdk-s3/encryption/default_key_provider.rb +40 -0
  29. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +61 -0
  30. data/lib/aws-sdk-s3/encryption/errors.rb +15 -0
  31. data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +58 -0
  32. data/lib/aws-sdk-s3/encryption/io_decrypter.rb +36 -0
  33. data/lib/aws-sdk-s3/encryption/io_encrypter.rb +71 -0
  34. data/lib/aws-sdk-s3/encryption/key_provider.rb +31 -0
  35. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +75 -0
  36. data/lib/aws-sdk-s3/encryption/materials.rb +60 -0
  37. data/lib/aws-sdk-s3/encryption/utils.rb +81 -0
  38. data/lib/aws-sdk-s3/encryptionV2/client.rb +388 -0
  39. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +198 -0
  40. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +103 -0
  41. data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +38 -0
  42. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +66 -0
  43. data/lib/aws-sdk-s3/encryptionV2/errors.rb +13 -0
  44. data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +56 -0
  45. data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +35 -0
  46. data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +71 -0
  47. data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +29 -0
  48. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +99 -0
  49. data/lib/aws-sdk-s3/encryptionV2/materials.rb +58 -0
  50. data/lib/aws-sdk-s3/encryptionV2/utils.rb +116 -0
  51. data/lib/aws-sdk-s3/encryption_v2.rb +20 -0
  52. data/lib/aws-sdk-s3/errors.rb +115 -0
  53. data/lib/aws-sdk-s3/event_streams.rb +69 -0
  54. data/lib/aws-sdk-s3/file_downloader.rb +142 -0
  55. data/lib/aws-sdk-s3/file_part.rb +78 -0
  56. data/lib/aws-sdk-s3/file_uploader.rb +70 -0
  57. data/lib/aws-sdk-s3/legacy_signer.rb +189 -0
  58. data/lib/aws-sdk-s3/multipart_file_uploader.rb +227 -0
  59. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +173 -0
  60. data/lib/aws-sdk-s3/multipart_upload.rb +401 -0
  61. data/lib/aws-sdk-s3/multipart_upload_error.rb +18 -0
  62. data/lib/aws-sdk-s3/multipart_upload_part.rb +423 -0
  63. data/lib/aws-sdk-s3/object.rb +1422 -0
  64. data/lib/aws-sdk-s3/object_acl.rb +333 -0
  65. data/lib/aws-sdk-s3/object_copier.rb +101 -0
  66. data/lib/aws-sdk-s3/object_multipart_copier.rb +182 -0
  67. data/lib/aws-sdk-s3/object_summary.rb +1181 -0
  68. data/lib/aws-sdk-s3/object_version.rb +550 -0
  69. data/lib/aws-sdk-s3/plugins/accelerate.rb +87 -0
  70. data/lib/aws-sdk-s3/plugins/bucket_arn.rb +212 -0
  71. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +91 -0
  72. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +45 -0
  73. data/lib/aws-sdk-s3/plugins/dualstack.rb +74 -0
  74. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +28 -0
  75. data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +25 -0
  76. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +55 -0
  77. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +62 -0
  78. data/lib/aws-sdk-s3/plugins/location_constraint.rb +35 -0
  79. data/lib/aws-sdk-s3/plugins/md5s.rb +84 -0
  80. data/lib/aws-sdk-s3/plugins/redirects.rb +45 -0
  81. data/lib/aws-sdk-s3/plugins/s3_host_id.rb +30 -0
  82. data/lib/aws-sdk-s3/plugins/s3_signer.rb +222 -0
  83. data/lib/aws-sdk-s3/plugins/sse_cpk.rb +70 -0
  84. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +118 -0
  85. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +97 -0
  86. data/lib/aws-sdk-s3/presigned_post.rb +686 -0
  87. data/lib/aws-sdk-s3/presigner.rb +253 -0
  88. data/lib/aws-sdk-s3/resource.rb +117 -0
  89. data/lib/aws-sdk-s3/types.rb +13154 -0
  90. data/lib/aws-sdk-s3/waiters.rb +243 -0
  91. metadata +184 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 75f8d275e892e31dfb80d004f49fb465fc4388e92f20e2827089d5dc76e0d821
4
+ data.tar.gz: 1f84cba631bb2e6a81d07ea671fec120d6bf33dcbfe6e427de26444c36627cf8
5
+ SHA512:
6
+ metadata.gz: f034970098a597fd9d6eeb87a8a82c1ed30ff918ca292b1a0a3f380f08e5b8f504ec619b1763312720f1b28e1df6ba7b56c0bac19dc09c9923bc21aa8be189d1
7
+ data.tar.gz: 0bb581e24c1e3d0fa6306c574146f7ef1e85ff949911d7917c0f4cf8cf85b364cf8b0210ed2ba54a85ec5838a463368ede8f978846e123f79f78e92e3fffd4c9
@@ -0,0 +1,73 @@
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/master/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ require 'aws-sdk-kms'
11
+ require 'aws-sigv4'
12
+ require 'aws-sdk-core'
13
+
14
+ require_relative 'aws-sdk-s3/types'
15
+ require_relative 'aws-sdk-s3/client_api'
16
+ require_relative 'aws-sdk-s3/client'
17
+ require_relative 'aws-sdk-s3/errors'
18
+ require_relative 'aws-sdk-s3/waiters'
19
+ require_relative 'aws-sdk-s3/resource'
20
+ require_relative 'aws-sdk-s3/bucket'
21
+ require_relative 'aws-sdk-s3/bucket_acl'
22
+ require_relative 'aws-sdk-s3/bucket_cors'
23
+ require_relative 'aws-sdk-s3/bucket_lifecycle'
24
+ require_relative 'aws-sdk-s3/bucket_lifecycle_configuration'
25
+ require_relative 'aws-sdk-s3/bucket_logging'
26
+ require_relative 'aws-sdk-s3/bucket_notification'
27
+ require_relative 'aws-sdk-s3/bucket_policy'
28
+ require_relative 'aws-sdk-s3/bucket_request_payment'
29
+ require_relative 'aws-sdk-s3/bucket_tagging'
30
+ require_relative 'aws-sdk-s3/bucket_versioning'
31
+ require_relative 'aws-sdk-s3/bucket_website'
32
+ require_relative 'aws-sdk-s3/multipart_upload'
33
+ require_relative 'aws-sdk-s3/multipart_upload_part'
34
+ require_relative 'aws-sdk-s3/object'
35
+ require_relative 'aws-sdk-s3/object_acl'
36
+ require_relative 'aws-sdk-s3/object_summary'
37
+ require_relative 'aws-sdk-s3/object_version'
38
+ require_relative 'aws-sdk-s3/customizations'
39
+ require_relative 'aws-sdk-s3/event_streams'
40
+
41
+ # This module provides support for Amazon Simple Storage Service. This module is available in the
42
+ # `aws-sdk-s3` gem.
43
+ #
44
+ # # Client
45
+ #
46
+ # The {Client} class provides one method for each API operation. Operation
47
+ # methods each accept a hash of request parameters and return a response
48
+ # structure.
49
+ #
50
+ # s3 = Aws::S3::Client.new
51
+ # resp = s3.abort_multipart_upload(params)
52
+ #
53
+ # See {Client} for more information.
54
+ #
55
+ # # Errors
56
+ #
57
+ # Errors returned from Amazon Simple Storage Service are defined in the
58
+ # {Errors} module and all extend {Errors::ServiceError}.
59
+ #
60
+ # begin
61
+ # # do stuff
62
+ # rescue Aws::S3::Errors::ServiceError
63
+ # # rescues all Amazon Simple Storage Service API errors
64
+ # end
65
+ #
66
+ # See {Errors} for more information.
67
+ #
68
+ # @service
69
+ module Aws::S3
70
+
71
+ GEM_VERSION = '1.75.0'
72
+
73
+ end
@@ -0,0 +1,861 @@
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/master/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::S3
11
+
12
+ class Bucket
13
+
14
+ extend Aws::Deprecations
15
+
16
+ # @overload def initialize(name, options = {})
17
+ # @param [String] name
18
+ # @option options [Client] :client
19
+ # @overload def initialize(options = {})
20
+ # @option options [required, String] :name
21
+ # @option options [Client] :client
22
+ def initialize(*args)
23
+ options = Hash === args.last ? args.pop.dup : {}
24
+ @name = extract_name(args, options)
25
+ @data = options.delete(:data)
26
+ @client = options.delete(:client) || Client.new(options)
27
+ @waiter_block_warned = false
28
+ end
29
+
30
+ # @!group Read-Only Attributes
31
+
32
+ # @return [String]
33
+ def name
34
+ @name
35
+ end
36
+
37
+ # Date the bucket was created.
38
+ # @return [Time]
39
+ def creation_date
40
+ data[:creation_date]
41
+ end
42
+
43
+ # @!endgroup
44
+
45
+ # @return [Client]
46
+ def client
47
+ @client
48
+ end
49
+
50
+ # @raise [NotImplementedError]
51
+ # @api private
52
+ def load
53
+ msg = "#load is not implemented, data only available via enumeration"
54
+ raise NotImplementedError, msg
55
+ end
56
+ alias :reload :load
57
+
58
+ # @raise [NotImplementedError] Raises when {#data_loaded?} is `false`.
59
+ # @return [Types::Bucket]
60
+ # Returns the data for this {Bucket}.
61
+ def data
62
+ load unless @data
63
+ @data
64
+ end
65
+
66
+ # @return [Boolean]
67
+ # Returns `true` if this resource is loaded. Accessing attributes or
68
+ # {#data} on an unloaded resource will trigger a call to {#load}.
69
+ def data_loaded?
70
+ !!@data
71
+ end
72
+
73
+ # @param [Hash] options ({})
74
+ # @return [Boolean]
75
+ # Returns `true` if the Bucket exists.
76
+ def exists?(options = {})
77
+ begin
78
+ wait_until_exists(options.merge(max_attempts: 1))
79
+ true
80
+ rescue Aws::Waiters::Errors::UnexpectedError => e
81
+ raise e.error
82
+ rescue Aws::Waiters::Errors::WaiterFailed
83
+ false
84
+ end
85
+ end
86
+
87
+ # @param [Hash] options ({})
88
+ # @option options [Integer] :max_attempts (20)
89
+ # @option options [Float] :delay (5)
90
+ # @option options [Proc] :before_attempt
91
+ # @option options [Proc] :before_wait
92
+ # @return [Bucket]
93
+ def wait_until_exists(options = {}, &block)
94
+ options, params = separate_params_and_options(options)
95
+ waiter = Waiters::BucketExists.new(options)
96
+ yield_waiter_and_warn(waiter, &block) if block_given?
97
+ waiter.wait(params.merge(bucket: @name))
98
+ Bucket.new({
99
+ name: @name,
100
+ client: @client
101
+ })
102
+ end
103
+
104
+ # @param [Hash] options ({})
105
+ # @option options [Integer] :max_attempts (20)
106
+ # @option options [Float] :delay (5)
107
+ # @option options [Proc] :before_attempt
108
+ # @option options [Proc] :before_wait
109
+ # @return [Bucket]
110
+ def wait_until_not_exists(options = {}, &block)
111
+ options, params = separate_params_and_options(options)
112
+ waiter = Waiters::BucketNotExists.new(options)
113
+ yield_waiter_and_warn(waiter, &block) if block_given?
114
+ waiter.wait(params.merge(bucket: @name))
115
+ Bucket.new({
116
+ name: @name,
117
+ client: @client
118
+ })
119
+ end
120
+
121
+ # @deprecated Use [Aws::S3::Client] #wait_until instead
122
+ #
123
+ # Waiter polls an API operation until a resource enters a desired
124
+ # state.
125
+ #
126
+ # @note The waiting operation is performed on a copy. The original resource
127
+ # remains unchanged.
128
+ #
129
+ # ## Basic Usage
130
+ #
131
+ # Waiter will polls until it is successful, it fails by
132
+ # entering a terminal state, or until a maximum number of attempts
133
+ # are made.
134
+ #
135
+ # # polls in a loop until condition is true
136
+ # resource.wait_until(options) {|resource| condition}
137
+ #
138
+ # ## Example
139
+ #
140
+ # instance.wait_until(max_attempts:10, delay:5) do |instance|
141
+ # instance.state.name == 'running'
142
+ # end
143
+ #
144
+ # ## Configuration
145
+ #
146
+ # You can configure the maximum number of polling attempts, and the
147
+ # delay (in seconds) between each polling attempt. The waiting condition is
148
+ # set by passing a block to {#wait_until}:
149
+ #
150
+ # # poll for ~25 seconds
151
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
152
+ #
153
+ # ## Callbacks
154
+ #
155
+ # You can be notified before each polling attempt and before each
156
+ # delay. If you throw `:success` or `:failure` from these callbacks,
157
+ # it will terminate the waiter.
158
+ #
159
+ # started_at = Time.now
160
+ # # poll for 1 hour, instead of a number of attempts
161
+ # proc = Proc.new do |attempts, response|
162
+ # throw :failure if Time.now - started_at > 3600
163
+ # end
164
+ #
165
+ # # disable max attempts
166
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
167
+ #
168
+ # ## Handling Errors
169
+ #
170
+ # When a waiter is successful, it returns the Resource. When a waiter
171
+ # fails, it raises an error.
172
+ #
173
+ # begin
174
+ # resource.wait_until(...)
175
+ # rescue Aws::Waiters::Errors::WaiterFailed
176
+ # # resource did not enter the desired state in time
177
+ # end
178
+ #
179
+ # @yieldparam [Resource] resource to be used in the waiting condition.
180
+ #
181
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
182
+ # terminates because the waiter has entered a state that it will not
183
+ # transition out of, preventing success.
184
+ #
185
+ # yet successful.
186
+ #
187
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
188
+ # encountered while polling for a resource that is not expected.
189
+ #
190
+ # @raise [NotImplementedError] Raised when the resource does not
191
+ #
192
+ # @option options [Integer] :max_attempts (10) Maximum number of
193
+ # attempts
194
+ # @option options [Integer] :delay (10) Delay between each
195
+ # attempt in seconds
196
+ # @option options [Proc] :before_attempt (nil) Callback
197
+ # invoked before each attempt
198
+ # @option options [Proc] :before_wait (nil) Callback
199
+ # invoked before each wait
200
+ # @return [Resource] if the waiter was successful
201
+ def wait_until(options = {}, &block)
202
+ self_copy = self.dup
203
+ attempts = 0
204
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
205
+ options[:delay] ||= 10
206
+ options[:poller] = Proc.new do
207
+ attempts += 1
208
+ if block.call(self_copy)
209
+ [:success, self_copy]
210
+ else
211
+ self_copy.reload unless attempts == options[:max_attempts]
212
+ :retry
213
+ end
214
+ end
215
+ Aws::Waiters::Waiter.new(options).wait({})
216
+ end
217
+
218
+ # @!group Actions
219
+
220
+ # @example Request syntax with placeholder values
221
+ #
222
+ # bucket.create({
223
+ # acl: "private", # accepts private, public-read, public-read-write, authenticated-read
224
+ # create_bucket_configuration: {
225
+ # 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
226
+ # },
227
+ # grant_full_control: "GrantFullControl",
228
+ # grant_read: "GrantRead",
229
+ # grant_read_acp: "GrantReadACP",
230
+ # grant_write: "GrantWrite",
231
+ # grant_write_acp: "GrantWriteACP",
232
+ # object_lock_enabled_for_bucket: false,
233
+ # })
234
+ # @param [Hash] options ({})
235
+ # @option options [String] :acl
236
+ # The canned ACL to apply to the bucket.
237
+ # @option options [Types::CreateBucketConfiguration] :create_bucket_configuration
238
+ # The configuration information for the bucket.
239
+ # @option options [String] :grant_full_control
240
+ # Allows grantee the read, write, read ACP, and write ACP permissions on
241
+ # the bucket.
242
+ # @option options [String] :grant_read
243
+ # Allows grantee to list the objects in the bucket.
244
+ # @option options [String] :grant_read_acp
245
+ # Allows grantee to read the bucket ACL.
246
+ # @option options [String] :grant_write
247
+ # Allows grantee to create, overwrite, and delete any object in the
248
+ # bucket.
249
+ # @option options [String] :grant_write_acp
250
+ # Allows grantee to write the ACL for the applicable bucket.
251
+ # @option options [Boolean] :object_lock_enabled_for_bucket
252
+ # Specifies whether you want S3 Object Lock to be enabled for the new
253
+ # bucket.
254
+ # @return [Types::CreateBucketOutput]
255
+ def create(options = {})
256
+ options = options.merge(bucket: @name)
257
+ resp = @client.create_bucket(options)
258
+ resp.data
259
+ end
260
+
261
+ # @example Request syntax with placeholder values
262
+ #
263
+ # bucket.delete()
264
+ # @param [Hash] options ({})
265
+ # @return [EmptyStructure]
266
+ def delete(options = {})
267
+ options = options.merge(bucket: @name)
268
+ resp = @client.delete_bucket(options)
269
+ resp.data
270
+ end
271
+
272
+ # @example Request syntax with placeholder values
273
+ #
274
+ # bucket.delete_objects({
275
+ # delete: { # required
276
+ # objects: [ # required
277
+ # {
278
+ # key: "ObjectKey", # required
279
+ # version_id: "ObjectVersionId",
280
+ # },
281
+ # ],
282
+ # quiet: false,
283
+ # },
284
+ # mfa: "MFA",
285
+ # request_payer: "requester", # accepts requester
286
+ # bypass_governance_retention: false,
287
+ # })
288
+ # @param [Hash] options ({})
289
+ # @option options [required, Types::Delete] :delete
290
+ # Container for the request.
291
+ # @option options [String] :mfa
292
+ # The concatenation of the authentication device's serial number, a
293
+ # space, and the value that is displayed on your authentication device.
294
+ # Required to permanently delete a versioned object if versioning is
295
+ # configured with MFA delete enabled.
296
+ # @option options [String] :request_payer
297
+ # Confirms that the requester knows that they will be charged for the
298
+ # request. Bucket owners need not specify this parameter in their
299
+ # requests. For information about downloading objects from requester
300
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
301
+ # in the *Amazon S3 Developer Guide*.
302
+ #
303
+ #
304
+ #
305
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
306
+ # @option options [Boolean] :bypass_governance_retention
307
+ # Specifies whether you want to delete this object even if it has a
308
+ # Governance-type Object Lock in place. You must have sufficient
309
+ # permissions to perform this operation.
310
+ # @return [Types::DeleteObjectsOutput]
311
+ def delete_objects(options = {})
312
+ options = options.merge(bucket: @name)
313
+ resp = @client.delete_objects(options)
314
+ resp.data
315
+ end
316
+
317
+ # @example Request syntax with placeholder values
318
+ #
319
+ # object = bucket.put_object({
320
+ # acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
321
+ # body: source_file,
322
+ # cache_control: "CacheControl",
323
+ # content_disposition: "ContentDisposition",
324
+ # content_encoding: "ContentEncoding",
325
+ # content_language: "ContentLanguage",
326
+ # content_length: 1,
327
+ # content_md5: "ContentMD5",
328
+ # content_type: "ContentType",
329
+ # expires: Time.now,
330
+ # grant_full_control: "GrantFullControl",
331
+ # grant_read: "GrantRead",
332
+ # grant_read_acp: "GrantReadACP",
333
+ # grant_write_acp: "GrantWriteACP",
334
+ # key: "ObjectKey", # required
335
+ # metadata: {
336
+ # "MetadataKey" => "MetadataValue",
337
+ # },
338
+ # server_side_encryption: "AES256", # accepts AES256, aws:kms
339
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE
340
+ # website_redirect_location: "WebsiteRedirectLocation",
341
+ # sse_customer_algorithm: "SSECustomerAlgorithm",
342
+ # sse_customer_key: "SSECustomerKey",
343
+ # sse_customer_key_md5: "SSECustomerKeyMD5",
344
+ # ssekms_key_id: "SSEKMSKeyId",
345
+ # ssekms_encryption_context: "SSEKMSEncryptionContext",
346
+ # request_payer: "requester", # accepts requester
347
+ # tagging: "TaggingHeader",
348
+ # object_lock_mode: "GOVERNANCE", # accepts GOVERNANCE, COMPLIANCE
349
+ # object_lock_retain_until_date: Time.now,
350
+ # object_lock_legal_hold_status: "ON", # accepts ON, OFF
351
+ # })
352
+ # @param [Hash] options ({})
353
+ # @option options [String] :acl
354
+ # The canned ACL to apply to the object. For more information, see
355
+ # [Canned ACL][1].
356
+ #
357
+ #
358
+ #
359
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL
360
+ # @option options [String, IO] :body
361
+ # Object data.
362
+ # @option options [String] :cache_control
363
+ # Can be used to specify caching behavior along the request/reply chain.
364
+ # For more information, see
365
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9][1].
366
+ #
367
+ #
368
+ #
369
+ # [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
370
+ # @option options [String] :content_disposition
371
+ # Specifies presentational information for the object. For more
372
+ # information, see
373
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1][1].
374
+ #
375
+ #
376
+ #
377
+ # [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
378
+ # @option options [String] :content_encoding
379
+ # Specifies what content encodings have been applied to the object and
380
+ # thus what decoding mechanisms must be applied to obtain the media-type
381
+ # referenced by the Content-Type header field. For more information, see
382
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11][1].
383
+ #
384
+ #
385
+ #
386
+ # [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
387
+ # @option options [String] :content_language
388
+ # The language the content is in.
389
+ # @option options [Integer] :content_length
390
+ # Size of the body in bytes. This parameter is useful when the size of
391
+ # the body cannot be determined automatically. For more information, see
392
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13][1].
393
+ #
394
+ #
395
+ #
396
+ # [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13
397
+ # @option options [String] :content_md5
398
+ # The base64-encoded 128-bit MD5 digest of the message (without the
399
+ # headers) according to RFC 1864. This header can be used as a message
400
+ # integrity check to verify that the data is the same data that was
401
+ # originally sent. Although it is optional, we recommend using the
402
+ # Content-MD5 mechanism as an end-to-end integrity check. For more
403
+ # information about REST request authentication, see [REST
404
+ # Authentication][1].
405
+ #
406
+ #
407
+ #
408
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
409
+ # @option options [String] :content_type
410
+ # A standard MIME type describing the format of the contents. For more
411
+ # information, see
412
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17][1].
413
+ #
414
+ #
415
+ #
416
+ # [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
417
+ # @option options [Time,DateTime,Date,Integer,String] :expires
418
+ # The date and time at which the object is no longer cacheable. For more
419
+ # information, see
420
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21][1].
421
+ #
422
+ #
423
+ #
424
+ # [1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21
425
+ # @option options [String] :grant_full_control
426
+ # Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
427
+ # object.
428
+ # @option options [String] :grant_read
429
+ # Allows grantee to read the object data and its metadata.
430
+ # @option options [String] :grant_read_acp
431
+ # Allows grantee to read the object ACL.
432
+ # @option options [String] :grant_write_acp
433
+ # Allows grantee to write the ACL for the applicable object.
434
+ # @option options [required, String] :key
435
+ # Object key for which the PUT operation was initiated.
436
+ # @option options [Hash<String,String>] :metadata
437
+ # A map of metadata to store with the object in S3.
438
+ # @option options [String] :server_side_encryption
439
+ # The server-side encryption algorithm used when storing this object in
440
+ # Amazon S3 (for example, AES256, aws:kms).
441
+ # @option options [String] :storage_class
442
+ # If you don't specify, S3 Standard is the default storage class.
443
+ # Amazon S3 supports other storage classes.
444
+ # @option options [String] :website_redirect_location
445
+ # If the bucket is configured as a website, redirects requests for this
446
+ # object to another object in the same bucket or to an external URL.
447
+ # Amazon S3 stores the value of this header in the object metadata. For
448
+ # information about object metadata, see [Object Key and Metadata][1].
449
+ #
450
+ # In the following example, the request header sets the redirect to an
451
+ # object (anotherPage.html) in the same bucket:
452
+ #
453
+ # `x-amz-website-redirect-location: /anotherPage.html`
454
+ #
455
+ # In the following example, the request header sets the object redirect
456
+ # to another website:
457
+ #
458
+ # `x-amz-website-redirect-location: http://www.example.com/`
459
+ #
460
+ # For more information about website hosting in Amazon S3, see [Hosting
461
+ # Websites on Amazon S3][2] and [How to Configure Website Page
462
+ # Redirects][3].
463
+ #
464
+ #
465
+ #
466
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
467
+ # [2]: https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html
468
+ # [3]: https://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
469
+ # @option options [String] :sse_customer_algorithm
470
+ # Specifies the algorithm to use to when encrypting the object (for
471
+ # example, AES256).
472
+ # @option options [String] :sse_customer_key
473
+ # Specifies the customer-provided encryption key for Amazon S3 to use in
474
+ # encrypting data. This value is used to store the object and then it is
475
+ # discarded; Amazon S3 does not store the encryption key. The key must
476
+ # be appropriate for use with the algorithm specified in the
477
+ # `x-amz-server-side​-encryption​-customer-algorithm` header.
478
+ # @option options [String] :sse_customer_key_md5
479
+ # Specifies the 128-bit MD5 digest of the encryption key according to
480
+ # RFC 1321. Amazon S3 uses this header for a message integrity check to
481
+ # ensure that the encryption key was transmitted without error.
482
+ # @option options [String] :ssekms_key_id
483
+ # If `x-amz-server-side-encryption` is present and has the value of
484
+ # `aws:kms`, this header specifies the ID of the AWS Key Management
485
+ # Service (AWS KMS) symmetrical customer managed customer master key
486
+ # (CMK) that was used for the object.
487
+ #
488
+ # If the value of `x-amz-server-side-encryption` is `aws:kms`, this
489
+ # header specifies the ID of the symmetric customer managed AWS KMS CMK
490
+ # that will be used for the object. If you specify
491
+ # `x-amz-server-side-encryption:aws:kms`, but do not provide`
492
+ # x-amz-server-side-encryption-aws-kms-key-id`, Amazon S3 uses the AWS
493
+ # managed CMK in AWS to protect the data.
494
+ # @option options [String] :ssekms_encryption_context
495
+ # Specifies the AWS KMS Encryption Context to use for object encryption.
496
+ # The value of this header is a base64-encoded UTF-8 string holding JSON
497
+ # with the encryption context key-value pairs.
498
+ # @option options [String] :request_payer
499
+ # Confirms that the requester knows that they will be charged for the
500
+ # request. Bucket owners need not specify this parameter in their
501
+ # requests. For information about downloading objects from requester
502
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
503
+ # in the *Amazon S3 Developer Guide*.
504
+ #
505
+ #
506
+ #
507
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
508
+ # @option options [String] :tagging
509
+ # The tag-set for the object. The tag-set must be encoded as URL Query
510
+ # parameters. (For example, "Key1=Value1")
511
+ # @option options [String] :object_lock_mode
512
+ # The Object Lock mode that you want to apply to this object.
513
+ # @option options [Time,DateTime,Date,Integer,String] :object_lock_retain_until_date
514
+ # The date and time when you want this object's Object Lock to expire.
515
+ # @option options [String] :object_lock_legal_hold_status
516
+ # Specifies whether a legal hold will be applied to this object. For
517
+ # more information about S3 Object Lock, see [Object Lock][1].
518
+ #
519
+ #
520
+ #
521
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock.html
522
+ # @return [Object]
523
+ def put_object(options = {})
524
+ options = options.merge(bucket: @name)
525
+ @client.put_object(options)
526
+ Object.new(
527
+ bucket_name: @name,
528
+ key: options[:key],
529
+ client: @client
530
+ )
531
+ end
532
+
533
+ # @!group Associations
534
+
535
+ # @return [BucketAcl]
536
+ def acl
537
+ BucketAcl.new(
538
+ bucket_name: @name,
539
+ client: @client
540
+ )
541
+ end
542
+
543
+ # @return [BucketCors]
544
+ def cors
545
+ BucketCors.new(
546
+ bucket_name: @name,
547
+ client: @client
548
+ )
549
+ end
550
+
551
+ # @return [BucketLifecycle]
552
+ def lifecycle
553
+ BucketLifecycle.new(
554
+ bucket_name: @name,
555
+ client: @client
556
+ )
557
+ end
558
+
559
+ # @return [BucketLifecycleConfiguration]
560
+ def lifecycle_configuration
561
+ BucketLifecycleConfiguration.new(
562
+ bucket_name: @name,
563
+ client: @client
564
+ )
565
+ end
566
+
567
+ # @return [BucketLogging]
568
+ def logging
569
+ BucketLogging.new(
570
+ bucket_name: @name,
571
+ client: @client
572
+ )
573
+ end
574
+
575
+ # @example Request syntax with placeholder values
576
+ #
577
+ # multipart_uploads = bucket.multipart_uploads({
578
+ # delimiter: "Delimiter",
579
+ # encoding_type: "url", # accepts url
580
+ # key_marker: "KeyMarker",
581
+ # prefix: "Prefix",
582
+ # upload_id_marker: "UploadIdMarker",
583
+ # })
584
+ # @param [Hash] options ({})
585
+ # @option options [String] :delimiter
586
+ # Character you use to group keys.
587
+ #
588
+ # All keys that contain the same string between the prefix, if
589
+ # specified, and the first occurrence of the delimiter after the prefix
590
+ # are grouped under a single result element, `CommonPrefixes`. If you
591
+ # don't specify the prefix parameter, then the substring starts at the
592
+ # beginning of the key. The keys that are grouped under `CommonPrefixes`
593
+ # result element are not returned elsewhere in the response.
594
+ # @option options [String] :encoding_type
595
+ # Requests Amazon S3 to encode the object keys in the response and
596
+ # specifies the encoding method to use. An object key may contain any
597
+ # Unicode character; however, XML 1.0 parser cannot parse some
598
+ # characters, such as characters with an ASCII value from 0 to 10. For
599
+ # characters that are not supported in XML 1.0, you can add this
600
+ # parameter to request that Amazon S3 encode the keys in the response.
601
+ # @option options [String] :key_marker
602
+ # Together with upload-id-marker, this parameter specifies the multipart
603
+ # upload after which listing should begin.
604
+ #
605
+ # If `upload-id-marker` is not specified, only the keys
606
+ # lexicographically greater than the specified `key-marker` will be
607
+ # included in the list.
608
+ #
609
+ # If `upload-id-marker` is specified, any multipart uploads for a key
610
+ # equal to the `key-marker` might also be included, provided those
611
+ # multipart uploads have upload IDs lexicographically greater than the
612
+ # specified `upload-id-marker`.
613
+ # @option options [String] :prefix
614
+ # Lists in-progress uploads only for those keys that begin with the
615
+ # specified prefix. You can use prefixes to separate a bucket into
616
+ # different grouping of keys. (You can think of using prefix to make
617
+ # groups in the same way you'd use a folder in a file system.)
618
+ # @option options [String] :upload_id_marker
619
+ # Together with key-marker, specifies the multipart upload after which
620
+ # listing should begin. If key-marker is not specified, the
621
+ # upload-id-marker parameter is ignored. Otherwise, any multipart
622
+ # uploads for a key equal to the key-marker might be included in the
623
+ # list only if they have an upload ID lexicographically greater than the
624
+ # specified `upload-id-marker`.
625
+ # @return [MultipartUpload::Collection]
626
+ def multipart_uploads(options = {})
627
+ batches = Enumerator.new do |y|
628
+ options = options.merge(bucket: @name)
629
+ resp = @client.list_multipart_uploads(options)
630
+ resp.each_page do |page|
631
+ batch = []
632
+ page.data.uploads.each do |u|
633
+ batch << MultipartUpload.new(
634
+ bucket_name: @name,
635
+ object_key: u.key,
636
+ id: u.upload_id,
637
+ data: u,
638
+ client: @client
639
+ )
640
+ end
641
+ y.yield(batch)
642
+ end
643
+ end
644
+ MultipartUpload::Collection.new(batches)
645
+ end
646
+
647
+ # @return [BucketNotification]
648
+ def notification
649
+ BucketNotification.new(
650
+ bucket_name: @name,
651
+ client: @client
652
+ )
653
+ end
654
+
655
+ # @param [String] key
656
+ # @return [Object]
657
+ def object(key)
658
+ Object.new(
659
+ bucket_name: @name,
660
+ key: key,
661
+ client: @client
662
+ )
663
+ end
664
+
665
+ # @example Request syntax with placeholder values
666
+ #
667
+ # object_versions = bucket.object_versions({
668
+ # delimiter: "Delimiter",
669
+ # encoding_type: "url", # accepts url
670
+ # key_marker: "KeyMarker",
671
+ # prefix: "Prefix",
672
+ # version_id_marker: "VersionIdMarker",
673
+ # })
674
+ # @param [Hash] options ({})
675
+ # @option options [String] :delimiter
676
+ # A delimiter is a character that you specify to group keys. All keys
677
+ # that contain the same string between the `prefix` and the first
678
+ # occurrence of the delimiter are grouped under a single result element
679
+ # in CommonPrefixes. These groups are counted as one result against the
680
+ # max-keys limitation. These keys are not returned elsewhere in the
681
+ # response.
682
+ # @option options [String] :encoding_type
683
+ # Requests Amazon S3 to encode the object keys in the response and
684
+ # specifies the encoding method to use. An object key may contain any
685
+ # Unicode character; however, XML 1.0 parser cannot parse some
686
+ # characters, such as characters with an ASCII value from 0 to 10. For
687
+ # characters that are not supported in XML 1.0, you can add this
688
+ # parameter to request that Amazon S3 encode the keys in the response.
689
+ # @option options [String] :key_marker
690
+ # Specifies the key to start with when listing objects in a bucket.
691
+ # @option options [String] :prefix
692
+ # Use this parameter to select only those keys that begin with the
693
+ # specified prefix. You can use prefixes to separate a bucket into
694
+ # different groupings of keys. (You can think of using prefix to make
695
+ # groups in the same way you'd use a folder in a file system.) You can
696
+ # use prefix with delimiter to roll up numerous objects into a single
697
+ # result under CommonPrefixes.
698
+ # @option options [String] :version_id_marker
699
+ # Specifies the object version you want to start listing from.
700
+ # @return [ObjectVersion::Collection]
701
+ def object_versions(options = {})
702
+ batches = Enumerator.new do |y|
703
+ options = options.merge(bucket: @name)
704
+ resp = @client.list_object_versions(options)
705
+ resp.each_page do |page|
706
+ batch = []
707
+ page.data.versions_delete_markers.each do |v|
708
+ batch << ObjectVersion.new(
709
+ bucket_name: @name,
710
+ object_key: v.key,
711
+ id: v.version_id,
712
+ data: v,
713
+ client: @client
714
+ )
715
+ end
716
+ y.yield(batch)
717
+ end
718
+ end
719
+ ObjectVersion::Collection.new(batches)
720
+ end
721
+
722
+ # @example Request syntax with placeholder values
723
+ #
724
+ # objects = bucket.objects({
725
+ # delimiter: "Delimiter",
726
+ # encoding_type: "url", # accepts url
727
+ # prefix: "Prefix",
728
+ # fetch_owner: false,
729
+ # start_after: "StartAfter",
730
+ # request_payer: "requester", # accepts requester
731
+ # })
732
+ # @param [Hash] options ({})
733
+ # @option options [String] :delimiter
734
+ # A delimiter is a character you use to group keys.
735
+ # @option options [String] :encoding_type
736
+ # Encoding type used by Amazon S3 to encode object keys in the response.
737
+ # @option options [String] :prefix
738
+ # Limits the response to keys that begin with the specified prefix.
739
+ # @option options [Boolean] :fetch_owner
740
+ # The owner field is not present in listV2 by default, if you want to
741
+ # return owner field with each key in the result then set the fetch
742
+ # owner field to true.
743
+ # @option options [String] :start_after
744
+ # StartAfter is where you want Amazon S3 to start listing from. Amazon
745
+ # S3 starts listing after this specified key. StartAfter can be any key
746
+ # in the bucket.
747
+ # @option options [String] :request_payer
748
+ # Confirms that the requester knows that she or he will be charged for
749
+ # the list objects request in V2 style. Bucket owners need not specify
750
+ # this parameter in their requests.
751
+ # @return [ObjectSummary::Collection]
752
+ def objects(options = {})
753
+ batches = Enumerator.new do |y|
754
+ options = options.merge(bucket: @name)
755
+ resp = @client.list_objects_v2(options)
756
+ resp.each_page do |page|
757
+ batch = []
758
+ page.data.contents.each do |c|
759
+ batch << ObjectSummary.new(
760
+ bucket_name: @name,
761
+ key: c.key,
762
+ data: c,
763
+ client: @client
764
+ )
765
+ end
766
+ y.yield(batch)
767
+ end
768
+ end
769
+ ObjectSummary::Collection.new(batches)
770
+ end
771
+
772
+ # @return [BucketPolicy]
773
+ def policy
774
+ BucketPolicy.new(
775
+ bucket_name: @name,
776
+ client: @client
777
+ )
778
+ end
779
+
780
+ # @return [BucketRequestPayment]
781
+ def request_payment
782
+ BucketRequestPayment.new(
783
+ bucket_name: @name,
784
+ client: @client
785
+ )
786
+ end
787
+
788
+ # @return [BucketTagging]
789
+ def tagging
790
+ BucketTagging.new(
791
+ bucket_name: @name,
792
+ client: @client
793
+ )
794
+ end
795
+
796
+ # @return [BucketVersioning]
797
+ def versioning
798
+ BucketVersioning.new(
799
+ bucket_name: @name,
800
+ client: @client
801
+ )
802
+ end
803
+
804
+ # @return [BucketWebsite]
805
+ def website
806
+ BucketWebsite.new(
807
+ bucket_name: @name,
808
+ client: @client
809
+ )
810
+ end
811
+
812
+ # @deprecated
813
+ # @api private
814
+ def identifiers
815
+ { name: @name }
816
+ end
817
+ deprecated(:identifiers)
818
+
819
+ private
820
+
821
+ def extract_name(args, options)
822
+ value = args[0] || options.delete(:name)
823
+ case value
824
+ when String then value
825
+ when nil then raise ArgumentError, "missing required option :name"
826
+ else
827
+ msg = "expected :name to be a String, got #{value.class}"
828
+ raise ArgumentError, msg
829
+ end
830
+ end
831
+
832
+ def yield_waiter_and_warn(waiter, &block)
833
+ if !@waiter_block_warned
834
+ msg = "pass options to configure the waiter; "\
835
+ "yielding the waiter is deprecated"
836
+ warn(msg)
837
+ @waiter_block_warned = true
838
+ end
839
+ yield(waiter.waiter)
840
+ end
841
+
842
+ def separate_params_and_options(options)
843
+ opts = Set.new(
844
+ [:client, :max_attempts, :delay, :before_attempt, :before_wait]
845
+ )
846
+ waiter_opts = {}
847
+ waiter_params = {}
848
+ options.each_pair do |key, value|
849
+ if opts.include?(key)
850
+ waiter_opts[key] = value
851
+ else
852
+ waiter_params[key] = value
853
+ end
854
+ end
855
+ waiter_opts[:client] ||= @client
856
+ [waiter_opts, waiter_params]
857
+ end
858
+
859
+ class Collection < Aws::Resources::Collection; end
860
+ end
861
+ end