aws-sdk-s3 1.121.0 → 1.123.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/bucket.rb +48 -25
  5. data/lib/aws-sdk-s3/bucket_acl.rb +9 -3
  6. data/lib/aws-sdk-s3/bucket_cors.rb +12 -4
  7. data/lib/aws-sdk-s3/bucket_lifecycle.rb +12 -4
  8. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +12 -4
  9. data/lib/aws-sdk-s3/bucket_logging.rb +9 -3
  10. data/lib/aws-sdk-s3/bucket_notification.rb +9 -3
  11. data/lib/aws-sdk-s3/bucket_policy.rb +12 -4
  12. data/lib/aws-sdk-s3/bucket_request_payment.rb +9 -3
  13. data/lib/aws-sdk-s3/bucket_tagging.rb +12 -4
  14. data/lib/aws-sdk-s3/bucket_versioning.rb +15 -5
  15. data/lib/aws-sdk-s3/bucket_website.rb +12 -4
  16. data/lib/aws-sdk-s3/client.rb +1547 -1300
  17. data/lib/aws-sdk-s3/customizations/bucket.rb +3 -1
  18. data/lib/aws-sdk-s3/customizations/object.rb +28 -18
  19. data/lib/aws-sdk-s3/encryption/client.rb +6 -2
  20. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +13 -9
  21. data/lib/aws-sdk-s3/encryptionV2/client.rb +6 -2
  22. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -6
  23. data/lib/aws-sdk-s3/file_downloader.rb +14 -12
  24. data/lib/aws-sdk-s3/file_uploader.rb +8 -6
  25. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +5 -3
  26. data/lib/aws-sdk-s3/multipart_upload.rb +12 -4
  27. data/lib/aws-sdk-s3/multipart_upload_part.rb +9 -3
  28. data/lib/aws-sdk-s3/object.rb +77 -48
  29. data/lib/aws-sdk-s3/object_acl.rb +9 -3
  30. data/lib/aws-sdk-s3/object_copier.rb +7 -5
  31. data/lib/aws-sdk-s3/object_summary.rb +63 -37
  32. data/lib/aws-sdk-s3/object_version.rb +21 -9
  33. data/lib/aws-sdk-s3/resource.rb +6 -2
  34. data/lib/aws-sdk-s3/types.rb +403 -263
  35. data/lib/aws-sdk-s3.rb +1 -1
  36. metadata +4 -4
@@ -134,7 +134,9 @@ module Aws
134
134
 
135
135
  # @api private
136
136
  def load
137
- @data = client.list_buckets.buckets.find { |b| b.name == name }
137
+ @data = Aws::Plugins::UserAgent.feature('resource') do
138
+ client.list_buckets.buckets.find { |b| b.name == name }
139
+ end
138
140
  raise "unable to load bucket #{name}" if @data.nil?
139
141
 
140
142
  self
@@ -68,11 +68,13 @@ module Aws
68
68
  # @see #copy_to
69
69
  #
70
70
  def copy_from(source, options = {})
71
- if Hash === source && source[:copy_source]
72
- # for backwards compatibility
73
- @client.copy_object(source.merge(bucket: bucket_name, key: key))
74
- else
75
- ObjectCopier.new(self, options).copy_from(source, options)
71
+ Aws::Plugins::UserAgent.feature('resource') do
72
+ if Hash === source && source[:copy_source]
73
+ # for backwards compatibility
74
+ @client.copy_object(source.merge(bucket: bucket_name, key: key))
75
+ else
76
+ ObjectCopier.new(self, options).copy_from(source, options)
77
+ end
76
78
  end
77
79
  end
78
80
 
@@ -109,7 +111,9 @@ module Aws
109
111
  # object.copy_to('src-bucket/src-key', multipart_copy: true)
110
112
  #
111
113
  def copy_to(target, options = {})
112
- ObjectCopier.new(self, options).copy_to(target, options)
114
+ Aws::Plugins::UserAgent.feature('resource') do
115
+ ObjectCopier.new(self, options).copy_to(target, options)
116
+ end
113
117
  end
114
118
 
115
119
  # Copies and deletes the current object. The object will only be deleted
@@ -371,10 +375,12 @@ module Aws
371
375
  tempfile: uploading_options.delete(:tempfile),
372
376
  part_size: uploading_options.delete(:part_size)
373
377
  )
374
- uploader.upload(
375
- uploading_options.merge(bucket: bucket_name, key: key),
376
- &block
377
- )
378
+ Aws::Plugins::UserAgent.feature('resource') do
379
+ uploader.upload(
380
+ uploading_options.merge(bucket: bucket_name, key: key),
381
+ &block
382
+ )
383
+ end
378
384
  true
379
385
  end
380
386
 
@@ -440,10 +446,12 @@ module Aws
440
446
  multipart_threshold: uploading_options.delete(:multipart_threshold),
441
447
  client: client
442
448
  )
443
- response = uploader.upload(
444
- source,
445
- uploading_options.merge(bucket: bucket_name, key: key)
446
- )
449
+ response = Aws::Plugins::UserAgent.feature('resource') do
450
+ uploader.upload(
451
+ source,
452
+ uploading_options.merge(bucket: bucket_name, key: key)
453
+ )
454
+ end
447
455
  yield response if block_given?
448
456
  true
449
457
  end
@@ -480,10 +488,12 @@ module Aws
480
488
  # any errors.
481
489
  def download_file(destination, options = {})
482
490
  downloader = FileDownloader.new(client: client)
483
- downloader.download(
484
- destination,
485
- options.merge(bucket: bucket_name, key: key)
486
- )
491
+ Aws::Plugins::UserAgent.feature('resource') do
492
+ downloader.download(
493
+ destination,
494
+ options.merge(bucket: bucket_name, key: key)
495
+ )
496
+ end
487
497
  true
488
498
  end
489
499
  end
@@ -270,7 +270,9 @@ module Aws
270
270
  envelope_location: @envelope_location,
271
271
  instruction_file_suffix: @instruction_file_suffix,
272
272
  }
273
- req.send_request
273
+ Aws::Plugins::UserAgent.feature('S3CryptoV1n') do
274
+ req.send_request
275
+ end
274
276
  end
275
277
 
276
278
  # Gets an object from Amazon S3, decrypting data locally.
@@ -298,7 +300,9 @@ module Aws
298
300
  envelope_location: envelope_location,
299
301
  instruction_file_suffix: instruction_file_suffix,
300
302
  }
301
- req.send_request(target: block)
303
+ Aws::Plugins::UserAgent.feature('S3CryptoV1n') do
304
+ req.send_request(target: block)
305
+ end
302
306
  end
303
307
 
304
308
  private
@@ -17,11 +17,13 @@ module Aws
17
17
  # envelope and encryption cipher.
18
18
  def encryption_cipher
19
19
  encryption_context = { "kms_cmk_id" => @kms_key_id }
20
- key_data = @kms_client.generate_data_key(
21
- key_id: @kms_key_id,
22
- encryption_context: encryption_context,
23
- key_spec: 'AES_256',
24
- )
20
+ key_data = Aws::Plugins::UserAgent.feature('S3CryptoV1n') do
21
+ @kms_client.generate_data_key(
22
+ key_id: @kms_key_id,
23
+ encryption_context: encryption_context,
24
+ key_spec: 'AES_256'
25
+ )
26
+ end
25
27
  cipher = Utils.aes_encryption_cipher(:CBC)
26
28
  cipher.key = key_data.plaintext
27
29
  envelope = {
@@ -58,10 +60,12 @@ module Aws
58
60
  "#{envelope['x-amz-wrap-alg']}"
59
61
  end
60
62
 
61
- key = @kms_client.decrypt(
62
- ciphertext_blob: decode64(envelope['x-amz-key-v2']),
63
- encryption_context: encryption_context
64
- ).plaintext
63
+ key = Aws::Plugins::UserAgent.feature('S3CryptoV1n') do
64
+ @kms_client.decrypt(
65
+ ciphertext_blob: decode64(envelope['x-amz-key-v2']),
66
+ encryption_context: encryption_context
67
+ ).plaintext
68
+ end
65
69
 
66
70
  iv = decode64(envelope['x-amz-iv'])
67
71
  block_mode =
@@ -361,7 +361,9 @@ module Aws
361
361
  instruction_file_suffix: @instruction_file_suffix,
362
362
  kms_encryption_context: kms_encryption_context
363
363
  }
364
- req.send_request
364
+ Aws::Plugins::UserAgent.feature('S3CryptoV2') do
365
+ req.send_request
366
+ end
365
367
  end
366
368
 
367
369
  # Gets an object from Amazon S3, decrypting data locally.
@@ -414,7 +416,9 @@ module Aws
414
416
  kms_allow_decrypt_with_any_cmk: kms_any_cmk_mode,
415
417
  security_profile: security_profile
416
418
  }
417
- req.send_request(target: block)
419
+ Aws::Plugins::UserAgent.feature('S3CryptoV2') do
420
+ req.send_request(target: block)
421
+ end
418
422
  end
419
423
 
420
424
  private
@@ -24,11 +24,13 @@ module Aws
24
24
  def encryption_cipher(options = {})
25
25
  validate_key_for_encryption
26
26
  encryption_context = build_encryption_context(@content_encryption_schema, options)
27
- key_data = @kms_client.generate_data_key(
28
- key_id: @kms_key_id,
29
- encryption_context: encryption_context,
30
- key_spec: 'AES_256'
31
- )
27
+ key_data = Aws::Plugins::UserAgent.feature('S3CryptoV2') do
28
+ @kms_client.generate_data_key(
29
+ key_id: @kms_key_id,
30
+ encryption_context: encryption_context,
31
+ key_spec: 'AES_256'
32
+ )
33
+ end
32
34
  cipher = Utils.aes_encryption_cipher(:GCM)
33
35
  cipher.key = key_data.plaintext
34
36
  envelope = {
@@ -83,7 +85,9 @@ module Aws
83
85
  decrypt_options[:key_id] = @kms_key_id
84
86
  end
85
87
 
86
- key = @kms_client.decrypt(decrypt_options).plaintext
88
+ key = Aws::Plugins::UserAgent.feature('S3CryptoV2') do
89
+ @kms_client.decrypt(decrypt_options).plaintext
90
+ end
87
91
  iv = decode64(envelope['x-amz-iv'])
88
92
  block_mode =
89
93
  case cek_alg
@@ -32,21 +32,23 @@ module Aws
32
32
  }
33
33
  @params[:version_id] = options[:version_id] if options[:version_id]
34
34
 
35
- case @mode
36
- when 'auto' then multipart_download
37
- when 'single_request' then single_request
38
- when 'get_range'
39
- if @chunk_size
40
- resp = @client.head_object(@params)
41
- multithreaded_get_by_ranges(construct_chunks(resp.content_length))
35
+ Aws::Plugins::UserAgent.feature('s3-transfer') do
36
+ case @mode
37
+ when 'auto' then multipart_download
38
+ when 'single_request' then single_request
39
+ when 'get_range'
40
+ if @chunk_size
41
+ resp = @client.head_object(@params)
42
+ multithreaded_get_by_ranges(construct_chunks(resp.content_length))
43
+ else
44
+ msg = 'In :get_range mode, :chunk_size must be provided'
45
+ raise ArgumentError, msg
46
+ end
42
47
  else
43
- msg = 'In :get_range mode, :chunk_size must be provided'
48
+ msg = "Invalid mode #{@mode} provided, "\
49
+ 'mode should be :single_request, :get_range or :auto'
44
50
  raise ArgumentError, msg
45
51
  end
46
- else
47
- msg = "Invalid mode #{@mode} provided, "\
48
- 'mode should be :single_request, :get_range or :auto'
49
- raise ArgumentError, msg
50
52
  end
51
53
  end
52
54
 
@@ -37,12 +37,14 @@ module Aws
37
37
  # objects smaller than the multipart threshold.
38
38
  # @return [void]
39
39
  def upload(source, options = {})
40
- if File.size(source) >= multipart_threshold
41
- MultipartFileUploader.new(@options).upload(source, options)
42
- else
43
- # remove multipart parameters not supported by put_object
44
- options.delete(:thread_count)
45
- put_object(source, options)
40
+ Aws::Plugins::UserAgent.feature('s3-transfer') do
41
+ if File.size(source) >= multipart_threshold
42
+ MultipartFileUploader.new(@options).upload(source, options)
43
+ else
44
+ # remove multipart parameters not supported by put_object
45
+ options.delete(:thread_count)
46
+ put_object(source, options)
47
+ end
46
48
  end
47
49
  end
48
50
 
@@ -45,9 +45,11 @@ module Aws
45
45
  # @option options [required,String] :key
46
46
  # @return [Seahorse::Client::Response] - the CompleteMultipartUploadResponse
47
47
  def upload(options = {}, &block)
48
- upload_id = initiate_upload(options)
49
- parts = upload_parts(upload_id, options, &block)
50
- complete_upload(upload_id, parts, options)
48
+ Aws::Plugins::UserAgent.feature('s3-transfer') do
49
+ upload_id = initiate_upload(options)
50
+ parts = upload_parts(upload_id, options, &block)
51
+ complete_upload(upload_id, parts, options)
52
+ end
51
53
  end
52
54
 
53
55
  private
@@ -217,7 +217,9 @@ module Aws::S3
217
217
  :retry
218
218
  end
219
219
  end
220
- Aws::Waiters::Waiter.new(options).wait({})
220
+ Aws::Plugins::UserAgent.feature('resource') do
221
+ Aws::Waiters::Waiter.new(options).wait({})
222
+ end
221
223
  end
222
224
 
223
225
  # @!group Actions
@@ -250,7 +252,9 @@ module Aws::S3
250
252
  key: @object_key,
251
253
  upload_id: @id
252
254
  )
253
- resp = @client.abort_multipart_upload(options)
255
+ resp = Aws::Plugins::UserAgent.feature('resource') do
256
+ @client.abort_multipart_upload(options)
257
+ end
254
258
  resp.data
255
259
  end
256
260
 
@@ -370,7 +374,9 @@ module Aws::S3
370
374
  key: @object_key,
371
375
  upload_id: @id
372
376
  )
373
- @client.complete_multipart_upload(options)
377
+ Aws::Plugins::UserAgent.feature('resource') do
378
+ @client.complete_multipart_upload(options)
379
+ end
374
380
  Object.new(
375
381
  bucket_name: @bucket_name,
376
382
  key: @object_key,
@@ -460,7 +466,9 @@ module Aws::S3
460
466
  key: @object_key,
461
467
  upload_id: @id
462
468
  )
463
- resp = @client.list_parts(options)
469
+ resp = Aws::Plugins::UserAgent.feature('resource') do
470
+ @client.list_parts(options)
471
+ end
464
472
  resp.each_page do |page|
465
473
  batch = []
466
474
  page.data.parts.each do |p|
@@ -256,7 +256,9 @@ module Aws::S3
256
256
  :retry
257
257
  end
258
258
  end
259
- Aws::Waiters::Waiter.new(options).wait({})
259
+ Aws::Plugins::UserAgent.feature('resource') do
260
+ Aws::Waiters::Waiter.new(options).wait({})
261
+ end
260
262
  end
261
263
 
262
264
  # @!group Actions
@@ -395,7 +397,9 @@ module Aws::S3
395
397
  upload_id: @multipart_upload_id,
396
398
  part_number: @part_number
397
399
  )
398
- resp = @client.upload_part_copy(options)
400
+ resp = Aws::Plugins::UserAgent.feature('resource') do
401
+ @client.upload_part_copy(options)
402
+ end
399
403
  resp.data
400
404
  end
401
405
 
@@ -521,7 +525,9 @@ module Aws::S3
521
525
  upload_id: @multipart_upload_id,
522
526
  part_number: @part_number
523
527
  )
524
- resp = @client.upload_part(options)
528
+ resp = Aws::Plugins::UserAgent.feature('resource') do
529
+ @client.upload_part(options)
530
+ end
525
531
  resp.data
526
532
  end
527
533