aws-sdk-s3 1.75.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 BucketLogging
|
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
|
+
# Describes where logs are stored and the prefix that Amazon S3 assigns
|
38
|
+
# to all log object keys for a bucket. For more information, see [PUT
|
39
|
+
# Bucket logging][1] in the *Amazon Simple Storage Service API
|
40
|
+
# Reference*.
|
41
|
+
#
|
42
|
+
#
|
43
|
+
#
|
44
|
+
# [1]: https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTlogging.html
|
45
|
+
# @return [Types::LoggingEnabled]
|
46
|
+
def logging_enabled
|
47
|
+
data[:logging_enabled]
|
48
|
+
end
|
49
|
+
|
50
|
+
# @!endgroup
|
51
|
+
|
52
|
+
# @return [Client]
|
53
|
+
def client
|
54
|
+
@client
|
55
|
+
end
|
56
|
+
|
57
|
+
# Loads, or reloads {#data} for the current {BucketLogging}.
|
58
|
+
# Returns `self` making it possible to chain methods.
|
59
|
+
#
|
60
|
+
# bucket_logging.reload.data
|
61
|
+
#
|
62
|
+
# @return [self]
|
63
|
+
def load
|
64
|
+
resp = @client.get_bucket_logging(bucket: @bucket_name)
|
65
|
+
@data = resp.data
|
66
|
+
self
|
67
|
+
end
|
68
|
+
alias :reload :load
|
69
|
+
|
70
|
+
# @return [Types::GetBucketLoggingOutput]
|
71
|
+
# Returns the data for this {BucketLogging}. Calls
|
72
|
+
# {Client#get_bucket_logging} if {#data_loaded?} is `false`.
|
73
|
+
def data
|
74
|
+
load unless @data
|
75
|
+
@data
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [Boolean]
|
79
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
80
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
81
|
+
def data_loaded?
|
82
|
+
!!@data
|
83
|
+
end
|
84
|
+
|
85
|
+
# @deprecated Use [Aws::S3::Client] #wait_until instead
|
86
|
+
#
|
87
|
+
# Waiter polls an API operation until a resource enters a desired
|
88
|
+
# state.
|
89
|
+
#
|
90
|
+
# @note The waiting operation is performed on a copy. The original resource
|
91
|
+
# remains unchanged.
|
92
|
+
#
|
93
|
+
# ## Basic Usage
|
94
|
+
#
|
95
|
+
# Waiter will polls until it is successful, it fails by
|
96
|
+
# entering a terminal state, or until a maximum number of attempts
|
97
|
+
# are made.
|
98
|
+
#
|
99
|
+
# # polls in a loop until condition is true
|
100
|
+
# resource.wait_until(options) {|resource| condition}
|
101
|
+
#
|
102
|
+
# ## Example
|
103
|
+
#
|
104
|
+
# instance.wait_until(max_attempts:10, delay:5) do |instance|
|
105
|
+
# instance.state.name == 'running'
|
106
|
+
# end
|
107
|
+
#
|
108
|
+
# ## Configuration
|
109
|
+
#
|
110
|
+
# You can configure the maximum number of polling attempts, and the
|
111
|
+
# delay (in seconds) between each polling attempt. The waiting condition is
|
112
|
+
# set by passing a block to {#wait_until}:
|
113
|
+
#
|
114
|
+
# # poll for ~25 seconds
|
115
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
116
|
+
#
|
117
|
+
# ## Callbacks
|
118
|
+
#
|
119
|
+
# You can be notified before each polling attempt and before each
|
120
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
121
|
+
# it will terminate the waiter.
|
122
|
+
#
|
123
|
+
# started_at = Time.now
|
124
|
+
# # poll for 1 hour, instead of a number of attempts
|
125
|
+
# proc = Proc.new do |attempts, response|
|
126
|
+
# throw :failure if Time.now - started_at > 3600
|
127
|
+
# end
|
128
|
+
#
|
129
|
+
# # disable max attempts
|
130
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
131
|
+
#
|
132
|
+
# ## Handling Errors
|
133
|
+
#
|
134
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
135
|
+
# fails, it raises an error.
|
136
|
+
#
|
137
|
+
# begin
|
138
|
+
# resource.wait_until(...)
|
139
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
140
|
+
# # resource did not enter the desired state in time
|
141
|
+
# end
|
142
|
+
#
|
143
|
+
# @yieldparam [Resource] resource to be used in the waiting condition.
|
144
|
+
#
|
145
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
|
146
|
+
# terminates because the waiter has entered a state that it will not
|
147
|
+
# transition out of, preventing success.
|
148
|
+
#
|
149
|
+
# yet successful.
|
150
|
+
#
|
151
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
|
152
|
+
# encountered while polling for a resource that is not expected.
|
153
|
+
#
|
154
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
155
|
+
#
|
156
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
157
|
+
# attempts
|
158
|
+
# @option options [Integer] :delay (10) Delay between each
|
159
|
+
# attempt in seconds
|
160
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
161
|
+
# invoked before each attempt
|
162
|
+
# @option options [Proc] :before_wait (nil) Callback
|
163
|
+
# invoked before each wait
|
164
|
+
# @return [Resource] if the waiter was successful
|
165
|
+
def wait_until(options = {}, &block)
|
166
|
+
self_copy = self.dup
|
167
|
+
attempts = 0
|
168
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
169
|
+
options[:delay] ||= 10
|
170
|
+
options[:poller] = Proc.new do
|
171
|
+
attempts += 1
|
172
|
+
if block.call(self_copy)
|
173
|
+
[:success, self_copy]
|
174
|
+
else
|
175
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
176
|
+
:retry
|
177
|
+
end
|
178
|
+
end
|
179
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
180
|
+
end
|
181
|
+
|
182
|
+
# @!group Actions
|
183
|
+
|
184
|
+
# @example Request syntax with placeholder values
|
185
|
+
#
|
186
|
+
# bucket_logging.put({
|
187
|
+
# bucket_logging_status: { # required
|
188
|
+
# logging_enabled: {
|
189
|
+
# target_bucket: "TargetBucket", # required
|
190
|
+
# target_grants: [
|
191
|
+
# {
|
192
|
+
# grantee: {
|
193
|
+
# display_name: "DisplayName",
|
194
|
+
# email_address: "EmailAddress",
|
195
|
+
# id: "ID",
|
196
|
+
# type: "CanonicalUser", # required, accepts CanonicalUser, AmazonCustomerByEmail, Group
|
197
|
+
# uri: "URI",
|
198
|
+
# },
|
199
|
+
# permission: "FULL_CONTROL", # accepts FULL_CONTROL, READ, WRITE
|
200
|
+
# },
|
201
|
+
# ],
|
202
|
+
# target_prefix: "TargetPrefix", # required
|
203
|
+
# },
|
204
|
+
# },
|
205
|
+
# content_md5: "ContentMD5",
|
206
|
+
# })
|
207
|
+
# @param [Hash] options ({})
|
208
|
+
# @option options [required, Types::BucketLoggingStatus] :bucket_logging_status
|
209
|
+
# Container for logging status information.
|
210
|
+
# @option options [String] :content_md5
|
211
|
+
# The MD5 hash of the `PutBucketLogging` request body.
|
212
|
+
# @return [EmptyStructure]
|
213
|
+
def put(options = {})
|
214
|
+
options = options.merge(bucket: @bucket_name)
|
215
|
+
resp = @client.put_bucket_logging(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,293 @@
|
|
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 BucketNotification
|
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 topic to which notifications are sent and the events for which
|
38
|
+
# notifications are generated.
|
39
|
+
# @return [Array<Types::TopicConfiguration>]
|
40
|
+
def topic_configurations
|
41
|
+
data[:topic_configurations]
|
42
|
+
end
|
43
|
+
|
44
|
+
# The Amazon Simple Queue Service queues to publish messages to and the
|
45
|
+
# events for which to publish messages.
|
46
|
+
# @return [Array<Types::QueueConfiguration>]
|
47
|
+
def queue_configurations
|
48
|
+
data[:queue_configurations]
|
49
|
+
end
|
50
|
+
|
51
|
+
# Describes the AWS Lambda functions to invoke and the events for which
|
52
|
+
# to invoke them.
|
53
|
+
# @return [Array<Types::LambdaFunctionConfiguration>]
|
54
|
+
def lambda_function_configurations
|
55
|
+
data[:lambda_function_configurations]
|
56
|
+
end
|
57
|
+
|
58
|
+
# @!endgroup
|
59
|
+
|
60
|
+
# @return [Client]
|
61
|
+
def client
|
62
|
+
@client
|
63
|
+
end
|
64
|
+
|
65
|
+
# Loads, or reloads {#data} for the current {BucketNotification}.
|
66
|
+
# Returns `self` making it possible to chain methods.
|
67
|
+
#
|
68
|
+
# bucket_notification.reload.data
|
69
|
+
#
|
70
|
+
# @return [self]
|
71
|
+
def load
|
72
|
+
resp = @client.get_bucket_notification_configuration(bucket: @bucket_name)
|
73
|
+
@data = resp.data
|
74
|
+
self
|
75
|
+
end
|
76
|
+
alias :reload :load
|
77
|
+
|
78
|
+
# @return [Types::NotificationConfiguration]
|
79
|
+
# Returns the data for this {BucketNotification}. Calls
|
80
|
+
# {Client#get_bucket_notification_configuration} if {#data_loaded?} is `false`.
|
81
|
+
def data
|
82
|
+
load unless @data
|
83
|
+
@data
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [Boolean]
|
87
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
88
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
89
|
+
def data_loaded?
|
90
|
+
!!@data
|
91
|
+
end
|
92
|
+
|
93
|
+
# @deprecated Use [Aws::S3::Client] #wait_until instead
|
94
|
+
#
|
95
|
+
# Waiter polls an API operation until a resource enters a desired
|
96
|
+
# state.
|
97
|
+
#
|
98
|
+
# @note The waiting operation is performed on a copy. The original resource
|
99
|
+
# remains unchanged.
|
100
|
+
#
|
101
|
+
# ## Basic Usage
|
102
|
+
#
|
103
|
+
# Waiter will polls until it is successful, it fails by
|
104
|
+
# entering a terminal state, or until a maximum number of attempts
|
105
|
+
# are made.
|
106
|
+
#
|
107
|
+
# # polls in a loop until condition is true
|
108
|
+
# resource.wait_until(options) {|resource| condition}
|
109
|
+
#
|
110
|
+
# ## Example
|
111
|
+
#
|
112
|
+
# instance.wait_until(max_attempts:10, delay:5) do |instance|
|
113
|
+
# instance.state.name == 'running'
|
114
|
+
# end
|
115
|
+
#
|
116
|
+
# ## Configuration
|
117
|
+
#
|
118
|
+
# You can configure the maximum number of polling attempts, and the
|
119
|
+
# delay (in seconds) between each polling attempt. The waiting condition is
|
120
|
+
# set by passing a block to {#wait_until}:
|
121
|
+
#
|
122
|
+
# # poll for ~25 seconds
|
123
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
124
|
+
#
|
125
|
+
# ## Callbacks
|
126
|
+
#
|
127
|
+
# You can be notified before each polling attempt and before each
|
128
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
129
|
+
# it will terminate the waiter.
|
130
|
+
#
|
131
|
+
# started_at = Time.now
|
132
|
+
# # poll for 1 hour, instead of a number of attempts
|
133
|
+
# proc = Proc.new do |attempts, response|
|
134
|
+
# throw :failure if Time.now - started_at > 3600
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
# # disable max attempts
|
138
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
139
|
+
#
|
140
|
+
# ## Handling Errors
|
141
|
+
#
|
142
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
143
|
+
# fails, it raises an error.
|
144
|
+
#
|
145
|
+
# begin
|
146
|
+
# resource.wait_until(...)
|
147
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
148
|
+
# # resource did not enter the desired state in time
|
149
|
+
# end
|
150
|
+
#
|
151
|
+
# @yieldparam [Resource] resource to be used in the waiting condition.
|
152
|
+
#
|
153
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter
|
154
|
+
# terminates because the waiter has entered a state that it will not
|
155
|
+
# transition out of, preventing success.
|
156
|
+
#
|
157
|
+
# yet successful.
|
158
|
+
#
|
159
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
|
160
|
+
# encountered while polling for a resource that is not expected.
|
161
|
+
#
|
162
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
163
|
+
#
|
164
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
165
|
+
# attempts
|
166
|
+
# @option options [Integer] :delay (10) Delay between each
|
167
|
+
# attempt in seconds
|
168
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
169
|
+
# invoked before each attempt
|
170
|
+
# @option options [Proc] :before_wait (nil) Callback
|
171
|
+
# invoked before each wait
|
172
|
+
# @return [Resource] if the waiter was successful
|
173
|
+
def wait_until(options = {}, &block)
|
174
|
+
self_copy = self.dup
|
175
|
+
attempts = 0
|
176
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
177
|
+
options[:delay] ||= 10
|
178
|
+
options[:poller] = Proc.new do
|
179
|
+
attempts += 1
|
180
|
+
if block.call(self_copy)
|
181
|
+
[:success, self_copy]
|
182
|
+
else
|
183
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
184
|
+
:retry
|
185
|
+
end
|
186
|
+
end
|
187
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
188
|
+
end
|
189
|
+
|
190
|
+
# @!group Actions
|
191
|
+
|
192
|
+
# @example Request syntax with placeholder values
|
193
|
+
#
|
194
|
+
# bucket_notification.put({
|
195
|
+
# notification_configuration: { # required
|
196
|
+
# topic_configurations: [
|
197
|
+
# {
|
198
|
+
# id: "NotificationId",
|
199
|
+
# topic_arn: "TopicArn", # required
|
200
|
+
# events: ["s3:ReducedRedundancyLostObject"], # required, accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:*, s3:ObjectRestore:Post, s3:ObjectRestore:Completed, s3:Replication:*, s3:Replication:OperationFailedReplication, s3:Replication:OperationNotTracked, s3:Replication:OperationMissedThreshold, s3:Replication:OperationReplicatedAfterThreshold
|
201
|
+
# filter: {
|
202
|
+
# key: {
|
203
|
+
# filter_rules: [
|
204
|
+
# {
|
205
|
+
# name: "prefix", # accepts prefix, suffix
|
206
|
+
# value: "FilterRuleValue",
|
207
|
+
# },
|
208
|
+
# ],
|
209
|
+
# },
|
210
|
+
# },
|
211
|
+
# },
|
212
|
+
# ],
|
213
|
+
# queue_configurations: [
|
214
|
+
# {
|
215
|
+
# id: "NotificationId",
|
216
|
+
# queue_arn: "QueueArn", # required
|
217
|
+
# events: ["s3:ReducedRedundancyLostObject"], # required, accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:*, s3:ObjectRestore:Post, s3:ObjectRestore:Completed, s3:Replication:*, s3:Replication:OperationFailedReplication, s3:Replication:OperationNotTracked, s3:Replication:OperationMissedThreshold, s3:Replication:OperationReplicatedAfterThreshold
|
218
|
+
# filter: {
|
219
|
+
# key: {
|
220
|
+
# filter_rules: [
|
221
|
+
# {
|
222
|
+
# name: "prefix", # accepts prefix, suffix
|
223
|
+
# value: "FilterRuleValue",
|
224
|
+
# },
|
225
|
+
# ],
|
226
|
+
# },
|
227
|
+
# },
|
228
|
+
# },
|
229
|
+
# ],
|
230
|
+
# lambda_function_configurations: [
|
231
|
+
# {
|
232
|
+
# id: "NotificationId",
|
233
|
+
# lambda_function_arn: "LambdaFunctionArn", # required
|
234
|
+
# events: ["s3:ReducedRedundancyLostObject"], # required, accepts s3:ReducedRedundancyLostObject, s3:ObjectCreated:*, s3:ObjectCreated:Put, s3:ObjectCreated:Post, s3:ObjectCreated:Copy, s3:ObjectCreated:CompleteMultipartUpload, s3:ObjectRemoved:*, s3:ObjectRemoved:Delete, s3:ObjectRemoved:DeleteMarkerCreated, s3:ObjectRestore:*, s3:ObjectRestore:Post, s3:ObjectRestore:Completed, s3:Replication:*, s3:Replication:OperationFailedReplication, s3:Replication:OperationNotTracked, s3:Replication:OperationMissedThreshold, s3:Replication:OperationReplicatedAfterThreshold
|
235
|
+
# filter: {
|
236
|
+
# key: {
|
237
|
+
# filter_rules: [
|
238
|
+
# {
|
239
|
+
# name: "prefix", # accepts prefix, suffix
|
240
|
+
# value: "FilterRuleValue",
|
241
|
+
# },
|
242
|
+
# ],
|
243
|
+
# },
|
244
|
+
# },
|
245
|
+
# },
|
246
|
+
# ],
|
247
|
+
# },
|
248
|
+
# })
|
249
|
+
# @param [Hash] options ({})
|
250
|
+
# @option options [required, Types::NotificationConfiguration] :notification_configuration
|
251
|
+
# A container for specifying the notification configuration of the
|
252
|
+
# bucket. If this element is empty, notifications are turned off for the
|
253
|
+
# bucket.
|
254
|
+
# @return [EmptyStructure]
|
255
|
+
def put(options = {})
|
256
|
+
options = options.merge(bucket: @bucket_name)
|
257
|
+
resp = @client.put_bucket_notification_configuration(options)
|
258
|
+
resp.data
|
259
|
+
end
|
260
|
+
|
261
|
+
# @!group Associations
|
262
|
+
|
263
|
+
# @return [Bucket]
|
264
|
+
def bucket
|
265
|
+
Bucket.new(
|
266
|
+
name: @bucket_name,
|
267
|
+
client: @client
|
268
|
+
)
|
269
|
+
end
|
270
|
+
|
271
|
+
# @deprecated
|
272
|
+
# @api private
|
273
|
+
def identifiers
|
274
|
+
{ bucket_name: @bucket_name }
|
275
|
+
end
|
276
|
+
deprecated(:identifiers)
|
277
|
+
|
278
|
+
private
|
279
|
+
|
280
|
+
def extract_bucket_name(args, options)
|
281
|
+
value = args[0] || options.delete(:bucket_name)
|
282
|
+
case value
|
283
|
+
when String then value
|
284
|
+
when nil then raise ArgumentError, "missing required option :bucket_name"
|
285
|
+
else
|
286
|
+
msg = "expected :bucket_name to be a String, got #{value.class}"
|
287
|
+
raise ArgumentError, msg
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
class Collection < Aws::Resources::Collection; end
|
292
|
+
end
|
293
|
+
end
|