aws-sdk-s3 1.147.0 → 1.156.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +68 -2
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/access_grants_credentials.rb +57 -0
  5. data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +241 -0
  6. data/lib/aws-sdk-s3/bucket.rb +12 -12
  7. data/lib/aws-sdk-s3/bucket_acl.rb +3 -3
  8. data/lib/aws-sdk-s3/bucket_cors.rb +4 -4
  9. data/lib/aws-sdk-s3/bucket_lifecycle.rb +4 -4
  10. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +4 -4
  11. data/lib/aws-sdk-s3/bucket_logging.rb +3 -3
  12. data/lib/aws-sdk-s3/bucket_notification.rb +3 -3
  13. data/lib/aws-sdk-s3/bucket_policy.rb +4 -4
  14. data/lib/aws-sdk-s3/bucket_region_cache.rb +9 -5
  15. data/lib/aws-sdk-s3/bucket_request_payment.rb +3 -3
  16. data/lib/aws-sdk-s3/bucket_tagging.rb +4 -4
  17. data/lib/aws-sdk-s3/bucket_versioning.rb +5 -5
  18. data/lib/aws-sdk-s3/bucket_website.rb +4 -4
  19. data/lib/aws-sdk-s3/client.rb +214 -143
  20. data/lib/aws-sdk-s3/client_api.rb +11 -2
  21. data/lib/aws-sdk-s3/customizations/bucket.rb +1 -1
  22. data/lib/aws-sdk-s3/customizations/errors.rb +15 -2
  23. data/lib/aws-sdk-s3/customizations/object.rb +5 -5
  24. data/lib/aws-sdk-s3/customizations.rb +4 -1
  25. data/lib/aws-sdk-s3/encryption/client.rb +2 -2
  26. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +2 -2
  27. data/lib/aws-sdk-s3/encryptionV2/client.rb +2 -2
  28. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +2 -2
  29. data/lib/aws-sdk-s3/endpoint_parameters.rb +8 -0
  30. data/lib/aws-sdk-s3/endpoint_provider.rb +1 -0
  31. data/lib/aws-sdk-s3/endpoints.rb +100 -1
  32. data/lib/aws-sdk-s3/express_credentials_provider.rb +27 -4
  33. data/lib/aws-sdk-s3/file_downloader.rb +1 -1
  34. data/lib/aws-sdk-s3/file_uploader.rb +1 -1
  35. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +1 -1
  36. data/lib/aws-sdk-s3/multipart_upload.rb +4 -4
  37. data/lib/aws-sdk-s3/multipart_upload_part.rb +3 -3
  38. data/lib/aws-sdk-s3/object.rb +30 -12
  39. data/lib/aws-sdk-s3/object_acl.rb +3 -3
  40. data/lib/aws-sdk-s3/object_copier.rb +1 -1
  41. data/lib/aws-sdk-s3/object_multipart_copier.rb +10 -8
  42. data/lib/aws-sdk-s3/object_summary.rb +10 -10
  43. data/lib/aws-sdk-s3/object_version.rb +23 -5
  44. data/lib/aws-sdk-s3/plugins/access_grants.rb +114 -0
  45. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +8 -2
  46. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +53 -16
  47. data/lib/aws-sdk-s3/plugins/s3_signer.rb +7 -2
  48. data/lib/aws-sdk-s3/presigner.rb +1 -0
  49. data/lib/aws-sdk-s3/resource.rb +2 -2
  50. data/lib/aws-sdk-s3/types.rb +48 -17
  51. data/lib/aws-sdk-s3.rb +1 -1
  52. data/sig/client.rbs +21 -0
  53. data/sig/customizations/bucket.rbs +19 -0
  54. data/sig/customizations/object.rbs +38 -0
  55. data/sig/customizations/object_summary.rbs +35 -0
  56. data/sig/object.rbs +6 -0
  57. data/sig/object_version.rbs +6 -0
  58. data/sig/resource.rbs +3 -0
  59. data/sig/types.rbs +6 -0
  60. data/sig/waiters.rbs +12 -0
  61. metadata +12 -7
  62. data/lib/aws-sdk-s3/express_credentials_cache.rb +0 -30
@@ -2,30 +2,53 @@
2
2
 
3
3
  module Aws
4
4
  module S3
5
+ # @api private
6
+ def self.express_credentials_cache
7
+ @express_credentials_cache ||= LRUCache.new(max_entries: 100)
8
+ end
9
+
5
10
  # Returns Credentials class for S3 Express. Accepts CreateSession
6
11
  # params as options. See {Client#create_session} for details.
7
12
  class ExpressCredentialsProvider
8
13
  # @param [Hash] options
9
- # @option options [Client] :client The S3 client used to create the session.
14
+ # @option options [Client] :client The S3 client used to create the
15
+ # session.
10
16
  # @option options [String] :session_mode (see: {Client#create_session})
17
+ # @option options [Boolean] :caching (true) When true, credentials will
18
+ # be cached.
11
19
  # @option options [Callable] :before_refresh Proc called before
12
20
  # credentials are refreshed.
13
21
  def initialize(options = {})
14
22
  @client = options.delete(:client)
23
+ @caching = options.delete(:caching) != false
15
24
  @options = options
16
- @cache = EXPRESS_CREDENTIALS_CACHE
25
+ return unless @caching
26
+
27
+ @cache = Aws::S3.express_credentials_cache
17
28
  end
18
29
 
19
30
  def express_credentials_for(bucket)
20
- @cache[bucket] || new_credentials_for(bucket)
31
+ if @caching
32
+ cached_credentials_for(bucket)
33
+ else
34
+ new_credentials_for(bucket)
35
+ end
21
36
  end
22
37
 
23
38
  attr_accessor :client
24
39
 
25
40
  private
26
41
 
42
+ def cached_credentials_for(bucket)
43
+ if @cache.key?(bucket)
44
+ @cache[bucket]
45
+ else
46
+ @cache[bucket] = new_credentials_for(bucket)
47
+ end
48
+ end
49
+
27
50
  def new_credentials_for(bucket)
28
- @cache[bucket] = ExpressCredentials.new(
51
+ ExpressCredentials.new(
29
52
  bucket: bucket,
30
53
  client: @client,
31
54
  **@options
@@ -44,7 +44,7 @@ module Aws
44
44
 
45
45
  validate!
46
46
 
47
- Aws::Plugins::UserAgent.feature('s3-transfer') do
47
+ Aws::Plugins::UserAgent.metric('S3_TRANSFER') do
48
48
  case @mode
49
49
  when 'auto' then multipart_download
50
50
  when 'single_request' then single_request
@@ -37,7 +37,7 @@ module Aws
37
37
  # objects smaller than the multipart threshold.
38
38
  # @return [void]
39
39
  def upload(source, options = {})
40
- Aws::Plugins::UserAgent.feature('s3-transfer') do
40
+ Aws::Plugins::UserAgent.metric('S3_TRANSFER') do
41
41
  if File.size(source) >= multipart_threshold
42
42
  MultipartFileUploader.new(@options).upload(source, options)
43
43
  else
@@ -46,7 +46,7 @@ module Aws
46
46
  # @option options [Integer] :thread_count (THREAD_COUNT)
47
47
  # @return [Seahorse::Client::Response] - the CompleteMultipartUploadResponse
48
48
  def upload(options = {}, &block)
49
- Aws::Plugins::UserAgent.feature('s3-transfer') do
49
+ Aws::Plugins::UserAgent.metric('S3_TRANSFER') do
50
50
  upload_id = initiate_upload(options)
51
51
  parts = upload_parts(upload_id, options, &block)
52
52
  complete_upload(upload_id, parts, options)
@@ -227,7 +227,7 @@ module Aws::S3
227
227
  :retry
228
228
  end
229
229
  end
230
- Aws::Plugins::UserAgent.feature('resource') do
230
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
231
231
  Aws::Waiters::Waiter.new(options).wait({})
232
232
  end
233
233
  end
@@ -268,7 +268,7 @@ module Aws::S3
268
268
  key: @object_key,
269
269
  upload_id: @id
270
270
  )
271
- resp = Aws::Plugins::UserAgent.feature('resource') do
271
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
272
272
  @client.abort_multipart_upload(options)
273
273
  end
274
274
  resp.data
@@ -409,7 +409,7 @@ module Aws::S3
409
409
  key: @object_key,
410
410
  upload_id: @id
411
411
  )
412
- Aws::Plugins::UserAgent.feature('resource') do
412
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
413
413
  @client.complete_multipart_upload(options)
414
414
  end
415
415
  Object.new(
@@ -519,7 +519,7 @@ module Aws::S3
519
519
  key: @object_key,
520
520
  upload_id: @id
521
521
  )
522
- resp = Aws::Plugins::UserAgent.feature('resource') do
522
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
523
523
  @client.list_parts(options)
524
524
  end
525
525
  resp.each_page do |page|
@@ -262,7 +262,7 @@ module Aws::S3
262
262
  :retry
263
263
  end
264
264
  end
265
- Aws::Plugins::UserAgent.feature('resource') do
265
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
266
266
  Aws::Waiters::Waiter.new(options).wait({})
267
267
  end
268
268
  end
@@ -500,7 +500,7 @@ module Aws::S3
500
500
  upload_id: @multipart_upload_id,
501
501
  part_number: @part_number
502
502
  )
503
- resp = Aws::Plugins::UserAgent.feature('resource') do
503
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
504
504
  @client.upload_part_copy(options)
505
505
  end
506
506
  resp.data
@@ -650,7 +650,7 @@ module Aws::S3
650
650
  upload_id: @multipart_upload_id,
651
651
  part_number: @part_number
652
652
  )
653
- resp = Aws::Plugins::UserAgent.feature('resource') do
653
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
654
654
  @client.upload_part(options)
655
655
  end
656
656
  resp.data
@@ -500,7 +500,7 @@ module Aws::S3
500
500
  #
501
501
  # @return [self]
502
502
  def load
503
- resp = Aws::Plugins::UserAgent.feature('resource') do
503
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
504
504
  @client.head_object(
505
505
  bucket: @bucket_name,
506
506
  key: @key
@@ -550,7 +550,7 @@ module Aws::S3
550
550
  options, params = separate_params_and_options(options)
551
551
  waiter = Waiters::ObjectExists.new(options)
552
552
  yield_waiter_and_warn(waiter, &block) if block_given?
553
- Aws::Plugins::UserAgent.feature('resource') do
553
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
554
554
  waiter.wait(params.merge(bucket: @bucket_name,
555
555
  key: @key))
556
556
  end
@@ -571,7 +571,7 @@ module Aws::S3
571
571
  options, params = separate_params_and_options(options)
572
572
  waiter = Waiters::ObjectNotExists.new(options)
573
573
  yield_waiter_and_warn(waiter, &block) if block_given?
574
- Aws::Plugins::UserAgent.feature('resource') do
574
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
575
575
  waiter.wait(params.merge(bucket: @bucket_name,
576
576
  key: @key))
577
577
  end
@@ -676,7 +676,7 @@ module Aws::S3
676
676
  :retry
677
677
  end
678
678
  end
679
- Aws::Plugins::UserAgent.feature('resource') do
679
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
680
680
  Aws::Waiters::Waiter.new(options).wait({})
681
681
  end
682
682
  end
@@ -1346,7 +1346,7 @@ module Aws::S3
1346
1346
  bucket: @bucket_name,
1347
1347
  key: @key
1348
1348
  )
1349
- resp = Aws::Plugins::UserAgent.feature('resource') do
1349
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
1350
1350
  @client.copy_object(options)
1351
1351
  end
1352
1352
  resp.data
@@ -1412,7 +1412,7 @@ module Aws::S3
1412
1412
  bucket: @bucket_name,
1413
1413
  key: @key
1414
1414
  )
1415
- resp = Aws::Plugins::UserAgent.feature('resource') do
1415
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
1416
1416
  @client.delete_object(options)
1417
1417
  end
1418
1418
  resp.data
@@ -1668,7 +1668,7 @@ module Aws::S3
1668
1668
  bucket: @bucket_name,
1669
1669
  key: @key
1670
1670
  )
1671
- resp = Aws::Plugins::UserAgent.feature('resource') do
1671
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
1672
1672
  @client.get_object(options, &block)
1673
1673
  end
1674
1674
  resp.data
@@ -2153,7 +2153,7 @@ module Aws::S3
2153
2153
  bucket: @bucket_name,
2154
2154
  key: @key
2155
2155
  )
2156
- resp = Aws::Plugins::UserAgent.feature('resource') do
2156
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
2157
2157
  @client.create_multipart_upload(options)
2158
2158
  end
2159
2159
  MultipartUpload.new(
@@ -2624,7 +2624,7 @@ module Aws::S3
2624
2624
  bucket: @bucket_name,
2625
2625
  key: @key
2626
2626
  )
2627
- resp = Aws::Plugins::UserAgent.feature('resource') do
2627
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
2628
2628
  @client.put_object(options)
2629
2629
  end
2630
2630
  resp.data
@@ -2765,7 +2765,7 @@ module Aws::S3
2765
2765
  bucket: @bucket_name,
2766
2766
  key: @key
2767
2767
  )
2768
- resp = Aws::Plugins::UserAgent.feature('resource') do
2768
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
2769
2769
  @client.restore_object(options)
2770
2770
  end
2771
2771
  resp.data
@@ -2779,6 +2779,12 @@ module Aws::S3
2779
2779
  # if_none_match: "IfNoneMatch",
2780
2780
  # if_unmodified_since: Time.now,
2781
2781
  # range: "Range",
2782
+ # response_cache_control: "ResponseCacheControl",
2783
+ # response_content_disposition: "ResponseContentDisposition",
2784
+ # response_content_encoding: "ResponseContentEncoding",
2785
+ # response_content_language: "ResponseContentLanguage",
2786
+ # response_content_type: "ResponseContentType",
2787
+ # response_expires: Time.now,
2782
2788
  # version_id: "ObjectVersionId",
2783
2789
  # sse_customer_algorithm: "SSECustomerAlgorithm",
2784
2790
  # sse_customer_key: "SSECustomerKey",
@@ -2866,6 +2872,18 @@ module Aws::S3
2866
2872
  # satisfiable, only the `ContentLength` is affected in the response. If
2867
2873
  # the Range is not satisfiable, S3 returns a `416 - Requested Range Not
2868
2874
  # Satisfiable` error.
2875
+ # @option options [String] :response_cache_control
2876
+ # Sets the `Cache-Control` header of the response.
2877
+ # @option options [String] :response_content_disposition
2878
+ # Sets the `Content-Disposition` header of the response.
2879
+ # @option options [String] :response_content_encoding
2880
+ # Sets the `Content-Encoding` header of the response.
2881
+ # @option options [String] :response_content_language
2882
+ # Sets the `Content-Language` header of the response.
2883
+ # @option options [String] :response_content_type
2884
+ # Sets the `Content-Type` header of the response.
2885
+ # @option options [Time,DateTime,Date,Integer,String] :response_expires
2886
+ # Sets the `Expires` header of the response.
2869
2887
  # @option options [String] :version_id
2870
2888
  # Version ID used to reference a specific version of the object.
2871
2889
  #
@@ -2936,7 +2954,7 @@ module Aws::S3
2936
2954
  bucket: @bucket_name,
2937
2955
  key: @key
2938
2956
  )
2939
- resp = Aws::Plugins::UserAgent.feature('resource') do
2957
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
2940
2958
  @client.head_object(options)
2941
2959
  end
2942
2960
  resp.data
@@ -3154,7 +3172,7 @@ module Aws::S3
3154
3172
  key: item.key
3155
3173
  }
3156
3174
  end
3157
- Aws::Plugins::UserAgent.feature('resource') do
3175
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
3158
3176
  batch[0].client.delete_objects(params)
3159
3177
  end
3160
3178
  end
@@ -79,7 +79,7 @@ module Aws::S3
79
79
  #
80
80
  # @return [self]
81
81
  def load
82
- resp = Aws::Plugins::UserAgent.feature('resource') do
82
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
83
83
  @client.get_object_acl(
84
84
  bucket: @bucket_name,
85
85
  key: @object_key
@@ -199,7 +199,7 @@ module Aws::S3
199
199
  :retry
200
200
  end
201
201
  end
202
- Aws::Plugins::UserAgent.feature('resource') do
202
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
203
203
  Aws::Waiters::Waiter.new(options).wait({})
204
204
  end
205
205
  end
@@ -332,7 +332,7 @@ module Aws::S3
332
332
  bucket: @bucket_name,
333
333
  key: @object_key
334
334
  )
335
- resp = Aws::Plugins::UserAgent.feature('resource') do
335
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
336
336
  @client.put_object_acl(options)
337
337
  end
338
338
  resp.data
@@ -28,7 +28,7 @@ module Aws
28
28
  options[:bucket] = target_bucket
29
29
  options[:key] = target_key
30
30
  options[:copy_source] = copy_source(source)
31
- Aws::Plugins::UserAgent.feature('s3-transfer') do
31
+ Aws::Plugins::UserAgent.metric('S3_TRANSFER') do
32
32
  if options.delete(:multipart_copy)
33
33
  apply_source_client(source, options)
34
34
  ObjectMultipartCopier.new(@options).copy(options)
@@ -138,9 +138,7 @@ module Aws
138
138
  end
139
139
 
140
140
  def source_metadata(options)
141
- if options[:content_length]
142
- return { content_length: options.delete(:content_length) }
143
- end
141
+ return options.slice(:content_length) if options[:content_length]
144
142
 
145
143
  client = options[:copy_source_client] || @client
146
144
 
@@ -150,11 +148,15 @@ module Aws
150
148
  bucket, key = options[:copy_source].match(/([^\/]+?)\/(.+)/)[1,2]
151
149
  end
152
150
 
153
- key = CGI.unescape(key)
154
- opts = { bucket: bucket, key: key }
155
- opts[:version_id] = version_id if version_id
156
- opts[:part_number] = options[:part_number] if options[:part_number]
157
- client.head_object(opts).to_h
151
+ head_opts = { bucket: bucket, key: CGI.unescape(key) }.tap { |opts|
152
+ opts[:version_id] = version_id if version_id
153
+ opts[:part_number] = options[:part_number] if options[:part_number]
154
+ }
155
+
156
+ client.head_object(head_opts).to_h.tap { |head|
157
+ head.delete(:server_side_encryption)
158
+ head.delete(:ssekms_key_id)
159
+ }
158
160
  end
159
161
 
160
162
  def default_part_size(source_size)
@@ -186,7 +186,7 @@ module Aws::S3
186
186
  options, params = separate_params_and_options(options)
187
187
  waiter = Waiters::ObjectExists.new(options)
188
188
  yield_waiter_and_warn(waiter, &block) if block_given?
189
- Aws::Plugins::UserAgent.feature('resource') do
189
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
190
190
  waiter.wait(params.merge(bucket: @bucket_name,
191
191
  key: @key))
192
192
  end
@@ -207,7 +207,7 @@ module Aws::S3
207
207
  options, params = separate_params_and_options(options)
208
208
  waiter = Waiters::ObjectNotExists.new(options)
209
209
  yield_waiter_and_warn(waiter, &block) if block_given?
210
- Aws::Plugins::UserAgent.feature('resource') do
210
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
211
211
  waiter.wait(params.merge(bucket: @bucket_name,
212
212
  key: @key))
213
213
  end
@@ -312,7 +312,7 @@ module Aws::S3
312
312
  :retry
313
313
  end
314
314
  end
315
- Aws::Plugins::UserAgent.feature('resource') do
315
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
316
316
  Aws::Waiters::Waiter.new(options).wait({})
317
317
  end
318
318
  end
@@ -982,7 +982,7 @@ module Aws::S3
982
982
  bucket: @bucket_name,
983
983
  key: @key
984
984
  )
985
- resp = Aws::Plugins::UserAgent.feature('resource') do
985
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
986
986
  @client.copy_object(options)
987
987
  end
988
988
  resp.data
@@ -1048,7 +1048,7 @@ module Aws::S3
1048
1048
  bucket: @bucket_name,
1049
1049
  key: @key
1050
1050
  )
1051
- resp = Aws::Plugins::UserAgent.feature('resource') do
1051
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
1052
1052
  @client.delete_object(options)
1053
1053
  end
1054
1054
  resp.data
@@ -1304,7 +1304,7 @@ module Aws::S3
1304
1304
  bucket: @bucket_name,
1305
1305
  key: @key
1306
1306
  )
1307
- resp = Aws::Plugins::UserAgent.feature('resource') do
1307
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
1308
1308
  @client.get_object(options, &block)
1309
1309
  end
1310
1310
  resp.data
@@ -1789,7 +1789,7 @@ module Aws::S3
1789
1789
  bucket: @bucket_name,
1790
1790
  key: @key
1791
1791
  )
1792
- resp = Aws::Plugins::UserAgent.feature('resource') do
1792
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
1793
1793
  @client.create_multipart_upload(options)
1794
1794
  end
1795
1795
  MultipartUpload.new(
@@ -2260,7 +2260,7 @@ module Aws::S3
2260
2260
  bucket: @bucket_name,
2261
2261
  key: @key
2262
2262
  )
2263
- resp = Aws::Plugins::UserAgent.feature('resource') do
2263
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
2264
2264
  @client.put_object(options)
2265
2265
  end
2266
2266
  resp.data
@@ -2401,7 +2401,7 @@ module Aws::S3
2401
2401
  bucket: @bucket_name,
2402
2402
  key: @key
2403
2403
  )
2404
- resp = Aws::Plugins::UserAgent.feature('resource') do
2404
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
2405
2405
  @client.restore_object(options)
2406
2406
  end
2407
2407
  resp.data
@@ -2628,7 +2628,7 @@ module Aws::S3
2628
2628
  key: item.key
2629
2629
  }
2630
2630
  end
2631
- Aws::Plugins::UserAgent.feature('resource') do
2631
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
2632
2632
  batch[0].client.delete_objects(params)
2633
2633
  end
2634
2634
  end
@@ -243,7 +243,7 @@ module Aws::S3
243
243
  :retry
244
244
  end
245
245
  end
246
- Aws::Plugins::UserAgent.feature('resource') do
246
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
247
247
  Aws::Waiters::Waiter.new(options).wait({})
248
248
  end
249
249
  end
@@ -303,7 +303,7 @@ module Aws::S3
303
303
  key: @object_key,
304
304
  version_id: @id
305
305
  )
306
- resp = Aws::Plugins::UserAgent.feature('resource') do
306
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
307
307
  @client.delete_object(options)
308
308
  end
309
309
  resp.data
@@ -530,7 +530,7 @@ module Aws::S3
530
530
  key: @object_key,
531
531
  version_id: @id
532
532
  )
533
- resp = Aws::Plugins::UserAgent.feature('resource') do
533
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
534
534
  @client.get_object(options, &block)
535
535
  end
536
536
  resp.data
@@ -544,6 +544,12 @@ module Aws::S3
544
544
  # if_none_match: "IfNoneMatch",
545
545
  # if_unmodified_since: Time.now,
546
546
  # range: "Range",
547
+ # response_cache_control: "ResponseCacheControl",
548
+ # response_content_disposition: "ResponseContentDisposition",
549
+ # response_content_encoding: "ResponseContentEncoding",
550
+ # response_content_language: "ResponseContentLanguage",
551
+ # response_content_type: "ResponseContentType",
552
+ # response_expires: Time.now,
547
553
  # sse_customer_algorithm: "SSECustomerAlgorithm",
548
554
  # sse_customer_key: "SSECustomerKey",
549
555
  # sse_customer_key_md5: "SSECustomerKeyMD5",
@@ -630,6 +636,18 @@ module Aws::S3
630
636
  # satisfiable, only the `ContentLength` is affected in the response. If
631
637
  # the Range is not satisfiable, S3 returns a `416 - Requested Range Not
632
638
  # Satisfiable` error.
639
+ # @option options [String] :response_cache_control
640
+ # Sets the `Cache-Control` header of the response.
641
+ # @option options [String] :response_content_disposition
642
+ # Sets the `Content-Disposition` header of the response.
643
+ # @option options [String] :response_content_encoding
644
+ # Sets the `Content-Encoding` header of the response.
645
+ # @option options [String] :response_content_language
646
+ # Sets the `Content-Language` header of the response.
647
+ # @option options [String] :response_content_type
648
+ # Sets the `Content-Type` header of the response.
649
+ # @option options [Time,DateTime,Date,Integer,String] :response_expires
650
+ # Sets the `Expires` header of the response.
633
651
  # @option options [String] :sse_customer_algorithm
634
652
  # Specifies the algorithm to use when encrypting the object (for
635
653
  # example, AES256).
@@ -694,7 +712,7 @@ module Aws::S3
694
712
  key: @object_key,
695
713
  version_id: @id
696
714
  )
697
- resp = Aws::Plugins::UserAgent.feature('resource') do
715
+ resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
698
716
  @client.head_object(options)
699
717
  end
700
718
  resp.data
@@ -868,7 +886,7 @@ module Aws::S3
868
886
  version_id: item.id
869
887
  }
870
888
  end
871
- Aws::Plugins::UserAgent.feature('resource') do
889
+ Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
872
890
  batch[0].client.delete_objects(params)
873
891
  end
874
892
  end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Plugins
6
+ # @api private
7
+ class AccessGrants < Seahorse::Client::Plugin
8
+ @s3control =
9
+ begin
10
+ require 'aws-sdk-s3control'
11
+ true
12
+ rescue LoadError
13
+ false
14
+ end
15
+
16
+ option(
17
+ :access_grants,
18
+ default: false,
19
+ doc_type: 'Boolean',
20
+ docstring: <<-DOCS)
21
+ When `true`, the S3 client will use the S3 Access Grants feature to
22
+ authenticate requests. Bucket credentials will be fetched from S3
23
+ Control using the `get_data_access` API.
24
+ DOCS
25
+
26
+ option(:access_grants_credentials_provider,
27
+ doc_type: 'Aws::S3::AccessGrantsCredentialsProvider',
28
+ rbs_type: 'untyped',
29
+ docstring: <<-DOCS) do |_cfg|
30
+ When `access_grants` is `true`, this option can be used to provide
31
+ additional options to the credentials provider, including a privilege
32
+ setting, caching, and fallback behavior.
33
+ DOCS
34
+ Aws::S3::AccessGrantsCredentialsProvider.new
35
+ end
36
+
37
+ # @api private
38
+ class Handler < Seahorse::Client::Handler
39
+ PERMISSION_MAP = {
40
+ head_object: 'READ',
41
+ get_object: 'READ',
42
+ get_object_acl: 'READ',
43
+ list_multipart_uploads: 'READ',
44
+ list_objects_v2: 'READ',
45
+ list_object_versions: 'READ',
46
+ list_parts: 'READ',
47
+ put_object: 'WRITE',
48
+ put_object_acl: 'WRITE',
49
+ delete_object: 'WRITE',
50
+ abort_multipart_upload: 'WRITE',
51
+ create_multipart_upload: 'WRITE',
52
+ upload_part: 'WRITE',
53
+ complete_multipart_upload: 'WRITE'
54
+ }.freeze
55
+
56
+ def call(context)
57
+ if access_grants_operation?(context) &&
58
+ !s3_express_endpoint?(context)
59
+ params = context[:endpoint_params]
60
+ permission = PERMISSION_MAP[context.operation_name]
61
+
62
+ provider = context.config.access_grants_credentials_provider
63
+ credentials = provider.access_grants_credentials_for(
64
+ bucket: params[:bucket],
65
+ key: params[:key],
66
+ prefix: params[:prefix],
67
+ permission: permission
68
+ )
69
+ context[:sigv4_credentials] = credentials # Sign will use this
70
+ end
71
+
72
+ with_metric(credentials) { @handler.call(context) }
73
+ end
74
+
75
+ private
76
+
77
+ def with_metric(credentials, &block)
78
+ return block.call unless credentials
79
+
80
+ Aws::Plugins::UserAgent.metric('S3_ACCESS_GRANTS', &block)
81
+ end
82
+
83
+ def access_grants_operation?(context)
84
+ params = context[:endpoint_params]
85
+ params[:bucket] && PERMISSION_MAP[context.operation_name]
86
+ end
87
+
88
+ def s3_express_endpoint?(context)
89
+ context[:endpoint_properties]['backend'] == 'S3Express'
90
+ end
91
+ end
92
+
93
+ def add_handlers(handlers, config)
94
+ return unless AccessGrants.s3control? && config.access_grants
95
+
96
+ handlers.add(Handler)
97
+ end
98
+
99
+ def after_initialize(client)
100
+ return unless AccessGrants.s3control? && client.config.access_grants
101
+
102
+ provider = client.config.access_grants_credentials_provider
103
+ provider.s3_client = client unless provider.s3_client
104
+ end
105
+
106
+ class << self
107
+ def s3control?
108
+ @s3control
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -31,7 +31,7 @@ for different buckets.
31
31
  def call(context)
32
32
  if (props = context[:endpoint_properties])
33
33
  # S3 Express endpoint - turn off md5 and enable crc32 default
34
- if (backend = props['backend']) && backend == 'S3Express'
34
+ if props['backend'] == 'S3Express'
35
35
  if context.operation_name == :put_object || checksum_required?(context)
36
36
  context[:default_request_checksum_algorithm] = 'CRC32'
37
37
  end
@@ -47,11 +47,17 @@ for different buckets.
47
47
  context[:sigv4_credentials] = credentials # Sign will use this
48
48
  end
49
49
  end
50
- @handler.call(context)
50
+ with_metric(credentials) { @handler.call(context) }
51
51
  end
52
52
 
53
53
  private
54
54
 
55
+ def with_metric(credentials, &block)
56
+ return block.call unless credentials
57
+
58
+ Aws::Plugins::UserAgent.metric('S3_EXPRESS_BUCKET', &block)
59
+ end
60
+
55
61
  def checksum_required?(context)
56
62
  context.operation.http_checksum_required ||
57
63
  (context.operation.http_checksum &&