aws-sdk-s3 1.156.0 → 1.190.0

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +193 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-s3/access_grants_credentials_provider.rb +12 -3
  5. data/lib/aws-sdk-s3/bucket.rb +304 -94
  6. data/lib/aws-sdk-s3/bucket_acl.rb +6 -5
  7. data/lib/aws-sdk-s3/bucket_cors.rb +6 -5
  8. data/lib/aws-sdk-s3/bucket_lifecycle.rb +7 -2
  9. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +60 -3
  10. data/lib/aws-sdk-s3/bucket_logging.rb +2 -2
  11. data/lib/aws-sdk-s3/bucket_policy.rb +10 -9
  12. data/lib/aws-sdk-s3/bucket_request_payment.rb +3 -3
  13. data/lib/aws-sdk-s3/bucket_tagging.rb +3 -3
  14. data/lib/aws-sdk-s3/bucket_versioning.rb +9 -9
  15. data/lib/aws-sdk-s3/bucket_website.rb +3 -3
  16. data/lib/aws-sdk-s3/client.rb +4081 -1812
  17. data/lib/aws-sdk-s3/client_api.rb +404 -162
  18. data/lib/aws-sdk-s3/customizations/object.rb +6 -0
  19. data/lib/aws-sdk-s3/customizations/object_summary.rb +5 -0
  20. data/lib/aws-sdk-s3/customizations/object_version.rb +13 -0
  21. data/lib/aws-sdk-s3/customizations.rb +24 -38
  22. data/lib/aws-sdk-s3/endpoint_parameters.rb +13 -18
  23. data/lib/aws-sdk-s3/endpoint_provider.rb +400 -276
  24. data/lib/aws-sdk-s3/endpoints.rb +465 -1706
  25. data/lib/aws-sdk-s3/errors.rb +58 -0
  26. data/lib/aws-sdk-s3/file_downloader.rb +14 -31
  27. data/lib/aws-sdk-s3/legacy_signer.rb +2 -1
  28. data/lib/aws-sdk-s3/multipart_file_uploader.rb +31 -13
  29. data/lib/aws-sdk-s3/multipart_upload.rb +108 -8
  30. data/lib/aws-sdk-s3/multipart_upload_part.rb +52 -36
  31. data/lib/aws-sdk-s3/object.rb +614 -203
  32. data/lib/aws-sdk-s3/object_acl.rb +11 -5
  33. data/lib/aws-sdk-s3/object_multipart_copier.rb +2 -1
  34. data/lib/aws-sdk-s3/object_summary.rb +518 -151
  35. data/lib/aws-sdk-s3/object_version.rb +81 -12
  36. data/lib/aws-sdk-s3/plugins/access_grants.rb +68 -4
  37. data/lib/aws-sdk-s3/plugins/checksum_algorithm.rb +31 -0
  38. data/lib/aws-sdk-s3/plugins/endpoints.rb +24 -212
  39. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +11 -20
  40. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +3 -3
  41. data/lib/aws-sdk-s3/plugins/md5s.rb +10 -71
  42. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +5 -7
  43. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +2 -1
  44. data/lib/aws-sdk-s3/presigner.rb +5 -5
  45. data/lib/aws-sdk-s3/resource.rb +45 -18
  46. data/lib/aws-sdk-s3/types.rb +3462 -1337
  47. data/lib/aws-sdk-s3.rb +35 -31
  48. data/sig/bucket.rbs +16 -6
  49. data/sig/bucket_acl.rbs +1 -1
  50. data/sig/bucket_cors.rbs +1 -1
  51. data/sig/bucket_lifecycle.rbs +1 -1
  52. data/sig/bucket_lifecycle_configuration.rbs +8 -4
  53. data/sig/bucket_logging.rbs +1 -1
  54. data/sig/bucket_policy.rbs +1 -1
  55. data/sig/bucket_request_payment.rbs +1 -1
  56. data/sig/bucket_tagging.rbs +1 -1
  57. data/sig/bucket_versioning.rbs +3 -3
  58. data/sig/bucket_website.rbs +1 -1
  59. data/sig/client.rbs +162 -45
  60. data/sig/errors.rbs +10 -0
  61. data/sig/multipart_upload.rbs +12 -2
  62. data/sig/multipart_upload_part.rbs +5 -1
  63. data/sig/object.rbs +26 -6
  64. data/sig/object_acl.rbs +1 -1
  65. data/sig/object_summary.rbs +18 -7
  66. data/sig/object_version.rbs +9 -3
  67. data/sig/resource.rbs +11 -4
  68. data/sig/types.rbs +210 -38
  69. metadata +8 -10
  70. data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +0 -31
@@ -62,6 +62,18 @@ module Aws::S3
62
62
  data[:checksum_algorithm]
63
63
  end
64
64
 
65
+ # The checksum type that is used to calculate the object’s checksum
66
+ # value. For more information, see [Checking object integrity][1] in the
67
+ # *Amazon S3 User Guide*.
68
+ #
69
+ #
70
+ #
71
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html
72
+ # @return [String]
73
+ def checksum_type
74
+ data[:checksum_type]
75
+ end
76
+
65
77
  # Size in bytes of the object.
66
78
  # @return [Integer]
67
79
  def size
@@ -257,6 +269,9 @@ module Aws::S3
257
269
  # request_payer: "requester", # accepts requester
258
270
  # bypass_governance_retention: false,
259
271
  # expected_bucket_owner: "AccountId",
272
+ # if_match: "IfMatch",
273
+ # if_match_last_modified_time: Time.now,
274
+ # if_match_size: 1,
260
275
  # })
261
276
  # @param [Hash] options ({})
262
277
  # @option options [String] :mfa
@@ -296,6 +311,46 @@ module Aws::S3
296
311
  # The account ID of the expected bucket owner. If the account ID that
297
312
  # you provide does not match the actual owner of the bucket, the request
298
313
  # fails with the HTTP status code `403 Forbidden` (access denied).
314
+ # @option options [String] :if_match
315
+ # The `If-Match` header field makes the request method conditional on
316
+ # ETags. If the ETag value does not match, the operation returns a `412
317
+ # Precondition Failed` error. If the ETag matches or if the object
318
+ # doesn't exist, the operation will return a `204 Success (No Content)
319
+ # response`.
320
+ #
321
+ # For more information about conditional requests, see [RFC 7232][1].
322
+ #
323
+ # <note markdown="1"> This functionality is only supported for directory buckets.
324
+ #
325
+ # </note>
326
+ #
327
+ #
328
+ #
329
+ # [1]: https://tools.ietf.org/html/rfc7232
330
+ # @option options [Time,DateTime,Date,Integer,String] :if_match_last_modified_time
331
+ # If present, the object is deleted only if its modification times
332
+ # matches the provided `Timestamp`. If the `Timestamp` values do not
333
+ # match, the operation returns a `412 Precondition Failed` error. If the
334
+ # `Timestamp` matches or if the object doesn’t exist, the operation
335
+ # returns a `204 Success (No Content)` response.
336
+ #
337
+ # <note markdown="1"> This functionality is only supported for directory buckets.
338
+ #
339
+ # </note>
340
+ # @option options [Integer] :if_match_size
341
+ # If present, the object is deleted only if its size matches the
342
+ # provided size in bytes. If the `Size` value does not match, the
343
+ # operation returns a `412 Precondition Failed` error. If the `Size`
344
+ # matches or if the object doesn’t exist, the operation returns a `204
345
+ # Success (No Content)` response.
346
+ #
347
+ # <note markdown="1"> This functionality is only supported for directory buckets.
348
+ #
349
+ # </note>
350
+ #
351
+ # You can use the `If-Match`, `x-amz-if-match-last-modified-time` and
352
+ # `x-amz-if-match-size` conditional headers in conjunction with
353
+ # each-other or individually.
299
354
  # @return [Types::DeleteObjectOutput]
300
355
  def delete(options = {})
301
356
  options = options.merge(
@@ -701,10 +756,20 @@ module Aws::S3
701
756
  # @option options [String] :checksum_mode
702
757
  # To retrieve the checksum, this parameter must be enabled.
703
758
  #
704
- # In addition, if you enable `ChecksumMode` and the object is encrypted
705
- # with Amazon Web Services Key Management Service (Amazon Web Services
706
- # KMS), you must have permission to use the `kms:Decrypt` action for the
707
- # request to succeed.
759
+ # **General purpose buckets** - If you enable checksum mode and the
760
+ # object is uploaded with a [checksum][1] and encrypted with an Key
761
+ # Management Service (KMS) key, you must have permission to use the
762
+ # `kms:Decrypt` action to retrieve the checksum.
763
+ #
764
+ # **Directory buckets** - If you enable `ChecksumMode` and the object is
765
+ # encrypted with Amazon Web Services Key Management Service (Amazon Web
766
+ # Services KMS), you must also have the `kms:GenerateDataKey` and
767
+ # `kms:Decrypt` permissions in IAM identity-based policies and KMS key
768
+ # policies for the KMS key to retrieve the checksum of the object.
769
+ #
770
+ #
771
+ #
772
+ # [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Checksum.html
708
773
  # @return [Types::HeadObjectOutput]
709
774
  def head(options = {})
710
775
  options = options.merge(
@@ -786,7 +851,7 @@ module Aws::S3
786
851
  # request_payer: "requester", # accepts requester
787
852
  # bypass_governance_retention: false,
788
853
  # expected_bucket_owner: "AccountId",
789
- # checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256
854
+ # checksum_algorithm: "CRC32", # accepts CRC32, CRC32C, SHA1, SHA256, CRC64NVME
790
855
  # })
791
856
  # @param options ({})
792
857
  # @option options [String] :mfa
@@ -850,22 +915,23 @@ module Aws::S3
850
915
  # For the `x-amz-checksum-algorithm ` header, replace ` algorithm ` with
851
916
  # the supported algorithm from the following list:
852
917
  #
853
- # * CRC32
918
+ # * `CRC32`
919
+ #
920
+ # * `CRC32C`
854
921
  #
855
- # * CRC32C
922
+ # * `CRC64NVME`
856
923
  #
857
- # * SHA1
924
+ # * `SHA1`
858
925
  #
859
- # * SHA256
926
+ # * `SHA256`
860
927
  #
861
928
  # For more information, see [Checking object integrity][1] in the
862
929
  # *Amazon S3 User Guide*.
863
930
  #
864
931
  # If the individual checksum value you provide through
865
932
  # `x-amz-checksum-algorithm ` doesn't match the checksum algorithm you
866
- # set through `x-amz-sdk-checksum-algorithm`, Amazon S3 ignores any
867
- # provided `ChecksumAlgorithm` parameter and uses the checksum algorithm
868
- # that matches the provided value in `x-amz-checksum-algorithm `.
933
+ # set through `x-amz-sdk-checksum-algorithm`, Amazon S3 fails the
934
+ # request with a `BadDigest` error.
869
935
  #
870
936
  # If you provide an individual checksum, Amazon S3 ignores any provided
871
937
  # `ChecksumAlgorithm` parameter.
@@ -898,3 +964,6 @@ module Aws::S3
898
964
  end
899
965
  end
900
966
  end
967
+
968
+ # Load customizations if they exist
969
+ require 'aws-sdk-s3/customizations/object_version'
@@ -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
- provider = context.config.access_grants_credentials_provider
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: params[: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)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Plugins
6
+ # @api private
7
+ class ChecksumAlgorithm < Seahorse::Client::Plugin
8
+
9
+ # S3 GetObject results for whole Multipart Objects contain a checksum
10
+ # that cannot be validated. These should be skipped by the
11
+ # ChecksumAlgorithm plugin.
12
+ class SkipWholeMultipartGetChecksumsHandler < Seahorse::Client::Handler
13
+ def call(context)
14
+ context[:http_checksum] ||= {}
15
+ context[:http_checksum][:skip_on_suffix] = true
16
+
17
+ @handler.call(context)
18
+ end
19
+ end
20
+
21
+ def add_handlers(handlers, _config)
22
+ handlers.add(
23
+ SkipWholeMultipartGetChecksumsHandler,
24
+ step: :initialize,
25
+ operations: [:get_object]
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -15,25 +15,28 @@ module Aws::S3
15
15
  :endpoint_provider,
16
16
  doc_type: 'Aws::S3::EndpointProvider',
17
17
  rbs_type: 'untyped',
18
- docstring: 'The endpoint provider used to resolve endpoints. Any '\
19
- 'object that responds to `#resolve_endpoint(parameters)` '\
20
- 'where `parameters` is a Struct similar to '\
21
- '`Aws::S3::EndpointParameters`'
22
- ) do |cfg|
18
+ docstring: <<~DOCS) do |_cfg|
19
+ The endpoint provider used to resolve endpoints. Any object that responds to
20
+ `#resolve_endpoint(parameters)` where `parameters` is a Struct similar to
21
+ `Aws::S3::EndpointParameters`.
22
+ DOCS
23
23
  Aws::S3::EndpointProvider.new
24
24
  end
25
25
 
26
26
  option(
27
27
  :disable_s3_express_session_auth,
28
28
  doc_type: 'Boolean',
29
- default: nil,
30
- docstring: "Parameter to indicate whether S3Express session auth should be disabled")
29
+ docstring: <<~DOCS) do |cfg|
30
+ Parameter to indicate whether S3Express session auth should be disabled
31
+ DOCS
32
+ nil
33
+ end
31
34
 
32
35
  # @api private
33
36
  class Handler < Seahorse::Client::Handler
34
37
  def call(context)
35
38
  unless context[:discovered_endpoint]
36
- params = parameters_for_operation(context)
39
+ params = Aws::S3::Endpoints.parameters_for_operation(context)
37
40
  endpoint = context.config.endpoint_provider.resolve_endpoint(params)
38
41
 
39
42
  context.http_request.endpoint = endpoint.url
@@ -46,11 +49,23 @@ module Aws::S3
46
49
  context[:auth_scheme] =
47
50
  Aws::Endpoints.resolve_auth_scheme(context, endpoint)
48
51
 
49
- @handler.call(context)
52
+ with_metrics(context) { @handler.call(context) }
50
53
  end
51
54
 
52
55
  private
53
56
 
57
+ def with_metrics(context, &block)
58
+ metrics = []
59
+ metrics << 'ENDPOINT_OVERRIDE' unless context.config.regional_endpoint
60
+ if context[:auth_scheme] && context[:auth_scheme]['name'] == 'sigv4a'
61
+ metrics << 'SIGV4A_SIGNING'
62
+ end
63
+ if context.config.credentials&.credentials&.account_id
64
+ metrics << 'RESOLVED_ACCOUNT_ID'
65
+ end
66
+ Aws::Plugins::UserAgent.metric(*metrics, &block)
67
+ end
68
+
54
69
  def apply_endpoint_headers(context, headers)
55
70
  headers.each do |key, values|
56
71
  value = values
@@ -61,209 +76,6 @@ module Aws::S3
61
76
  context.http_request.headers[key] = value
62
77
  end
63
78
  end
64
-
65
- def parameters_for_operation(context)
66
- case context.operation_name
67
- when :abort_multipart_upload
68
- Aws::S3::Endpoints::AbortMultipartUpload.build(context)
69
- when :complete_multipart_upload
70
- Aws::S3::Endpoints::CompleteMultipartUpload.build(context)
71
- when :copy_object
72
- Aws::S3::Endpoints::CopyObject.build(context)
73
- when :create_bucket
74
- Aws::S3::Endpoints::CreateBucket.build(context)
75
- when :create_multipart_upload
76
- Aws::S3::Endpoints::CreateMultipartUpload.build(context)
77
- when :create_session
78
- Aws::S3::Endpoints::CreateSession.build(context)
79
- when :delete_bucket
80
- Aws::S3::Endpoints::DeleteBucket.build(context)
81
- when :delete_bucket_analytics_configuration
82
- Aws::S3::Endpoints::DeleteBucketAnalyticsConfiguration.build(context)
83
- when :delete_bucket_cors
84
- Aws::S3::Endpoints::DeleteBucketCors.build(context)
85
- when :delete_bucket_encryption
86
- Aws::S3::Endpoints::DeleteBucketEncryption.build(context)
87
- when :delete_bucket_intelligent_tiering_configuration
88
- Aws::S3::Endpoints::DeleteBucketIntelligentTieringConfiguration.build(context)
89
- when :delete_bucket_inventory_configuration
90
- Aws::S3::Endpoints::DeleteBucketInventoryConfiguration.build(context)
91
- when :delete_bucket_lifecycle
92
- Aws::S3::Endpoints::DeleteBucketLifecycle.build(context)
93
- when :delete_bucket_metrics_configuration
94
- Aws::S3::Endpoints::DeleteBucketMetricsConfiguration.build(context)
95
- when :delete_bucket_ownership_controls
96
- Aws::S3::Endpoints::DeleteBucketOwnershipControls.build(context)
97
- when :delete_bucket_policy
98
- Aws::S3::Endpoints::DeleteBucketPolicy.build(context)
99
- when :delete_bucket_replication
100
- Aws::S3::Endpoints::DeleteBucketReplication.build(context)
101
- when :delete_bucket_tagging
102
- Aws::S3::Endpoints::DeleteBucketTagging.build(context)
103
- when :delete_bucket_website
104
- Aws::S3::Endpoints::DeleteBucketWebsite.build(context)
105
- when :delete_object
106
- Aws::S3::Endpoints::DeleteObject.build(context)
107
- when :delete_object_tagging
108
- Aws::S3::Endpoints::DeleteObjectTagging.build(context)
109
- when :delete_objects
110
- Aws::S3::Endpoints::DeleteObjects.build(context)
111
- when :delete_public_access_block
112
- Aws::S3::Endpoints::DeletePublicAccessBlock.build(context)
113
- when :get_bucket_accelerate_configuration
114
- Aws::S3::Endpoints::GetBucketAccelerateConfiguration.build(context)
115
- when :get_bucket_acl
116
- Aws::S3::Endpoints::GetBucketAcl.build(context)
117
- when :get_bucket_analytics_configuration
118
- Aws::S3::Endpoints::GetBucketAnalyticsConfiguration.build(context)
119
- when :get_bucket_cors
120
- Aws::S3::Endpoints::GetBucketCors.build(context)
121
- when :get_bucket_encryption
122
- Aws::S3::Endpoints::GetBucketEncryption.build(context)
123
- when :get_bucket_intelligent_tiering_configuration
124
- Aws::S3::Endpoints::GetBucketIntelligentTieringConfiguration.build(context)
125
- when :get_bucket_inventory_configuration
126
- Aws::S3::Endpoints::GetBucketInventoryConfiguration.build(context)
127
- when :get_bucket_lifecycle
128
- Aws::S3::Endpoints::GetBucketLifecycle.build(context)
129
- when :get_bucket_lifecycle_configuration
130
- Aws::S3::Endpoints::GetBucketLifecycleConfiguration.build(context)
131
- when :get_bucket_location
132
- Aws::S3::Endpoints::GetBucketLocation.build(context)
133
- when :get_bucket_logging
134
- Aws::S3::Endpoints::GetBucketLogging.build(context)
135
- when :get_bucket_metrics_configuration
136
- Aws::S3::Endpoints::GetBucketMetricsConfiguration.build(context)
137
- when :get_bucket_notification
138
- Aws::S3::Endpoints::GetBucketNotification.build(context)
139
- when :get_bucket_notification_configuration
140
- Aws::S3::Endpoints::GetBucketNotificationConfiguration.build(context)
141
- when :get_bucket_ownership_controls
142
- Aws::S3::Endpoints::GetBucketOwnershipControls.build(context)
143
- when :get_bucket_policy
144
- Aws::S3::Endpoints::GetBucketPolicy.build(context)
145
- when :get_bucket_policy_status
146
- Aws::S3::Endpoints::GetBucketPolicyStatus.build(context)
147
- when :get_bucket_replication
148
- Aws::S3::Endpoints::GetBucketReplication.build(context)
149
- when :get_bucket_request_payment
150
- Aws::S3::Endpoints::GetBucketRequestPayment.build(context)
151
- when :get_bucket_tagging
152
- Aws::S3::Endpoints::GetBucketTagging.build(context)
153
- when :get_bucket_versioning
154
- Aws::S3::Endpoints::GetBucketVersioning.build(context)
155
- when :get_bucket_website
156
- Aws::S3::Endpoints::GetBucketWebsite.build(context)
157
- when :get_object
158
- Aws::S3::Endpoints::GetObject.build(context)
159
- when :get_object_acl
160
- Aws::S3::Endpoints::GetObjectAcl.build(context)
161
- when :get_object_attributes
162
- Aws::S3::Endpoints::GetObjectAttributes.build(context)
163
- when :get_object_legal_hold
164
- Aws::S3::Endpoints::GetObjectLegalHold.build(context)
165
- when :get_object_lock_configuration
166
- Aws::S3::Endpoints::GetObjectLockConfiguration.build(context)
167
- when :get_object_retention
168
- Aws::S3::Endpoints::GetObjectRetention.build(context)
169
- when :get_object_tagging
170
- Aws::S3::Endpoints::GetObjectTagging.build(context)
171
- when :get_object_torrent
172
- Aws::S3::Endpoints::GetObjectTorrent.build(context)
173
- when :get_public_access_block
174
- Aws::S3::Endpoints::GetPublicAccessBlock.build(context)
175
- when :head_bucket
176
- Aws::S3::Endpoints::HeadBucket.build(context)
177
- when :head_object
178
- Aws::S3::Endpoints::HeadObject.build(context)
179
- when :list_bucket_analytics_configurations
180
- Aws::S3::Endpoints::ListBucketAnalyticsConfigurations.build(context)
181
- when :list_bucket_intelligent_tiering_configurations
182
- Aws::S3::Endpoints::ListBucketIntelligentTieringConfigurations.build(context)
183
- when :list_bucket_inventory_configurations
184
- Aws::S3::Endpoints::ListBucketInventoryConfigurations.build(context)
185
- when :list_bucket_metrics_configurations
186
- Aws::S3::Endpoints::ListBucketMetricsConfigurations.build(context)
187
- when :list_buckets
188
- Aws::S3::Endpoints::ListBuckets.build(context)
189
- when :list_directory_buckets
190
- Aws::S3::Endpoints::ListDirectoryBuckets.build(context)
191
- when :list_multipart_uploads
192
- Aws::S3::Endpoints::ListMultipartUploads.build(context)
193
- when :list_object_versions
194
- Aws::S3::Endpoints::ListObjectVersions.build(context)
195
- when :list_objects
196
- Aws::S3::Endpoints::ListObjects.build(context)
197
- when :list_objects_v2
198
- Aws::S3::Endpoints::ListObjectsV2.build(context)
199
- when :list_parts
200
- Aws::S3::Endpoints::ListParts.build(context)
201
- when :put_bucket_accelerate_configuration
202
- Aws::S3::Endpoints::PutBucketAccelerateConfiguration.build(context)
203
- when :put_bucket_acl
204
- Aws::S3::Endpoints::PutBucketAcl.build(context)
205
- when :put_bucket_analytics_configuration
206
- Aws::S3::Endpoints::PutBucketAnalyticsConfiguration.build(context)
207
- when :put_bucket_cors
208
- Aws::S3::Endpoints::PutBucketCors.build(context)
209
- when :put_bucket_encryption
210
- Aws::S3::Endpoints::PutBucketEncryption.build(context)
211
- when :put_bucket_intelligent_tiering_configuration
212
- Aws::S3::Endpoints::PutBucketIntelligentTieringConfiguration.build(context)
213
- when :put_bucket_inventory_configuration
214
- Aws::S3::Endpoints::PutBucketInventoryConfiguration.build(context)
215
- when :put_bucket_lifecycle
216
- Aws::S3::Endpoints::PutBucketLifecycle.build(context)
217
- when :put_bucket_lifecycle_configuration
218
- Aws::S3::Endpoints::PutBucketLifecycleConfiguration.build(context)
219
- when :put_bucket_logging
220
- Aws::S3::Endpoints::PutBucketLogging.build(context)
221
- when :put_bucket_metrics_configuration
222
- Aws::S3::Endpoints::PutBucketMetricsConfiguration.build(context)
223
- when :put_bucket_notification
224
- Aws::S3::Endpoints::PutBucketNotification.build(context)
225
- when :put_bucket_notification_configuration
226
- Aws::S3::Endpoints::PutBucketNotificationConfiguration.build(context)
227
- when :put_bucket_ownership_controls
228
- Aws::S3::Endpoints::PutBucketOwnershipControls.build(context)
229
- when :put_bucket_policy
230
- Aws::S3::Endpoints::PutBucketPolicy.build(context)
231
- when :put_bucket_replication
232
- Aws::S3::Endpoints::PutBucketReplication.build(context)
233
- when :put_bucket_request_payment
234
- Aws::S3::Endpoints::PutBucketRequestPayment.build(context)
235
- when :put_bucket_tagging
236
- Aws::S3::Endpoints::PutBucketTagging.build(context)
237
- when :put_bucket_versioning
238
- Aws::S3::Endpoints::PutBucketVersioning.build(context)
239
- when :put_bucket_website
240
- Aws::S3::Endpoints::PutBucketWebsite.build(context)
241
- when :put_object
242
- Aws::S3::Endpoints::PutObject.build(context)
243
- when :put_object_acl
244
- Aws::S3::Endpoints::PutObjectAcl.build(context)
245
- when :put_object_legal_hold
246
- Aws::S3::Endpoints::PutObjectLegalHold.build(context)
247
- when :put_object_lock_configuration
248
- Aws::S3::Endpoints::PutObjectLockConfiguration.build(context)
249
- when :put_object_retention
250
- Aws::S3::Endpoints::PutObjectRetention.build(context)
251
- when :put_object_tagging
252
- Aws::S3::Endpoints::PutObjectTagging.build(context)
253
- when :put_public_access_block
254
- Aws::S3::Endpoints::PutPublicAccessBlock.build(context)
255
- when :restore_object
256
- Aws::S3::Endpoints::RestoreObject.build(context)
257
- when :select_object_content
258
- Aws::S3::Endpoints::SelectObjectContent.build(context)
259
- when :upload_part
260
- Aws::S3::Endpoints::UploadPart.build(context)
261
- when :upload_part_copy
262
- Aws::S3::Endpoints::UploadPartCopy.build(context)
263
- when :write_get_object_response
264
- Aws::S3::Endpoints::WriteGetObjectResponse.build(context)
265
- end
266
- end
267
79
  end
268
80
 
269
81
  def add_handlers(handlers, _config)
@@ -29,24 +29,17 @@ for different buckets.
29
29
  # @api private
30
30
  class Handler < Seahorse::Client::Handler
31
31
  def call(context)
32
- if (props = context[:endpoint_properties])
33
- # S3 Express endpoint - turn off md5 and enable crc32 default
34
- if props['backend'] == 'S3Express'
35
- if context.operation_name == :put_object || checksum_required?(context)
36
- context[:default_request_checksum_algorithm] = 'CRC32'
37
- end
38
- context[:s3_express_endpoint] = true
39
- end
32
+ context[:s3_express_endpoint] = true if s3_express_endpoint?(context)
40
33
 
41
- # if s3 express auth, use new credentials and sign additional header
42
- if context[:auth_scheme]['name'] == 'sigv4-s3express' &&
43
- !context.config.disable_s3_express_session_auth
44
- bucket = context.params[:bucket]
45
- credentials_provider = context.config.express_credentials_provider
46
- credentials = credentials_provider.express_credentials_for(bucket)
47
- context[:sigv4_credentials] = credentials # Sign will use this
48
- end
34
+ # if s3 express auth, use new credentials and sign additional header
35
+ if context[:auth_scheme]['name'] == 'sigv4-s3express' &&
36
+ !context.config.disable_s3_express_session_auth
37
+ bucket = context.params[:bucket]
38
+ credentials_provider = context.config.express_credentials_provider
39
+ credentials = credentials_provider.express_credentials_for(bucket)
40
+ context[:sigv4_credentials] = credentials # Sign will use this
49
41
  end
42
+
50
43
  with_metric(credentials) { @handler.call(context) }
51
44
  end
52
45
 
@@ -58,10 +51,8 @@ for different buckets.
58
51
  Aws::Plugins::UserAgent.metric('S3_EXPRESS_BUCKET', &block)
59
52
  end
60
53
 
61
- def checksum_required?(context)
62
- context.operation.http_checksum_required ||
63
- (context.operation.http_checksum &&
64
- context.operation.http_checksum['requestChecksumRequired'])
54
+ def s3_express_endpoint?(context)
55
+ context[:endpoint_properties]['backend'] == 'S3Express'
65
56
  end
66
57
  end
67
58
 
@@ -71,9 +71,9 @@ module Aws
71
71
 
72
72
  def check_for_error(context)
73
73
  xml = context.http_response.body_contents
74
- if xml.match(/\?>\s*<Error>/)
75
- error_code = xml.match(/<Code>(.+?)<\/Code>/)[1]
76
- error_message = xml.match(/<Message>(.+?)<\/Message>/)[1]
74
+ if xml.match(/<\?xml\s[^>]*\?>\s*<Error>/)
75
+ error_code = xml.match(%r{<Code>(.+?)</Code>})[1]
76
+ error_message = xml.match(%r{<Message>(.+?)</Message>})[1]
77
77
  S3::Errors.error_class(error_code).new(context, error_message)
78
78
  elsif incomplete_xml_body?(xml, context.operation.output)
79
79
  Seahorse::Client::NetworkingError.new(