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,251 @@
|
|
|
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 BucketTagging
|
|
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
|
+
# Contains the tag set.
|
|
38
|
+
# @return [Array<Types::Tag>]
|
|
39
|
+
def tag_set
|
|
40
|
+
data[:tag_set]
|
|
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 {BucketTagging}.
|
|
51
|
+
# Returns `self` making it possible to chain methods.
|
|
52
|
+
#
|
|
53
|
+
# bucket_tagging.reload.data
|
|
54
|
+
#
|
|
55
|
+
# @return [self]
|
|
56
|
+
def load
|
|
57
|
+
resp = @client.get_bucket_tagging(bucket: @bucket_name)
|
|
58
|
+
@data = resp.data
|
|
59
|
+
self
|
|
60
|
+
end
|
|
61
|
+
alias :reload :load
|
|
62
|
+
|
|
63
|
+
# @return [Types::GetBucketTaggingOutput]
|
|
64
|
+
# Returns the data for this {BucketTagging}. Calls
|
|
65
|
+
# {Client#get_bucket_tagging} 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_tagging.delete()
|
|
180
|
+
# @param [Hash] options ({})
|
|
181
|
+
# @return [EmptyStructure]
|
|
182
|
+
def delete(options = {})
|
|
183
|
+
options = options.merge(bucket: @bucket_name)
|
|
184
|
+
resp = @client.delete_bucket_tagging(options)
|
|
185
|
+
resp.data
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# @example Request syntax with placeholder values
|
|
189
|
+
#
|
|
190
|
+
# bucket_tagging.put({
|
|
191
|
+
# content_md5: "ContentMD5",
|
|
192
|
+
# tagging: { # required
|
|
193
|
+
# tag_set: [ # required
|
|
194
|
+
# {
|
|
195
|
+
# key: "ObjectKey", # required
|
|
196
|
+
# value: "Value", # required
|
|
197
|
+
# },
|
|
198
|
+
# ],
|
|
199
|
+
# },
|
|
200
|
+
# })
|
|
201
|
+
# @param [Hash] options ({})
|
|
202
|
+
# @option options [String] :content_md5
|
|
203
|
+
# The base64-encoded 128-bit MD5 digest of the data. You must use this
|
|
204
|
+
# header as a message integrity check to verify that the request body
|
|
205
|
+
# was not corrupted in transit. For more information, see [RFC 1864][1].
|
|
206
|
+
#
|
|
207
|
+
#
|
|
208
|
+
#
|
|
209
|
+
# [1]: http://www.ietf.org/rfc/rfc1864.txt
|
|
210
|
+
# @option options [required, Types::Tagging] :tagging
|
|
211
|
+
# Container for the `TagSet` and `Tag` elements.
|
|
212
|
+
# @return [EmptyStructure]
|
|
213
|
+
def put(options = {})
|
|
214
|
+
options = options.merge(bucket: @bucket_name)
|
|
215
|
+
resp = @client.put_bucket_tagging(options)
|
|
216
|
+
resp.data
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# @!group Associations
|
|
220
|
+
|
|
221
|
+
# @return [Bucket]
|
|
222
|
+
def bucket
|
|
223
|
+
Bucket.new(
|
|
224
|
+
name: @bucket_name,
|
|
225
|
+
client: @client
|
|
226
|
+
)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# @deprecated
|
|
230
|
+
# @api private
|
|
231
|
+
def identifiers
|
|
232
|
+
{ bucket_name: @bucket_name }
|
|
233
|
+
end
|
|
234
|
+
deprecated(:identifiers)
|
|
235
|
+
|
|
236
|
+
private
|
|
237
|
+
|
|
238
|
+
def extract_bucket_name(args, options)
|
|
239
|
+
value = args[0] || options.delete(:bucket_name)
|
|
240
|
+
case value
|
|
241
|
+
when String then value
|
|
242
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
|
243
|
+
else
|
|
244
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
|
245
|
+
raise ArgumentError, msg
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
class Collection < Aws::Resources::Collection; end
|
|
250
|
+
end
|
|
251
|
+
end
|
|
@@ -0,0 +1,312 @@
|
|
|
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 BucketVersioning
|
|
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 versioning state of the bucket.
|
|
38
|
+
# @return [String]
|
|
39
|
+
def status
|
|
40
|
+
data[:status]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Specifies whether MFA delete is enabled in the bucket versioning
|
|
44
|
+
# configuration. This element is only returned if the bucket has been
|
|
45
|
+
# configured with MFA delete. If the bucket has never been so
|
|
46
|
+
# configured, this element is not returned.
|
|
47
|
+
# @return [String]
|
|
48
|
+
def mfa_delete
|
|
49
|
+
data[:mfa_delete]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# @!endgroup
|
|
53
|
+
|
|
54
|
+
# @return [Client]
|
|
55
|
+
def client
|
|
56
|
+
@client
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Loads, or reloads {#data} for the current {BucketVersioning}.
|
|
60
|
+
# Returns `self` making it possible to chain methods.
|
|
61
|
+
#
|
|
62
|
+
# bucket_versioning.reload.data
|
|
63
|
+
#
|
|
64
|
+
# @return [self]
|
|
65
|
+
def load
|
|
66
|
+
resp = @client.get_bucket_versioning(bucket: @bucket_name)
|
|
67
|
+
@data = resp.data
|
|
68
|
+
self
|
|
69
|
+
end
|
|
70
|
+
alias :reload :load
|
|
71
|
+
|
|
72
|
+
# @return [Types::GetBucketVersioningOutput]
|
|
73
|
+
# Returns the data for this {BucketVersioning}. Calls
|
|
74
|
+
# {Client#get_bucket_versioning} if {#data_loaded?} is `false`.
|
|
75
|
+
def data
|
|
76
|
+
load unless @data
|
|
77
|
+
@data
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# @return [Boolean]
|
|
81
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
|
82
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
|
83
|
+
def data_loaded?
|
|
84
|
+
!!@data
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @deprecated Use [Aws::S3::Client] #wait_until instead
|
|
88
|
+
#
|
|
89
|
+
# Waiter polls an API operation until a resource enters a desired
|
|
90
|
+
# state.
|
|
91
|
+
#
|
|
92
|
+
# @note The waiting operation is performed on a copy. The original resource
|
|
93
|
+
# remains unchanged.
|
|
94
|
+
#
|
|
95
|
+
# ## Basic Usage
|
|
96
|
+
#
|
|
97
|
+
# Waiter will polls until it is successful, it fails by
|
|
98
|
+
# entering a terminal state, or until a maximum number of attempts
|
|
99
|
+
# are made.
|
|
100
|
+
#
|
|
101
|
+
# # polls in a loop until condition is true
|
|
102
|
+
# resource.wait_until(options) {|resource| condition}
|
|
103
|
+
#
|
|
104
|
+
# ## Example
|
|
105
|
+
#
|
|
106
|
+
# instance.wait_until(max_attempts:10, delay:5) do |instance|
|
|
107
|
+
# instance.state.name == 'running'
|
|
108
|
+
# end
|
|
109
|
+
#
|
|
110
|
+
# ## Configuration
|
|
111
|
+
#
|
|
112
|
+
# You can configure the maximum number of polling attempts, and the
|
|
113
|
+
# delay (in seconds) between each polling attempt. The waiting condition is
|
|
114
|
+
# set by passing a block to {#wait_until}:
|
|
115
|
+
#
|
|
116
|
+
# # poll for ~25 seconds
|
|
117
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
|
118
|
+
#
|
|
119
|
+
# ## Callbacks
|
|
120
|
+
#
|
|
121
|
+
# You can be notified before each polling attempt and before each
|
|
122
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
|
123
|
+
# it will terminate the waiter.
|
|
124
|
+
#
|
|
125
|
+
# started_at = Time.now
|
|
126
|
+
# # poll for 1 hour, instead of a number of attempts
|
|
127
|
+
# proc = Proc.new do |attempts, response|
|
|
128
|
+
# throw :failure if Time.now - started_at > 3600
|
|
129
|
+
# end
|
|
130
|
+
#
|
|
131
|
+
# # disable max attempts
|
|
132
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
|
133
|
+
#
|
|
134
|
+
# ## Handling Errors
|
|
135
|
+
#
|
|
136
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
|
137
|
+
# fails, it raises an error.
|
|
138
|
+
#
|
|
139
|
+
# begin
|
|
140
|
+
# resource.wait_until(...)
|
|
141
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
|
142
|
+
# # resource did not enter the desired state in time
|
|
143
|
+
# end
|
|
144
|
+
#
|
|
145
|
+
# @yieldparam [Resource] resource to be used in the waiting condition.
|
|
146
|
+
#
|
|
147
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
|
|
148
|
+
# terminates because the waiter has entered a state that it will not
|
|
149
|
+
# transition out of, preventing success.
|
|
150
|
+
#
|
|
151
|
+
# yet successful.
|
|
152
|
+
#
|
|
153
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
|
|
154
|
+
# encountered while polling for a resource that is not expected.
|
|
155
|
+
#
|
|
156
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
|
157
|
+
#
|
|
158
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
|
159
|
+
# attempts
|
|
160
|
+
# @option options [Integer] :delay (10) Delay between each
|
|
161
|
+
# attempt in seconds
|
|
162
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
|
163
|
+
# invoked before each attempt
|
|
164
|
+
# @option options [Proc] :before_wait (nil) Callback
|
|
165
|
+
# invoked before each wait
|
|
166
|
+
# @return [Resource] if the waiter was successful
|
|
167
|
+
def wait_until(options = {}, &block)
|
|
168
|
+
self_copy = self.dup
|
|
169
|
+
attempts = 0
|
|
170
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
|
171
|
+
options[:delay] ||= 10
|
|
172
|
+
options[:poller] = Proc.new do
|
|
173
|
+
attempts += 1
|
|
174
|
+
if block.call(self_copy)
|
|
175
|
+
[:success, self_copy]
|
|
176
|
+
else
|
|
177
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
|
178
|
+
:retry
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# @!group Actions
|
|
185
|
+
|
|
186
|
+
# @example Request syntax with placeholder values
|
|
187
|
+
#
|
|
188
|
+
# bucket_versioning.enable({
|
|
189
|
+
# content_md5: "ContentMD5",
|
|
190
|
+
# mfa: "MFA",
|
|
191
|
+
# })
|
|
192
|
+
# @param [Hash] options ({})
|
|
193
|
+
# @option options [String] :content_md5
|
|
194
|
+
# >The base64-encoded 128-bit MD5 digest of the data. You must use
|
|
195
|
+
# this header as a message integrity check to verify that the request
|
|
196
|
+
# body was not corrupted in transit. For more information, see [RFC
|
|
197
|
+
# 1864][1].
|
|
198
|
+
#
|
|
199
|
+
#
|
|
200
|
+
#
|
|
201
|
+
# [1]: http://www.ietf.org/rfc/rfc1864.txt
|
|
202
|
+
# @option options [String] :mfa
|
|
203
|
+
# The concatenation of the authentication device's serial number, a
|
|
204
|
+
# space, and the value that is displayed on your authentication device.
|
|
205
|
+
# @return [EmptyStructure]
|
|
206
|
+
def enable(options = {})
|
|
207
|
+
options = Aws::Util.deep_merge(options,
|
|
208
|
+
bucket: @bucket_name,
|
|
209
|
+
versioning_configuration: {
|
|
210
|
+
status: "Enabled"
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
resp = @client.put_bucket_versioning(options)
|
|
214
|
+
resp.data
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# @example Request syntax with placeholder values
|
|
218
|
+
#
|
|
219
|
+
# bucket_versioning.put({
|
|
220
|
+
# content_md5: "ContentMD5",
|
|
221
|
+
# mfa: "MFA",
|
|
222
|
+
# versioning_configuration: { # required
|
|
223
|
+
# mfa_delete: "Enabled", # accepts Enabled, Disabled
|
|
224
|
+
# status: "Enabled", # accepts Enabled, Suspended
|
|
225
|
+
# },
|
|
226
|
+
# })
|
|
227
|
+
# @param [Hash] options ({})
|
|
228
|
+
# @option options [String] :content_md5
|
|
229
|
+
# >The base64-encoded 128-bit MD5 digest of the data. You must use
|
|
230
|
+
# this header as a message integrity check to verify that the request
|
|
231
|
+
# body was not corrupted in transit. For more information, see [RFC
|
|
232
|
+
# 1864][1].
|
|
233
|
+
#
|
|
234
|
+
#
|
|
235
|
+
#
|
|
236
|
+
# [1]: http://www.ietf.org/rfc/rfc1864.txt
|
|
237
|
+
# @option options [String] :mfa
|
|
238
|
+
# The concatenation of the authentication device's serial number, a
|
|
239
|
+
# space, and the value that is displayed on your authentication device.
|
|
240
|
+
# @option options [required, Types::VersioningConfiguration] :versioning_configuration
|
|
241
|
+
# Container for setting the versioning state.
|
|
242
|
+
# @return [EmptyStructure]
|
|
243
|
+
def put(options = {})
|
|
244
|
+
options = options.merge(bucket: @bucket_name)
|
|
245
|
+
resp = @client.put_bucket_versioning(options)
|
|
246
|
+
resp.data
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# @example Request syntax with placeholder values
|
|
250
|
+
#
|
|
251
|
+
# bucket_versioning.suspend({
|
|
252
|
+
# content_md5: "ContentMD5",
|
|
253
|
+
# mfa: "MFA",
|
|
254
|
+
# })
|
|
255
|
+
# @param [Hash] options ({})
|
|
256
|
+
# @option options [String] :content_md5
|
|
257
|
+
# >The base64-encoded 128-bit MD5 digest of the data. You must use
|
|
258
|
+
# this header as a message integrity check to verify that the request
|
|
259
|
+
# body was not corrupted in transit. For more information, see [RFC
|
|
260
|
+
# 1864][1].
|
|
261
|
+
#
|
|
262
|
+
#
|
|
263
|
+
#
|
|
264
|
+
# [1]: http://www.ietf.org/rfc/rfc1864.txt
|
|
265
|
+
# @option options [String] :mfa
|
|
266
|
+
# The concatenation of the authentication device's serial number, a
|
|
267
|
+
# space, and the value that is displayed on your authentication device.
|
|
268
|
+
# @return [EmptyStructure]
|
|
269
|
+
def suspend(options = {})
|
|
270
|
+
options = Aws::Util.deep_merge(options,
|
|
271
|
+
bucket: @bucket_name,
|
|
272
|
+
versioning_configuration: {
|
|
273
|
+
status: "Suspended"
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
resp = @client.put_bucket_versioning(options)
|
|
277
|
+
resp.data
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# @!group Associations
|
|
281
|
+
|
|
282
|
+
# @return [Bucket]
|
|
283
|
+
def bucket
|
|
284
|
+
Bucket.new(
|
|
285
|
+
name: @bucket_name,
|
|
286
|
+
client: @client
|
|
287
|
+
)
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# @deprecated
|
|
291
|
+
# @api private
|
|
292
|
+
def identifiers
|
|
293
|
+
{ bucket_name: @bucket_name }
|
|
294
|
+
end
|
|
295
|
+
deprecated(:identifiers)
|
|
296
|
+
|
|
297
|
+
private
|
|
298
|
+
|
|
299
|
+
def extract_bucket_name(args, options)
|
|
300
|
+
value = args[0] || options.delete(:bucket_name)
|
|
301
|
+
case value
|
|
302
|
+
when String then value
|
|
303
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
|
304
|
+
else
|
|
305
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
|
306
|
+
raise ArgumentError, msg
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
class Collection < Aws::Resources::Collection; end
|
|
311
|
+
end
|
|
312
|
+
end
|