aws-sdk-s3 1.114.0 → 1.136.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +163 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/bucket.rb +123 -61
  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 +2084 -1724
  17. data/lib/aws-sdk-s3/client_api.rb +213 -189
  18. data/lib/aws-sdk-s3/customizations/bucket.rb +23 -47
  19. data/lib/aws-sdk-s3/customizations/errors.rb +27 -0
  20. data/lib/aws-sdk-s3/customizations/object.rb +95 -19
  21. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  22. data/lib/aws-sdk-s3/customizations.rb +2 -0
  23. data/lib/aws-sdk-s3/encryption/client.rb +6 -2
  24. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +13 -9
  25. data/lib/aws-sdk-s3/encryptionV2/client.rb +6 -2
  26. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +1 -0
  27. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -6
  28. data/lib/aws-sdk-s3/endpoint_parameters.rb +146 -0
  29. data/lib/aws-sdk-s3/endpoint_provider.rb +509 -0
  30. data/lib/aws-sdk-s3/endpoints.rb +2150 -0
  31. data/lib/aws-sdk-s3/file_downloader.rb +170 -44
  32. data/lib/aws-sdk-s3/file_uploader.rb +8 -6
  33. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +41 -13
  34. data/lib/aws-sdk-s3/multipart_upload.rb +27 -13
  35. data/lib/aws-sdk-s3/multipart_upload_part.rb +20 -10
  36. data/lib/aws-sdk-s3/object.rb +156 -110
  37. data/lib/aws-sdk-s3/object_acl.rb +14 -6
  38. data/lib/aws-sdk-s3/object_copier.rb +7 -5
  39. data/lib/aws-sdk-s3/object_multipart_copier.rb +41 -19
  40. data/lib/aws-sdk-s3/object_summary.rb +149 -94
  41. data/lib/aws-sdk-s3/object_version.rb +55 -21
  42. data/lib/aws-sdk-s3/plugins/accelerate.rb +3 -50
  43. data/lib/aws-sdk-s3/plugins/arn.rb +0 -184
  44. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +3 -39
  45. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +1 -6
  46. data/lib/aws-sdk-s3/plugins/dualstack.rb +1 -49
  47. data/lib/aws-sdk-s3/plugins/endpoints.rb +262 -0
  48. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +2 -1
  49. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +0 -29
  50. data/lib/aws-sdk-s3/plugins/s3_signer.rb +32 -126
  51. data/lib/aws-sdk-s3/presigned_post.rb +61 -59
  52. data/lib/aws-sdk-s3/presigner.rb +24 -35
  53. data/lib/aws-sdk-s3/resource.rb +7 -3
  54. data/lib/aws-sdk-s3/types.rb +858 -4125
  55. data/lib/aws-sdk-s3.rb +5 -1
  56. metadata +12 -11
  57. data/lib/aws-sdk-s3/arn/access_point_arn.rb +0 -69
  58. data/lib/aws-sdk-s3/arn/multi_region_access_point_arn.rb +0 -68
  59. data/lib/aws-sdk-s3/arn/object_lambda_arn.rb +0 -69
  60. data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +0 -74
  61. data/lib/aws-sdk-s3/plugins/object_lambda_endpoint.rb +0 -25
@@ -5,22 +5,6 @@ require 'uri'
5
5
  module Aws
6
6
  module S3
7
7
  class Bucket
8
- # Save the old initialize method so that we can call 'super'.
9
- old_initialize = instance_method(:initialize)
10
- # Make the method redefinable
11
- alias_method :initialize, :initialize
12
- # Define a new initialize method that extracts out a bucket ARN.
13
- define_method(:initialize) do |*args|
14
- old_initialize.bind(self).call(*args)
15
- resolved_region, arn = Plugins::ARN.resolve_arn!(
16
- name,
17
- client.config.region,
18
- client.config.s3_use_arn_region
19
- )
20
- @resolved_region = resolved_region
21
- @arn = arn
22
- end
23
-
24
8
  # Deletes all objects and versioned objects from this bucket
25
9
  #
26
10
  # @example
@@ -105,14 +89,27 @@ module Aws
105
89
  if options[:virtual_host]
106
90
  scheme = options.fetch(:secure, true) ? 'https' : 'http'
107
91
  "#{scheme}://#{name}"
108
- elsif @arn
109
- Plugins::ARN.resolve_url!(
110
- client.config.endpoint.dup,
111
- @arn,
112
- @resolved_region
113
- ).to_s
114
92
  else
115
- s3_bucket_url
93
+ # Taken from Aws::S3::Endpoints module
94
+ unless client.config.regional_endpoint
95
+ endpoint = client.config.endpoint.to_s
96
+ end
97
+ params = Aws::S3::EndpointParameters.new(
98
+ bucket: name,
99
+ region: client.config.region,
100
+ use_fips: client.config.use_fips_endpoint,
101
+ use_dual_stack: client.config.use_dualstack_endpoint,
102
+ endpoint: endpoint,
103
+ force_path_style: client.config.force_path_style,
104
+ accelerate: client.config.use_accelerate_endpoint,
105
+ use_global_endpoint: client.config.s3_us_east_1_regional_endpoint == 'legacy',
106
+ use_object_lambda_endpoint: nil,
107
+ disable_access_points: nil,
108
+ disable_multi_region_access_points: client.config.s3_disable_multiregion_access_points,
109
+ use_arn_region: client.config.s3_use_arn_region,
110
+ )
111
+ endpoint = Aws::S3::EndpointProvider.new.resolve_endpoint(params)
112
+ endpoint.url
116
113
  end
117
114
  end
118
115
 
@@ -137,34 +134,13 @@ module Aws
137
134
 
138
135
  # @api private
139
136
  def load
140
- @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
141
140
  raise "unable to load bucket #{name}" if @data.nil?
142
141
 
143
142
  self
144
143
  end
145
-
146
- private
147
-
148
- def s3_bucket_url
149
- url = client.config.endpoint.dup
150
- if bucket_as_hostname?(url.scheme == 'https')
151
- url.host = "#{name}.#{url.host}"
152
- else
153
- url.path += '/' unless url.path[-1] == '/'
154
- url.path += Seahorse::Util.uri_escape(name)
155
- end
156
- if (client.config.region == 'us-east-1') &&
157
- (client.config.s3_us_east_1_regional_endpoint == 'legacy')
158
- url.host = Plugins::IADRegionalEndpoint.legacy_host(url.host)
159
- end
160
- url.to_s
161
- end
162
-
163
- def bucket_as_hostname?(https)
164
- Plugins::BucketDns.dns_compatible?(name, https) &&
165
- !client.config.force_path_style
166
- end
167
-
168
144
  end
169
145
  end
170
146
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Errors
6
+ # Hijack PermanentRedirect dynamic error to also include endpoint
7
+ # and bucket.
8
+ class PermanentRedirect < ServiceError
9
+ # @param [Seahorse::Client::RequestContext] context
10
+ # @param [String] message
11
+ # @param [Aws::S3::Types::PermanentRedirect] _data
12
+ def initialize(context, message, _data = Aws::EmptyStructure.new)
13
+ data = Aws::S3::Types::PermanentRedirect.new(message: message)
14
+ body = context.http_response.body_contents
15
+ if (endpoint = body.match(/<Endpoint>(.+?)<\/Endpoint>/))
16
+ data.endpoint = endpoint[1]
17
+ end
18
+ if (bucket = body.match(/<Bucket>(.+?)<\/Bucket>/))
19
+ data.bucket = bucket[1]
20
+ end
21
+ data.region = context.http_response.headers['x-amz-bucket-region']
22
+ super(context, message, data)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -27,10 +27,13 @@ module Aws
27
27
  # necessary for objects larger than 5GB and can provide
28
28
  # performance improvements on large objects. Amazon S3 does
29
29
  # not accept multipart copies for objects smaller than 5MB.
30
+ # Object metadata such as Content-Type will be copied, however,
31
+ # Checksums are not copied.
30
32
  #
31
33
  # @option options [Integer] :content_length Only used when
32
34
  # `:multipart_copy` is `true`. Passing this options avoids a HEAD
33
- # request to query the source object size. Raises an `ArgumentError` if
35
+ # request to query the source object size but prevents object metadata
36
+ # from being copied. Raises an `ArgumentError` if
34
37
  # this option is provided when `:multipart_copy` is `false` or not set.
35
38
  #
36
39
  # @option options [S3::Client] :copy_source_client Only used when
@@ -43,6 +46,14 @@ module Aws
43
46
  # different region. You do not need to specify this option
44
47
  # if you have provided a `:source_client` or a `:content_length`.
45
48
  #
49
+ # @option options [Boolean] :use_source_parts (false) Only used when
50
+ # `:multipart_copy` is `true`. Use part sizes defined on the source
51
+ # object if any exist. If copying or moving an object that
52
+ # is already multipart, this does not re-part the object, instead
53
+ # re-using the part definitions on the original. That means the etag
54
+ # and any checksums will not change. This is especially useful if the
55
+ # source object has parts with varied sizes.
56
+ #
46
57
  # @example Basic object copy
47
58
  #
48
59
  # bucket = Aws::S3::Bucket.new('target-bucket')
@@ -65,11 +76,13 @@ module Aws
65
76
  # @see #copy_to
66
77
  #
67
78
  def copy_from(source, options = {})
68
- if Hash === source && source[:copy_source]
69
- # for backwards compatibility
70
- @client.copy_object(source.merge(bucket: bucket_name, key: key))
71
- else
72
- ObjectCopier.new(self, options).copy_from(source, options)
79
+ Aws::Plugins::UserAgent.feature('resource') do
80
+ if Hash === source && source[:copy_source]
81
+ # for backwards compatibility
82
+ @client.copy_object(source.merge(bucket: bucket_name, key: key))
83
+ else
84
+ ObjectCopier.new(self, options).copy_from(source, options)
85
+ end
73
86
  end
74
87
  end
75
88
 
@@ -106,7 +119,9 @@ module Aws
106
119
  # object.copy_to('src-bucket/src-key', multipart_copy: true)
107
120
  #
108
121
  def copy_to(target, options = {})
109
- ObjectCopier.new(self, options).copy_to(target, options)
122
+ Aws::Plugins::UserAgent.feature('resource') do
123
+ ObjectCopier.new(self, options).copy_to(target, options)
124
+ end
110
125
  end
111
126
 
112
127
  # Copies and deletes the current object. The object will only be deleted
@@ -338,6 +353,10 @@ module Aws
338
353
  # obj.upload_stream do |write_stream|
339
354
  # IO.copy_stream(STDIN, write_stream)
340
355
  # end
356
+ # @param [Hash] options
357
+ # Additional options for {Client#create_multipart_upload},
358
+ # {Client#complete_multipart_upload},
359
+ # and {Client#upload_part} can be provided.
341
360
  #
342
361
  # @option options [Integer] :thread_count (10) The number of parallel
343
362
  # multipart uploads
@@ -360,6 +379,9 @@ module Aws
360
379
  # @return [Boolean] Returns `true` when the object is uploaded
361
380
  # without any errors.
362
381
  #
382
+ # @see Client#create_multipart_upload
383
+ # @see Client#complete_multipart_upload
384
+ # @see Client#upload_part
363
385
  def upload_stream(options = {}, &block)
364
386
  uploading_options = options.dup
365
387
  uploader = MultipartStreamUploader.new(
@@ -368,10 +390,12 @@ module Aws
368
390
  tempfile: uploading_options.delete(:tempfile),
369
391
  part_size: uploading_options.delete(:part_size)
370
392
  )
371
- uploader.upload(
372
- uploading_options.merge(bucket: bucket_name, key: key),
373
- &block
374
- )
393
+ Aws::Plugins::UserAgent.feature('resource') do
394
+ uploader.upload(
395
+ uploading_options.merge(bucket: bucket_name, key: key),
396
+ &block
397
+ )
398
+ end
375
399
  true
376
400
  end
377
401
 
@@ -410,6 +434,13 @@ module Aws
410
434
  # using an open Tempfile, rewind it before uploading or else the object
411
435
  # will be empty.
412
436
  #
437
+ # @param [Hash] options
438
+ # Additional options for {Client#put_object}
439
+ # when file sizes below the multipart threshold. For files larger than
440
+ # the multipart threshold, options for {Client#create_multipart_upload},
441
+ # {Client#complete_multipart_upload},
442
+ # and {Client#upload_part} can be provided.
443
+ #
413
444
  # @option options [Integer] :multipart_threshold (104857600) Files larger
414
445
  # than or equal to `:multipart_threshold` are uploaded using the S3
415
446
  # multipart APIs.
@@ -431,16 +462,23 @@ module Aws
431
462
  #
432
463
  # @return [Boolean] Returns `true` when the object is uploaded
433
464
  # without any errors.
465
+ #
466
+ # @see Client#put_object
467
+ # @see Client#create_multipart_upload
468
+ # @see Client#complete_multipart_upload
469
+ # @see Client#upload_part
434
470
  def upload_file(source, options = {})
435
471
  uploading_options = options.dup
436
472
  uploader = FileUploader.new(
437
473
  multipart_threshold: uploading_options.delete(:multipart_threshold),
438
474
  client: client
439
475
  )
440
- response = uploader.upload(
441
- source,
442
- uploading_options.merge(bucket: bucket_name, key: key)
443
- )
476
+ response = Aws::Plugins::UserAgent.feature('resource') do
477
+ uploader.upload(
478
+ source,
479
+ uploading_options.merge(bucket: bucket_name, key: key)
480
+ )
481
+ end
444
482
  yield response if block_given?
445
483
  true
446
484
  end
@@ -456,8 +494,21 @@ module Aws
456
494
  # # and the parts are downloaded in parallel
457
495
  # obj.download_file('/path/to/very_large_file')
458
496
  #
497
+ # You can provide a callback to monitor progress of the download:
498
+ #
499
+ # # bytes and part_sizes are each an array with 1 entry per part
500
+ # # part_sizes may not be known until the first bytes are retrieved
501
+ # progress = Proc.new do |bytes, part_sizes, file_size|
502
+ # puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{part_sizes[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / file_size}%" }
503
+ # end
504
+ # obj.download_file('/path/to/file', progress_callback: progress)
505
+ #
459
506
  # @param [String] destination Where to download the file to.
460
507
  #
508
+ # @param [Hash] options
509
+ # Additional options for {Client#get_object} and #{Client#head_object}
510
+ # may be provided.
511
+ #
461
512
  # @option options [String] mode `auto`, `single_request`, `get_range`
462
513
  # `single_request` mode forces only 1 GET request is made in download,
463
514
  # `get_range` mode allows `chunk_size` parameter to configured in
@@ -473,14 +524,39 @@ module Aws
473
524
  # retrieve the object. For more about object versioning, see:
474
525
  # https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html
475
526
  #
527
+ # @option options [String] checksum_mode (ENABLED) When `ENABLED` and
528
+ # the object has a stored checksum, it will be used to validate the
529
+ # download and will raise an `Aws::Errors::ChecksumError` if
530
+ # checksum validation fails. You may provide a `on_checksum_validated`
531
+ # callback if you need to verify that validation occurred and which
532
+ # algorithm was used. To disable checksum validation, set
533
+ # `checksum_mode` to "DISABLED".
534
+ #
535
+ # @option options [Callable] on_checksum_validated Called each time a
536
+ # request's checksum is validated with the checksum algorithm and the
537
+ # response. For multipart downloads, this will be called for each
538
+ # part that is downloaded and validated.
539
+ #
540
+ # @option options [Proc] :progress_callback
541
+ # A Proc that will be called when each chunk of the download is received.
542
+ # It will be invoked with [bytes_read], [part_sizes], file_size.
543
+ # When the object is downloaded as parts (rather than by ranges), the
544
+ # part_sizes will not be known ahead of time and will be nil in the
545
+ # callback until the first bytes in the part are received.
546
+ #
476
547
  # @return [Boolean] Returns `true` when the file is downloaded without
477
548
  # any errors.
549
+ #
550
+ # @see Client#get_object
551
+ # @see Client#head_object
478
552
  def download_file(destination, options = {})
479
553
  downloader = FileDownloader.new(client: client)
480
- downloader.download(
481
- destination,
482
- options.merge(bucket: bucket_name, key: key)
483
- )
554
+ Aws::Plugins::UserAgent.feature('resource') do
555
+ downloader.download(
556
+ destination,
557
+ options.merge(bucket: bucket_name, key: key)
558
+ )
559
+ end
484
560
  true
485
561
  end
486
562
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Types
6
+ # This error is not modeled.
7
+ #
8
+ # The bucket you are attempting to access must be addressed using the
9
+ # specified endpoint. Please send all future requests to this endpoint.
10
+ #
11
+ # @!attribute [rw] endpoint
12
+ # @return [String]
13
+ #
14
+ # @!attribute [rw] bucket
15
+ # @return [String]
16
+ #
17
+ # @!attribute [rw] message
18
+ # @return [String]
19
+ #
20
+ class PermanentRedirect < Struct.new(:endpoint, :bucket, :region, :message)
21
+ SENSITIVE = []
22
+ include Aws::Structure
23
+ end
24
+ end
25
+ end
26
+ end
@@ -18,10 +18,12 @@ require 'aws-sdk-s3/presigner'
18
18
 
19
19
  # customizations to generated classes
20
20
  require 'aws-sdk-s3/customizations/bucket'
21
+ require 'aws-sdk-s3/customizations/errors'
21
22
  require 'aws-sdk-s3/customizations/object'
22
23
  require 'aws-sdk-s3/customizations/object_summary'
23
24
  require 'aws-sdk-s3/customizations/multipart_upload'
24
25
  require 'aws-sdk-s3/customizations/types/list_object_versions_output'
26
+ require 'aws-sdk-s3/customizations/types/permanent_redirect'
25
27
 
26
28
  [
27
29
  Aws::S3::Object::Collection,
@@ -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
@@ -173,6 +173,7 @@ module Aws
173
173
  auth_tag = context.client.get_object(
174
174
  bucket: context.params[:bucket],
175
175
  key: context.params[:key],
176
+ version_id: context.params[:version_id],
176
177
  range: "bytes=-#{auth_tag_length}"
177
178
  ).body.read
178
179
 
@@ -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
@@ -0,0 +1,146 @@
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/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::S3
11
+ # Endpoint parameters used to influence endpoints per request.
12
+ #
13
+ # @!attribute bucket
14
+ # The S3 bucket used to send the request. This is an optional parameter that will be set automatically for operations that are scoped to an S3 bucket.
15
+ #
16
+ # @return [String]
17
+ #
18
+ # @!attribute region
19
+ # The AWS region used to dispatch the request.
20
+ #
21
+ # @return [String]
22
+ #
23
+ # @!attribute use_fips
24
+ # When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
25
+ #
26
+ # @return [Boolean]
27
+ #
28
+ # @!attribute use_dual_stack
29
+ # When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
30
+ #
31
+ # @return [Boolean]
32
+ #
33
+ # @!attribute endpoint
34
+ # Override the endpoint used to send this request
35
+ #
36
+ # @return [String]
37
+ #
38
+ # @!attribute force_path_style
39
+ # When true, force a path-style endpoint to be used where the bucket name is part of the path.
40
+ #
41
+ # @return [Boolean]
42
+ #
43
+ # @!attribute accelerate
44
+ # When true, use S3 Accelerate. NOTE: Not all regions support S3 accelerate.
45
+ #
46
+ # @return [Boolean]
47
+ #
48
+ # @!attribute use_global_endpoint
49
+ # Whether the global endpoint should be used, rather then the regional endpoint for us-east-1.
50
+ #
51
+ # @return [Boolean]
52
+ #
53
+ # @!attribute use_object_lambda_endpoint
54
+ # Internal parameter to use object lambda endpoint for an operation (eg: WriteGetObjectResponse)
55
+ #
56
+ # @return [Boolean]
57
+ #
58
+ # @!attribute disable_access_points
59
+ # Internal parameter to disable Access Point Buckets
60
+ #
61
+ # @return [Boolean]
62
+ #
63
+ # @!attribute disable_multi_region_access_points
64
+ # Whether multi-region access points (MRAP) should be disabled.
65
+ #
66
+ # @return [Boolean]
67
+ #
68
+ # @!attribute use_arn_region
69
+ # When an Access Point ARN is provided and this flag is enabled, the SDK MUST use the ARN&#39;s region when constructing the endpoint instead of the client&#39;s configured region.
70
+ #
71
+ # @return [Boolean]
72
+ #
73
+ EndpointParameters = Struct.new(
74
+ :bucket,
75
+ :region,
76
+ :use_fips,
77
+ :use_dual_stack,
78
+ :endpoint,
79
+ :force_path_style,
80
+ :accelerate,
81
+ :use_global_endpoint,
82
+ :use_object_lambda_endpoint,
83
+ :disable_access_points,
84
+ :disable_multi_region_access_points,
85
+ :use_arn_region,
86
+ ) do
87
+ include Aws::Structure
88
+
89
+ # @api private
90
+ class << self
91
+ PARAM_MAP = {
92
+ 'Bucket' => :bucket,
93
+ 'Region' => :region,
94
+ 'UseFIPS' => :use_fips,
95
+ 'UseDualStack' => :use_dual_stack,
96
+ 'Endpoint' => :endpoint,
97
+ 'ForcePathStyle' => :force_path_style,
98
+ 'Accelerate' => :accelerate,
99
+ 'UseGlobalEndpoint' => :use_global_endpoint,
100
+ 'UseObjectLambdaEndpoint' => :use_object_lambda_endpoint,
101
+ 'DisableAccessPoints' => :disable_access_points,
102
+ 'DisableMultiRegionAccessPoints' => :disable_multi_region_access_points,
103
+ 'UseArnRegion' => :use_arn_region,
104
+ }.freeze
105
+ end
106
+
107
+ def initialize(options = {})
108
+ self[:bucket] = options[:bucket]
109
+ self[:region] = options[:region]
110
+ self[:use_fips] = options[:use_fips]
111
+ self[:use_fips] = false if self[:use_fips].nil?
112
+ if self[:use_fips].nil?
113
+ raise ArgumentError, "Missing required EndpointParameter: :use_fips"
114
+ end
115
+ self[:use_dual_stack] = options[:use_dual_stack]
116
+ self[:use_dual_stack] = false if self[:use_dual_stack].nil?
117
+ if self[:use_dual_stack].nil?
118
+ raise ArgumentError, "Missing required EndpointParameter: :use_dual_stack"
119
+ end
120
+ self[:endpoint] = options[:endpoint]
121
+ self[:force_path_style] = options[:force_path_style]
122
+ self[:force_path_style] = false if self[:force_path_style].nil?
123
+ if self[:force_path_style].nil?
124
+ raise ArgumentError, "Missing required EndpointParameter: :force_path_style"
125
+ end
126
+ self[:accelerate] = options[:accelerate]
127
+ self[:accelerate] = false if self[:accelerate].nil?
128
+ if self[:accelerate].nil?
129
+ raise ArgumentError, "Missing required EndpointParameter: :accelerate"
130
+ end
131
+ self[:use_global_endpoint] = options[:use_global_endpoint]
132
+ self[:use_global_endpoint] = false if self[:use_global_endpoint].nil?
133
+ if self[:use_global_endpoint].nil?
134
+ raise ArgumentError, "Missing required EndpointParameter: :use_global_endpoint"
135
+ end
136
+ self[:use_object_lambda_endpoint] = options[:use_object_lambda_endpoint]
137
+ self[:disable_access_points] = options[:disable_access_points]
138
+ self[:disable_multi_region_access_points] = options[:disable_multi_region_access_points]
139
+ self[:disable_multi_region_access_points] = false if self[:disable_multi_region_access_points].nil?
140
+ if self[:disable_multi_region_access_points].nil?
141
+ raise ArgumentError, "Missing required EndpointParameter: :disable_multi_region_access_points"
142
+ end
143
+ self[:use_arn_region] = options[:use_arn_region]
144
+ end
145
+ end
146
+ end