aws-sdk-s3 1.156.0 → 1.162.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +12 -3
- data/lib/aws-sdk-s3/bucket.rb +79 -16
- data/lib/aws-sdk-s3/client.rb +565 -313
- data/lib/aws-sdk-s3/client_api.rb +16 -1
- data/lib/aws-sdk-s3/endpoints.rb +99 -396
- data/lib/aws-sdk-s3/multipart_upload.rb +20 -0
- data/lib/aws-sdk-s3/object.rb +36 -4
- data/lib/aws-sdk-s3/object_summary.rb +28 -0
- data/lib/aws-sdk-s3/object_version.rb +17 -4
- data/lib/aws-sdk-s3/plugins/access_grants.rb +68 -4
- data/lib/aws-sdk-s3/plugins/endpoints.rb +10 -1
- data/lib/aws-sdk-s3/resource.rb +10 -8
- data/lib/aws-sdk-s3/types.rb +294 -47
- data/lib/aws-sdk-s3.rb +1 -1
- data/sig/bucket.rbs +1 -0
- data/sig/client.rbs +8 -1
- data/sig/multipart_upload.rbs +1 -0
- data/sig/object.rbs +1 -0
- data/sig/object_summary.rbs +1 -0
- data/sig/resource.rbs +3 -1
- data/sig/types.rbs +9 -0
- metadata +4 -4
@@ -295,6 +295,7 @@ module Aws::S3
|
|
295
295
|
# checksum_sha256: "ChecksumSHA256",
|
296
296
|
# request_payer: "requester", # accepts requester
|
297
297
|
# expected_bucket_owner: "AccountId",
|
298
|
+
# if_none_match: "IfNoneMatch",
|
298
299
|
# sse_customer_algorithm: "SSECustomerAlgorithm",
|
299
300
|
# sse_customer_key: "SSECustomerKey",
|
300
301
|
# sse_customer_key_md5: "SSECustomerKeyMD5",
|
@@ -362,6 +363,25 @@ module Aws::S3
|
|
362
363
|
# The account ID of the expected bucket owner. If the account ID that
|
363
364
|
# you provide does not match the actual owner of the bucket, the request
|
364
365
|
# fails with the HTTP status code `403 Forbidden` (access denied).
|
366
|
+
# @option options [String] :if_none_match
|
367
|
+
# Uploads the object only if the object key name does not already exist
|
368
|
+
# in the bucket specified. Otherwise, Amazon S3 returns a `412
|
369
|
+
# Precondition Failed` error.
|
370
|
+
#
|
371
|
+
# If a conflicting operation occurs during the upload S3 returns a `409
|
372
|
+
# ConditionalRequestConflict` response. On a 409 failure you should
|
373
|
+
# re-initiate the multipart upload with `CreateMultipartUpload` and
|
374
|
+
# re-upload each part.
|
375
|
+
#
|
376
|
+
# Expects the '*' (asterisk) character.
|
377
|
+
#
|
378
|
+
# For more information about conditional requests, see [RFC 7232][1], or
|
379
|
+
# [Conditional requests][2] in the *Amazon S3 User Guide*.
|
380
|
+
#
|
381
|
+
#
|
382
|
+
#
|
383
|
+
# [1]: https://tools.ietf.org/html/rfc7232
|
384
|
+
# [2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html
|
365
385
|
# @option options [String] :sse_customer_algorithm
|
366
386
|
# The server-side encryption (SSE) algorithm used to encrypt the object.
|
367
387
|
# This parameter is required only when the object was created using a
|
data/lib/aws-sdk-s3/object.rb
CHANGED
@@ -1662,6 +1662,15 @@ module Aws::S3
|
|
1662
1662
|
# fails with the HTTP status code `403 Forbidden` (access denied).
|
1663
1663
|
# @option options [String] :checksum_mode
|
1664
1664
|
# To retrieve the checksum, this mode must be enabled.
|
1665
|
+
#
|
1666
|
+
# In addition, if you enable checksum mode and the object is uploaded
|
1667
|
+
# with a [checksum][1] and encrypted with an Key Management Service
|
1668
|
+
# (KMS) key, you must have permission to use the `kms:Decrypt` action to
|
1669
|
+
# retrieve the checksum.
|
1670
|
+
#
|
1671
|
+
#
|
1672
|
+
#
|
1673
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Checksum.html
|
1665
1674
|
# @return [Types::GetObjectOutput]
|
1666
1675
|
def get(options = {}, &block)
|
1667
1676
|
options = options.merge(
|
@@ -2182,6 +2191,7 @@ module Aws::S3
|
|
2182
2191
|
# checksum_sha1: "ChecksumSHA1",
|
2183
2192
|
# checksum_sha256: "ChecksumSHA256",
|
2184
2193
|
# expires: Time.now,
|
2194
|
+
# if_none_match: "IfNoneMatch",
|
2185
2195
|
# grant_full_control: "GrantFullControl",
|
2186
2196
|
# grant_read: "GrantRead",
|
2187
2197
|
# grant_read_acp: "GrantReadACP",
|
@@ -2396,6 +2406,24 @@ module Aws::S3
|
|
2396
2406
|
#
|
2397
2407
|
#
|
2398
2408
|
# [1]: https://www.rfc-editor.org/rfc/rfc7234#section-5.3
|
2409
|
+
# @option options [String] :if_none_match
|
2410
|
+
# Uploads the object only if the object key name does not already exist
|
2411
|
+
# in the bucket specified. Otherwise, Amazon S3 returns a `412
|
2412
|
+
# Precondition Failed` error.
|
2413
|
+
#
|
2414
|
+
# If a conflicting operation occurs during the upload S3 returns a `409
|
2415
|
+
# ConditionalRequestConflict` response. On a 409 failure you should
|
2416
|
+
# retry the upload.
|
2417
|
+
#
|
2418
|
+
# Expects the '*' (asterisk) character.
|
2419
|
+
#
|
2420
|
+
# For more information about conditional requests, see [RFC 7232][1], or
|
2421
|
+
# [Conditional requests][2] in the *Amazon S3 User Guide*.
|
2422
|
+
#
|
2423
|
+
#
|
2424
|
+
#
|
2425
|
+
# [1]: https://tools.ietf.org/html/rfc7232
|
2426
|
+
# [2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html
|
2399
2427
|
# @option options [String] :grant_full_control
|
2400
2428
|
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
2401
2429
|
# object.
|
@@ -2944,10 +2972,14 @@ module Aws::S3
|
|
2944
2972
|
# @option options [String] :checksum_mode
|
2945
2973
|
# To retrieve the checksum, this parameter must be enabled.
|
2946
2974
|
#
|
2947
|
-
# In addition, if you enable
|
2948
|
-
# with
|
2949
|
-
# KMS), you must have permission to use the `kms:Decrypt` action
|
2950
|
-
#
|
2975
|
+
# In addition, if you enable checksum mode and the object is uploaded
|
2976
|
+
# with a [checksum][1] and encrypted with an Key Management Service
|
2977
|
+
# (KMS) key, you must have permission to use the `kms:Decrypt` action to
|
2978
|
+
# retrieve the checksum.
|
2979
|
+
#
|
2980
|
+
#
|
2981
|
+
#
|
2982
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Checksum.html
|
2951
2983
|
# @return [Types::HeadObjectOutput]
|
2952
2984
|
def head(options = {})
|
2953
2985
|
options = options.merge(
|
@@ -1298,6 +1298,15 @@ module Aws::S3
|
|
1298
1298
|
# fails with the HTTP status code `403 Forbidden` (access denied).
|
1299
1299
|
# @option options [String] :checksum_mode
|
1300
1300
|
# To retrieve the checksum, this mode must be enabled.
|
1301
|
+
#
|
1302
|
+
# In addition, if you enable checksum mode and the object is uploaded
|
1303
|
+
# with a [checksum][1] and encrypted with an Key Management Service
|
1304
|
+
# (KMS) key, you must have permission to use the `kms:Decrypt` action to
|
1305
|
+
# retrieve the checksum.
|
1306
|
+
#
|
1307
|
+
#
|
1308
|
+
#
|
1309
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Checksum.html
|
1301
1310
|
# @return [Types::GetObjectOutput]
|
1302
1311
|
def get(options = {}, &block)
|
1303
1312
|
options = options.merge(
|
@@ -1818,6 +1827,7 @@ module Aws::S3
|
|
1818
1827
|
# checksum_sha1: "ChecksumSHA1",
|
1819
1828
|
# checksum_sha256: "ChecksumSHA256",
|
1820
1829
|
# expires: Time.now,
|
1830
|
+
# if_none_match: "IfNoneMatch",
|
1821
1831
|
# grant_full_control: "GrantFullControl",
|
1822
1832
|
# grant_read: "GrantRead",
|
1823
1833
|
# grant_read_acp: "GrantReadACP",
|
@@ -2032,6 +2042,24 @@ module Aws::S3
|
|
2032
2042
|
#
|
2033
2043
|
#
|
2034
2044
|
# [1]: https://www.rfc-editor.org/rfc/rfc7234#section-5.3
|
2045
|
+
# @option options [String] :if_none_match
|
2046
|
+
# Uploads the object only if the object key name does not already exist
|
2047
|
+
# in the bucket specified. Otherwise, Amazon S3 returns a `412
|
2048
|
+
# Precondition Failed` error.
|
2049
|
+
#
|
2050
|
+
# If a conflicting operation occurs during the upload S3 returns a `409
|
2051
|
+
# ConditionalRequestConflict` response. On a 409 failure you should
|
2052
|
+
# retry the upload.
|
2053
|
+
#
|
2054
|
+
# Expects the '*' (asterisk) character.
|
2055
|
+
#
|
2056
|
+
# For more information about conditional requests, see [RFC 7232][1], or
|
2057
|
+
# [Conditional requests][2] in the *Amazon S3 User Guide*.
|
2058
|
+
#
|
2059
|
+
#
|
2060
|
+
#
|
2061
|
+
# [1]: https://tools.ietf.org/html/rfc7232
|
2062
|
+
# [2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html
|
2035
2063
|
# @option options [String] :grant_full_control
|
2036
2064
|
# Gives the grantee READ, READ\_ACP, and WRITE\_ACP permissions on the
|
2037
2065
|
# object.
|
@@ -523,6 +523,15 @@ module Aws::S3
|
|
523
523
|
# fails with the HTTP status code `403 Forbidden` (access denied).
|
524
524
|
# @option options [String] :checksum_mode
|
525
525
|
# To retrieve the checksum, this mode must be enabled.
|
526
|
+
#
|
527
|
+
# In addition, if you enable checksum mode and the object is uploaded
|
528
|
+
# with a [checksum][1] and encrypted with an Key Management Service
|
529
|
+
# (KMS) key, you must have permission to use the `kms:Decrypt` action to
|
530
|
+
# retrieve the checksum.
|
531
|
+
#
|
532
|
+
#
|
533
|
+
#
|
534
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Checksum.html
|
526
535
|
# @return [Types::GetObjectOutput]
|
527
536
|
def get(options = {}, &block)
|
528
537
|
options = options.merge(
|
@@ -701,10 +710,14 @@ module Aws::S3
|
|
701
710
|
# @option options [String] :checksum_mode
|
702
711
|
# To retrieve the checksum, this parameter must be enabled.
|
703
712
|
#
|
704
|
-
# In addition, if you enable
|
705
|
-
# with
|
706
|
-
# KMS), you must have permission to use the `kms:Decrypt` action
|
707
|
-
#
|
713
|
+
# In addition, if you enable checksum mode and the object is uploaded
|
714
|
+
# with a [checksum][1] and encrypted with an Key Management Service
|
715
|
+
# (KMS) key, you must have permission to use the `kms:Decrypt` action to
|
716
|
+
# retrieve the checksum.
|
717
|
+
#
|
718
|
+
#
|
719
|
+
#
|
720
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Checksum.html
|
708
721
|
# @return [Types::HeadObjectOutput]
|
709
722
|
def head(options = {})
|
710
723
|
options = options.merge(
|
@@ -44,25 +44,47 @@ setting, caching, and fallback behavior.
|
|
44
44
|
list_objects_v2: 'READ',
|
45
45
|
list_object_versions: 'READ',
|
46
46
|
list_parts: 'READ',
|
47
|
+
head_bucket: 'READ',
|
48
|
+
get_object_attributes: 'READ',
|
47
49
|
put_object: 'WRITE',
|
48
50
|
put_object_acl: 'WRITE',
|
49
51
|
delete_object: 'WRITE',
|
50
52
|
abort_multipart_upload: 'WRITE',
|
51
53
|
create_multipart_upload: 'WRITE',
|
52
54
|
upload_part: 'WRITE',
|
53
|
-
complete_multipart_upload: 'WRITE'
|
55
|
+
complete_multipart_upload: 'WRITE',
|
56
|
+
delete_objects: 'WRITE',
|
57
|
+
copy_object: 'READWRITE'
|
54
58
|
}.freeze
|
55
59
|
|
56
60
|
def call(context)
|
61
|
+
provider = context.config.access_grants_credentials_provider
|
62
|
+
|
57
63
|
if access_grants_operation?(context) &&
|
58
|
-
!s3_express_endpoint?(context)
|
64
|
+
!s3_express_endpoint?(context) &&
|
65
|
+
!credentials_head_bucket_call?(provider)
|
59
66
|
params = context[:endpoint_params]
|
60
67
|
permission = PERMISSION_MAP[context.operation_name]
|
61
68
|
|
62
|
-
|
69
|
+
key =
|
70
|
+
case context.operation_name
|
71
|
+
when :delete_objects
|
72
|
+
delete_params = context.params[:delete]
|
73
|
+
common_prefixes(delete_params[:objects].map { |o| o[:key] })
|
74
|
+
when :copy_object
|
75
|
+
source_bucket, source_key = params[:copy_source].split('/', 2)
|
76
|
+
if params[:bucket] != source_bucket
|
77
|
+
raise ArgumentError,
|
78
|
+
'source and destination bucket must be the same'
|
79
|
+
end
|
80
|
+
common_prefixes([params[:key], source_key])
|
81
|
+
else
|
82
|
+
params[:key]
|
83
|
+
end
|
84
|
+
|
63
85
|
credentials = provider.access_grants_credentials_for(
|
64
86
|
bucket: params[:bucket],
|
65
|
-
key:
|
87
|
+
key: key,
|
66
88
|
prefix: params[:prefix],
|
67
89
|
permission: permission
|
68
90
|
)
|
@@ -80,6 +102,12 @@ setting, caching, and fallback behavior.
|
|
80
102
|
Aws::Plugins::UserAgent.metric('S3_ACCESS_GRANTS', &block)
|
81
103
|
end
|
82
104
|
|
105
|
+
# HeadBucket is a supported call. When fetching credentials,
|
106
|
+
# this plugin is executed again, and becomes recursive.
|
107
|
+
def credentials_head_bucket_call?(provider)
|
108
|
+
provider.instance_variable_get(:@head_bucket_call)
|
109
|
+
end
|
110
|
+
|
83
111
|
def access_grants_operation?(context)
|
84
112
|
params = context[:endpoint_params]
|
85
113
|
params[:bucket] && PERMISSION_MAP[context.operation_name]
|
@@ -88,6 +116,42 @@ setting, caching, and fallback behavior.
|
|
88
116
|
def s3_express_endpoint?(context)
|
89
117
|
context[:endpoint_properties]['backend'] == 'S3Express'
|
90
118
|
end
|
119
|
+
|
120
|
+
# Return the common prefix of the keys, regardless of the delimiter.
|
121
|
+
# For example, given keys ['foo/bar', 'foo/baz'], the common prefix
|
122
|
+
# is 'foo/ba'.
|
123
|
+
def common_prefixes(keys)
|
124
|
+
return '' if keys.empty?
|
125
|
+
|
126
|
+
first_key = keys[0]
|
127
|
+
common_ancestor = first_key
|
128
|
+
last_prefix = ''
|
129
|
+
keys.each do |k|
|
130
|
+
until common_ancestor.empty?
|
131
|
+
break if k.start_with?(common_ancestor)
|
132
|
+
|
133
|
+
last_index = common_ancestor.rindex('/')
|
134
|
+
return '' if last_index.nil?
|
135
|
+
|
136
|
+
last_prefix = common_ancestor[(last_index + 1)..-1]
|
137
|
+
common_ancestor = common_ancestor[0...last_index]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
new_common_ancestor = "#{common_ancestor}/#{last_prefix}"
|
141
|
+
keys.each do |k|
|
142
|
+
until last_prefix.empty?
|
143
|
+
break if k.start_with?(new_common_ancestor)
|
144
|
+
|
145
|
+
last_prefix = last_prefix[0...-1]
|
146
|
+
new_common_ancestor = "#{common_ancestor}/#{last_prefix}"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
if new_common_ancestor == "#{first_key}/"
|
150
|
+
first_key
|
151
|
+
else
|
152
|
+
new_common_ancestor
|
153
|
+
end
|
154
|
+
end
|
91
155
|
end
|
92
156
|
|
93
157
|
def add_handlers(handlers, config)
|
@@ -46,11 +46,20 @@ module Aws::S3
|
|
46
46
|
context[:auth_scheme] =
|
47
47
|
Aws::Endpoints.resolve_auth_scheme(context, endpoint)
|
48
48
|
|
49
|
-
@handler.call(context)
|
49
|
+
with_metrics(context) { @handler.call(context) }
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
+
def with_metrics(context, &block)
|
55
|
+
metrics = []
|
56
|
+
metrics << 'ENDPOINT_OVERRIDE' unless context.config.regional_endpoint
|
57
|
+
if context[:auth_scheme] && context[:auth_scheme]['name'] == 'sigv4a'
|
58
|
+
metrics << 'SIGV4A_SIGNING'
|
59
|
+
end
|
60
|
+
Aws::Plugins::UserAgent.metric(*metrics, &block)
|
61
|
+
end
|
62
|
+
|
54
63
|
def apply_endpoint_headers(context, headers)
|
55
64
|
headers.each do |key, values|
|
56
65
|
value = values
|
data/lib/aws-sdk-s3/resource.rb
CHANGED
@@ -193,18 +193,20 @@ module Aws::S3
|
|
193
193
|
# @return [Bucket::Collection]
|
194
194
|
def buckets(options = {})
|
195
195
|
batches = Enumerator.new do |y|
|
196
|
-
batch = []
|
197
196
|
resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
|
198
197
|
@client.list_buckets(options)
|
199
198
|
end
|
200
|
-
resp.
|
201
|
-
batch
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
199
|
+
resp.each_page do |page|
|
200
|
+
batch = []
|
201
|
+
page.data.buckets.each do |b|
|
202
|
+
batch << Bucket.new(
|
203
|
+
name: b.name,
|
204
|
+
data: b,
|
205
|
+
client: @client
|
206
|
+
)
|
207
|
+
end
|
208
|
+
y.yield(batch)
|
206
209
|
end
|
207
|
-
y.yield(batch)
|
208
210
|
end
|
209
211
|
Bucket::Collection.new(batches)
|
210
212
|
end
|