aws-sdk-ec2 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,7 +49,7 @@ module Aws::EC2
49
49
  # The resource type.
50
50
  # @return [String]
51
51
  def resource_type
52
- data.resource_type
52
+ data[:resource_type]
53
53
  end
54
54
 
55
55
  # @!endgroup
@@ -96,6 +96,101 @@ module Aws::EC2
96
96
  !!@data
97
97
  end
98
98
 
99
+ # @deprecated Use [Aws::EC2::Client] #wait_until instead
100
+ #
101
+ # Waiter polls an API operation until a resource enters a desired
102
+ # state.
103
+ #
104
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
105
+ #
106
+ # ## Basic Usage
107
+ #
108
+ # Waiter will polls until it is successful, it fails by
109
+ # entering a terminal state, or until a maximum number of attempts
110
+ # are made.
111
+ #
112
+ # # polls in a loop until condition is true
113
+ # resource.wait_until(options) {|resource| condition}
114
+ #
115
+ # ## Example
116
+ #
117
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
118
+ #
119
+ # ## Configuration
120
+ #
121
+ # You can configure the maximum number of polling attempts, and the
122
+ # delay (in seconds) between each polling attempt. The waiting condition is set
123
+ # by passing a block to {#wait_until}:
124
+ #
125
+ # # poll for ~25 seconds
126
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
127
+ #
128
+ # ## Callbacks
129
+ #
130
+ # You can be notified before each polling attempt and before each
131
+ # delay. If you throw `:success` or `:failure` from these callbacks,
132
+ # it will terminate the waiter.
133
+ #
134
+ # started_at = Time.now
135
+ # # poll for 1 hour, instead of a number of attempts
136
+ # proc = Proc.new do |attempts, response|
137
+ # throw :failure if Time.now - started_at > 3600
138
+ # end
139
+ #
140
+ # # disable max attempts
141
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
142
+ #
143
+ # ## Handling Errors
144
+ #
145
+ # When a waiter is successful, it returns the Resource. When a waiter
146
+ # fails, it raises an error.
147
+ #
148
+ # begin
149
+ # resource.wait_until(...)
150
+ # rescue Aws::Waiters::Errors::WaiterFailed
151
+ # # resource did not enter the desired state in time
152
+ # end
153
+ #
154
+ #
155
+ # @yield param [Resource] resource to be used in the waiting condition
156
+ #
157
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
158
+ # because the waiter has entered a state that it will not transition
159
+ # out of, preventing success.
160
+ #
161
+ # yet successful.
162
+ #
163
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
164
+ # while polling for a resource that is not expected.
165
+ #
166
+ # @raise [NotImplementedError] Raised when the resource does not
167
+ #
168
+ # @option options [Integer] :max_attempts (10) Maximum number of
169
+ # attempts
170
+ # @option options [Integer] :delay (10) Delay between each
171
+ # attempt in seconds
172
+ # @option options [Proc] :before_attempt (nil) Callback
173
+ # invoked before each attempt
174
+ # @option options [Proc] :before_wait (nil) Callback
175
+ # invoked before each wait
176
+ # @return [Resource] if the waiter was successful
177
+ def wait_until(options = {}, &block)
178
+ self_copy = self.dup
179
+ attempts = 0
180
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
181
+ options[:delay] ||= 10
182
+ options[:poller] = Proc.new do
183
+ attempts += 1
184
+ if block.call(self_copy)
185
+ [:success, self_copy]
186
+ else
187
+ self_copy.reload unless attempts == options[:max_attempts]
188
+ :retry
189
+ end
190
+ end
191
+ Aws::Waiters::Waiter.new(options).wait({})
192
+ end
193
+
99
194
  # @!group Actions
100
195
 
101
196
  # @example Request syntax with placeholder values
@@ -34,25 +34,25 @@ module Aws::EC2
34
34
  # Information about the volume attachments.
35
35
  # @return [Array<Types::VolumeAttachment>]
36
36
  def attachments
37
- data.attachments
37
+ data[:attachments]
38
38
  end
39
39
 
40
40
  # The Availability Zone for the volume.
41
41
  # @return [String]
42
42
  def availability_zone
43
- data.availability_zone
43
+ data[:availability_zone]
44
44
  end
45
45
 
46
46
  # The time stamp when volume creation was initiated.
47
47
  # @return [Time]
48
48
  def create_time
49
- data.create_time
49
+ data[:create_time]
50
50
  end
51
51
 
52
52
  # Indicates whether the volume will be encrypted.
53
53
  # @return [Boolean]
54
54
  def encrypted
55
- data.encrypted
55
+ data[:encrypted]
56
56
  end
57
57
 
58
58
  # The full ARN of the AWS Key Management Service (AWS KMS) customer
@@ -60,25 +60,25 @@ module Aws::EC2
60
60
  # for the volume.
61
61
  # @return [String]
62
62
  def kms_key_id
63
- data.kms_key_id
63
+ data[:kms_key_id]
64
64
  end
65
65
 
66
66
  # The size of the volume, in GiBs.
67
67
  # @return [Integer]
68
68
  def size
69
- data.size
69
+ data[:size]
70
70
  end
71
71
 
72
72
  # The snapshot from which the volume was created, if applicable.
73
73
  # @return [String]
74
74
  def snapshot_id
75
- data.snapshot_id
75
+ data[:snapshot_id]
76
76
  end
77
77
 
78
78
  # The volume state.
79
79
  # @return [String]
80
80
  def state
81
- data.state
81
+ data[:state]
82
82
  end
83
83
 
84
84
  # The number of I/O operations per second (IOPS) that the volume
@@ -102,13 +102,13 @@ module Aws::EC2
102
102
  # [1]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html
103
103
  # @return [Integer]
104
104
  def iops
105
- data.iops
105
+ data[:iops]
106
106
  end
107
107
 
108
108
  # Any tags assigned to the volume.
109
109
  # @return [Array<Types::Tag>]
110
110
  def tags
111
- data.tags
111
+ data[:tags]
112
112
  end
113
113
 
114
114
  # The volume type. This can be `gp2` for General Purpose SSD, `io1` for
@@ -116,7 +116,7 @@ module Aws::EC2
116
116
  # Cold HDD, or `standard` for Magnetic volumes.
117
117
  # @return [String]
118
118
  def volume_type
119
- data.volume_type
119
+ data[:volume_type]
120
120
  end
121
121
 
122
122
  # @!endgroup
@@ -154,6 +154,101 @@ module Aws::EC2
154
154
  !!@data
155
155
  end
156
156
 
157
+ # @deprecated Use [Aws::EC2::Client] #wait_until instead
158
+ #
159
+ # Waiter polls an API operation until a resource enters a desired
160
+ # state.
161
+ #
162
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
163
+ #
164
+ # ## Basic Usage
165
+ #
166
+ # Waiter will polls until it is successful, it fails by
167
+ # entering a terminal state, or until a maximum number of attempts
168
+ # are made.
169
+ #
170
+ # # polls in a loop until condition is true
171
+ # resource.wait_until(options) {|resource| condition}
172
+ #
173
+ # ## Example
174
+ #
175
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
176
+ #
177
+ # ## Configuration
178
+ #
179
+ # You can configure the maximum number of polling attempts, and the
180
+ # delay (in seconds) between each polling attempt. The waiting condition is set
181
+ # by passing a block to {#wait_until}:
182
+ #
183
+ # # poll for ~25 seconds
184
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
185
+ #
186
+ # ## Callbacks
187
+ #
188
+ # You can be notified before each polling attempt and before each
189
+ # delay. If you throw `:success` or `:failure` from these callbacks,
190
+ # it will terminate the waiter.
191
+ #
192
+ # started_at = Time.now
193
+ # # poll for 1 hour, instead of a number of attempts
194
+ # proc = Proc.new do |attempts, response|
195
+ # throw :failure if Time.now - started_at > 3600
196
+ # end
197
+ #
198
+ # # disable max attempts
199
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
200
+ #
201
+ # ## Handling Errors
202
+ #
203
+ # When a waiter is successful, it returns the Resource. When a waiter
204
+ # fails, it raises an error.
205
+ #
206
+ # begin
207
+ # resource.wait_until(...)
208
+ # rescue Aws::Waiters::Errors::WaiterFailed
209
+ # # resource did not enter the desired state in time
210
+ # end
211
+ #
212
+ #
213
+ # @yield param [Resource] resource to be used in the waiting condition
214
+ #
215
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
216
+ # because the waiter has entered a state that it will not transition
217
+ # out of, preventing success.
218
+ #
219
+ # yet successful.
220
+ #
221
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
222
+ # while polling for a resource that is not expected.
223
+ #
224
+ # @raise [NotImplementedError] Raised when the resource does not
225
+ #
226
+ # @option options [Integer] :max_attempts (10) Maximum number of
227
+ # attempts
228
+ # @option options [Integer] :delay (10) Delay between each
229
+ # attempt in seconds
230
+ # @option options [Proc] :before_attempt (nil) Callback
231
+ # invoked before each attempt
232
+ # @option options [Proc] :before_wait (nil) Callback
233
+ # invoked before each wait
234
+ # @return [Resource] if the waiter was successful
235
+ def wait_until(options = {}, &block)
236
+ self_copy = self.dup
237
+ attempts = 0
238
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
239
+ options[:delay] ||= 10
240
+ options[:poller] = Proc.new do
241
+ attempts += 1
242
+ if block.call(self_copy)
243
+ [:success, self_copy]
244
+ else
245
+ self_copy.reload unless attempts == options[:max_attempts]
246
+ :retry
247
+ end
248
+ end
249
+ Aws::Waiters::Waiter.new(options).wait({})
250
+ end
251
+
157
252
  # @!group Actions
158
253
 
159
254
  # @example Request syntax with placeholder values
@@ -34,50 +34,50 @@ module Aws::EC2
34
34
  # The primary IPv4 CIDR block for the VPC.
35
35
  # @return [String]
36
36
  def cidr_block
37
- data.cidr_block
37
+ data[:cidr_block]
38
38
  end
39
39
 
40
40
  # The ID of the set of DHCP options you've associated with the VPC (or
41
41
  # `default` if the default options are associated with the VPC).
42
42
  # @return [String]
43
43
  def dhcp_options_id
44
- data.dhcp_options_id
44
+ data[:dhcp_options_id]
45
45
  end
46
46
 
47
47
  # The current state of the VPC.
48
48
  # @return [String]
49
49
  def state
50
- data.state
50
+ data[:state]
51
51
  end
52
52
 
53
53
  # The allowed tenancy of instances launched into the VPC.
54
54
  # @return [String]
55
55
  def instance_tenancy
56
- data.instance_tenancy
56
+ data[:instance_tenancy]
57
57
  end
58
58
 
59
59
  # Information about the IPv6 CIDR blocks associated with the VPC.
60
60
  # @return [Array<Types::VpcIpv6CidrBlockAssociation>]
61
61
  def ipv_6_cidr_block_association_set
62
- data.ipv_6_cidr_block_association_set
62
+ data[:ipv_6_cidr_block_association_set]
63
63
  end
64
64
 
65
65
  # Information about the IPv4 CIDR blocks associated with the VPC.
66
66
  # @return [Array<Types::VpcCidrBlockAssociation>]
67
67
  def cidr_block_association_set
68
- data.cidr_block_association_set
68
+ data[:cidr_block_association_set]
69
69
  end
70
70
 
71
71
  # Indicates whether the VPC is the default VPC.
72
72
  # @return [Boolean]
73
73
  def is_default
74
- data.is_default
74
+ data[:is_default]
75
75
  end
76
76
 
77
77
  # Any tags assigned to the VPC.
78
78
  # @return [Array<Types::Tag>]
79
79
  def tags
80
- data.tags
80
+ data[:tags]
81
81
  end
82
82
 
83
83
  # @!endgroup
@@ -163,6 +163,101 @@ module Aws::EC2
163
163
  })
164
164
  end
165
165
 
166
+ # @deprecated Use [Aws::EC2::Client] #wait_until instead
167
+ #
168
+ # Waiter polls an API operation until a resource enters a desired
169
+ # state.
170
+ #
171
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
172
+ #
173
+ # ## Basic Usage
174
+ #
175
+ # Waiter will polls until it is successful, it fails by
176
+ # entering a terminal state, or until a maximum number of attempts
177
+ # are made.
178
+ #
179
+ # # polls in a loop until condition is true
180
+ # resource.wait_until(options) {|resource| condition}
181
+ #
182
+ # ## Example
183
+ #
184
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
185
+ #
186
+ # ## Configuration
187
+ #
188
+ # You can configure the maximum number of polling attempts, and the
189
+ # delay (in seconds) between each polling attempt. The waiting condition is set
190
+ # by passing a block to {#wait_until}:
191
+ #
192
+ # # poll for ~25 seconds
193
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
194
+ #
195
+ # ## Callbacks
196
+ #
197
+ # You can be notified before each polling attempt and before each
198
+ # delay. If you throw `:success` or `:failure` from these callbacks,
199
+ # it will terminate the waiter.
200
+ #
201
+ # started_at = Time.now
202
+ # # poll for 1 hour, instead of a number of attempts
203
+ # proc = Proc.new do |attempts, response|
204
+ # throw :failure if Time.now - started_at > 3600
205
+ # end
206
+ #
207
+ # # disable max attempts
208
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
209
+ #
210
+ # ## Handling Errors
211
+ #
212
+ # When a waiter is successful, it returns the Resource. When a waiter
213
+ # fails, it raises an error.
214
+ #
215
+ # begin
216
+ # resource.wait_until(...)
217
+ # rescue Aws::Waiters::Errors::WaiterFailed
218
+ # # resource did not enter the desired state in time
219
+ # end
220
+ #
221
+ #
222
+ # @yield param [Resource] resource to be used in the waiting condition
223
+ #
224
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
225
+ # because the waiter has entered a state that it will not transition
226
+ # out of, preventing success.
227
+ #
228
+ # yet successful.
229
+ #
230
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
231
+ # while polling for a resource that is not expected.
232
+ #
233
+ # @raise [NotImplementedError] Raised when the resource does not
234
+ #
235
+ # @option options [Integer] :max_attempts (10) Maximum number of
236
+ # attempts
237
+ # @option options [Integer] :delay (10) Delay between each
238
+ # attempt in seconds
239
+ # @option options [Proc] :before_attempt (nil) Callback
240
+ # invoked before each attempt
241
+ # @option options [Proc] :before_wait (nil) Callback
242
+ # invoked before each wait
243
+ # @return [Resource] if the waiter was successful
244
+ def wait_until(options = {}, &block)
245
+ self_copy = self.dup
246
+ attempts = 0
247
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
248
+ options[:delay] ||= 10
249
+ options[:poller] = Proc.new do
250
+ attempts += 1
251
+ if block.call(self_copy)
252
+ [:success, self_copy]
253
+ else
254
+ self_copy.reload unless attempts == options[:max_attempts]
255
+ :retry
256
+ end
257
+ end
258
+ Aws::Waiters::Waiter.new(options).wait({})
259
+ end
260
+
166
261
  # @!group Actions
167
262
 
168
263
  # @example Request syntax with placeholder values
@@ -671,9 +766,9 @@ module Aws::EC2
671
766
 
672
767
  # @return [DhcpOptions, nil]
673
768
  def dhcp_options
674
- if data.dhcp_options_id
769
+ if data[:dhcp_options_id]
675
770
  DhcpOptions.new(
676
- id: data.dhcp_options_id,
771
+ id: data[:dhcp_options_id],
677
772
  client: @client
678
773
  )
679
774
  else