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.
@@ -57,19 +57,19 @@ module Aws::S3
57
57
  # Date and time at which the part was uploaded.
58
58
  # @return [Time]
59
59
  def last_modified
60
- data.last_modified
60
+ data[:last_modified]
61
61
  end
62
62
 
63
63
  # Entity tag returned when the part was uploaded.
64
64
  # @return [String]
65
65
  def etag
66
- data.etag
66
+ data[:etag]
67
67
  end
68
68
 
69
69
  # Size of the uploaded part data.
70
70
  # @return [Integer]
71
71
  def size
72
- data.size
72
+ data[:size]
73
73
  end
74
74
 
75
75
  # @!endgroup
@@ -102,6 +102,101 @@ module Aws::S3
102
102
  !!@data
103
103
  end
104
104
 
105
+ # @deprecated Use [Aws::S3::Client] #wait_until instead
106
+ #
107
+ # Waiter polls an API operation until a resource enters a desired
108
+ # state.
109
+ #
110
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
111
+ #
112
+ # ## Basic Usage
113
+ #
114
+ # Waiter will polls until it is successful, it fails by
115
+ # entering a terminal state, or until a maximum number of attempts
116
+ # are made.
117
+ #
118
+ # # polls in a loop until condition is true
119
+ # resource.wait_until(options) {|resource| condition}
120
+ #
121
+ # ## Example
122
+ #
123
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
124
+ #
125
+ # ## Configuration
126
+ #
127
+ # You can configure the maximum number of polling attempts, and the
128
+ # delay (in seconds) between each polling attempt. The waiting condition is set
129
+ # by passing a block to {#wait_until}:
130
+ #
131
+ # # poll for ~25 seconds
132
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
133
+ #
134
+ # ## Callbacks
135
+ #
136
+ # You can be notified before each polling attempt and before each
137
+ # delay. If you throw `:success` or `:failure` from these callbacks,
138
+ # it will terminate the waiter.
139
+ #
140
+ # started_at = Time.now
141
+ # # poll for 1 hour, instead of a number of attempts
142
+ # proc = Proc.new do |attempts, response|
143
+ # throw :failure if Time.now - started_at > 3600
144
+ # end
145
+ #
146
+ # # disable max attempts
147
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
148
+ #
149
+ # ## Handling Errors
150
+ #
151
+ # When a waiter is successful, it returns the Resource. When a waiter
152
+ # fails, it raises an error.
153
+ #
154
+ # begin
155
+ # resource.wait_until(...)
156
+ # rescue Aws::Waiters::Errors::WaiterFailed
157
+ # # resource did not enter the desired state in time
158
+ # end
159
+ #
160
+ #
161
+ # @yield param [Resource] resource to be used in the waiting condition
162
+ #
163
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
164
+ # because the waiter has entered a state that it will not transition
165
+ # out of, preventing success.
166
+ #
167
+ # yet successful.
168
+ #
169
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
170
+ # while polling for a resource that is not expected.
171
+ #
172
+ # @raise [NotImplementedError] Raised when the resource does not
173
+ #
174
+ # @option options [Integer] :max_attempts (10) Maximum number of
175
+ # attempts
176
+ # @option options [Integer] :delay (10) Delay between each
177
+ # attempt in seconds
178
+ # @option options [Proc] :before_attempt (nil) Callback
179
+ # invoked before each attempt
180
+ # @option options [Proc] :before_wait (nil) Callback
181
+ # invoked before each wait
182
+ # @return [Resource] if the waiter was successful
183
+ def wait_until(options = {}, &block)
184
+ self_copy = self.dup
185
+ attempts = 0
186
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
187
+ options[:delay] ||= 10
188
+ options[:poller] = Proc.new do
189
+ attempts += 1
190
+ if block.call(self_copy)
191
+ [:success, self_copy]
192
+ else
193
+ self_copy.reload unless attempts == options[:max_attempts]
194
+ :retry
195
+ end
196
+ end
197
+ Aws::Waiters::Waiter.new(options).wait({})
198
+ end
199
+
105
200
  # @!group Actions
106
201
 
107
202
  # @example Request syntax with placeholder values
@@ -43,12 +43,12 @@ module Aws::S3
43
43
  # response.
44
44
  # @return [Boolean]
45
45
  def delete_marker
46
- data.delete_marker
46
+ data[:delete_marker]
47
47
  end
48
48
 
49
49
  # @return [String]
50
50
  def accept_ranges
51
- data.accept_ranges
51
+ data[:accept_ranges]
52
52
  end
53
53
 
54
54
  # If the object expiration is configured (see PUT Bucket lifecycle), the
@@ -57,33 +57,33 @@ module Aws::S3
57
57
  # the rule-id is URL encoded.
58
58
  # @return [String]
59
59
  def expiration
60
- data.expiration
60
+ data[:expiration]
61
61
  end
62
62
 
63
63
  # Provides information about object restoration operation and expiration
64
64
  # time of the restored object copy.
65
65
  # @return [String]
66
66
  def restore
67
- data.restore
67
+ data[:restore]
68
68
  end
69
69
 
70
70
  # Last modified date of the object
71
71
  # @return [Time]
72
72
  def last_modified
73
- data.last_modified
73
+ data[:last_modified]
74
74
  end
75
75
 
76
76
  # Size of the body in bytes.
77
77
  # @return [Integer]
78
78
  def content_length
79
- data.content_length
79
+ data[:content_length]
80
80
  end
81
81
 
82
82
  # An ETag is an opaque identifier assigned by a web server to a specific
83
83
  # version of a resource found at a URL
84
84
  # @return [String]
85
85
  def etag
86
- data.etag
86
+ data[:etag]
87
87
  end
88
88
 
89
89
  # This is set to the number of metadata entries not returned in
@@ -93,25 +93,25 @@ module Aws::S3
93
93
  # legal HTTP headers.
94
94
  # @return [Integer]
95
95
  def missing_meta
96
- data.missing_meta
96
+ data[:missing_meta]
97
97
  end
98
98
 
99
99
  # Version of the object.
100
100
  # @return [String]
101
101
  def version_id
102
- data.version_id
102
+ data[:version_id]
103
103
  end
104
104
 
105
105
  # Specifies caching behavior along the request/reply chain.
106
106
  # @return [String]
107
107
  def cache_control
108
- data.cache_control
108
+ data[:cache_control]
109
109
  end
110
110
 
111
111
  # Specifies presentational information for the object.
112
112
  # @return [String]
113
113
  def content_disposition
114
- data.content_disposition
114
+ data[:content_disposition]
115
115
  end
116
116
 
117
117
  # Specifies what content encodings have been applied to the object and
@@ -119,30 +119,30 @@ module Aws::S3
119
119
  # referenced by the Content-Type header field.
120
120
  # @return [String]
121
121
  def content_encoding
122
- data.content_encoding
122
+ data[:content_encoding]
123
123
  end
124
124
 
125
125
  # The language the content is in.
126
126
  # @return [String]
127
127
  def content_language
128
- data.content_language
128
+ data[:content_language]
129
129
  end
130
130
 
131
131
  # A standard MIME type describing the format of the object data.
132
132
  # @return [String]
133
133
  def content_type
134
- data.content_type
134
+ data[:content_type]
135
135
  end
136
136
 
137
137
  # The date and time at which the object is no longer cacheable.
138
138
  # @return [Time]
139
139
  def expires
140
- data.expires
140
+ data[:expires]
141
141
  end
142
142
 
143
143
  # @return [String]
144
144
  def expires_string
145
- data.expires_string
145
+ data[:expires_string]
146
146
  end
147
147
 
148
148
  # If the bucket is configured as a website, redirects requests for this
@@ -150,20 +150,20 @@ module Aws::S3
150
150
  # Amazon S3 stores the value of this header in the object metadata.
151
151
  # @return [String]
152
152
  def website_redirect_location
153
- data.website_redirect_location
153
+ data[:website_redirect_location]
154
154
  end
155
155
 
156
156
  # The Server-side encryption algorithm used when storing this object in
157
157
  # S3 (e.g., AES256, aws:kms).
158
158
  # @return [String]
159
159
  def server_side_encryption
160
- data.server_side_encryption
160
+ data[:server_side_encryption]
161
161
  end
162
162
 
163
163
  # A map of metadata to store with the object in S3.
164
164
  # @return [Hash<String,String>]
165
165
  def metadata
166
- data.metadata
166
+ data[:metadata]
167
167
  end
168
168
 
169
169
  # If server-side encryption with a customer-provided encryption key was
@@ -171,7 +171,7 @@ module Aws::S3
171
171
  # encryption algorithm used.
172
172
  # @return [String]
173
173
  def sse_customer_algorithm
174
- data.sse_customer_algorithm
174
+ data[:sse_customer_algorithm]
175
175
  end
176
176
 
177
177
  # If server-side encryption with a customer-provided encryption key was
@@ -180,37 +180,37 @@ module Aws::S3
180
180
  # key.
181
181
  # @return [String]
182
182
  def sse_customer_key_md5
183
- data.sse_customer_key_md5
183
+ data[:sse_customer_key_md5]
184
184
  end
185
185
 
186
186
  # If present, specifies the ID of the AWS Key Management Service (KMS)
187
187
  # master encryption key that was used for the object.
188
188
  # @return [String]
189
189
  def ssekms_key_id
190
- data.ssekms_key_id
190
+ data[:ssekms_key_id]
191
191
  end
192
192
 
193
193
  # @return [String]
194
194
  def storage_class
195
- data.storage_class
195
+ data[:storage_class]
196
196
  end
197
197
 
198
198
  # If present, indicates that the requester was successfully charged for
199
199
  # the request.
200
200
  # @return [String]
201
201
  def request_charged
202
- data.request_charged
202
+ data[:request_charged]
203
203
  end
204
204
 
205
205
  # @return [String]
206
206
  def replication_status
207
- data.replication_status
207
+ data[:replication_status]
208
208
  end
209
209
 
210
210
  # The count of parts this object has.
211
211
  # @return [Integer]
212
212
  def parts_count
213
- data.parts_count
213
+ data[:parts_count]
214
214
  end
215
215
 
216
216
  # @!endgroup
@@ -303,6 +303,101 @@ module Aws::S3
303
303
  })
304
304
  end
305
305
 
306
+ # @deprecated Use [Aws::S3::Client] #wait_until instead
307
+ #
308
+ # Waiter polls an API operation until a resource enters a desired
309
+ # state.
310
+ #
311
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
312
+ #
313
+ # ## Basic Usage
314
+ #
315
+ # Waiter will polls until it is successful, it fails by
316
+ # entering a terminal state, or until a maximum number of attempts
317
+ # are made.
318
+ #
319
+ # # polls in a loop until condition is true
320
+ # resource.wait_until(options) {|resource| condition}
321
+ #
322
+ # ## Example
323
+ #
324
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
325
+ #
326
+ # ## Configuration
327
+ #
328
+ # You can configure the maximum number of polling attempts, and the
329
+ # delay (in seconds) between each polling attempt. The waiting condition is set
330
+ # by passing a block to {#wait_until}:
331
+ #
332
+ # # poll for ~25 seconds
333
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
334
+ #
335
+ # ## Callbacks
336
+ #
337
+ # You can be notified before each polling attempt and before each
338
+ # delay. If you throw `:success` or `:failure` from these callbacks,
339
+ # it will terminate the waiter.
340
+ #
341
+ # started_at = Time.now
342
+ # # poll for 1 hour, instead of a number of attempts
343
+ # proc = Proc.new do |attempts, response|
344
+ # throw :failure if Time.now - started_at > 3600
345
+ # end
346
+ #
347
+ # # disable max attempts
348
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
349
+ #
350
+ # ## Handling Errors
351
+ #
352
+ # When a waiter is successful, it returns the Resource. When a waiter
353
+ # fails, it raises an error.
354
+ #
355
+ # begin
356
+ # resource.wait_until(...)
357
+ # rescue Aws::Waiters::Errors::WaiterFailed
358
+ # # resource did not enter the desired state in time
359
+ # end
360
+ #
361
+ #
362
+ # @yield param [Resource] resource to be used in the waiting condition
363
+ #
364
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
365
+ # because the waiter has entered a state that it will not transition
366
+ # out of, preventing success.
367
+ #
368
+ # yet successful.
369
+ #
370
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
371
+ # while polling for a resource that is not expected.
372
+ #
373
+ # @raise [NotImplementedError] Raised when the resource does not
374
+ #
375
+ # @option options [Integer] :max_attempts (10) Maximum number of
376
+ # attempts
377
+ # @option options [Integer] :delay (10) Delay between each
378
+ # attempt in seconds
379
+ # @option options [Proc] :before_attempt (nil) Callback
380
+ # invoked before each attempt
381
+ # @option options [Proc] :before_wait (nil) Callback
382
+ # invoked before each wait
383
+ # @return [Resource] if the waiter was successful
384
+ def wait_until(options = {}, &block)
385
+ self_copy = self.dup
386
+ attempts = 0
387
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
388
+ options[:delay] ||= 10
389
+ options[:poller] = Proc.new do
390
+ attempts += 1
391
+ if block.call(self_copy)
392
+ [:success, self_copy]
393
+ else
394
+ self_copy.reload unless attempts == options[:max_attempts]
395
+ :retry
396
+ end
397
+ end
398
+ Aws::Waiters::Waiter.new(options).wait({})
399
+ end
400
+
306
401
  # @!group Actions
307
402
 
308
403
  # @example Request syntax with placeholder values
@@ -40,20 +40,20 @@ module Aws::S3
40
40
 
41
41
  # @return [Types::Owner]
42
42
  def owner
43
- data.owner
43
+ data[:owner]
44
44
  end
45
45
 
46
46
  # A list of grants.
47
47
  # @return [Array<Types::Grant>]
48
48
  def grants
49
- data.grants
49
+ data[:grants]
50
50
  end
51
51
 
52
52
  # If present, indicates that the requester was successfully charged for
53
53
  # the request.
54
54
  # @return [String]
55
55
  def request_charged
56
- data.request_charged
56
+ data[:request_charged]
57
57
  end
58
58
 
59
59
  # @!endgroup
@@ -94,6 +94,101 @@ module Aws::S3
94
94
  !!@data
95
95
  end
96
96
 
97
+ # @deprecated Use [Aws::S3::Client] #wait_until instead
98
+ #
99
+ # Waiter polls an API operation until a resource enters a desired
100
+ # state.
101
+ #
102
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
103
+ #
104
+ # ## Basic Usage
105
+ #
106
+ # Waiter will polls until it is successful, it fails by
107
+ # entering a terminal state, or until a maximum number of attempts
108
+ # are made.
109
+ #
110
+ # # polls in a loop until condition is true
111
+ # resource.wait_until(options) {|resource| condition}
112
+ #
113
+ # ## Example
114
+ #
115
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
116
+ #
117
+ # ## Configuration
118
+ #
119
+ # You can configure the maximum number of polling attempts, and the
120
+ # delay (in seconds) between each polling attempt. The waiting condition is set
121
+ # by passing a block to {#wait_until}:
122
+ #
123
+ # # poll for ~25 seconds
124
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
125
+ #
126
+ # ## Callbacks
127
+ #
128
+ # You can be notified before each polling attempt and before each
129
+ # delay. If you throw `:success` or `:failure` from these callbacks,
130
+ # it will terminate the waiter.
131
+ #
132
+ # started_at = Time.now
133
+ # # poll for 1 hour, instead of a number of attempts
134
+ # proc = Proc.new do |attempts, response|
135
+ # throw :failure if Time.now - started_at > 3600
136
+ # end
137
+ #
138
+ # # disable max attempts
139
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
140
+ #
141
+ # ## Handling Errors
142
+ #
143
+ # When a waiter is successful, it returns the Resource. When a waiter
144
+ # fails, it raises an error.
145
+ #
146
+ # begin
147
+ # resource.wait_until(...)
148
+ # rescue Aws::Waiters::Errors::WaiterFailed
149
+ # # resource did not enter the desired state in time
150
+ # end
151
+ #
152
+ #
153
+ # @yield param [Resource] resource to be used in the waiting condition
154
+ #
155
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
156
+ # because the waiter has entered a state that it will not transition
157
+ # out of, preventing success.
158
+ #
159
+ # yet successful.
160
+ #
161
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
162
+ # while polling for a resource that is not expected.
163
+ #
164
+ # @raise [NotImplementedError] Raised when the resource does not
165
+ #
166
+ # @option options [Integer] :max_attempts (10) Maximum number of
167
+ # attempts
168
+ # @option options [Integer] :delay (10) Delay between each
169
+ # attempt in seconds
170
+ # @option options [Proc] :before_attempt (nil) Callback
171
+ # invoked before each attempt
172
+ # @option options [Proc] :before_wait (nil) Callback
173
+ # invoked before each wait
174
+ # @return [Resource] if the waiter was successful
175
+ def wait_until(options = {}, &block)
176
+ self_copy = self.dup
177
+ attempts = 0
178
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
179
+ options[:delay] ||= 10
180
+ options[:poller] = Proc.new do
181
+ attempts += 1
182
+ if block.call(self_copy)
183
+ [:success, self_copy]
184
+ else
185
+ self_copy.reload unless attempts == options[:max_attempts]
186
+ :retry
187
+ end
188
+ end
189
+ Aws::Waiters::Waiter.new(options).wait({})
190
+ end
191
+
97
192
  # @!group Actions
98
193
 
99
194
  # @example Request syntax with placeholder values