aws-sdk-s3 1.0.0.rc1

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 (69) hide show
  1. checksums.yaml +7 -0
  2. data/lib/aws-sdk-s3.rb +66 -0
  3. data/lib/aws-sdk-s3/bucket.rb +595 -0
  4. data/lib/aws-sdk-s3/bucket_acl.rb +168 -0
  5. data/lib/aws-sdk-s3/bucket_cors.rb +146 -0
  6. data/lib/aws-sdk-s3/bucket_lifecycle.rb +164 -0
  7. data/lib/aws-sdk-s3/bucket_logging.rb +142 -0
  8. data/lib/aws-sdk-s3/bucket_notification.rb +187 -0
  9. data/lib/aws-sdk-s3/bucket_policy.rb +138 -0
  10. data/lib/aws-sdk-s3/bucket_region_cache.rb +79 -0
  11. data/lib/aws-sdk-s3/bucket_request_payment.rb +128 -0
  12. data/lib/aws-sdk-s3/bucket_tagging.rb +143 -0
  13. data/lib/aws-sdk-s3/bucket_versioning.rb +188 -0
  14. data/lib/aws-sdk-s3/bucket_website.rb +177 -0
  15. data/lib/aws-sdk-s3/client.rb +3171 -0
  16. data/lib/aws-sdk-s3/client_api.rb +1991 -0
  17. data/lib/aws-sdk-s3/customizations.rb +29 -0
  18. data/lib/aws-sdk-s3/customizations/bucket.rb +127 -0
  19. data/lib/aws-sdk-s3/customizations/multipart_upload.rb +42 -0
  20. data/lib/aws-sdk-s3/customizations/object.rb +257 -0
  21. data/lib/aws-sdk-s3/customizations/object_summary.rb +65 -0
  22. data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +11 -0
  23. data/lib/aws-sdk-s3/encryption.rb +19 -0
  24. data/lib/aws-sdk-s3/encryption/client.rb +369 -0
  25. data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +178 -0
  26. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +63 -0
  27. data/lib/aws-sdk-s3/encryption/default_key_provider.rb +38 -0
  28. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +50 -0
  29. data/lib/aws-sdk-s3/encryption/errors.rb +13 -0
  30. data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +50 -0
  31. data/lib/aws-sdk-s3/encryption/io_decrypter.rb +29 -0
  32. data/lib/aws-sdk-s3/encryption/io_encrypter.rb +69 -0
  33. data/lib/aws-sdk-s3/encryption/key_provider.rb +29 -0
  34. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +71 -0
  35. data/lib/aws-sdk-s3/encryption/materials.rb +58 -0
  36. data/lib/aws-sdk-s3/encryption/utils.rb +79 -0
  37. data/lib/aws-sdk-s3/errors.rb +23 -0
  38. data/lib/aws-sdk-s3/file_part.rb +75 -0
  39. data/lib/aws-sdk-s3/file_uploader.rb +58 -0
  40. data/lib/aws-sdk-s3/legacy_signer.rb +186 -0
  41. data/lib/aws-sdk-s3/multipart_file_uploader.rb +187 -0
  42. data/lib/aws-sdk-s3/multipart_upload.rb +287 -0
  43. data/lib/aws-sdk-s3/multipart_upload_error.rb +16 -0
  44. data/lib/aws-sdk-s3/multipart_upload_part.rb +314 -0
  45. data/lib/aws-sdk-s3/object.rb +942 -0
  46. data/lib/aws-sdk-s3/object_acl.rb +214 -0
  47. data/lib/aws-sdk-s3/object_copier.rb +99 -0
  48. data/lib/aws-sdk-s3/object_multipart_copier.rb +179 -0
  49. data/lib/aws-sdk-s3/object_summary.rb +794 -0
  50. data/lib/aws-sdk-s3/object_version.rb +406 -0
  51. data/lib/aws-sdk-s3/plugins/accelerate.rb +92 -0
  52. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +89 -0
  53. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +23 -0
  54. data/lib/aws-sdk-s3/plugins/dualstack.rb +70 -0
  55. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +29 -0
  56. data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +23 -0
  57. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +47 -0
  58. data/lib/aws-sdk-s3/plugins/location_constraint.rb +33 -0
  59. data/lib/aws-sdk-s3/plugins/md5s.rb +79 -0
  60. data/lib/aws-sdk-s3/plugins/redirects.rb +41 -0
  61. data/lib/aws-sdk-s3/plugins/s3_signer.rb +208 -0
  62. data/lib/aws-sdk-s3/plugins/sse_cpk.rb +68 -0
  63. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +94 -0
  64. data/lib/aws-sdk-s3/presigned_post.rb +647 -0
  65. data/lib/aws-sdk-s3/presigner.rb +160 -0
  66. data/lib/aws-sdk-s3/resource.rb +96 -0
  67. data/lib/aws-sdk-s3/types.rb +5750 -0
  68. data/lib/aws-sdk-s3/waiters.rb +178 -0
  69. metadata +154 -0
@@ -0,0 +1,794 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module S3
10
+ class ObjectSummary
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(bucket_name, key, options = {})
15
+ # @param [String] bucket_name
16
+ # @param [String] key
17
+ # @option options [Client] :client
18
+ # @overload def initialize(options = {})
19
+ # @option options [required, String] :bucket_name
20
+ # @option options [required, String] :key
21
+ # @option options [Client] :client
22
+ def initialize(*args)
23
+ options = Hash === args.last ? args.pop.dup : {}
24
+ @bucket_name = extract_bucket_name(args, options)
25
+ @key = extract_key(args, options)
26
+ @data = options.delete(:data)
27
+ @client = options.delete(:client) || Client.new(options)
28
+ end
29
+
30
+ # @!group Read-Only Attributes
31
+
32
+ # @return [String]
33
+ def bucket_name
34
+ @bucket_name
35
+ end
36
+
37
+ # @return [String]
38
+ def key
39
+ @key
40
+ end
41
+
42
+ # @return [Time]
43
+ def last_modified
44
+ data.last_modified
45
+ end
46
+
47
+ # @return [String]
48
+ def etag
49
+ data.etag
50
+ end
51
+
52
+ # @return [Integer]
53
+ def size
54
+ data.size
55
+ end
56
+
57
+ # The class of storage used to store the object.
58
+ # @return [String]
59
+ def storage_class
60
+ data.storage_class
61
+ end
62
+
63
+ # @return [Types::Owner]
64
+ def owner
65
+ data.owner
66
+ end
67
+
68
+ # @!endgroup
69
+
70
+ # @return [Client]
71
+ def client
72
+ @client
73
+ end
74
+
75
+ # @raise [Errors::ResourceNotLoadable]
76
+ # @api private
77
+ def load
78
+ msg = "#load is not implemented, data only available via enumeration"
79
+ raise Errors::ResourceNotLoadable, msg
80
+ end
81
+ alias :reload :load
82
+
83
+ # @raise [Errors::ResourceNotLoadableError] Raises when {#data_loaded?} is `false`.
84
+ # @return [Types::Object]
85
+ # Returns the data for this {ObjectSummary}.
86
+ def data
87
+ load unless @data
88
+ @data
89
+ end
90
+
91
+ # @return [Boolean]
92
+ # Returns `true` if this resource is loaded. Accessing attributes or
93
+ # {#data} on an unloaded resource will trigger a call to {#load}.
94
+ def data_loaded?
95
+ !!@data
96
+ end
97
+
98
+ # @param [Hash] options ({})
99
+ # @return [Boolean]
100
+ # Returns `true` if the ObjectSummary exists.
101
+ def exists?(options = {})
102
+ begin
103
+ wait_until_exists(options.merge(max_attempts: 1))
104
+ true
105
+ rescue Aws::Waiters::Errors::UnexpectedError => e
106
+ raise e.error
107
+ rescue Aws::Waiters::Errors::WaiterFailed
108
+ false
109
+ end
110
+ end
111
+
112
+ # @param [Hash] options ({})
113
+ # @option options [Integer] :max_attempts (20)
114
+ # @option options [Float] :delay (5)
115
+ # @option options [Proc] :before_attempt
116
+ # @option options [Proc] :before_wait
117
+ # @return [ObjectSummary]
118
+ def wait_until_exists(options = {})
119
+ options, params = separate_params_and_options(options)
120
+ waiter = Waiters::ObjectExists.new(options)
121
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
122
+ waiter.wait(params.merge(bucket: @bucket_name,
123
+ key: @key))
124
+ ObjectSummary.new({
125
+ bucket_name: @bucket_name,
126
+ key: @key,
127
+ client: @client
128
+ })
129
+ end
130
+
131
+ # @param [Hash] options ({})
132
+ # @option options [Integer] :max_attempts (20)
133
+ # @option options [Float] :delay (5)
134
+ # @option options [Proc] :before_attempt
135
+ # @option options [Proc] :before_wait
136
+ # @return [ObjectSummary]
137
+ def wait_until_not_exists(options = {})
138
+ options, params = separate_params_and_options(options)
139
+ waiter = Waiters::ObjectNotExists.new(options)
140
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
141
+ waiter.wait(params.merge(bucket: @bucket_name,
142
+ key: @key))
143
+ ObjectSummary.new({
144
+ bucket_name: @bucket_name,
145
+ key: @key,
146
+ client: @client
147
+ })
148
+ end
149
+
150
+ # @!group Actions
151
+
152
+ # @example Request syntax with placeholder values
153
+ #
154
+ # object_summary.copy_from({
155
+ # acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
156
+ # cache_control: "CacheControl",
157
+ # content_disposition: "ContentDisposition",
158
+ # content_encoding: "ContentEncoding",
159
+ # content_language: "ContentLanguage",
160
+ # content_type: "ContentType",
161
+ # copy_source: "CopySource", # required
162
+ # copy_source_if_match: "CopySourceIfMatch",
163
+ # copy_source_if_modified_since: Time.now,
164
+ # copy_source_if_none_match: "CopySourceIfNoneMatch",
165
+ # copy_source_if_unmodified_since: Time.now,
166
+ # expires: Time.now,
167
+ # grant_full_control: "GrantFullControl",
168
+ # grant_read: "GrantRead",
169
+ # grant_read_acp: "GrantReadACP",
170
+ # grant_write_acp: "GrantWriteACP",
171
+ # metadata: {
172
+ # "MetadataKey" => "MetadataValue",
173
+ # },
174
+ # metadata_directive: "COPY", # accepts COPY, REPLACE
175
+ # server_side_encryption: "AES256", # accepts AES256, aws:kms
176
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
177
+ # website_redirect_location: "WebsiteRedirectLocation",
178
+ # sse_customer_algorithm: "SSECustomerAlgorithm",
179
+ # sse_customer_key: "SSECustomerKey",
180
+ # sse_customer_key_md5: "SSECustomerKeyMD5",
181
+ # ssekms_key_id: "SSEKMSKeyId",
182
+ # copy_source_sse_customer_algorithm: "CopySourceSSECustomerAlgorithm",
183
+ # copy_source_sse_customer_key: "CopySourceSSECustomerKey",
184
+ # copy_source_sse_customer_key_md5: "CopySourceSSECustomerKeyMD5",
185
+ # request_payer: "requester", # accepts requester
186
+ # })
187
+ # @param [Hash] options ({})
188
+ # @option options [String] :acl
189
+ # The canned ACL to apply to the object.
190
+ # @option options [String] :cache_control
191
+ # Specifies caching behavior along the request/reply chain.
192
+ # @option options [String] :content_disposition
193
+ # Specifies presentational information for the object.
194
+ # @option options [String] :content_encoding
195
+ # Specifies what content encodings have been applied to the object and
196
+ # thus what decoding mechanisms must be applied to obtain the media-type
197
+ # referenced by the Content-Type header field.
198
+ # @option options [String] :content_language
199
+ # The language the content is in.
200
+ # @option options [String] :content_type
201
+ # A standard MIME type describing the format of the object data.
202
+ # @option options [required, String] :copy_source
203
+ # The name of the source bucket and key name of the source object,
204
+ # separated by a slash (/). Must be URL-encoded.
205
+ # @option options [String] :copy_source_if_match
206
+ # Copies the object if its entity tag (ETag) matches the specified tag.
207
+ # @option options [Time,DateTime,Date,Integer,String] :copy_source_if_modified_since
208
+ # Copies the object if it has been modified since the specified time.
209
+ # @option options [String] :copy_source_if_none_match
210
+ # Copies the object if its entity tag (ETag) is different than the
211
+ # specified ETag.
212
+ # @option options [Time,DateTime,Date,Integer,String] :copy_source_if_unmodified_since
213
+ # Copies the object if it hasn't been modified since the specified
214
+ # time.
215
+ # @option options [Time,DateTime,Date,Integer,String] :expires
216
+ # The date and time at which the object is no longer cacheable.
217
+ # @option options [String] :grant_full_control
218
+ # Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
219
+ # object.
220
+ # @option options [String] :grant_read
221
+ # Allows grantee to read the object data and its metadata.
222
+ # @option options [String] :grant_read_acp
223
+ # Allows grantee to read the object ACL.
224
+ # @option options [String] :grant_write_acp
225
+ # Allows grantee to write the ACL for the applicable object.
226
+ # @option options [Hash<String,String>] :metadata
227
+ # A map of metadata to store with the object in S3.
228
+ # @option options [String] :metadata_directive
229
+ # Specifies whether the metadata is copied from the source object or
230
+ # replaced with metadata provided in the request.
231
+ # @option options [String] :server_side_encryption
232
+ # The Server-side encryption algorithm used when storing this object in
233
+ # S3 (e.g., AES256, aws:kms).
234
+ # @option options [String] :storage_class
235
+ # The type of storage to use for the object. Defaults to 'STANDARD'.
236
+ # @option options [String] :website_redirect_location
237
+ # If the bucket is configured as a website, redirects requests for this
238
+ # object to another object in the same bucket or to an external URL.
239
+ # Amazon S3 stores the value of this header in the object metadata.
240
+ # @option options [String] :sse_customer_algorithm
241
+ # Specifies the algorithm to use to when encrypting the object (e.g.,
242
+ # AES256).
243
+ # @option options [String] :sse_customer_key
244
+ # Specifies the customer-provided encryption key for Amazon S3 to use in
245
+ # encrypting data. This value is used to store the object and then it is
246
+ # discarded; Amazon does not store the encryption key. The key must be
247
+ # appropriate for use with the algorithm specified in the
248
+ # x-amz-server-side​-encryption​-customer-algorithm header.
249
+ # @option options [String] :sse_customer_key_md5
250
+ # Specifies the 128-bit MD5 digest of the encryption key according to
251
+ # RFC 1321. Amazon S3 uses this header for a message integrity check to
252
+ # ensure the encryption key was transmitted without error.
253
+ # @option options [String] :ssekms_key_id
254
+ # Specifies the AWS KMS key ID to use for object encryption. All GET and
255
+ # PUT requests for an object protected by AWS KMS will fail if not made
256
+ # via SSL or using SigV4. Documentation on configuring any of the
257
+ # officially supported AWS SDKs and CLI can be found at
258
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
259
+ # @option options [String] :copy_source_sse_customer_algorithm
260
+ # Specifies the algorithm to use when decrypting the source object
261
+ # (e.g., AES256).
262
+ # @option options [String] :copy_source_sse_customer_key
263
+ # Specifies the customer-provided encryption key for Amazon S3 to use to
264
+ # decrypt the source object. The encryption key provided in this header
265
+ # must be one that was used when the source object was created.
266
+ # @option options [String] :copy_source_sse_customer_key_md5
267
+ # Specifies the 128-bit MD5 digest of the encryption key according to
268
+ # RFC 1321. Amazon S3 uses this header for a message integrity check to
269
+ # ensure the encryption key was transmitted without error.
270
+ # @option options [String] :request_payer
271
+ # Confirms that the requester knows that she or he will be charged for
272
+ # the request. Bucket owners need not specify this parameter in their
273
+ # requests. Documentation on downloading objects from requester pays
274
+ # buckets can be found at
275
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
276
+ # @return [Types::CopyObjectOutput]
277
+ def copy_from(options = {})
278
+ options = options.merge(
279
+ bucket: @bucket_name,
280
+ key: @key
281
+ )
282
+ resp = @client.copy_object(options)
283
+ resp.data
284
+ end
285
+
286
+ # @example Request syntax with placeholder values
287
+ #
288
+ # object_summary.delete({
289
+ # mfa: "MFA",
290
+ # version_id: "ObjectVersionId",
291
+ # request_payer: "requester", # accepts requester
292
+ # })
293
+ # @param [Hash] options ({})
294
+ # @option options [String] :mfa
295
+ # The concatenation of the authentication device's serial number, a
296
+ # space, and the value that is displayed on your authentication device.
297
+ # @option options [String] :version_id
298
+ # VersionId used to reference a specific version of the object.
299
+ # @option options [String] :request_payer
300
+ # Confirms that the requester knows that she or he will be charged for
301
+ # the request. Bucket owners need not specify this parameter in their
302
+ # requests. Documentation on downloading objects from requester pays
303
+ # buckets can be found at
304
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
305
+ # @return [Types::DeleteObjectOutput]
306
+ def delete(options = {})
307
+ options = options.merge(
308
+ bucket: @bucket_name,
309
+ key: @key
310
+ )
311
+ resp = @client.delete_object(options)
312
+ resp.data
313
+ end
314
+
315
+ # @example Request syntax with placeholder values
316
+ #
317
+ # object_summary.get({
318
+ # if_match: "IfMatch",
319
+ # if_modified_since: Time.now,
320
+ # if_none_match: "IfNoneMatch",
321
+ # if_unmodified_since: Time.now,
322
+ # range: "Range",
323
+ # response_cache_control: "ResponseCacheControl",
324
+ # response_content_disposition: "ResponseContentDisposition",
325
+ # response_content_encoding: "ResponseContentEncoding",
326
+ # response_content_language: "ResponseContentLanguage",
327
+ # response_content_type: "ResponseContentType",
328
+ # response_expires: Time.now,
329
+ # version_id: "ObjectVersionId",
330
+ # sse_customer_algorithm: "SSECustomerAlgorithm",
331
+ # sse_customer_key: "SSECustomerKey",
332
+ # sse_customer_key_md5: "SSECustomerKeyMD5",
333
+ # request_payer: "requester", # accepts requester
334
+ # part_number: 1,
335
+ # })
336
+ # @param [Hash] options ({})
337
+ # @option options [String] :if_match
338
+ # Return the object only if its entity tag (ETag) is the same as the one
339
+ # specified, otherwise return a 412 (precondition failed).
340
+ # @option options [Time,DateTime,Date,Integer,String] :if_modified_since
341
+ # Return the object only if it has been modified since the specified
342
+ # time, otherwise return a 304 (not modified).
343
+ # @option options [String] :if_none_match
344
+ # Return the object only if its entity tag (ETag) is different from the
345
+ # one specified, otherwise return a 304 (not modified).
346
+ # @option options [Time,DateTime,Date,Integer,String] :if_unmodified_since
347
+ # Return the object only if it has not been modified since the specified
348
+ # time, otherwise return a 412 (precondition failed).
349
+ # @option options [String] :range
350
+ # Downloads the specified range bytes of an object. For more information
351
+ # about the HTTP Range header, go to
352
+ # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.
353
+ # @option options [String] :response_cache_control
354
+ # Sets the Cache-Control header of the response.
355
+ # @option options [String] :response_content_disposition
356
+ # Sets the Content-Disposition header of the response
357
+ # @option options [String] :response_content_encoding
358
+ # Sets the Content-Encoding header of the response.
359
+ # @option options [String] :response_content_language
360
+ # Sets the Content-Language header of the response.
361
+ # @option options [String] :response_content_type
362
+ # Sets the Content-Type header of the response.
363
+ # @option options [Time,DateTime,Date,Integer,String] :response_expires
364
+ # Sets the Expires header of the response.
365
+ # @option options [String] :version_id
366
+ # VersionId used to reference a specific version of the object.
367
+ # @option options [String] :sse_customer_algorithm
368
+ # Specifies the algorithm to use to when encrypting the object (e.g.,
369
+ # AES256).
370
+ # @option options [String] :sse_customer_key
371
+ # Specifies the customer-provided encryption key for Amazon S3 to use in
372
+ # encrypting data. This value is used to store the object and then it is
373
+ # discarded; Amazon does not store the encryption key. The key must be
374
+ # appropriate for use with the algorithm specified in the
375
+ # x-amz-server-side​-encryption​-customer-algorithm header.
376
+ # @option options [String] :sse_customer_key_md5
377
+ # Specifies the 128-bit MD5 digest of the encryption key according to
378
+ # RFC 1321. Amazon S3 uses this header for a message integrity check to
379
+ # ensure the encryption key was transmitted without error.
380
+ # @option options [String] :request_payer
381
+ # Confirms that the requester knows that she or he will be charged for
382
+ # the request. Bucket owners need not specify this parameter in their
383
+ # requests. Documentation on downloading objects from requester pays
384
+ # buckets can be found at
385
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
386
+ # @option options [Integer] :part_number
387
+ # Part number of the object being read. This is a positive integer
388
+ # between 1 and 10,000. Effectively performs a 'ranged' GET request
389
+ # for the part specified. Useful for downloading just a part of an
390
+ # object.
391
+ # @return [Types::GetObjectOutput]
392
+ def get(options = {})
393
+ options = options.merge(
394
+ bucket: @bucket_name,
395
+ key: @key
396
+ )
397
+ resp = @client.get_object(options)
398
+ resp.data
399
+ end
400
+
401
+ # @example Request syntax with placeholder values
402
+ #
403
+ # multipartupload = object_summary.initiate_multipart_upload({
404
+ # acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
405
+ # cache_control: "CacheControl",
406
+ # content_disposition: "ContentDisposition",
407
+ # content_encoding: "ContentEncoding",
408
+ # content_language: "ContentLanguage",
409
+ # content_type: "ContentType",
410
+ # expires: Time.now,
411
+ # grant_full_control: "GrantFullControl",
412
+ # grant_read: "GrantRead",
413
+ # grant_read_acp: "GrantReadACP",
414
+ # grant_write_acp: "GrantWriteACP",
415
+ # metadata: {
416
+ # "MetadataKey" => "MetadataValue",
417
+ # },
418
+ # server_side_encryption: "AES256", # accepts AES256, aws:kms
419
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
420
+ # website_redirect_location: "WebsiteRedirectLocation",
421
+ # sse_customer_algorithm: "SSECustomerAlgorithm",
422
+ # sse_customer_key: "SSECustomerKey",
423
+ # sse_customer_key_md5: "SSECustomerKeyMD5",
424
+ # ssekms_key_id: "SSEKMSKeyId",
425
+ # request_payer: "requester", # accepts requester
426
+ # })
427
+ # @param [Hash] options ({})
428
+ # @option options [String] :acl
429
+ # The canned ACL to apply to the object.
430
+ # @option options [String] :cache_control
431
+ # Specifies caching behavior along the request/reply chain.
432
+ # @option options [String] :content_disposition
433
+ # Specifies presentational information for the object.
434
+ # @option options [String] :content_encoding
435
+ # Specifies what content encodings have been applied to the object and
436
+ # thus what decoding mechanisms must be applied to obtain the media-type
437
+ # referenced by the Content-Type header field.
438
+ # @option options [String] :content_language
439
+ # The language the content is in.
440
+ # @option options [String] :content_type
441
+ # A standard MIME type describing the format of the object data.
442
+ # @option options [Time,DateTime,Date,Integer,String] :expires
443
+ # The date and time at which the object is no longer cacheable.
444
+ # @option options [String] :grant_full_control
445
+ # Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
446
+ # object.
447
+ # @option options [String] :grant_read
448
+ # Allows grantee to read the object data and its metadata.
449
+ # @option options [String] :grant_read_acp
450
+ # Allows grantee to read the object ACL.
451
+ # @option options [String] :grant_write_acp
452
+ # Allows grantee to write the ACL for the applicable object.
453
+ # @option options [Hash<String,String>] :metadata
454
+ # A map of metadata to store with the object in S3.
455
+ # @option options [String] :server_side_encryption
456
+ # The Server-side encryption algorithm used when storing this object in
457
+ # S3 (e.g., AES256, aws:kms).
458
+ # @option options [String] :storage_class
459
+ # The type of storage to use for the object. Defaults to 'STANDARD'.
460
+ # @option options [String] :website_redirect_location
461
+ # If the bucket is configured as a website, redirects requests for this
462
+ # object to another object in the same bucket or to an external URL.
463
+ # Amazon S3 stores the value of this header in the object metadata.
464
+ # @option options [String] :sse_customer_algorithm
465
+ # Specifies the algorithm to use to when encrypting the object (e.g.,
466
+ # AES256).
467
+ # @option options [String] :sse_customer_key
468
+ # Specifies the customer-provided encryption key for Amazon S3 to use in
469
+ # encrypting data. This value is used to store the object and then it is
470
+ # discarded; Amazon does not store the encryption key. The key must be
471
+ # appropriate for use with the algorithm specified in the
472
+ # x-amz-server-side​-encryption​-customer-algorithm header.
473
+ # @option options [String] :sse_customer_key_md5
474
+ # Specifies the 128-bit MD5 digest of the encryption key according to
475
+ # RFC 1321. Amazon S3 uses this header for a message integrity check to
476
+ # ensure the encryption key was transmitted without error.
477
+ # @option options [String] :ssekms_key_id
478
+ # Specifies the AWS KMS key ID to use for object encryption. All GET and
479
+ # PUT requests for an object protected by AWS KMS will fail if not made
480
+ # via SSL or using SigV4. Documentation on configuring any of the
481
+ # officially supported AWS SDKs and CLI can be found at
482
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
483
+ # @option options [String] :request_payer
484
+ # Confirms that the requester knows that she or he will be charged for
485
+ # the request. Bucket owners need not specify this parameter in their
486
+ # requests. Documentation on downloading objects from requester pays
487
+ # buckets can be found at
488
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
489
+ # @return [MultipartUpload]
490
+ def initiate_multipart_upload(options = {})
491
+ options = options.merge(
492
+ bucket: @bucket_name,
493
+ key: @key
494
+ )
495
+ resp = @client.create_multipart_upload(options)
496
+ MultipartUpload.new(
497
+ bucket_name: @bucket_name,
498
+ object_key: @key,
499
+ id: resp.data.upload_id,
500
+ client: @client
501
+ )
502
+ end
503
+
504
+ # @example Request syntax with placeholder values
505
+ #
506
+ # object_summary.put({
507
+ # acl: "private", # accepts private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control
508
+ # body: source_file,
509
+ # cache_control: "CacheControl",
510
+ # content_disposition: "ContentDisposition",
511
+ # content_encoding: "ContentEncoding",
512
+ # content_language: "ContentLanguage",
513
+ # content_length: 1,
514
+ # content_md5: "ContentMD5",
515
+ # content_type: "ContentType",
516
+ # expires: Time.now,
517
+ # grant_full_control: "GrantFullControl",
518
+ # grant_read: "GrantRead",
519
+ # grant_read_acp: "GrantReadACP",
520
+ # grant_write_acp: "GrantWriteACP",
521
+ # metadata: {
522
+ # "MetadataKey" => "MetadataValue",
523
+ # },
524
+ # server_side_encryption: "AES256", # accepts AES256, aws:kms
525
+ # storage_class: "STANDARD", # accepts STANDARD, REDUCED_REDUNDANCY, STANDARD_IA
526
+ # website_redirect_location: "WebsiteRedirectLocation",
527
+ # sse_customer_algorithm: "SSECustomerAlgorithm",
528
+ # sse_customer_key: "SSECustomerKey",
529
+ # sse_customer_key_md5: "SSECustomerKeyMD5",
530
+ # ssekms_key_id: "SSEKMSKeyId",
531
+ # request_payer: "requester", # accepts requester
532
+ # })
533
+ # @param [Hash] options ({})
534
+ # @option options [String] :acl
535
+ # The canned ACL to apply to the object.
536
+ # @option options [String, IO] :body
537
+ # Object data.
538
+ # @option options [String] :cache_control
539
+ # Specifies caching behavior along the request/reply chain.
540
+ # @option options [String] :content_disposition
541
+ # Specifies presentational information for the object.
542
+ # @option options [String] :content_encoding
543
+ # Specifies what content encodings have been applied to the object and
544
+ # thus what decoding mechanisms must be applied to obtain the media-type
545
+ # referenced by the Content-Type header field.
546
+ # @option options [String] :content_language
547
+ # The language the content is in.
548
+ # @option options [Integer] :content_length
549
+ # Size of the body in bytes. This parameter is useful when the size of
550
+ # the body cannot be determined automatically.
551
+ # @option options [String] :content_md5
552
+ # The base64-encoded 128-bit MD5 digest of the part data.
553
+ # @option options [String] :content_type
554
+ # A standard MIME type describing the format of the object data.
555
+ # @option options [Time,DateTime,Date,Integer,String] :expires
556
+ # The date and time at which the object is no longer cacheable.
557
+ # @option options [String] :grant_full_control
558
+ # Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
559
+ # object.
560
+ # @option options [String] :grant_read
561
+ # Allows grantee to read the object data and its metadata.
562
+ # @option options [String] :grant_read_acp
563
+ # Allows grantee to read the object ACL.
564
+ # @option options [String] :grant_write_acp
565
+ # Allows grantee to write the ACL for the applicable object.
566
+ # @option options [Hash<String,String>] :metadata
567
+ # A map of metadata to store with the object in S3.
568
+ # @option options [String] :server_side_encryption
569
+ # The Server-side encryption algorithm used when storing this object in
570
+ # S3 (e.g., AES256, aws:kms).
571
+ # @option options [String] :storage_class
572
+ # The type of storage to use for the object. Defaults to 'STANDARD'.
573
+ # @option options [String] :website_redirect_location
574
+ # If the bucket is configured as a website, redirects requests for this
575
+ # object to another object in the same bucket or to an external URL.
576
+ # Amazon S3 stores the value of this header in the object metadata.
577
+ # @option options [String] :sse_customer_algorithm
578
+ # Specifies the algorithm to use to when encrypting the object (e.g.,
579
+ # AES256).
580
+ # @option options [String] :sse_customer_key
581
+ # Specifies the customer-provided encryption key for Amazon S3 to use in
582
+ # encrypting data. This value is used to store the object and then it is
583
+ # discarded; Amazon does not store the encryption key. The key must be
584
+ # appropriate for use with the algorithm specified in the
585
+ # x-amz-server-side​-encryption​-customer-algorithm header.
586
+ # @option options [String] :sse_customer_key_md5
587
+ # Specifies the 128-bit MD5 digest of the encryption key according to
588
+ # RFC 1321. Amazon S3 uses this header for a message integrity check to
589
+ # ensure the encryption key was transmitted without error.
590
+ # @option options [String] :ssekms_key_id
591
+ # Specifies the AWS KMS key ID to use for object encryption. All GET and
592
+ # PUT requests for an object protected by AWS KMS will fail if not made
593
+ # via SSL or using SigV4. Documentation on configuring any of the
594
+ # officially supported AWS SDKs and CLI can be found at
595
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version
596
+ # @option options [String] :request_payer
597
+ # Confirms that the requester knows that she or he will be charged for
598
+ # the request. Bucket owners need not specify this parameter in their
599
+ # requests. Documentation on downloading objects from requester pays
600
+ # buckets can be found at
601
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
602
+ # @return [Types::PutObjectOutput]
603
+ def put(options = {})
604
+ options = options.merge(
605
+ bucket: @bucket_name,
606
+ key: @key
607
+ )
608
+ resp = @client.put_object(options)
609
+ resp.data
610
+ end
611
+
612
+ # @example Request syntax with placeholder values
613
+ #
614
+ # object_summary.restore_object({
615
+ # version_id: "ObjectVersionId",
616
+ # restore_request: {
617
+ # days: 1, # required
618
+ # glacier_job_parameters: {
619
+ # tier: "Standard", # required, accepts Standard, Bulk, Expedited
620
+ # },
621
+ # },
622
+ # request_payer: "requester", # accepts requester
623
+ # })
624
+ # @param [Hash] options ({})
625
+ # @option options [String] :version_id
626
+ # @option options [Types::RestoreRequest] :restore_request
627
+ # @option options [String] :request_payer
628
+ # Confirms that the requester knows that she or he will be charged for
629
+ # the request. Bucket owners need not specify this parameter in their
630
+ # requests. Documentation on downloading objects from requester pays
631
+ # buckets can be found at
632
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
633
+ # @return [Types::RestoreObjectOutput]
634
+ def restore_object(options = {})
635
+ options = options.merge(
636
+ bucket: @bucket_name,
637
+ key: @key
638
+ )
639
+ resp = @client.restore_object(options)
640
+ resp.data
641
+ end
642
+
643
+ # @!group Associations
644
+
645
+ # @return [ObjectAcl]
646
+ def acl
647
+ ObjectAcl.new(
648
+ bucket_name: @bucket_name,
649
+ object_key: @key,
650
+ client: @client
651
+ )
652
+ end
653
+
654
+ # @return [Bucket]
655
+ def bucket
656
+ Bucket.new(
657
+ name: @bucket_name,
658
+ client: @client
659
+ )
660
+ end
661
+
662
+ # @param [String] id
663
+ # @return [MultipartUpload]
664
+ def multipart_upload(id)
665
+ MultipartUpload.new(
666
+ bucket_name: @bucket_name,
667
+ object_key: @key,
668
+ id: id,
669
+ client: @client
670
+ )
671
+ end
672
+
673
+ # @return [Object]
674
+ def object
675
+ Object.new(
676
+ bucket_name: @bucket_name,
677
+ key: @key,
678
+ client: @client
679
+ )
680
+ end
681
+
682
+ # @param [String] id
683
+ # @return [ObjectVersion]
684
+ def version(id)
685
+ ObjectVersion.new(
686
+ bucket_name: @bucket_name,
687
+ object_key: @key,
688
+ id: id,
689
+ client: @client
690
+ )
691
+ end
692
+
693
+ # @deprecated
694
+ # @api private
695
+ def identifiers
696
+ {
697
+ bucket_name: @bucket_name,
698
+ key: @key
699
+ }
700
+ end
701
+ deprecated(:identifiers)
702
+
703
+ private
704
+
705
+ def extract_bucket_name(args, options)
706
+ value = args[0] || options.delete(:bucket_name)
707
+ case value
708
+ when String then value
709
+ when nil then raise ArgumentError, "missing required option :bucket_name"
710
+ else
711
+ msg = "expected :bucket_name to be a String, got #{value.class}"
712
+ raise ArgumentError, msg
713
+ end
714
+ end
715
+
716
+ def extract_key(args, options)
717
+ value = args[1] || options.delete(:key)
718
+ case value
719
+ when String then value
720
+ when nil then raise ArgumentError, "missing required option :key"
721
+ else
722
+ msg = "expected :key to be a String, got #{value.class}"
723
+ raise ArgumentError, msg
724
+ end
725
+ end
726
+
727
+ def yield_waiter_and_warn(waiter, &block)
728
+ if !@waiter_block_warned
729
+ msg = "pass options to configure the waiter; "
730
+ msg << "yielding the waiter is deprecated"
731
+ warn(msg)
732
+ @waiter_block_warned = true
733
+ end
734
+ yield(waiter.waiter)
735
+ end
736
+
737
+ def separate_params_and_options(options)
738
+ opts = Set.new([:client, :max_attempts, :delay, :before_attempt, :before_wait])
739
+ waiter_opts = {}
740
+ waiter_params = {}
741
+ options.each_pair do |key, value|
742
+ if opts.include?(key)
743
+ waiter_opts[key] = value
744
+ else
745
+ waiter_params[key] = value
746
+ end
747
+ end
748
+ waiter_opts[:client] ||= @client
749
+ [waiter_opts, waiter_params]
750
+ end
751
+
752
+ class Collection < Aws::Resources::Collection
753
+
754
+ # @!group Batch Actions
755
+
756
+ # @example Request syntax with placeholder values
757
+ #
758
+ # object_summary.batch_delete!({
759
+ # mfa: "MFA",
760
+ # request_payer: "requester", # accepts requester
761
+ # })
762
+ # @param options ({})
763
+ # @option options [String] :mfa
764
+ # The concatenation of the authentication device's serial number, a
765
+ # space, and the value that is displayed on your authentication device.
766
+ # @option options [String] :request_payer
767
+ # Confirms that the requester knows that she or he will be charged for
768
+ # the request. Bucket owners need not specify this parameter in their
769
+ # requests. Documentation on downloading objects from requester pays
770
+ # buckets can be found at
771
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html
772
+ # @return [void]
773
+ def batch_delete!(options = {})
774
+ batch_enum.each do |batch|
775
+ params = Aws::Util.copy_hash(options)
776
+ params[:bucket] = batch[0].bucket_name
777
+ params[:delete] ||= {}
778
+ params[:delete][:objects] ||= []
779
+ batch.each do |item|
780
+ params[:delete][:objects] << {
781
+ key: item.key
782
+ }
783
+ end
784
+ batch[0].client.delete_objects(params)
785
+ end
786
+ nil
787
+ end
788
+
789
+ # @!endgroup
790
+
791
+ end
792
+ end
793
+ end
794
+ end