aws-sdk-s3 1.75.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.
- checksums.yaml +7 -0
- data/lib/aws-sdk-s3.rb +73 -0
- data/lib/aws-sdk-s3/bucket.rb +861 -0
- data/lib/aws-sdk-s3/bucket_acl.rb +277 -0
- data/lib/aws-sdk-s3/bucket_cors.rb +262 -0
- data/lib/aws-sdk-s3/bucket_lifecycle.rb +264 -0
- data/lib/aws-sdk-s3/bucket_lifecycle_configuration.rb +283 -0
- data/lib/aws-sdk-s3/bucket_logging.rb +251 -0
- data/lib/aws-sdk-s3/bucket_notification.rb +293 -0
- data/lib/aws-sdk-s3/bucket_policy.rb +242 -0
- data/lib/aws-sdk-s3/bucket_region_cache.rb +81 -0
- data/lib/aws-sdk-s3/bucket_request_payment.rb +236 -0
- data/lib/aws-sdk-s3/bucket_tagging.rb +251 -0
- data/lib/aws-sdk-s3/bucket_versioning.rb +312 -0
- data/lib/aws-sdk-s3/bucket_website.rb +292 -0
- data/lib/aws-sdk-s3/client.rb +11818 -0
- data/lib/aws-sdk-s3/client_api.rb +3014 -0
- data/lib/aws-sdk-s3/customizations.rb +34 -0
- data/lib/aws-sdk-s3/customizations/bucket.rb +162 -0
- data/lib/aws-sdk-s3/customizations/multipart_upload.rb +44 -0
- data/lib/aws-sdk-s3/customizations/object.rb +389 -0
- data/lib/aws-sdk-s3/customizations/object_summary.rb +85 -0
- data/lib/aws-sdk-s3/customizations/types/list_object_versions_output.rb +13 -0
- data/lib/aws-sdk-s3/encryption.rb +21 -0
- data/lib/aws-sdk-s3/encryption/client.rb +375 -0
- data/lib/aws-sdk-s3/encryption/decrypt_handler.rb +190 -0
- data/lib/aws-sdk-s3/encryption/default_cipher_provider.rb +65 -0
- data/lib/aws-sdk-s3/encryption/default_key_provider.rb +40 -0
- data/lib/aws-sdk-s3/encryption/encrypt_handler.rb +61 -0
- data/lib/aws-sdk-s3/encryption/errors.rb +15 -0
- data/lib/aws-sdk-s3/encryption/io_auth_decrypter.rb +58 -0
- data/lib/aws-sdk-s3/encryption/io_decrypter.rb +36 -0
- data/lib/aws-sdk-s3/encryption/io_encrypter.rb +71 -0
- data/lib/aws-sdk-s3/encryption/key_provider.rb +31 -0
- data/lib/aws-sdk-s3/encryption/kms_cipher_provider.rb +75 -0
- data/lib/aws-sdk-s3/encryption/materials.rb +60 -0
- data/lib/aws-sdk-s3/encryption/utils.rb +81 -0
- data/lib/aws-sdk-s3/encryptionV2/client.rb +388 -0
- data/lib/aws-sdk-s3/encryptionV2/decrypt_handler.rb +198 -0
- data/lib/aws-sdk-s3/encryptionV2/default_cipher_provider.rb +103 -0
- data/lib/aws-sdk-s3/encryptionV2/default_key_provider.rb +38 -0
- data/lib/aws-sdk-s3/encryptionV2/encrypt_handler.rb +66 -0
- data/lib/aws-sdk-s3/encryptionV2/errors.rb +13 -0
- data/lib/aws-sdk-s3/encryptionV2/io_auth_decrypter.rb +56 -0
- data/lib/aws-sdk-s3/encryptionV2/io_decrypter.rb +35 -0
- data/lib/aws-sdk-s3/encryptionV2/io_encrypter.rb +71 -0
- data/lib/aws-sdk-s3/encryptionV2/key_provider.rb +29 -0
- data/lib/aws-sdk-s3/encryptionV2/kms_cipher_provider.rb +99 -0
- data/lib/aws-sdk-s3/encryptionV2/materials.rb +58 -0
- data/lib/aws-sdk-s3/encryptionV2/utils.rb +116 -0
- data/lib/aws-sdk-s3/encryption_v2.rb +20 -0
- data/lib/aws-sdk-s3/errors.rb +115 -0
- data/lib/aws-sdk-s3/event_streams.rb +69 -0
- data/lib/aws-sdk-s3/file_downloader.rb +142 -0
- data/lib/aws-sdk-s3/file_part.rb +78 -0
- data/lib/aws-sdk-s3/file_uploader.rb +70 -0
- data/lib/aws-sdk-s3/legacy_signer.rb +189 -0
- data/lib/aws-sdk-s3/multipart_file_uploader.rb +227 -0
- data/lib/aws-sdk-s3/multipart_stream_uploader.rb +173 -0
- data/lib/aws-sdk-s3/multipart_upload.rb +401 -0
- data/lib/aws-sdk-s3/multipart_upload_error.rb +18 -0
- data/lib/aws-sdk-s3/multipart_upload_part.rb +423 -0
- data/lib/aws-sdk-s3/object.rb +1422 -0
- data/lib/aws-sdk-s3/object_acl.rb +333 -0
- data/lib/aws-sdk-s3/object_copier.rb +101 -0
- data/lib/aws-sdk-s3/object_multipart_copier.rb +182 -0
- data/lib/aws-sdk-s3/object_summary.rb +1181 -0
- data/lib/aws-sdk-s3/object_version.rb +550 -0
- data/lib/aws-sdk-s3/plugins/accelerate.rb +87 -0
- data/lib/aws-sdk-s3/plugins/bucket_arn.rb +212 -0
- data/lib/aws-sdk-s3/plugins/bucket_dns.rb +91 -0
- data/lib/aws-sdk-s3/plugins/bucket_name_restrictions.rb +45 -0
- data/lib/aws-sdk-s3/plugins/dualstack.rb +74 -0
- data/lib/aws-sdk-s3/plugins/expect_100_continue.rb +28 -0
- data/lib/aws-sdk-s3/plugins/get_bucket_location_fix.rb +25 -0
- data/lib/aws-sdk-s3/plugins/http_200_errors.rb +55 -0
- data/lib/aws-sdk-s3/plugins/iad_regional_endpoint.rb +62 -0
- data/lib/aws-sdk-s3/plugins/location_constraint.rb +35 -0
- data/lib/aws-sdk-s3/plugins/md5s.rb +84 -0
- data/lib/aws-sdk-s3/plugins/redirects.rb +45 -0
- data/lib/aws-sdk-s3/plugins/s3_host_id.rb +30 -0
- data/lib/aws-sdk-s3/plugins/s3_signer.rb +222 -0
- data/lib/aws-sdk-s3/plugins/sse_cpk.rb +70 -0
- data/lib/aws-sdk-s3/plugins/streaming_retry.rb +118 -0
- data/lib/aws-sdk-s3/plugins/url_encoded_keys.rb +97 -0
- data/lib/aws-sdk-s3/presigned_post.rb +686 -0
- data/lib/aws-sdk-s3/presigner.rb +253 -0
- data/lib/aws-sdk-s3/resource.rb +117 -0
- data/lib/aws-sdk-s3/types.rb +13154 -0
- data/lib/aws-sdk-s3/waiters.rb +243 -0
- metadata +184 -0
|
@@ -0,0 +1,242 @@
|
|
|
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/master/CONTRIBUTING.md
|
|
7
|
+
#
|
|
8
|
+
# WARNING ABOUT GENERATED CODE
|
|
9
|
+
|
|
10
|
+
module Aws::S3
|
|
11
|
+
|
|
12
|
+
class BucketPolicy
|
|
13
|
+
|
|
14
|
+
extend Aws::Deprecations
|
|
15
|
+
|
|
16
|
+
# @overload def initialize(bucket_name, options = {})
|
|
17
|
+
# @param [String] bucket_name
|
|
18
|
+
# @option options [Client] :client
|
|
19
|
+
# @overload def initialize(options = {})
|
|
20
|
+
# @option options [required, String] :bucket_name
|
|
21
|
+
# @option options [Client] :client
|
|
22
|
+
def initialize(*args)
|
|
23
|
+
options = Hash === args.last ? args.pop.dup : {}
|
|
24
|
+
@bucket_name = extract_bucket_name(args, options)
|
|
25
|
+
@data = options.delete(:data)
|
|
26
|
+
@client = options.delete(:client) || Client.new(options)
|
|
27
|
+
@waiter_block_warned = false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @!group Read-Only Attributes
|
|
31
|
+
|
|
32
|
+
# @return [String]
|
|
33
|
+
def bucket_name
|
|
34
|
+
@bucket_name
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# The bucket policy as a JSON document.
|
|
38
|
+
# @return [IO]
|
|
39
|
+
def policy
|
|
40
|
+
data[:policy]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @!endgroup
|
|
44
|
+
|
|
45
|
+
# @return [Client]
|
|
46
|
+
def client
|
|
47
|
+
@client
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Loads, or reloads {#data} for the current {BucketPolicy}.
|
|
51
|
+
# Returns `self` making it possible to chain methods.
|
|
52
|
+
#
|
|
53
|
+
# bucket_policy.reload.data
|
|
54
|
+
#
|
|
55
|
+
# @return [self]
|
|
56
|
+
def load
|
|
57
|
+
resp = @client.get_bucket_policy(bucket: @bucket_name)
|
|
58
|
+
@data = resp.data
|
|
59
|
+
self
|
|
60
|
+
end
|
|
61
|
+
alias :reload :load
|
|
62
|
+
|
|
63
|
+
# @return [Types::GetBucketPolicyOutput]
|
|
64
|
+
# Returns the data for this {BucketPolicy}. Calls
|
|
65
|
+
# {Client#get_bucket_policy} if {#data_loaded?} is `false`.
|
|
66
|
+
def data
|
|
67
|
+
load unless @data
|
|
68
|
+
@data
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @return [Boolean]
|
|
72
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
|
73
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
|
74
|
+
def data_loaded?
|
|
75
|
+
!!@data
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @deprecated Use [Aws::S3::Client] #wait_until instead
|
|
79
|
+
#
|
|
80
|
+
# Waiter polls an API operation until a resource enters a desired
|
|
81
|
+
# state.
|
|
82
|
+
#
|
|
83
|
+
# @note The waiting operation is performed on a copy. The original resource
|
|
84
|
+
# remains unchanged.
|
|
85
|
+
#
|
|
86
|
+
# ## Basic Usage
|
|
87
|
+
#
|
|
88
|
+
# Waiter will polls until it is successful, it fails by
|
|
89
|
+
# entering a terminal state, or until a maximum number of attempts
|
|
90
|
+
# are made.
|
|
91
|
+
#
|
|
92
|
+
# # polls in a loop until condition is true
|
|
93
|
+
# resource.wait_until(options) {|resource| condition}
|
|
94
|
+
#
|
|
95
|
+
# ## Example
|
|
96
|
+
#
|
|
97
|
+
# instance.wait_until(max_attempts:10, delay:5) do |instance|
|
|
98
|
+
# instance.state.name == 'running'
|
|
99
|
+
# end
|
|
100
|
+
#
|
|
101
|
+
# ## Configuration
|
|
102
|
+
#
|
|
103
|
+
# You can configure the maximum number of polling attempts, and the
|
|
104
|
+
# delay (in seconds) between each polling attempt. The waiting condition is
|
|
105
|
+
# set by passing a block to {#wait_until}:
|
|
106
|
+
#
|
|
107
|
+
# # poll for ~25 seconds
|
|
108
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
|
109
|
+
#
|
|
110
|
+
# ## Callbacks
|
|
111
|
+
#
|
|
112
|
+
# You can be notified before each polling attempt and before each
|
|
113
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
|
114
|
+
# it will terminate the waiter.
|
|
115
|
+
#
|
|
116
|
+
# started_at = Time.now
|
|
117
|
+
# # poll for 1 hour, instead of a number of attempts
|
|
118
|
+
# proc = Proc.new do |attempts, response|
|
|
119
|
+
# throw :failure if Time.now - started_at > 3600
|
|
120
|
+
# end
|
|
121
|
+
#
|
|
122
|
+
# # disable max attempts
|
|
123
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
|
124
|
+
#
|
|
125
|
+
# ## Handling Errors
|
|
126
|
+
#
|
|
127
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
|
128
|
+
# fails, it raises an error.
|
|
129
|
+
#
|
|
130
|
+
# begin
|
|
131
|
+
# resource.wait_until(...)
|
|
132
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
|
133
|
+
# # resource did not enter the desired state in time
|
|
134
|
+
# end
|
|
135
|
+
#
|
|
136
|
+
# @yieldparam [Resource] resource to be used in the waiting condition.
|
|
137
|
+
#
|
|
138
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
|
|
139
|
+
# terminates because the waiter has entered a state that it will not
|
|
140
|
+
# transition out of, preventing success.
|
|
141
|
+
#
|
|
142
|
+
# yet successful.
|
|
143
|
+
#
|
|
144
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
|
|
145
|
+
# encountered while polling for a resource that is not expected.
|
|
146
|
+
#
|
|
147
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
|
148
|
+
#
|
|
149
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
|
150
|
+
# attempts
|
|
151
|
+
# @option options [Integer] :delay (10) Delay between each
|
|
152
|
+
# attempt in seconds
|
|
153
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
|
154
|
+
# invoked before each attempt
|
|
155
|
+
# @option options [Proc] :before_wait (nil) Callback
|
|
156
|
+
# invoked before each wait
|
|
157
|
+
# @return [Resource] if the waiter was successful
|
|
158
|
+
def wait_until(options = {}, &block)
|
|
159
|
+
self_copy = self.dup
|
|
160
|
+
attempts = 0
|
|
161
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
|
162
|
+
options[:delay] ||= 10
|
|
163
|
+
options[:poller] = Proc.new do
|
|
164
|
+
attempts += 1
|
|
165
|
+
if block.call(self_copy)
|
|
166
|
+
[:success, self_copy]
|
|
167
|
+
else
|
|
168
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
|
169
|
+
:retry
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# @!group Actions
|
|
176
|
+
|
|
177
|
+
# @example Request syntax with placeholder values
|
|
178
|
+
#
|
|
179
|
+
# bucket_policy.delete()
|
|
180
|
+
# @param [Hash] options ({})
|
|
181
|
+
# @return [EmptyStructure]
|
|
182
|
+
def delete(options = {})
|
|
183
|
+
options = options.merge(bucket: @bucket_name)
|
|
184
|
+
resp = @client.delete_bucket_policy(options)
|
|
185
|
+
resp.data
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# @example Request syntax with placeholder values
|
|
189
|
+
#
|
|
190
|
+
# bucket_policy.put({
|
|
191
|
+
# content_md5: "ContentMD5",
|
|
192
|
+
# confirm_remove_self_bucket_access: false,
|
|
193
|
+
# policy: "Policy", # required
|
|
194
|
+
# })
|
|
195
|
+
# @param [Hash] options ({})
|
|
196
|
+
# @option options [String] :content_md5
|
|
197
|
+
# The MD5 hash of the request body.
|
|
198
|
+
# @option options [Boolean] :confirm_remove_self_bucket_access
|
|
199
|
+
# Set this parameter to true to confirm that you want to remove your
|
|
200
|
+
# permissions to change this bucket policy in the future.
|
|
201
|
+
# @option options [required, String] :policy
|
|
202
|
+
# The bucket policy as a JSON document.
|
|
203
|
+
# @return [EmptyStructure]
|
|
204
|
+
def put(options = {})
|
|
205
|
+
options = options.merge(bucket: @bucket_name)
|
|
206
|
+
resp = @client.put_bucket_policy(options)
|
|
207
|
+
resp.data
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# @!group Associations
|
|
211
|
+
|
|
212
|
+
# @return [Bucket]
|
|
213
|
+
def bucket
|
|
214
|
+
Bucket.new(
|
|
215
|
+
name: @bucket_name,
|
|
216
|
+
client: @client
|
|
217
|
+
)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# @deprecated
|
|
221
|
+
# @api private
|
|
222
|
+
def identifiers
|
|
223
|
+
{ bucket_name: @bucket_name }
|
|
224
|
+
end
|
|
225
|
+
deprecated(:identifiers)
|
|
226
|
+
|
|
227
|
+
private
|
|
228
|
+
|
|
229
|
+
def extract_bucket_name(args, options)
|
|
230
|
+
value = args[0] || options.delete(:bucket_name)
|
|
231
|
+
case value
|
|
232
|
+
when String then value
|
|
233
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
|
234
|
+
else
|
|
235
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
|
236
|
+
raise ArgumentError, msg
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
class Collection < Aws::Resources::Collection; end
|
|
241
|
+
end
|
|
242
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'thread'
|
|
4
|
+
|
|
5
|
+
module Aws
|
|
6
|
+
module S3
|
|
7
|
+
class BucketRegionCache
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
@regions = {}
|
|
11
|
+
@listeners = []
|
|
12
|
+
@mutex = Mutex.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Registers a block as a callback. This listener is called when a
|
|
16
|
+
# new bucket/region pair is added to the cache.
|
|
17
|
+
#
|
|
18
|
+
# S3::BUCKET_REGIONS.bucket_added do |bucket_name, region_name|
|
|
19
|
+
# # ...
|
|
20
|
+
# end
|
|
21
|
+
#
|
|
22
|
+
# This happens when a request is made against the classic endpoint,
|
|
23
|
+
# "s3.amazonaws.com" and an error is returned requiring the request
|
|
24
|
+
# to be resent with Signature Version 4. At this point, multiple
|
|
25
|
+
# requests are made to discover the bucket region so that a v4
|
|
26
|
+
# signature can be generated.
|
|
27
|
+
#
|
|
28
|
+
# An application can register listeners here to avoid these extra
|
|
29
|
+
# requests in the future. By constructing an {S3::Client} with
|
|
30
|
+
# the proper region, a proper signature can be generated and redirects
|
|
31
|
+
# avoided.
|
|
32
|
+
# @return [void]
|
|
33
|
+
def bucket_added(&block)
|
|
34
|
+
if block
|
|
35
|
+
@mutex.synchronize { @listeners << block }
|
|
36
|
+
else
|
|
37
|
+
raise ArgumentError, 'missing required block'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @param [String] bucket_name
|
|
42
|
+
# @return [String,nil] Returns the cached region for the named bucket.
|
|
43
|
+
# Returns `nil` if the bucket is not in the cache.
|
|
44
|
+
# @api private
|
|
45
|
+
def [](bucket_name)
|
|
46
|
+
@mutex.synchronize { @regions[bucket_name] }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Caches a bucket's region. Calling this method will trigger each
|
|
50
|
+
# of the {#bucket_added} listener callbacks.
|
|
51
|
+
# @param [String] bucket_name
|
|
52
|
+
# @param [String] region_name
|
|
53
|
+
# @return [void]
|
|
54
|
+
# @api private
|
|
55
|
+
def []=(bucket_name, region_name)
|
|
56
|
+
@mutex.synchronize do
|
|
57
|
+
@regions[bucket_name] = region_name
|
|
58
|
+
@listeners.each { |block| block.call(bucket_name, region_name) }
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# @api private
|
|
63
|
+
def clear
|
|
64
|
+
@mutex.synchronize { @regions = {} }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# @return [Hash] Returns a hash of cached bucket names and region names.
|
|
68
|
+
def to_hash
|
|
69
|
+
@mutex.synchronize do
|
|
70
|
+
@regions.dup
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
alias to_h to_hash
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @api private
|
|
78
|
+
BUCKET_REGIONS = BucketRegionCache.new
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,236 @@
|
|
|
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/master/CONTRIBUTING.md
|
|
7
|
+
#
|
|
8
|
+
# WARNING ABOUT GENERATED CODE
|
|
9
|
+
|
|
10
|
+
module Aws::S3
|
|
11
|
+
|
|
12
|
+
class BucketRequestPayment
|
|
13
|
+
|
|
14
|
+
extend Aws::Deprecations
|
|
15
|
+
|
|
16
|
+
# @overload def initialize(bucket_name, options = {})
|
|
17
|
+
# @param [String] bucket_name
|
|
18
|
+
# @option options [Client] :client
|
|
19
|
+
# @overload def initialize(options = {})
|
|
20
|
+
# @option options [required, String] :bucket_name
|
|
21
|
+
# @option options [Client] :client
|
|
22
|
+
def initialize(*args)
|
|
23
|
+
options = Hash === args.last ? args.pop.dup : {}
|
|
24
|
+
@bucket_name = extract_bucket_name(args, options)
|
|
25
|
+
@data = options.delete(:data)
|
|
26
|
+
@client = options.delete(:client) || Client.new(options)
|
|
27
|
+
@waiter_block_warned = false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @!group Read-Only Attributes
|
|
31
|
+
|
|
32
|
+
# @return [String]
|
|
33
|
+
def bucket_name
|
|
34
|
+
@bucket_name
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Specifies who pays for the download and request fees.
|
|
38
|
+
# @return [String]
|
|
39
|
+
def payer
|
|
40
|
+
data[:payer]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @!endgroup
|
|
44
|
+
|
|
45
|
+
# @return [Client]
|
|
46
|
+
def client
|
|
47
|
+
@client
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Loads, or reloads {#data} for the current {BucketRequestPayment}.
|
|
51
|
+
# Returns `self` making it possible to chain methods.
|
|
52
|
+
#
|
|
53
|
+
# bucket_request_payment.reload.data
|
|
54
|
+
#
|
|
55
|
+
# @return [self]
|
|
56
|
+
def load
|
|
57
|
+
resp = @client.get_bucket_request_payment(bucket: @bucket_name)
|
|
58
|
+
@data = resp.data
|
|
59
|
+
self
|
|
60
|
+
end
|
|
61
|
+
alias :reload :load
|
|
62
|
+
|
|
63
|
+
# @return [Types::GetBucketRequestPaymentOutput]
|
|
64
|
+
# Returns the data for this {BucketRequestPayment}. Calls
|
|
65
|
+
# {Client#get_bucket_request_payment} if {#data_loaded?} is `false`.
|
|
66
|
+
def data
|
|
67
|
+
load unless @data
|
|
68
|
+
@data
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @return [Boolean]
|
|
72
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
|
73
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
|
74
|
+
def data_loaded?
|
|
75
|
+
!!@data
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# @deprecated Use [Aws::S3::Client] #wait_until instead
|
|
79
|
+
#
|
|
80
|
+
# Waiter polls an API operation until a resource enters a desired
|
|
81
|
+
# state.
|
|
82
|
+
#
|
|
83
|
+
# @note The waiting operation is performed on a copy. The original resource
|
|
84
|
+
# remains unchanged.
|
|
85
|
+
#
|
|
86
|
+
# ## Basic Usage
|
|
87
|
+
#
|
|
88
|
+
# Waiter will polls until it is successful, it fails by
|
|
89
|
+
# entering a terminal state, or until a maximum number of attempts
|
|
90
|
+
# are made.
|
|
91
|
+
#
|
|
92
|
+
# # polls in a loop until condition is true
|
|
93
|
+
# resource.wait_until(options) {|resource| condition}
|
|
94
|
+
#
|
|
95
|
+
# ## Example
|
|
96
|
+
#
|
|
97
|
+
# instance.wait_until(max_attempts:10, delay:5) do |instance|
|
|
98
|
+
# instance.state.name == 'running'
|
|
99
|
+
# end
|
|
100
|
+
#
|
|
101
|
+
# ## Configuration
|
|
102
|
+
#
|
|
103
|
+
# You can configure the maximum number of polling attempts, and the
|
|
104
|
+
# delay (in seconds) between each polling attempt. The waiting condition is
|
|
105
|
+
# set by passing a block to {#wait_until}:
|
|
106
|
+
#
|
|
107
|
+
# # poll for ~25 seconds
|
|
108
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
|
109
|
+
#
|
|
110
|
+
# ## Callbacks
|
|
111
|
+
#
|
|
112
|
+
# You can be notified before each polling attempt and before each
|
|
113
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
|
114
|
+
# it will terminate the waiter.
|
|
115
|
+
#
|
|
116
|
+
# started_at = Time.now
|
|
117
|
+
# # poll for 1 hour, instead of a number of attempts
|
|
118
|
+
# proc = Proc.new do |attempts, response|
|
|
119
|
+
# throw :failure if Time.now - started_at > 3600
|
|
120
|
+
# end
|
|
121
|
+
#
|
|
122
|
+
# # disable max attempts
|
|
123
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
|
124
|
+
#
|
|
125
|
+
# ## Handling Errors
|
|
126
|
+
#
|
|
127
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
|
128
|
+
# fails, it raises an error.
|
|
129
|
+
#
|
|
130
|
+
# begin
|
|
131
|
+
# resource.wait_until(...)
|
|
132
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
|
133
|
+
# # resource did not enter the desired state in time
|
|
134
|
+
# end
|
|
135
|
+
#
|
|
136
|
+
# @yieldparam [Resource] resource to be used in the waiting condition.
|
|
137
|
+
#
|
|
138
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
|
|
139
|
+
# terminates because the waiter has entered a state that it will not
|
|
140
|
+
# transition out of, preventing success.
|
|
141
|
+
#
|
|
142
|
+
# yet successful.
|
|
143
|
+
#
|
|
144
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
|
|
145
|
+
# encountered while polling for a resource that is not expected.
|
|
146
|
+
#
|
|
147
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
|
148
|
+
#
|
|
149
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
|
150
|
+
# attempts
|
|
151
|
+
# @option options [Integer] :delay (10) Delay between each
|
|
152
|
+
# attempt in seconds
|
|
153
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
|
154
|
+
# invoked before each attempt
|
|
155
|
+
# @option options [Proc] :before_wait (nil) Callback
|
|
156
|
+
# invoked before each wait
|
|
157
|
+
# @return [Resource] if the waiter was successful
|
|
158
|
+
def wait_until(options = {}, &block)
|
|
159
|
+
self_copy = self.dup
|
|
160
|
+
attempts = 0
|
|
161
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
|
162
|
+
options[:delay] ||= 10
|
|
163
|
+
options[:poller] = Proc.new do
|
|
164
|
+
attempts += 1
|
|
165
|
+
if block.call(self_copy)
|
|
166
|
+
[:success, self_copy]
|
|
167
|
+
else
|
|
168
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
|
169
|
+
:retry
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# @!group Actions
|
|
176
|
+
|
|
177
|
+
# @example Request syntax with placeholder values
|
|
178
|
+
#
|
|
179
|
+
# bucket_request_payment.put({
|
|
180
|
+
# content_md5: "ContentMD5",
|
|
181
|
+
# request_payment_configuration: { # required
|
|
182
|
+
# payer: "Requester", # required, accepts Requester, BucketOwner
|
|
183
|
+
# },
|
|
184
|
+
# })
|
|
185
|
+
# @param [Hash] options ({})
|
|
186
|
+
# @option options [String] :content_md5
|
|
187
|
+
# >The base64-encoded 128-bit MD5 digest of the data. You must use
|
|
188
|
+
# this header as a message integrity check to verify that the request
|
|
189
|
+
# body was not corrupted in transit. For more information, see [RFC
|
|
190
|
+
# 1864][1].
|
|
191
|
+
#
|
|
192
|
+
#
|
|
193
|
+
#
|
|
194
|
+
# [1]: http://www.ietf.org/rfc/rfc1864.txt
|
|
195
|
+
# @option options [required, Types::RequestPaymentConfiguration] :request_payment_configuration
|
|
196
|
+
# Container for Payer.
|
|
197
|
+
# @return [EmptyStructure]
|
|
198
|
+
def put(options = {})
|
|
199
|
+
options = options.merge(bucket: @bucket_name)
|
|
200
|
+
resp = @client.put_bucket_request_payment(options)
|
|
201
|
+
resp.data
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# @!group Associations
|
|
205
|
+
|
|
206
|
+
# @return [Bucket]
|
|
207
|
+
def bucket
|
|
208
|
+
Bucket.new(
|
|
209
|
+
name: @bucket_name,
|
|
210
|
+
client: @client
|
|
211
|
+
)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# @deprecated
|
|
215
|
+
# @api private
|
|
216
|
+
def identifiers
|
|
217
|
+
{ bucket_name: @bucket_name }
|
|
218
|
+
end
|
|
219
|
+
deprecated(:identifiers)
|
|
220
|
+
|
|
221
|
+
private
|
|
222
|
+
|
|
223
|
+
def extract_bucket_name(args, options)
|
|
224
|
+
value = args[0] || options.delete(:bucket_name)
|
|
225
|
+
case value
|
|
226
|
+
when String then value
|
|
227
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
|
228
|
+
else
|
|
229
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
|
230
|
+
raise ArgumentError, msg
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
class Collection < Aws::Resources::Collection; end
|
|
235
|
+
end
|
|
236
|
+
end
|