aws-sdk-s3 1.103.0 → 1.202.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 (109) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +664 -0
  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 +250 -0
  6. data/lib/aws-sdk-s3/bucket.rb +858 -116
  7. data/lib/aws-sdk-s3/bucket_acl.rb +32 -9
  8. data/lib/aws-sdk-s3/bucket_cors.rb +38 -13
  9. data/lib/aws-sdk-s3/bucket_lifecycle.rb +43 -12
  10. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +100 -13
  11. data/lib/aws-sdk-s3/bucket_logging.rb +35 -6
  12. data/lib/aws-sdk-s3/bucket_notification.rb +27 -9
  13. data/lib/aws-sdk-s3/bucket_policy.rb +79 -10
  14. data/lib/aws-sdk-s3/bucket_region_cache.rb +9 -5
  15. data/lib/aws-sdk-s3/bucket_request_payment.rb +29 -7
  16. data/lib/aws-sdk-s3/bucket_tagging.rb +35 -11
  17. data/lib/aws-sdk-s3/bucket_versioning.rb +108 -17
  18. data/lib/aws-sdk-s3/bucket_website.rb +35 -11
  19. data/lib/aws-sdk-s3/client.rb +11799 -3636
  20. data/lib/aws-sdk-s3/client_api.rb +1201 -276
  21. data/lib/aws-sdk-s3/customizations/bucket.rb +23 -47
  22. data/lib/aws-sdk-s3/customizations/errors.rb +40 -0
  23. data/lib/aws-sdk-s3/customizations/object.rb +216 -70
  24. data/lib/aws-sdk-s3/customizations/object_summary.rb +5 -0
  25. data/lib/aws-sdk-s3/customizations/object_version.rb +13 -0
  26. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  27. data/lib/aws-sdk-s3/customizations.rb +27 -29
  28. data/lib/aws-sdk-s3/default_executor.rb +103 -0
  29. data/lib/aws-sdk-s3/encryption/client.rb +6 -2
  30. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +13 -9
  31. data/lib/aws-sdk-s3/encryptionV2/client.rb +6 -2
  32. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +1 -0
  33. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +10 -6
  34. data/lib/aws-sdk-s3/endpoint_parameters.rb +181 -0
  35. data/lib/aws-sdk-s3/endpoint_provider.rb +716 -0
  36. data/lib/aws-sdk-s3/endpoints.rb +1518 -0
  37. data/lib/aws-sdk-s3/errors.rb +58 -0
  38. data/lib/aws-sdk-s3/express_credentials.rb +55 -0
  39. data/lib/aws-sdk-s3/express_credentials_provider.rb +59 -0
  40. data/lib/aws-sdk-s3/file_downloader.rb +241 -87
  41. data/lib/aws-sdk-s3/file_uploader.rb +16 -13
  42. data/lib/aws-sdk-s3/legacy_signer.rb +2 -1
  43. data/lib/aws-sdk-s3/multipart_download_error.rb +8 -0
  44. data/lib/aws-sdk-s3/multipart_file_uploader.rb +108 -86
  45. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +110 -92
  46. data/lib/aws-sdk-s3/multipart_upload.rb +294 -19
  47. data/lib/aws-sdk-s3/multipart_upload_error.rb +3 -4
  48. data/lib/aws-sdk-s3/multipart_upload_part.rb +297 -31
  49. data/lib/aws-sdk-s3/object.rb +2224 -269
  50. data/lib/aws-sdk-s3/object_acl.rb +59 -17
  51. data/lib/aws-sdk-s3/object_copier.rb +7 -5
  52. data/lib/aws-sdk-s3/object_multipart_copier.rb +48 -23
  53. data/lib/aws-sdk-s3/object_summary.rb +1915 -220
  54. data/lib/aws-sdk-s3/object_version.rb +450 -58
  55. data/lib/aws-sdk-s3/plugins/accelerate.rb +3 -44
  56. data/lib/aws-sdk-s3/plugins/access_grants.rb +178 -0
  57. data/lib/aws-sdk-s3/plugins/arn.rb +0 -197
  58. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +3 -39
  59. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +1 -6
  60. data/lib/aws-sdk-s3/plugins/checksum_algorithm.rb +31 -0
  61. data/lib/aws-sdk-s3/plugins/dualstack.rb +1 -55
  62. data/lib/aws-sdk-s3/plugins/endpoints.rb +86 -0
  63. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +2 -1
  64. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +88 -0
  65. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +55 -18
  66. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +6 -29
  67. data/lib/aws-sdk-s3/plugins/location_constraint.rb +3 -1
  68. data/lib/aws-sdk-s3/plugins/md5s.rb +10 -68
  69. data/lib/aws-sdk-s3/plugins/s3_signer.rb +42 -111
  70. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +28 -9
  71. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +2 -1
  72. data/lib/aws-sdk-s3/presigned_post.rb +99 -78
  73. data/lib/aws-sdk-s3/presigner.rb +32 -41
  74. data/lib/aws-sdk-s3/resource.rb +139 -12
  75. data/lib/aws-sdk-s3/transfer_manager.rb +304 -0
  76. data/lib/aws-sdk-s3/types.rb +10204 -5378
  77. data/lib/aws-sdk-s3.rb +35 -27
  78. data/sig/bucket.rbs +231 -0
  79. data/sig/bucket_acl.rbs +78 -0
  80. data/sig/bucket_cors.rbs +69 -0
  81. data/sig/bucket_lifecycle.rbs +88 -0
  82. data/sig/bucket_lifecycle_configuration.rbs +115 -0
  83. data/sig/bucket_logging.rbs +76 -0
  84. data/sig/bucket_notification.rbs +114 -0
  85. data/sig/bucket_policy.rbs +59 -0
  86. data/sig/bucket_request_payment.rbs +54 -0
  87. data/sig/bucket_tagging.rbs +65 -0
  88. data/sig/bucket_versioning.rbs +77 -0
  89. data/sig/bucket_website.rbs +93 -0
  90. data/sig/client.rbs +2586 -0
  91. data/sig/customizations/bucket.rbs +19 -0
  92. data/sig/customizations/object.rbs +38 -0
  93. data/sig/customizations/object_summary.rbs +35 -0
  94. data/sig/errors.rbs +44 -0
  95. data/sig/multipart_upload.rbs +120 -0
  96. data/sig/multipart_upload_part.rbs +109 -0
  97. data/sig/object.rbs +464 -0
  98. data/sig/object_acl.rbs +86 -0
  99. data/sig/object_summary.rbs +347 -0
  100. data/sig/object_version.rbs +143 -0
  101. data/sig/resource.rbs +141 -0
  102. data/sig/types.rbs +2868 -0
  103. data/sig/waiters.rbs +95 -0
  104. metadata +51 -16
  105. data/lib/aws-sdk-s3/arn/access_point_arn.rb +0 -69
  106. data/lib/aws-sdk-s3/arn/multi_region_access_point_arn.rb +0 -69
  107. data/lib/aws-sdk-s3/arn/object_lambda_arn.rb +0 -69
  108. data/lib/aws-sdk-s3/arn/outpost_access_point_arn.rb +0 -73
  109. data/lib/aws-sdk-s3/plugins/object_lambda_endpoint.rb +0 -25
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ # @api private
6
+ class DefaultExecutor
7
+ DEFAULT_MAX_THREADS = 10
8
+ RUNNING = :running
9
+ SHUTTING_DOWN = :shutting_down
10
+ SHUTDOWN = :shutdown
11
+
12
+ def initialize(options = {})
13
+ @max_threads = options[:max_threads] || DEFAULT_MAX_THREADS
14
+ @state = RUNNING
15
+ @queue = Queue.new
16
+ @pool = []
17
+ @mutex = Mutex.new
18
+ end
19
+
20
+ # Submits a task for execution.
21
+ # @param [Object] args Variable number of arguments to pass to the block
22
+ # @param [Proc] block The block to be executed
23
+ # @return [Boolean] Returns true if the task was submitted successfully
24
+ def post(*args, &block)
25
+ @mutex.synchronize do
26
+ raise 'Executor has been shutdown and is no longer accepting tasks' unless @state == RUNNING
27
+
28
+ @queue << [args, block]
29
+ ensure_worker_available
30
+ end
31
+ true
32
+ end
33
+
34
+ # Immediately terminates all worker threads and clears pending tasks.
35
+ # This is a forceful shutdown that doesn't wait for running tasks to complete.
36
+ #
37
+ # @return [Boolean] true when termination is complete
38
+ def kill
39
+ @mutex.synchronize do
40
+ @state = SHUTDOWN
41
+ @pool.each(&:kill)
42
+ @pool.clear
43
+ @queue.clear
44
+ end
45
+ true
46
+ end
47
+
48
+ # Gracefully shuts down the executor, optionally with a timeout.
49
+ # Stops accepting new tasks and waits for running tasks to complete.
50
+ #
51
+ # @param timeout [Numeric, nil] Maximum time in seconds to wait for shutdown.
52
+ # If nil, waits indefinitely. If timeout expires, remaining threads are killed.
53
+ # @return [Boolean] true when shutdown is complete
54
+ def shutdown(timeout = nil)
55
+ @mutex.synchronize do
56
+ return true if @state == SHUTDOWN
57
+
58
+ @state = SHUTTING_DOWN
59
+ @pool.size.times { @queue << :shutdown }
60
+ end
61
+
62
+ if timeout
63
+ deadline = Time.now + timeout
64
+ @pool.each do |thread|
65
+ remaining = deadline - Time.now
66
+ break if remaining <= 0
67
+
68
+ thread.join([remaining, 0].max)
69
+ end
70
+ @pool.select(&:alive?).each(&:kill)
71
+ else
72
+ @pool.each(&:join)
73
+ end
74
+
75
+ @mutex.synchronize do
76
+ @pool.clear
77
+ @state = SHUTDOWN
78
+ end
79
+ true
80
+ end
81
+
82
+ private
83
+
84
+ def ensure_worker_available
85
+ return unless @state == RUNNING
86
+
87
+ @pool.select!(&:alive?)
88
+ @pool << spawn_worker if @pool.size < @max_threads
89
+ end
90
+
91
+ def spawn_worker
92
+ Thread.new do
93
+ while (job = @queue.shift)
94
+ break if job == :shutdown
95
+
96
+ args, block = job
97
+ block.call(*args)
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -270,7 +270,9 @@ module Aws
270
270
  envelope_location: @envelope_location,
271
271
  instruction_file_suffix: @instruction_file_suffix,
272
272
  }
273
- req.send_request
273
+ Aws::Plugins::UserAgent.metric('S3_CRYPTO_V1N') do
274
+ req.send_request
275
+ end
274
276
  end
275
277
 
276
278
  # Gets an object from Amazon S3, decrypting data locally.
@@ -298,7 +300,9 @@ module Aws
298
300
  envelope_location: envelope_location,
299
301
  instruction_file_suffix: instruction_file_suffix,
300
302
  }
301
- req.send_request(target: block)
303
+ Aws::Plugins::UserAgent.metric('S3_CRYPTO_V1N') do
304
+ req.send_request(target: block)
305
+ end
302
306
  end
303
307
 
304
308
  private
@@ -17,11 +17,13 @@ module Aws
17
17
  # envelope and encryption cipher.
18
18
  def encryption_cipher
19
19
  encryption_context = { "kms_cmk_id" => @kms_key_id }
20
- key_data = @kms_client.generate_data_key(
21
- key_id: @kms_key_id,
22
- encryption_context: encryption_context,
23
- key_spec: 'AES_256',
24
- )
20
+ key_data = Aws::Plugins::UserAgent.metric('S3_CRYPTO_V1N') do
21
+ @kms_client.generate_data_key(
22
+ key_id: @kms_key_id,
23
+ encryption_context: encryption_context,
24
+ key_spec: 'AES_256'
25
+ )
26
+ end
25
27
  cipher = Utils.aes_encryption_cipher(:CBC)
26
28
  cipher.key = key_data.plaintext
27
29
  envelope = {
@@ -58,10 +60,12 @@ module Aws
58
60
  "#{envelope['x-amz-wrap-alg']}"
59
61
  end
60
62
 
61
- key = @kms_client.decrypt(
62
- ciphertext_blob: decode64(envelope['x-amz-key-v2']),
63
- encryption_context: encryption_context
64
- ).plaintext
63
+ key = Aws::Plugins::UserAgent.metric('S3_CRYPTO_V1N') do
64
+ @kms_client.decrypt(
65
+ ciphertext_blob: decode64(envelope['x-amz-key-v2']),
66
+ encryption_context: encryption_context
67
+ ).plaintext
68
+ end
65
69
 
66
70
  iv = decode64(envelope['x-amz-iv'])
67
71
  block_mode =
@@ -361,7 +361,9 @@ module Aws
361
361
  instruction_file_suffix: @instruction_file_suffix,
362
362
  kms_encryption_context: kms_encryption_context
363
363
  }
364
- req.send_request
364
+ Aws::Plugins::UserAgent.metric('S3_CRYPTO_V2') do
365
+ req.send_request
366
+ end
365
367
  end
366
368
 
367
369
  # Gets an object from Amazon S3, decrypting data locally.
@@ -414,7 +416,9 @@ module Aws
414
416
  kms_allow_decrypt_with_any_cmk: kms_any_cmk_mode,
415
417
  security_profile: security_profile
416
418
  }
417
- req.send_request(target: block)
419
+ Aws::Plugins::UserAgent.metric('S3_CRYPTO_V2') do
420
+ req.send_request(target: block)
421
+ end
418
422
  end
419
423
 
420
424
  private
@@ -173,6 +173,7 @@ module Aws
173
173
  auth_tag = context.client.get_object(
174
174
  bucket: context.params[:bucket],
175
175
  key: context.params[:key],
176
+ version_id: context.params[:version_id],
176
177
  range: "bytes=-#{auth_tag_length}"
177
178
  ).body.read
178
179
 
@@ -24,11 +24,13 @@ module Aws
24
24
  def encryption_cipher(options = {})
25
25
  validate_key_for_encryption
26
26
  encryption_context = build_encryption_context(@content_encryption_schema, options)
27
- key_data = @kms_client.generate_data_key(
28
- key_id: @kms_key_id,
29
- encryption_context: encryption_context,
30
- key_spec: 'AES_256'
31
- )
27
+ key_data = Aws::Plugins::UserAgent.metric('S3_CRYPTO_V2') do
28
+ @kms_client.generate_data_key(
29
+ key_id: @kms_key_id,
30
+ encryption_context: encryption_context,
31
+ key_spec: 'AES_256'
32
+ )
33
+ end
32
34
  cipher = Utils.aes_encryption_cipher(:GCM)
33
35
  cipher.key = key_data.plaintext
34
36
  envelope = {
@@ -83,7 +85,9 @@ module Aws
83
85
  decrypt_options[:key_id] = @kms_key_id
84
86
  end
85
87
 
86
- key = @kms_client.decrypt(decrypt_options).plaintext
88
+ key = Aws::Plugins::UserAgent.metric('S3_CRYPTO_V2') do
89
+ @kms_client.decrypt(decrypt_options).plaintext
90
+ end
87
91
  iv = decode64(envelope['x-amz-iv'])
88
92
  block_mode =
89
93
  case cek_alg
@@ -0,0 +1,181 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::S3
11
+ # Endpoint parameters used to influence endpoints per request.
12
+ #
13
+ # @!attribute bucket
14
+ # The S3 bucket used to send the request. This is an optional parameter that will be set automatically for operations that are scoped to an S3 bucket.
15
+ #
16
+ # @return [string]
17
+ #
18
+ # @!attribute region
19
+ # The AWS region used to dispatch the request.
20
+ #
21
+ # @return [string]
22
+ #
23
+ # @!attribute use_fips
24
+ # When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
25
+ #
26
+ # @return [boolean]
27
+ #
28
+ # @!attribute use_dual_stack
29
+ # When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
30
+ #
31
+ # @return [boolean]
32
+ #
33
+ # @!attribute endpoint
34
+ # Override the endpoint used to send this request
35
+ #
36
+ # @return [string]
37
+ #
38
+ # @!attribute force_path_style
39
+ # When true, force a path-style endpoint to be used where the bucket name is part of the path.
40
+ #
41
+ # @return [boolean]
42
+ #
43
+ # @!attribute accelerate
44
+ # When true, use S3 Accelerate. NOTE: Not all regions support S3 accelerate.
45
+ #
46
+ # @return [boolean]
47
+ #
48
+ # @!attribute use_global_endpoint
49
+ # Whether the global endpoint should be used, rather then the regional endpoint for us-east-1.
50
+ #
51
+ # @return [boolean]
52
+ #
53
+ # @!attribute use_object_lambda_endpoint
54
+ # Internal parameter to use object lambda endpoint for an operation (eg: WriteGetObjectResponse)
55
+ #
56
+ # @return [boolean]
57
+ #
58
+ # @!attribute key
59
+ # The S3 Key used to send the request. This is an optional parameter that will be set automatically for operations that are scoped to an S3 Key.
60
+ #
61
+ # @return [string]
62
+ #
63
+ # @!attribute prefix
64
+ # The S3 Prefix used to send the request. This is an optional parameter that will be set automatically for operations that are scoped to an S3 Prefix.
65
+ #
66
+ # @return [string]
67
+ #
68
+ # @!attribute copy_source
69
+ # The Copy Source used for Copy Object request. This is an optional parameter that will be set automatically for operations that are scoped to Copy Source.
70
+ #
71
+ # @return [string]
72
+ #
73
+ # @!attribute disable_access_points
74
+ # Internal parameter to disable Access Point Buckets
75
+ #
76
+ # @return [boolean]
77
+ #
78
+ # @!attribute disable_multi_region_access_points
79
+ # Whether multi-region access points (MRAP) should be disabled.
80
+ #
81
+ # @return [boolean]
82
+ #
83
+ # @!attribute use_arn_region
84
+ # When an Access Point ARN is provided and this flag is enabled, the SDK MUST use the ARN&#39;s region when constructing the endpoint instead of the client&#39;s configured region.
85
+ #
86
+ # @return [boolean]
87
+ #
88
+ # @!attribute use_s3_express_control_endpoint
89
+ # Internal parameter to indicate whether S3Express operation should use control plane, (ex. CreateBucket)
90
+ #
91
+ # @return [boolean]
92
+ #
93
+ # @!attribute disable_s3_express_session_auth
94
+ # Parameter to indicate whether S3Express session auth should be disabled
95
+ #
96
+ # @return [boolean]
97
+ #
98
+ EndpointParameters = Struct.new(
99
+ :bucket,
100
+ :region,
101
+ :use_fips,
102
+ :use_dual_stack,
103
+ :endpoint,
104
+ :force_path_style,
105
+ :accelerate,
106
+ :use_global_endpoint,
107
+ :use_object_lambda_endpoint,
108
+ :key,
109
+ :prefix,
110
+ :copy_source,
111
+ :disable_access_points,
112
+ :disable_multi_region_access_points,
113
+ :use_arn_region,
114
+ :use_s3_express_control_endpoint,
115
+ :disable_s3_express_session_auth,
116
+ ) do
117
+ include Aws::Structure
118
+
119
+ # @api private
120
+ class << self
121
+ PARAM_MAP = {
122
+ 'Bucket' => :bucket,
123
+ 'Region' => :region,
124
+ 'UseFIPS' => :use_fips,
125
+ 'UseDualStack' => :use_dual_stack,
126
+ 'Endpoint' => :endpoint,
127
+ 'ForcePathStyle' => :force_path_style,
128
+ 'Accelerate' => :accelerate,
129
+ 'UseGlobalEndpoint' => :use_global_endpoint,
130
+ 'UseObjectLambdaEndpoint' => :use_object_lambda_endpoint,
131
+ 'Key' => :key,
132
+ 'Prefix' => :prefix,
133
+ 'CopySource' => :copy_source,
134
+ 'DisableAccessPoints' => :disable_access_points,
135
+ 'DisableMultiRegionAccessPoints' => :disable_multi_region_access_points,
136
+ 'UseArnRegion' => :use_arn_region,
137
+ 'UseS3ExpressControlEndpoint' => :use_s3_express_control_endpoint,
138
+ 'DisableS3ExpressSessionAuth' => :disable_s3_express_session_auth,
139
+ }.freeze
140
+ end
141
+
142
+ def initialize(options = {})
143
+ self[:bucket] = options[:bucket]
144
+ self[:region] = options[:region]
145
+ self[:use_fips] = options[:use_fips]
146
+ self[:use_fips] = false if self[:use_fips].nil?
147
+ self[:use_dual_stack] = options[:use_dual_stack]
148
+ self[:use_dual_stack] = false if self[:use_dual_stack].nil?
149
+ self[:endpoint] = options[:endpoint]
150
+ self[:force_path_style] = options[:force_path_style]
151
+ self[:force_path_style] = false if self[:force_path_style].nil?
152
+ self[:accelerate] = options[:accelerate]
153
+ self[:accelerate] = false if self[:accelerate].nil?
154
+ self[:use_global_endpoint] = options[:use_global_endpoint]
155
+ self[:use_global_endpoint] = false if self[:use_global_endpoint].nil?
156
+ self[:use_object_lambda_endpoint] = options[:use_object_lambda_endpoint]
157
+ self[:key] = options[:key]
158
+ self[:prefix] = options[:prefix]
159
+ self[:copy_source] = options[:copy_source]
160
+ self[:disable_access_points] = options[:disable_access_points]
161
+ self[:disable_multi_region_access_points] = options[:disable_multi_region_access_points]
162
+ self[:disable_multi_region_access_points] = false if self[:disable_multi_region_access_points].nil?
163
+ self[:use_arn_region] = options[:use_arn_region]
164
+ self[:use_s3_express_control_endpoint] = options[:use_s3_express_control_endpoint]
165
+ self[:disable_s3_express_session_auth] = options[:disable_s3_express_session_auth]
166
+ end
167
+
168
+ def self.create(config, options={})
169
+ new({
170
+ region: config.region,
171
+ use_fips: config.use_fips_endpoint,
172
+ endpoint: (config.endpoint.to_s unless config.regional_endpoint),
173
+ force_path_style: config.force_path_style,
174
+ use_global_endpoint: config.s3_us_east_1_regional_endpoint == 'legacy',
175
+ disable_multi_region_access_points: config.s3_disable_multiregion_access_points,
176
+ use_arn_region: config.s3_use_arn_region,
177
+ disable_s3_express_session_auth: config.disable_s3_express_session_auth,
178
+ }.merge(options))
179
+ end
180
+ end
181
+ end