aws-sdk-s3 1.45.0 → 1.143.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1106 -0
  3. data/LICENSE.txt +202 -0
  4. data/VERSION +1 -0
  5. data/lib/aws-sdk-s3/bucket.rb +784 -98
  6. data/lib/aws-sdk-s3/bucket_acl.rb +64 -18
  7. data/lib/aws-sdk-s3/bucket_cors.rb +79 -18
  8. data/lib/aws-sdk-s3/bucket_lifecycle.rb +66 -20
  9. data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +68 -20
  10. data/lib/aws-sdk-s3/bucket_logging.rb +68 -16
  11. data/lib/aws-sdk-s3/bucket_notification.rb +52 -20
  12. data/lib/aws-sdk-s3/bucket_policy.rb +107 -17
  13. data/lib/aws-sdk-s3/bucket_region_cache.rb +2 -0
  14. data/lib/aws-sdk-s3/bucket_request_payment.rb +60 -15
  15. data/lib/aws-sdk-s3/bucket_tagging.rb +71 -18
  16. data/lib/aws-sdk-s3/bucket_versioning.rb +133 -17
  17. data/lib/aws-sdk-s3/bucket_website.rb +78 -21
  18. data/lib/aws-sdk-s3/client.rb +12610 -902
  19. data/lib/aws-sdk-s3/client_api.rb +1086 -191
  20. data/lib/aws-sdk-s3/customizations/bucket.rb +56 -37
  21. data/lib/aws-sdk-s3/customizations/errors.rb +27 -0
  22. data/lib/aws-sdk-s3/customizations/multipart_upload.rb +2 -0
  23. data/lib/aws-sdk-s3/customizations/object.rb +282 -68
  24. data/lib/aws-sdk-s3/customizations/object_summary.rb +5 -0
  25. data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +2 -0
  26. data/lib/aws-sdk-s3/customizations/types/permanent_redirect.rb +26 -0
  27. data/lib/aws-sdk-s3/customizations.rb +11 -1
  28. data/lib/aws-sdk-s3/encryption/client.rb +28 -7
  29. data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +71 -29
  30. data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +43 -5
  31. data/lib/aws-sdk-s3/encryption/default_key_provider.rb +2 -0
  32. data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +13 -2
  33. data/lib/aws-sdk-s3/encryption/errors.rb +2 -0
  34. data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +2 -0
  35. data/lib/aws-sdk-s3/encryption/io_decrypter.rb +11 -3
  36. data/lib/aws-sdk-s3/encryption/io_encrypter.rb +2 -0
  37. data/lib/aws-sdk-s3/encryption/key_provider.rb +2 -0
  38. data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +46 -11
  39. data/lib/aws-sdk-s3/encryption/materials.rb +8 -6
  40. data/lib/aws-sdk-s3/encryption/utils.rb +25 -0
  41. data/lib/aws-sdk-s3/encryption.rb +4 -0
  42. data/lib/aws-sdk-s3/encryptionV2/client.rb +570 -0
  43. data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +223 -0
  44. data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +170 -0
  45. data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +40 -0
  46. data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +65 -0
  47. data/lib/aws-sdk-s3/encryptionV2/errors.rb +37 -0
  48. data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +58 -0
  49. data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +37 -0
  50. data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +73 -0
  51. data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +31 -0
  52. data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +173 -0
  53. data/lib/aws-sdk-s3/encryptionV2/materials.rb +60 -0
  54. data/lib/aws-sdk-s3/encryptionV2/utils.rb +103 -0
  55. data/lib/aws-sdk-s3/encryption_v2.rb +23 -0
  56. data/lib/aws-sdk-s3/endpoint_parameters.rb +178 -0
  57. data/lib/aws-sdk-s3/endpoint_provider.rb +591 -0
  58. data/lib/aws-sdk-s3/endpoints.rb +2590 -0
  59. data/lib/aws-sdk-s3/errors.rb +123 -1
  60. data/lib/aws-sdk-s3/event_streams.rb +8 -1
  61. data/lib/aws-sdk-s3/express_credentials.rb +55 -0
  62. data/lib/aws-sdk-s3/express_credentials_cache.rb +30 -0
  63. data/lib/aws-sdk-s3/express_credentials_provider.rb +36 -0
  64. data/lib/aws-sdk-s3/file_downloader.rb +176 -44
  65. data/lib/aws-sdk-s3/file_part.rb +11 -6
  66. data/lib/aws-sdk-s3/file_uploader.rb +39 -18
  67. data/lib/aws-sdk-s3/legacy_signer.rb +17 -25
  68. data/lib/aws-sdk-s3/multipart_file_uploader.rb +78 -20
  69. data/lib/aws-sdk-s3/multipart_stream_uploader.rb +56 -18
  70. data/lib/aws-sdk-s3/multipart_upload.rb +242 -32
  71. data/lib/aws-sdk-s3/multipart_upload_error.rb +2 -0
  72. data/lib/aws-sdk-s3/multipart_upload_part.rb +367 -45
  73. data/lib/aws-sdk-s3/object.rb +2191 -227
  74. data/lib/aws-sdk-s3/object_acl.rb +103 -25
  75. data/lib/aws-sdk-s3/object_copier.rb +9 -5
  76. data/lib/aws-sdk-s3/object_multipart_copier.rb +43 -19
  77. data/lib/aws-sdk-s3/object_summary.rb +1811 -208
  78. data/lib/aws-sdk-s3/object_version.rb +452 -80
  79. data/lib/aws-sdk-s3/plugins/accelerate.rb +17 -64
  80. data/lib/aws-sdk-s3/plugins/arn.rb +70 -0
  81. data/lib/aws-sdk-s3/plugins/bucket_dns.rb +7 -43
  82. data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +20 -3
  83. data/lib/aws-sdk-s3/plugins/dualstack.rb +7 -50
  84. data/lib/aws-sdk-s3/plugins/endpoints.rb +274 -0
  85. data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +5 -4
  86. data/lib/aws-sdk-s3/plugins/express_session_auth.rb +91 -0
  87. data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +3 -1
  88. data/lib/aws-sdk-s3/plugins/http_200_errors.rb +11 -3
  89. data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +44 -0
  90. data/lib/aws-sdk-s3/plugins/location_constraint.rb +5 -1
  91. data/lib/aws-sdk-s3/plugins/md5s.rb +35 -30
  92. data/lib/aws-sdk-s3/plugins/redirects.rb +2 -0
  93. data/lib/aws-sdk-s3/plugins/s3_host_id.rb +2 -0
  94. data/lib/aws-sdk-s3/plugins/s3_signer.rb +56 -92
  95. data/lib/aws-sdk-s3/plugins/skip_whole_multipart_get_checksums.rb +31 -0
  96. data/lib/aws-sdk-s3/plugins/sse_cpk.rb +3 -1
  97. data/lib/aws-sdk-s3/plugins/streaming_retry.rb +139 -0
  98. data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +2 -0
  99. data/lib/aws-sdk-s3/presigned_post.rb +160 -99
  100. data/lib/aws-sdk-s3/presigner.rb +171 -80
  101. data/lib/aws-sdk-s3/resource.rb +120 -8
  102. data/lib/aws-sdk-s3/types.rb +11353 -4225
  103. data/lib/aws-sdk-s3/waiters.rb +67 -1
  104. data/lib/aws-sdk-s3.rb +16 -6
  105. data/sig/bucket.rbs +212 -0
  106. data/sig/bucket_acl.rbs +78 -0
  107. data/sig/bucket_cors.rbs +69 -0
  108. data/sig/bucket_lifecycle.rbs +88 -0
  109. data/sig/bucket_lifecycle_configuration.rbs +111 -0
  110. data/sig/bucket_logging.rbs +76 -0
  111. data/sig/bucket_notification.rbs +114 -0
  112. data/sig/bucket_policy.rbs +59 -0
  113. data/sig/bucket_request_payment.rbs +54 -0
  114. data/sig/bucket_tagging.rbs +65 -0
  115. data/sig/bucket_versioning.rbs +77 -0
  116. data/sig/bucket_website.rbs +93 -0
  117. data/sig/client.rbs +2360 -0
  118. data/sig/errors.rbs +34 -0
  119. data/sig/multipart_upload.rbs +110 -0
  120. data/sig/multipart_upload_part.rbs +105 -0
  121. data/sig/object.rbs +436 -0
  122. data/sig/object_acl.rbs +86 -0
  123. data/sig/object_summary.rbs +334 -0
  124. data/sig/object_version.rbs +131 -0
  125. data/sig/resource.rbs +124 -0
  126. data/sig/types.rbs +2562 -0
  127. data/sig/waiters.rbs +83 -0
  128. metadata +68 -15
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
 
3
5
  module Aws
4
6
  module S3
5
7
  class Bucket
6
-
7
8
  # Deletes all objects and versioned objects from this bucket
8
9
  #
9
10
  # @example
@@ -31,10 +32,10 @@ module Aws
31
32
  # each attempt.
32
33
  #
33
34
  # @return [void]
34
- def delete! options = { }
35
+ def delete!(options = {})
35
36
  options = {
36
37
  initial_wait: 1.3,
37
- max_attempts: 3,
38
+ max_attempts: 3
38
39
  }.merge(options)
39
40
 
40
41
  attempts = 0
@@ -43,38 +44,72 @@ module Aws
43
44
  delete
44
45
  rescue Errors::BucketNotEmpty
45
46
  attempts += 1
46
- if attempts >= options[:max_attempts]
47
- raise
48
- else
49
- Kernel.sleep(options[:initial_wait] ** attempts)
50
- retry
51
- end
47
+ raise if attempts >= options[:max_attempts]
48
+
49
+ Kernel.sleep(options[:initial_wait]**attempts)
50
+ retry
52
51
  end
53
52
  end
54
53
 
55
54
  # Returns a public URL for this bucket.
56
55
  #
57
- # bucket = s3.bucket('bucket-name')
58
- # bucket.url
59
- # #=> "https://bucket-name.s3.amazonaws.com"
56
+ # @example
57
+ #
58
+ # bucket = s3.bucket('bucket-name')
59
+ # bucket.url
60
+ # #=> "https://bucket-name.s3.amazonaws.com"
61
+ #
62
+ # It will also work when provided an Access Point ARN.
63
+ #
64
+ # @example
65
+ #
66
+ # bucket = s3.bucket(
67
+ # 'arn:aws:s3:us-east-1:123456789012:accesspoint:myendpoint'
68
+ # )
69
+ # bucket.url
70
+ # #=> "https://myendpoint-123456789012.s3-accesspoint.us-west-2.amazonaws.com"
60
71
  #
61
72
  # You can pass `virtual_host: true` to use the bucket name as the
62
73
  # host name.
63
74
  #
64
- # bucket = s3.bucket('my.bucket.com')
75
+ # bucket = s3.bucket('my-bucket.com')
65
76
  # bucket.url(virtual_host: true)
66
- # #=> "http://my.bucket.com"
77
+ # #=> "http://my-bucket.com"
67
78
  #
68
79
  # @option options [Boolean] :virtual_host (false) When `true`,
69
80
  # the bucket name will be used as the host name. This is useful
70
81
  # when you have a CNAME configured for this bucket.
71
82
  #
83
+ # @option options [Boolean] :secure (true) When `false`, http
84
+ # will be used with virtual_host. This is required when
85
+ # the bucket name has a dot (.) in it.
86
+ #
72
87
  # @return [String] the URL for this bucket.
73
88
  def url(options = {})
74
89
  if options[:virtual_host]
75
- "http://#{name}"
90
+ scheme = options.fetch(:secure, true) ? 'https' : 'http'
91
+ "#{scheme}://#{name}"
76
92
  else
77
- s3_bucket_url
93
+ # Taken from Aws::S3::Endpoints module
94
+ unless client.config.regional_endpoint
95
+ endpoint = client.config.endpoint.to_s
96
+ end
97
+ params = Aws::S3::EndpointParameters.new(
98
+ bucket: name,
99
+ region: client.config.region,
100
+ use_fips: client.config.use_fips_endpoint,
101
+ use_dual_stack: client.config.use_dualstack_endpoint,
102
+ endpoint: endpoint,
103
+ force_path_style: client.config.force_path_style,
104
+ accelerate: client.config.use_accelerate_endpoint,
105
+ use_global_endpoint: client.config.s3_us_east_1_regional_endpoint == 'legacy',
106
+ use_object_lambda_endpoint: nil,
107
+ disable_access_points: nil,
108
+ disable_multi_region_access_points: client.config.s3_disable_multiregion_access_points,
109
+ use_arn_region: client.config.s3_use_arn_region,
110
+ )
111
+ endpoint = Aws::S3::EndpointProvider.new.resolve_endpoint(params)
112
+ endpoint.url
78
113
  end
79
114
  end
80
115
 
@@ -93,35 +128,19 @@ module Aws
93
128
  client.config.credentials,
94
129
  client.config.region,
95
130
  name,
96
- {url: url}.merge(options)
131
+ { url: url }.merge(options)
97
132
  )
98
133
  end
99
134
 
100
135
  # @api private
101
136
  def load
102
- @data = client.list_buckets.buckets.find { |b| b.name == name }
103
- raise "unable to load bucket #{name}" if @data.nil?
104
- self
105
- end
106
-
107
- private
108
-
109
- def s3_bucket_url
110
- url = client.config.endpoint.dup
111
- if bucket_as_hostname?(url.scheme == 'https')
112
- url.host = "#{name}.#{url.host}"
113
- else
114
- url.path += '/' unless url.path[-1] == '/'
115
- url.path += Seahorse::Util.uri_escape(name)
137
+ @data = Aws::Plugins::UserAgent.feature('resource') do
138
+ client.list_buckets.buckets.find { |b| b.name == name }
116
139
  end
117
- url.to_s
118
- end
140
+ raise "unable to load bucket #{name}" if @data.nil?
119
141
 
120
- def bucket_as_hostname?(https)
121
- Plugins::BucketDns.dns_compatible?(name, https) &&
122
- !client.config.force_path_style
142
+ self
123
143
  end
124
-
125
144
  end
126
145
  end
127
146
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ module Errors
6
+ # Hijack PermanentRedirect dynamic error to also include endpoint
7
+ # and bucket.
8
+ class PermanentRedirect < ServiceError
9
+ # @param [Seahorse::Client::RequestContext] context
10
+ # @param [String] message
11
+ # @param [Aws::S3::Types::PermanentRedirect] _data
12
+ def initialize(context, message, _data = Aws::EmptyStructure.new)
13
+ data = Aws::S3::Types::PermanentRedirect.new(message: message)
14
+ body = context.http_response.body_contents
15
+ if (endpoint = body.match(/<Endpoint>(.+?)<\/Endpoint>/))
16
+ data.endpoint = endpoint[1]
17
+ end
18
+ if (bucket = body.match(/<Bucket>(.+?)<\/Bucket>/))
19
+ data.bucket = bucket[1]
20
+ end
21
+ data.region = context.http_response.headers['x-amz-bucket-region']
22
+ super(context, message, data)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aws
2
4
  module S3
3
5
  class MultipartUpload