aws-sdk-s3 1.147.0 → 1.152.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -2
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/access_grants_credentials.rb +57 -0
- data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +241 -0
- data/lib/aws-sdk-s3/bucket.rb +10 -10
- data/lib/aws-sdk-s3/bucket_acl.rb +3 -3
- data/lib/aws-sdk-s3/bucket_cors.rb +4 -4
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +4 -4
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +4 -4
- data/lib/aws-sdk-s3/bucket_logging.rb +3 -3
- data/lib/aws-sdk-s3/bucket_notification.rb +3 -3
- data/lib/aws-sdk-s3/bucket_policy.rb +4 -4
- data/lib/aws-sdk-s3/bucket_region_cache.rb +9 -5
- data/lib/aws-sdk-s3/bucket_request_payment.rb +3 -3
- data/lib/aws-sdk-s3/bucket_tagging.rb +4 -4
- data/lib/aws-sdk-s3/bucket_versioning.rb +5 -5
- data/lib/aws-sdk-s3/bucket_website.rb +4 -4
- data/lib/aws-sdk-s3/client.rb +174 -138
- data/lib/aws-sdk-s3/client_api.rb +3 -2
- data/lib/aws-sdk-s3/customizations/bucket.rb +1 -1
- data/lib/aws-sdk-s3/customizations/errors.rb +15 -2
- data/lib/aws-sdk-s3/customizations/object.rb +5 -5
- data/lib/aws-sdk-s3/customizations.rb +4 -1
- data/lib/aws-sdk-s3/encryption/client.rb +2 -2
- data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +2 -2
- data/lib/aws-sdk-s3/encryptionV2/client.rb +2 -2
- data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +2 -2
- data/lib/aws-sdk-s3/endpoint_parameters.rb +8 -0
- data/lib/aws-sdk-s3/endpoint_provider.rb +1 -0
- data/lib/aws-sdk-s3/endpoints.rb +100 -1
- data/lib/aws-sdk-s3/express_credentials_provider.rb +27 -4
- data/lib/aws-sdk-s3/file_downloader.rb +1 -1
- data/lib/aws-sdk-s3/file_uploader.rb +1 -1
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +1 -1
- data/lib/aws-sdk-s3/multipart_upload.rb +4 -4
- data/lib/aws-sdk-s3/multipart_upload_part.rb +3 -3
- data/lib/aws-sdk-s3/object.rb +12 -12
- data/lib/aws-sdk-s3/object_acl.rb +3 -3
- data/lib/aws-sdk-s3/object_copier.rb +1 -1
- data/lib/aws-sdk-s3/object_multipart_copier.rb +10 -8
- data/lib/aws-sdk-s3/object_summary.rb +10 -10
- data/lib/aws-sdk-s3/object_version.rb +5 -5
- data/lib/aws-sdk-s3/plugins/access_grants.rb +114 -0
- data/lib/aws-sdk-s3/plugins/express_session_auth.rb +8 -2
- data/lib/aws-sdk-s3/plugins/http_200_errors.rb +53 -16
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +7 -2
- data/lib/aws-sdk-s3/presigner.rb +1 -0
- data/lib/aws-sdk-s3/resource.rb +2 -2
- data/lib/aws-sdk-s3.rb +1 -1
- data/sig/client.rbs +2 -0
- data/sig/customizations/bucket.rbs +19 -0
- data/sig/customizations/object.rbs +38 -0
- data/sig/customizations/object_summary.rbs +35 -0
- data/sig/resource.rbs +2 -0
- metadata +10 -5
- 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
|
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
|
-
|
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
|
-
@
|
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
|
-
|
51
|
+
ExpressCredentials.new(
|
29
52
|
bucket: bucket,
|
30
53
|
client: @client,
|
31
54
|
**@options
|
@@ -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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
653
|
+
resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
654
654
|
@client.upload_part(options)
|
655
655
|
end
|
656
656
|
resp.data
|
data/lib/aws-sdk-s3/object.rb
CHANGED
@@ -500,7 +500,7 @@ module Aws::S3
|
|
500
500
|
#
|
501
501
|
# @return [self]
|
502
502
|
def load
|
503
|
-
resp = Aws::Plugins::UserAgent.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
2768
|
+
resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
2769
2769
|
@client.restore_object(options)
|
2770
2770
|
end
|
2771
2771
|
resp.data
|
@@ -2936,7 +2936,7 @@ module Aws::S3
|
|
2936
2936
|
bucket: @bucket_name,
|
2937
2937
|
key: @key
|
2938
2938
|
)
|
2939
|
-
resp = Aws::Plugins::UserAgent.
|
2939
|
+
resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
2940
2940
|
@client.head_object(options)
|
2941
2941
|
end
|
2942
2942
|
resp.data
|
@@ -3154,7 +3154,7 @@ module Aws::S3
|
|
3154
3154
|
key: item.key
|
3155
3155
|
}
|
3156
3156
|
end
|
3157
|
-
Aws::Plugins::UserAgent.
|
3157
|
+
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
3158
3158
|
batch[0].client.delete_objects(params)
|
3159
3159
|
end
|
3160
3160
|
end
|
@@ -79,7 +79,7 @@ module Aws::S3
|
|
79
79
|
#
|
80
80
|
# @return [self]
|
81
81
|
def load
|
82
|
-
resp = Aws::Plugins::UserAgent.
|
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.
|
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.
|
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.
|
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
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
533
|
+
resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
534
534
|
@client.get_object(options, &block)
|
535
535
|
end
|
536
536
|
resp.data
|
@@ -694,7 +694,7 @@ module Aws::S3
|
|
694
694
|
key: @object_key,
|
695
695
|
version_id: @id
|
696
696
|
)
|
697
|
-
resp = Aws::Plugins::UserAgent.
|
697
|
+
resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
698
698
|
@client.head_object(options)
|
699
699
|
end
|
700
700
|
resp.data
|
@@ -868,7 +868,7 @@ module Aws::S3
|
|
868
868
|
version_id: item.id
|
869
869
|
}
|
870
870
|
end
|
871
|
-
Aws::Plugins::UserAgent.
|
871
|
+
Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
872
872
|
batch[0].client.delete_objects(params)
|
873
873
|
end
|
874
874
|
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
|
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 &&
|