aws-sdk-s3 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,28 +40,28 @@ module Aws::S3
40
40
 
41
41
  # @return [Time]
42
42
  def last_modified
43
- data.last_modified
43
+ data[:last_modified]
44
44
  end
45
45
 
46
46
  # @return [String]
47
47
  def etag
48
- data.etag
48
+ data[:etag]
49
49
  end
50
50
 
51
51
  # @return [Integer]
52
52
  def size
53
- data.size
53
+ data[:size]
54
54
  end
55
55
 
56
56
  # The class of storage used to store the object.
57
57
  # @return [String]
58
58
  def storage_class
59
- data.storage_class
59
+ data[:storage_class]
60
60
  end
61
61
 
62
62
  # @return [Types::Owner]
63
63
  def owner
64
- data.owner
64
+ data[:owner]
65
65
  end
66
66
 
67
67
  # @!endgroup
@@ -146,6 +146,101 @@ module Aws::S3
146
146
  })
147
147
  end
148
148
 
149
+ # @deprecated Use [Aws::S3::Client] #wait_until instead
150
+ #
151
+ # Waiter polls an API operation until a resource enters a desired
152
+ # state.
153
+ #
154
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
155
+ #
156
+ # ## Basic Usage
157
+ #
158
+ # Waiter will polls until it is successful, it fails by
159
+ # entering a terminal state, or until a maximum number of attempts
160
+ # are made.
161
+ #
162
+ # # polls in a loop until condition is true
163
+ # resource.wait_until(options) {|resource| condition}
164
+ #
165
+ # ## Example
166
+ #
167
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
168
+ #
169
+ # ## Configuration
170
+ #
171
+ # You can configure the maximum number of polling attempts, and the
172
+ # delay (in seconds) between each polling attempt. The waiting condition is set
173
+ # by passing a block to {#wait_until}:
174
+ #
175
+ # # poll for ~25 seconds
176
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
177
+ #
178
+ # ## Callbacks
179
+ #
180
+ # You can be notified before each polling attempt and before each
181
+ # delay. If you throw `:success` or `:failure` from these callbacks,
182
+ # it will terminate the waiter.
183
+ #
184
+ # started_at = Time.now
185
+ # # poll for 1 hour, instead of a number of attempts
186
+ # proc = Proc.new do |attempts, response|
187
+ # throw :failure if Time.now - started_at > 3600
188
+ # end
189
+ #
190
+ # # disable max attempts
191
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
192
+ #
193
+ # ## Handling Errors
194
+ #
195
+ # When a waiter is successful, it returns the Resource. When a waiter
196
+ # fails, it raises an error.
197
+ #
198
+ # begin
199
+ # resource.wait_until(...)
200
+ # rescue Aws::Waiters::Errors::WaiterFailed
201
+ # # resource did not enter the desired state in time
202
+ # end
203
+ #
204
+ #
205
+ # @yield param [Resource] resource to be used in the waiting condition
206
+ #
207
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
208
+ # because the waiter has entered a state that it will not transition
209
+ # out of, preventing success.
210
+ #
211
+ # yet successful.
212
+ #
213
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
214
+ # while polling for a resource that is not expected.
215
+ #
216
+ # @raise [NotImplementedError] Raised when the resource does not
217
+ #
218
+ # @option options [Integer] :max_attempts (10) Maximum number of
219
+ # attempts
220
+ # @option options [Integer] :delay (10) Delay between each
221
+ # attempt in seconds
222
+ # @option options [Proc] :before_attempt (nil) Callback
223
+ # invoked before each attempt
224
+ # @option options [Proc] :before_wait (nil) Callback
225
+ # invoked before each wait
226
+ # @return [Resource] if the waiter was successful
227
+ def wait_until(options = {}, &block)
228
+ self_copy = self.dup
229
+ attempts = 0
230
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
231
+ options[:delay] ||= 10
232
+ options[:poller] = Proc.new do
233
+ attempts += 1
234
+ if block.call(self_copy)
235
+ [:success, self_copy]
236
+ else
237
+ self_copy.reload unless attempts == options[:max_attempts]
238
+ :retry
239
+ end
240
+ end
241
+ Aws::Waiters::Waiter.new(options).wait({})
242
+ end
243
+
149
244
  # @!group Actions
150
245
 
151
246
  # @example Request syntax with placeholder values
@@ -48,49 +48,49 @@ module Aws::S3
48
48
 
49
49
  # @return [String]
50
50
  def etag
51
- data.etag
51
+ data[:etag]
52
52
  end
53
53
 
54
54
  # Size in bytes of the object.
55
55
  # @return [Integer]
56
56
  def size
57
- data.size
57
+ data[:size]
58
58
  end
59
59
 
60
60
  # The class of storage used to store the object.
61
61
  # @return [String]
62
62
  def storage_class
63
- data.storage_class
63
+ data[:storage_class]
64
64
  end
65
65
 
66
66
  # The object key.
67
67
  # @return [String]
68
68
  def key
69
- data.key
69
+ data[:key]
70
70
  end
71
71
 
72
72
  # Version ID of an object.
73
73
  # @return [String]
74
74
  def version_id
75
- data.version_id
75
+ data[:version_id]
76
76
  end
77
77
 
78
78
  # Specifies whether the object is (true) or is not (false) the latest
79
79
  # version of an object.
80
80
  # @return [Boolean]
81
81
  def is_latest
82
- data.is_latest
82
+ data[:is_latest]
83
83
  end
84
84
 
85
85
  # Date and time the object was last modified.
86
86
  # @return [Time]
87
87
  def last_modified
88
- data.last_modified
88
+ data[:last_modified]
89
89
  end
90
90
 
91
91
  # @return [Types::Owner]
92
92
  def owner
93
- data.owner
93
+ data[:owner]
94
94
  end
95
95
 
96
96
  # @!endgroup
@@ -123,6 +123,101 @@ module Aws::S3
123
123
  !!@data
124
124
  end
125
125
 
126
+ # @deprecated Use [Aws::S3::Client] #wait_until instead
127
+ #
128
+ # Waiter polls an API operation until a resource enters a desired
129
+ # state.
130
+ #
131
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
132
+ #
133
+ # ## Basic Usage
134
+ #
135
+ # Waiter will polls until it is successful, it fails by
136
+ # entering a terminal state, or until a maximum number of attempts
137
+ # are made.
138
+ #
139
+ # # polls in a loop until condition is true
140
+ # resource.wait_until(options) {|resource| condition}
141
+ #
142
+ # ## Example
143
+ #
144
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
145
+ #
146
+ # ## Configuration
147
+ #
148
+ # You can configure the maximum number of polling attempts, and the
149
+ # delay (in seconds) between each polling attempt. The waiting condition is set
150
+ # by passing a block to {#wait_until}:
151
+ #
152
+ # # poll for ~25 seconds
153
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
154
+ #
155
+ # ## Callbacks
156
+ #
157
+ # You can be notified before each polling attempt and before each
158
+ # delay. If you throw `:success` or `:failure` from these callbacks,
159
+ # it will terminate the waiter.
160
+ #
161
+ # started_at = Time.now
162
+ # # poll for 1 hour, instead of a number of attempts
163
+ # proc = Proc.new do |attempts, response|
164
+ # throw :failure if Time.now - started_at > 3600
165
+ # end
166
+ #
167
+ # # disable max attempts
168
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
169
+ #
170
+ # ## Handling Errors
171
+ #
172
+ # When a waiter is successful, it returns the Resource. When a waiter
173
+ # fails, it raises an error.
174
+ #
175
+ # begin
176
+ # resource.wait_until(...)
177
+ # rescue Aws::Waiters::Errors::WaiterFailed
178
+ # # resource did not enter the desired state in time
179
+ # end
180
+ #
181
+ #
182
+ # @yield param [Resource] resource to be used in the waiting condition
183
+ #
184
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
185
+ # because the waiter has entered a state that it will not transition
186
+ # out of, preventing success.
187
+ #
188
+ # yet successful.
189
+ #
190
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
191
+ # while polling for a resource that is not expected.
192
+ #
193
+ # @raise [NotImplementedError] Raised when the resource does not
194
+ #
195
+ # @option options [Integer] :max_attempts (10) Maximum number of
196
+ # attempts
197
+ # @option options [Integer] :delay (10) Delay between each
198
+ # attempt in seconds
199
+ # @option options [Proc] :before_attempt (nil) Callback
200
+ # invoked before each attempt
201
+ # @option options [Proc] :before_wait (nil) Callback
202
+ # invoked before each wait
203
+ # @return [Resource] if the waiter was successful
204
+ def wait_until(options = {}, &block)
205
+ self_copy = self.dup
206
+ attempts = 0
207
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
208
+ options[:delay] ||= 10
209
+ options[:poller] = Proc.new do
210
+ attempts += 1
211
+ if block.call(self_copy)
212
+ [:success, self_copy]
213
+ else
214
+ self_copy.reload unless attempts == options[:max_attempts]
215
+ :retry
216
+ end
217
+ end
218
+ Aws::Waiters::Waiter.new(options).wait({})
219
+ end
220
+
126
221
  # @!group Actions
127
222
 
128
223
  # @example Request syntax with placeholder values
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-kms