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,550 @@
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 ObjectVersion
13
+
14
+ extend Aws::Deprecations
15
+
16
+ # @overload def initialize(bucket_name, object_key, id, options = {})
17
+ # @param [String] bucket_name
18
+ # @param [String] object_key
19
+ # @param [String] id
20
+ # @option options [Client] :client
21
+ # @overload def initialize(options = {})
22
+ # @option options [required, String] :bucket_name
23
+ # @option options [required, String] :object_key
24
+ # @option options [required, String] :id
25
+ # @option options [Client] :client
26
+ def initialize(*args)
27
+ options = Hash === args.last ? args.pop.dup : {}
28
+ @bucket_name = extract_bucket_name(args, options)
29
+ @object_key = extract_object_key(args, options)
30
+ @id = extract_id(args, options)
31
+ @data = options.delete(:data)
32
+ @client = options.delete(:client) || Client.new(options)
33
+ @waiter_block_warned = false
34
+ end
35
+
36
+ # @!group Read-Only Attributes
37
+
38
+ # @return [String]
39
+ def bucket_name
40
+ @bucket_name
41
+ end
42
+
43
+ # @return [String]
44
+ def object_key
45
+ @object_key
46
+ end
47
+
48
+ # @return [String]
49
+ def id
50
+ @id
51
+ end
52
+
53
+ # The entity tag is an MD5 hash of that version of the object.
54
+ # @return [String]
55
+ def etag
56
+ data[:etag]
57
+ end
58
+
59
+ # Size in bytes of the object.
60
+ # @return [Integer]
61
+ def size
62
+ data[:size]
63
+ end
64
+
65
+ # The class of storage used to store the object.
66
+ # @return [String]
67
+ def storage_class
68
+ data[:storage_class]
69
+ end
70
+
71
+ # The object key.
72
+ # @return [String]
73
+ def key
74
+ data[:key]
75
+ end
76
+
77
+ # Version ID of an object.
78
+ # @return [String]
79
+ def version_id
80
+ data[:version_id]
81
+ end
82
+
83
+ # Specifies whether the object is (true) or is not (false) the latest
84
+ # version of an object.
85
+ # @return [Boolean]
86
+ def is_latest
87
+ data[:is_latest]
88
+ end
89
+
90
+ # Date and time the object was last modified.
91
+ # @return [Time]
92
+ def last_modified
93
+ data[:last_modified]
94
+ end
95
+
96
+ # Specifies the owner of the object.
97
+ # @return [Types::Owner]
98
+ def owner
99
+ data[:owner]
100
+ end
101
+
102
+ # @!endgroup
103
+
104
+ # @return [Client]
105
+ def client
106
+ @client
107
+ end
108
+
109
+ # @raise [NotImplementedError]
110
+ # @api private
111
+ def load
112
+ msg = "#load is not implemented, data only available via enumeration"
113
+ raise NotImplementedError, msg
114
+ end
115
+ alias :reload :load
116
+
117
+ # @raise [NotImplementedError] Raises when {#data_loaded?} is `false`.
118
+ # @return [Types::ObjectVersion]
119
+ # Returns the data for this {ObjectVersion}.
120
+ def data
121
+ load unless @data
122
+ @data
123
+ end
124
+
125
+ # @return [Boolean]
126
+ # Returns `true` if this resource is loaded. Accessing attributes or
127
+ # {#data} on an unloaded resource will trigger a call to {#load}.
128
+ def data_loaded?
129
+ !!@data
130
+ end
131
+
132
+ # @deprecated Use [Aws::S3::Client] #wait_until instead
133
+ #
134
+ # Waiter polls an API operation until a resource enters a desired
135
+ # state.
136
+ #
137
+ # @note The waiting operation is performed on a copy. The original resource
138
+ # remains unchanged.
139
+ #
140
+ # ## Basic Usage
141
+ #
142
+ # Waiter will polls until it is successful, it fails by
143
+ # entering a terminal state, or until a maximum number of attempts
144
+ # are made.
145
+ #
146
+ # # polls in a loop until condition is true
147
+ # resource.wait_until(options) {|resource| condition}
148
+ #
149
+ # ## Example
150
+ #
151
+ # instance.wait_until(max_attempts:10, delay:5) do |instance|
152
+ # instance.state.name == 'running'
153
+ # end
154
+ #
155
+ # ## Configuration
156
+ #
157
+ # You can configure the maximum number of polling attempts, and the
158
+ # delay (in seconds) between each polling attempt. The waiting condition is
159
+ # set by passing a block to {#wait_until}:
160
+ #
161
+ # # poll for ~25 seconds
162
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
163
+ #
164
+ # ## Callbacks
165
+ #
166
+ # You can be notified before each polling attempt and before each
167
+ # delay. If you throw `:success` or `:failure` from these callbacks,
168
+ # it will terminate the waiter.
169
+ #
170
+ # started_at = Time.now
171
+ # # poll for 1 hour, instead of a number of attempts
172
+ # proc = Proc.new do |attempts, response|
173
+ # throw :failure if Time.now - started_at > 3600
174
+ # end
175
+ #
176
+ # # disable max attempts
177
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
178
+ #
179
+ # ## Handling Errors
180
+ #
181
+ # When a waiter is successful, it returns the Resource. When a waiter
182
+ # fails, it raises an error.
183
+ #
184
+ # begin
185
+ # resource.wait_until(...)
186
+ # rescue Aws::Waiters::Errors::WaiterFailed
187
+ # # resource did not enter the desired state in time
188
+ # end
189
+ #
190
+ # @yieldparam [Resource] resource to be used in the waiting condition.
191
+ #
192
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
193
+ # terminates because the waiter has entered a state that it will not
194
+ # transition out of, preventing success.
195
+ #
196
+ # yet successful.
197
+ #
198
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
199
+ # encountered while polling for a resource that is not expected.
200
+ #
201
+ # @raise [NotImplementedError] Raised when the resource does not
202
+ #
203
+ # @option options [Integer] :max_attempts (10) Maximum number of
204
+ # attempts
205
+ # @option options [Integer] :delay (10) Delay between each
206
+ # attempt in seconds
207
+ # @option options [Proc] :before_attempt (nil) Callback
208
+ # invoked before each attempt
209
+ # @option options [Proc] :before_wait (nil) Callback
210
+ # invoked before each wait
211
+ # @return [Resource] if the waiter was successful
212
+ def wait_until(options = {}, &block)
213
+ self_copy = self.dup
214
+ attempts = 0
215
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
216
+ options[:delay] ||= 10
217
+ options[:poller] = Proc.new do
218
+ attempts += 1
219
+ if block.call(self_copy)
220
+ [:success, self_copy]
221
+ else
222
+ self_copy.reload unless attempts == options[:max_attempts]
223
+ :retry
224
+ end
225
+ end
226
+ Aws::Waiters::Waiter.new(options).wait({})
227
+ end
228
+
229
+ # @!group Actions
230
+
231
+ # @example Request syntax with placeholder values
232
+ #
233
+ # object_version.delete({
234
+ # mfa: "MFA",
235
+ # request_payer: "requester", # accepts requester
236
+ # bypass_governance_retention: false,
237
+ # })
238
+ # @param [Hash] options ({})
239
+ # @option options [String] :mfa
240
+ # The concatenation of the authentication device's serial number, a
241
+ # space, and the value that is displayed on your authentication device.
242
+ # Required to permanently delete a versioned object if versioning is
243
+ # configured with MFA delete enabled.
244
+ # @option options [String] :request_payer
245
+ # Confirms that the requester knows that they will be charged for the
246
+ # request. Bucket owners need not specify this parameter in their
247
+ # requests. For information about downloading objects from requester
248
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
249
+ # in the *Amazon S3 Developer Guide*.
250
+ #
251
+ #
252
+ #
253
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
254
+ # @option options [Boolean] :bypass_governance_retention
255
+ # Indicates whether S3 Object Lock should bypass Governance-mode
256
+ # restrictions to process this operation.
257
+ # @return [Types::DeleteObjectOutput]
258
+ def delete(options = {})
259
+ options = options.merge(
260
+ bucket: @bucket_name,
261
+ key: @object_key,
262
+ version_id: @id
263
+ )
264
+ resp = @client.delete_object(options)
265
+ resp.data
266
+ end
267
+
268
+ # @example Request syntax with placeholder values
269
+ #
270
+ # object_version.get({
271
+ # if_match: "IfMatch",
272
+ # if_modified_since: Time.now,
273
+ # if_none_match: "IfNoneMatch",
274
+ # if_unmodified_since: Time.now,
275
+ # range: "Range",
276
+ # response_cache_control: "ResponseCacheControl",
277
+ # response_content_disposition: "ResponseContentDisposition",
278
+ # response_content_encoding: "ResponseContentEncoding",
279
+ # response_content_language: "ResponseContentLanguage",
280
+ # response_content_type: "ResponseContentType",
281
+ # response_expires: Time.now,
282
+ # sse_customer_algorithm: "SSECustomerAlgorithm",
283
+ # sse_customer_key: "SSECustomerKey",
284
+ # sse_customer_key_md5: "SSECustomerKeyMD5",
285
+ # request_payer: "requester", # accepts requester
286
+ # part_number: 1,
287
+ # })
288
+ # @param [Hash] options ({})
289
+ # @option options [String] :if_match
290
+ # Return the object only if its entity tag (ETag) is the same as the one
291
+ # specified, otherwise return a 412 (precondition failed).
292
+ # @option options [Time,DateTime,Date,Integer,String] :if_modified_since
293
+ # Return the object only if it has been modified since the specified
294
+ # time, otherwise return a 304 (not modified).
295
+ # @option options [String] :if_none_match
296
+ # Return the object only if its entity tag (ETag) is different from the
297
+ # one specified, otherwise return a 304 (not modified).
298
+ # @option options [Time,DateTime,Date,Integer,String] :if_unmodified_since
299
+ # Return the object only if it has not been modified since the specified
300
+ # time, otherwise return a 412 (precondition failed).
301
+ # @option options [String] :range
302
+ # Downloads the specified range bytes of an object. For more information
303
+ # about the HTTP Range header, see
304
+ # [https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35][1].
305
+ #
306
+ # <note markdown="1"> Amazon S3 doesn't support retrieving multiple ranges of data per
307
+ # `GET` request.
308
+ #
309
+ # </note>
310
+ #
311
+ #
312
+ #
313
+ # [1]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35
314
+ # @option options [String] :response_cache_control
315
+ # Sets the `Cache-Control` header of the response.
316
+ # @option options [String] :response_content_disposition
317
+ # Sets the `Content-Disposition` header of the response
318
+ # @option options [String] :response_content_encoding
319
+ # Sets the `Content-Encoding` header of the response.
320
+ # @option options [String] :response_content_language
321
+ # Sets the `Content-Language` header of the response.
322
+ # @option options [String] :response_content_type
323
+ # Sets the `Content-Type` header of the response.
324
+ # @option options [Time,DateTime,Date,Integer,String] :response_expires
325
+ # Sets the `Expires` header of the response.
326
+ # @option options [String] :sse_customer_algorithm
327
+ # Specifies the algorithm to use to when encrypting the object (for
328
+ # example, AES256).
329
+ # @option options [String] :sse_customer_key
330
+ # Specifies the customer-provided encryption key for Amazon S3 to use in
331
+ # encrypting data. This value is used to store the object and then it is
332
+ # discarded; Amazon S3 does not store the encryption key. The key must
333
+ # be appropriate for use with the algorithm specified in the
334
+ # `x-amz-server-side​-encryption​-customer-algorithm` header.
335
+ # @option options [String] :sse_customer_key_md5
336
+ # Specifies the 128-bit MD5 digest of the encryption key according to
337
+ # RFC 1321. Amazon S3 uses this header for a message integrity check to
338
+ # ensure that the encryption key was transmitted without error.
339
+ # @option options [String] :request_payer
340
+ # Confirms that the requester knows that they will be charged for the
341
+ # request. Bucket owners need not specify this parameter in their
342
+ # requests. For information about downloading objects from requester
343
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
344
+ # in the *Amazon S3 Developer Guide*.
345
+ #
346
+ #
347
+ #
348
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
349
+ # @option options [Integer] :part_number
350
+ # Part number of the object being read. This is a positive integer
351
+ # between 1 and 10,000. Effectively performs a 'ranged' GET request
352
+ # for the part specified. Useful for downloading just a part of an
353
+ # object.
354
+ # @return [Types::GetObjectOutput]
355
+ def get(options = {}, &block)
356
+ options = options.merge(
357
+ bucket: @bucket_name,
358
+ key: @object_key,
359
+ version_id: @id
360
+ )
361
+ resp = @client.get_object(options, &block)
362
+ resp.data
363
+ end
364
+
365
+ # @example Request syntax with placeholder values
366
+ #
367
+ # object_version.head({
368
+ # if_match: "IfMatch",
369
+ # if_modified_since: Time.now,
370
+ # if_none_match: "IfNoneMatch",
371
+ # if_unmodified_since: Time.now,
372
+ # range: "Range",
373
+ # sse_customer_algorithm: "SSECustomerAlgorithm",
374
+ # sse_customer_key: "SSECustomerKey",
375
+ # sse_customer_key_md5: "SSECustomerKeyMD5",
376
+ # request_payer: "requester", # accepts requester
377
+ # part_number: 1,
378
+ # })
379
+ # @param [Hash] options ({})
380
+ # @option options [String] :if_match
381
+ # Return the object only if its entity tag (ETag) is the same as the one
382
+ # specified, otherwise return a 412 (precondition failed).
383
+ # @option options [Time,DateTime,Date,Integer,String] :if_modified_since
384
+ # Return the object only if it has been modified since the specified
385
+ # time, otherwise return a 304 (not modified).
386
+ # @option options [String] :if_none_match
387
+ # Return the object only if its entity tag (ETag) is different from the
388
+ # one specified, otherwise return a 304 (not modified).
389
+ # @option options [Time,DateTime,Date,Integer,String] :if_unmodified_since
390
+ # Return the object only if it has not been modified since the specified
391
+ # time, otherwise return a 412 (precondition failed).
392
+ # @option options [String] :range
393
+ # Downloads the specified range bytes of an object. For more information
394
+ # about the HTTP Range header, see
395
+ # [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35]().
396
+ #
397
+ # <note markdown="1"> Amazon S3 doesn't support retrieving multiple ranges of data per
398
+ # `GET` request.
399
+ #
400
+ # </note>
401
+ # @option options [String] :sse_customer_algorithm
402
+ # Specifies the algorithm to use to when encrypting the object (for
403
+ # example, AES256).
404
+ # @option options [String] :sse_customer_key
405
+ # Specifies the customer-provided encryption key for Amazon S3 to use in
406
+ # encrypting data. This value is used to store the object and then it is
407
+ # discarded; Amazon S3 does not store the encryption key. The key must
408
+ # be appropriate for use with the algorithm specified in the
409
+ # `x-amz-server-side​-encryption​-customer-algorithm` header.
410
+ # @option options [String] :sse_customer_key_md5
411
+ # Specifies the 128-bit MD5 digest of the encryption key according to
412
+ # RFC 1321. Amazon S3 uses this header for a message integrity check to
413
+ # ensure that the encryption key was transmitted without error.
414
+ # @option options [String] :request_payer
415
+ # Confirms that the requester knows that they will be charged for the
416
+ # request. Bucket owners need not specify this parameter in their
417
+ # requests. For information about downloading objects from requester
418
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
419
+ # in the *Amazon S3 Developer Guide*.
420
+ #
421
+ #
422
+ #
423
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
424
+ # @option options [Integer] :part_number
425
+ # Part number of the object being read. This is a positive integer
426
+ # between 1 and 10,000. Effectively performs a 'ranged' HEAD request
427
+ # for the part specified. Useful querying about the size of the part and
428
+ # the number of parts in this object.
429
+ # @return [Types::HeadObjectOutput]
430
+ def head(options = {})
431
+ options = options.merge(
432
+ bucket: @bucket_name,
433
+ key: @object_key,
434
+ version_id: @id
435
+ )
436
+ resp = @client.head_object(options)
437
+ resp.data
438
+ end
439
+
440
+ # @!group Associations
441
+
442
+ # @return [Object]
443
+ def object
444
+ Object.new(
445
+ bucket_name: @bucket_name,
446
+ key: @object_key,
447
+ client: @client
448
+ )
449
+ end
450
+
451
+ # @deprecated
452
+ # @api private
453
+ def identifiers
454
+ {
455
+ bucket_name: @bucket_name,
456
+ object_key: @object_key,
457
+ id: @id
458
+ }
459
+ end
460
+ deprecated(:identifiers)
461
+
462
+ private
463
+
464
+ def extract_bucket_name(args, options)
465
+ value = args[0] || options.delete(:bucket_name)
466
+ case value
467
+ when String then value
468
+ when nil then raise ArgumentError, "missing required option :bucket_name"
469
+ else
470
+ msg = "expected :bucket_name to be a String, got #{value.class}"
471
+ raise ArgumentError, msg
472
+ end
473
+ end
474
+
475
+ def extract_object_key(args, options)
476
+ value = args[1] || options.delete(:object_key)
477
+ case value
478
+ when String then value
479
+ when nil then raise ArgumentError, "missing required option :object_key"
480
+ else
481
+ msg = "expected :object_key to be a String, got #{value.class}"
482
+ raise ArgumentError, msg
483
+ end
484
+ end
485
+
486
+ def extract_id(args, options)
487
+ value = args[2] || options.delete(:id)
488
+ case value
489
+ when String then value
490
+ when nil then raise ArgumentError, "missing required option :id"
491
+ else
492
+ msg = "expected :id to be a String, got #{value.class}"
493
+ raise ArgumentError, msg
494
+ end
495
+ end
496
+
497
+ class Collection < Aws::Resources::Collection
498
+
499
+ # @!group Batch Actions
500
+
501
+ # @example Request syntax with placeholder values
502
+ #
503
+ # object_version.batch_delete!({
504
+ # mfa: "MFA",
505
+ # request_payer: "requester", # accepts requester
506
+ # bypass_governance_retention: false,
507
+ # })
508
+ # @param options ({})
509
+ # @option options [String] :mfa
510
+ # The concatenation of the authentication device's serial number, a
511
+ # space, and the value that is displayed on your authentication device.
512
+ # Required to permanently delete a versioned object if versioning is
513
+ # configured with MFA delete enabled.
514
+ # @option options [String] :request_payer
515
+ # Confirms that the requester knows that they will be charged for the
516
+ # request. Bucket owners need not specify this parameter in their
517
+ # requests. For information about downloading objects from requester
518
+ # pays buckets, see [Downloading Objects in Requestor Pays Buckets][1]
519
+ # in the *Amazon S3 Developer Guide*.
520
+ #
521
+ #
522
+ #
523
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
524
+ # @option options [Boolean] :bypass_governance_retention
525
+ # Specifies whether you want to delete this object even if it has a
526
+ # Governance-type Object Lock in place. You must have sufficient
527
+ # permissions to perform this operation.
528
+ # @return [void]
529
+ def batch_delete!(options = {})
530
+ batch_enum.each do |batch|
531
+ params = Aws::Util.copy_hash(options)
532
+ params[:bucket] = batch[0].bucket_name
533
+ params[:delete] ||= {}
534
+ params[:delete][:objects] ||= []
535
+ batch.each do |item|
536
+ params[:delete][:objects] << {
537
+ key: item.object_key,
538
+ version_id: item.id
539
+ }
540
+ end
541
+ batch[0].client.delete_objects(params)
542
+ end
543
+ nil
544
+ end
545
+
546
+ # @!endgroup
547
+
548
+ end
549
+ end
550
+ end