aws-sdk-ec2 1.5.0 → 1.6.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 +4 -4
- data/lib/aws-sdk-ec2.rb +1 -1
- data/lib/aws-sdk-ec2/classic_address.rb +104 -9
- data/lib/aws-sdk-ec2/client.rb +1 -1
- data/lib/aws-sdk-ec2/dhcp_options.rb +97 -2
- data/lib/aws-sdk-ec2/image.rb +118 -23
- data/lib/aws-sdk-ec2/instance.rb +147 -52
- data/lib/aws-sdk-ec2/internet_gateway.rb +97 -2
- data/lib/aws-sdk-ec2/key_pair.rb +97 -2
- data/lib/aws-sdk-ec2/key_pair_info.rb +96 -1
- data/lib/aws-sdk-ec2/network_acl.rb +102 -7
- data/lib/aws-sdk-ec2/network_interface.rb +121 -26
- data/lib/aws-sdk-ec2/network_interface_association.rb +100 -5
- data/lib/aws-sdk-ec2/placement_group.rb +97 -2
- data/lib/aws-sdk-ec2/route.rb +106 -11
- data/lib/aws-sdk-ec2/route_table.rb +106 -11
- data/lib/aws-sdk-ec2/route_table_association.rb +102 -7
- data/lib/aws-sdk-ec2/security_group.rb +102 -7
- data/lib/aws-sdk-ec2/snapshot.rb +110 -15
- data/lib/aws-sdk-ec2/subnet.rb +107 -12
- data/lib/aws-sdk-ec2/tag.rb +96 -1
- data/lib/aws-sdk-ec2/volume.rb +106 -11
- data/lib/aws-sdk-ec2/vpc.rb +105 -10
- data/lib/aws-sdk-ec2/vpc_address.rb +105 -10
- data/lib/aws-sdk-ec2/vpc_peering_connection.rb +104 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 058c7eacf8eb00c641d672f08e546d631e13821b
|
4
|
+
data.tar.gz: 85cff28e4fff5a7877256ae8f0991cf1f4dce693
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72e740690dcb4a3e295d008280543771905715b510365244f829fe0c6f98f37bb37debbd7d471e21504b5785be61fe20720d710ce2cef24881b5b7519b58a07e
|
7
|
+
data.tar.gz: bdd54152968199b7c544b6ad89cbaddde909806d7d5eb20788e5a0eb48ef438bd99cc6c63e4fe6108009516fecea99aef0c18abaa4ca5bea40810e12e510121a
|
data/lib/aws-sdk-ec2.rb
CHANGED
@@ -33,46 +33,46 @@ module Aws::EC2
|
|
33
33
|
# The ID of the instance that the address is associated with (if any).
|
34
34
|
# @return [String]
|
35
35
|
def instance_id
|
36
|
-
data
|
36
|
+
data[:instance_id]
|
37
37
|
end
|
38
38
|
|
39
39
|
# The ID representing the allocation of the address for use with
|
40
40
|
# EC2-VPC.
|
41
41
|
# @return [String]
|
42
42
|
def allocation_id
|
43
|
-
data
|
43
|
+
data[:allocation_id]
|
44
44
|
end
|
45
45
|
|
46
46
|
# The ID representing the association of the address with an instance in
|
47
47
|
# a VPC.
|
48
48
|
# @return [String]
|
49
49
|
def association_id
|
50
|
-
data
|
50
|
+
data[:association_id]
|
51
51
|
end
|
52
52
|
|
53
53
|
# Indicates whether this Elastic IP address is for use with instances in
|
54
54
|
# EC2-Classic (`standard`) or instances in a VPC (`vpc`).
|
55
55
|
# @return [String]
|
56
56
|
def domain
|
57
|
-
data
|
57
|
+
data[:domain]
|
58
58
|
end
|
59
59
|
|
60
60
|
# The ID of the network interface.
|
61
61
|
# @return [String]
|
62
62
|
def network_interface_id
|
63
|
-
data
|
63
|
+
data[:network_interface_id]
|
64
64
|
end
|
65
65
|
|
66
66
|
# The ID of the AWS account that owns the network interface.
|
67
67
|
# @return [String]
|
68
68
|
def network_interface_owner_id
|
69
|
-
data
|
69
|
+
data[:network_interface_owner_id]
|
70
70
|
end
|
71
71
|
|
72
72
|
# The private IP address associated with the Elastic IP address.
|
73
73
|
# @return [String]
|
74
74
|
def private_ip_address
|
75
|
-
data
|
75
|
+
data[:private_ip_address]
|
76
76
|
end
|
77
77
|
|
78
78
|
# @!endgroup
|
@@ -110,6 +110,101 @@ module Aws::EC2
|
|
110
110
|
!!@data
|
111
111
|
end
|
112
112
|
|
113
|
+
# @deprecated Use [Aws::EC2::Client] #wait_until instead
|
114
|
+
#
|
115
|
+
# Waiter polls an API operation until a resource enters a desired
|
116
|
+
# state.
|
117
|
+
#
|
118
|
+
# @note The waiting operation is performed on a copy. The original resource remains unchanged
|
119
|
+
#
|
120
|
+
# ## Basic Usage
|
121
|
+
#
|
122
|
+
# Waiter will polls until it is successful, it fails by
|
123
|
+
# entering a terminal state, or until a maximum number of attempts
|
124
|
+
# are made.
|
125
|
+
#
|
126
|
+
# # polls in a loop until condition is true
|
127
|
+
# resource.wait_until(options) {|resource| condition}
|
128
|
+
#
|
129
|
+
# ## Example
|
130
|
+
#
|
131
|
+
# instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
|
132
|
+
#
|
133
|
+
# ## Configuration
|
134
|
+
#
|
135
|
+
# You can configure the maximum number of polling attempts, and the
|
136
|
+
# delay (in seconds) between each polling attempt. The waiting condition is set
|
137
|
+
# by passing a block to {#wait_until}:
|
138
|
+
#
|
139
|
+
# # poll for ~25 seconds
|
140
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
141
|
+
#
|
142
|
+
# ## Callbacks
|
143
|
+
#
|
144
|
+
# You can be notified before each polling attempt and before each
|
145
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
146
|
+
# it will terminate the waiter.
|
147
|
+
#
|
148
|
+
# started_at = Time.now
|
149
|
+
# # poll for 1 hour, instead of a number of attempts
|
150
|
+
# proc = Proc.new do |attempts, response|
|
151
|
+
# throw :failure if Time.now - started_at > 3600
|
152
|
+
# end
|
153
|
+
#
|
154
|
+
# # disable max attempts
|
155
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
156
|
+
#
|
157
|
+
# ## Handling Errors
|
158
|
+
#
|
159
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
160
|
+
# fails, it raises an error.
|
161
|
+
#
|
162
|
+
# begin
|
163
|
+
# resource.wait_until(...)
|
164
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
165
|
+
# # resource did not enter the desired state in time
|
166
|
+
# end
|
167
|
+
#
|
168
|
+
#
|
169
|
+
# @yield param [Resource] resource to be used in the waiting condition
|
170
|
+
#
|
171
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
|
172
|
+
# because the waiter has entered a state that it will not transition
|
173
|
+
# out of, preventing success.
|
174
|
+
#
|
175
|
+
# yet successful.
|
176
|
+
#
|
177
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
|
178
|
+
# while polling for a resource that is not expected.
|
179
|
+
#
|
180
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
181
|
+
#
|
182
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
183
|
+
# attempts
|
184
|
+
# @option options [Integer] :delay (10) Delay between each
|
185
|
+
# attempt in seconds
|
186
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
187
|
+
# invoked before each attempt
|
188
|
+
# @option options [Proc] :before_wait (nil) Callback
|
189
|
+
# invoked before each wait
|
190
|
+
# @return [Resource] if the waiter was successful
|
191
|
+
def wait_until(options = {}, &block)
|
192
|
+
self_copy = self.dup
|
193
|
+
attempts = 0
|
194
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
195
|
+
options[:delay] ||= 10
|
196
|
+
options[:poller] = Proc.new do
|
197
|
+
attempts += 1
|
198
|
+
if block.call(self_copy)
|
199
|
+
[:success, self_copy]
|
200
|
+
else
|
201
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
202
|
+
:retry
|
203
|
+
end
|
204
|
+
end
|
205
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
206
|
+
end
|
207
|
+
|
113
208
|
# @!group Actions
|
114
209
|
|
115
210
|
# @example Request syntax with placeholder values
|
@@ -174,7 +269,7 @@ module Aws::EC2
|
|
174
269
|
# `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
|
175
270
|
# @return [EmptyStructure]
|
176
271
|
def disassociate(options = {})
|
177
|
-
options = options.merge(public_ip: data
|
272
|
+
options = options.merge(public_ip: data[:public_ip])
|
178
273
|
resp = @client.disassociate_address(options)
|
179
274
|
resp.data
|
180
275
|
end
|
@@ -195,7 +290,7 @@ module Aws::EC2
|
|
195
290
|
# `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
|
196
291
|
# @return [EmptyStructure]
|
197
292
|
def release(options = {})
|
198
|
-
options = options.merge(public_ip: data
|
293
|
+
options = options.merge(public_ip: data[:public_ip])
|
199
294
|
resp = @client.release_address(options)
|
200
295
|
resp.data
|
201
296
|
end
|
data/lib/aws-sdk-ec2/client.rb
CHANGED
@@ -21196,7 +21196,7 @@ module Aws::EC2
|
|
21196
21196
|
params: params,
|
21197
21197
|
config: config)
|
21198
21198
|
context[:gem_name] = 'aws-sdk-ec2'
|
21199
|
-
context[:gem_version] = '1.
|
21199
|
+
context[:gem_version] = '1.6.0'
|
21200
21200
|
Seahorse::Client::Request.new(handlers, context)
|
21201
21201
|
end
|
21202
21202
|
|
@@ -34,13 +34,13 @@ module Aws::EC2
|
|
34
34
|
# One or more DHCP options in the set.
|
35
35
|
# @return [Array<Types::DhcpConfiguration>]
|
36
36
|
def dhcp_configurations
|
37
|
-
data
|
37
|
+
data[:dhcp_configurations]
|
38
38
|
end
|
39
39
|
|
40
40
|
# Any tags assigned to the DHCP options set.
|
41
41
|
# @return [Array<Types::Tag>]
|
42
42
|
def tags
|
43
|
-
data
|
43
|
+
data[:tags]
|
44
44
|
end
|
45
45
|
|
46
46
|
# @!endgroup
|
@@ -78,6 +78,101 @@ module Aws::EC2
|
|
78
78
|
!!@data
|
79
79
|
end
|
80
80
|
|
81
|
+
# @deprecated Use [Aws::EC2::Client] #wait_until instead
|
82
|
+
#
|
83
|
+
# Waiter polls an API operation until a resource enters a desired
|
84
|
+
# state.
|
85
|
+
#
|
86
|
+
# @note The waiting operation is performed on a copy. The original resource remains unchanged
|
87
|
+
#
|
88
|
+
# ## Basic Usage
|
89
|
+
#
|
90
|
+
# Waiter will polls until it is successful, it fails by
|
91
|
+
# entering a terminal state, or until a maximum number of attempts
|
92
|
+
# are made.
|
93
|
+
#
|
94
|
+
# # polls in a loop until condition is true
|
95
|
+
# resource.wait_until(options) {|resource| condition}
|
96
|
+
#
|
97
|
+
# ## Example
|
98
|
+
#
|
99
|
+
# instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
|
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 set
|
105
|
+
# 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
|
+
#
|
137
|
+
# @yield param [Resource] resource to be used in the waiting condition
|
138
|
+
#
|
139
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
|
140
|
+
# because the waiter has entered a state that it will not transition
|
141
|
+
# out of, preventing success.
|
142
|
+
#
|
143
|
+
# yet successful.
|
144
|
+
#
|
145
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
|
146
|
+
# while polling for a resource that is not expected.
|
147
|
+
#
|
148
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
149
|
+
#
|
150
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
151
|
+
# attempts
|
152
|
+
# @option options [Integer] :delay (10) Delay between each
|
153
|
+
# attempt in seconds
|
154
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
155
|
+
# invoked before each attempt
|
156
|
+
# @option options [Proc] :before_wait (nil) Callback
|
157
|
+
# invoked before each wait
|
158
|
+
# @return [Resource] if the waiter was successful
|
159
|
+
def wait_until(options = {}, &block)
|
160
|
+
self_copy = self.dup
|
161
|
+
attempts = 0
|
162
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
163
|
+
options[:delay] ||= 10
|
164
|
+
options[:poller] = Proc.new do
|
165
|
+
attempts += 1
|
166
|
+
if block.call(self_copy)
|
167
|
+
[:success, self_copy]
|
168
|
+
else
|
169
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
170
|
+
:retry
|
171
|
+
end
|
172
|
+
end
|
173
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
174
|
+
end
|
175
|
+
|
81
176
|
# @!group Actions
|
82
177
|
|
83
178
|
# @example Request syntax with placeholder values
|
data/lib/aws-sdk-ec2/image.rb
CHANGED
@@ -34,25 +34,25 @@ module Aws::EC2
|
|
34
34
|
# The architecture of the image.
|
35
35
|
# @return [String]
|
36
36
|
def architecture
|
37
|
-
data
|
37
|
+
data[:architecture]
|
38
38
|
end
|
39
39
|
|
40
40
|
# The date and time the image was created.
|
41
41
|
# @return [String]
|
42
42
|
def creation_date
|
43
|
-
data
|
43
|
+
data[:creation_date]
|
44
44
|
end
|
45
45
|
|
46
46
|
# The location of the AMI.
|
47
47
|
# @return [String]
|
48
48
|
def image_location
|
49
|
-
data
|
49
|
+
data[:image_location]
|
50
50
|
end
|
51
51
|
|
52
52
|
# The type of image.
|
53
53
|
# @return [String]
|
54
54
|
def image_type
|
55
|
-
data
|
55
|
+
data[:image_type]
|
56
56
|
end
|
57
57
|
|
58
58
|
# Indicates whether the image has public launch permissions. The value
|
@@ -60,122 +60,122 @@ module Aws::EC2
|
|
60
60
|
# has only implicit and explicit launch permissions.
|
61
61
|
# @return [Boolean]
|
62
62
|
def public
|
63
|
-
data
|
63
|
+
data[:public]
|
64
64
|
end
|
65
65
|
|
66
66
|
# The kernel associated with the image, if any. Only applicable for
|
67
67
|
# machine images.
|
68
68
|
# @return [String]
|
69
69
|
def kernel_id
|
70
|
-
data
|
70
|
+
data[:kernel_id]
|
71
71
|
end
|
72
72
|
|
73
73
|
# The AWS account ID of the image owner.
|
74
74
|
# @return [String]
|
75
75
|
def owner_id
|
76
|
-
data
|
76
|
+
data[:owner_id]
|
77
77
|
end
|
78
78
|
|
79
79
|
# The value is `Windows` for Windows AMIs; otherwise blank.
|
80
80
|
# @return [String]
|
81
81
|
def platform
|
82
|
-
data
|
82
|
+
data[:platform]
|
83
83
|
end
|
84
84
|
|
85
85
|
# Any product codes associated with the AMI.
|
86
86
|
# @return [Array<Types::ProductCode>]
|
87
87
|
def product_codes
|
88
|
-
data
|
88
|
+
data[:product_codes]
|
89
89
|
end
|
90
90
|
|
91
91
|
# The RAM disk associated with the image, if any. Only applicable for
|
92
92
|
# machine images.
|
93
93
|
# @return [String]
|
94
94
|
def ramdisk_id
|
95
|
-
data
|
95
|
+
data[:ramdisk_id]
|
96
96
|
end
|
97
97
|
|
98
98
|
# The current state of the AMI. If the state is `available`, the image
|
99
99
|
# is successfully registered and can be used to launch an instance.
|
100
100
|
# @return [String]
|
101
101
|
def state
|
102
|
-
data
|
102
|
+
data[:state]
|
103
103
|
end
|
104
104
|
|
105
105
|
# Any block device mapping entries.
|
106
106
|
# @return [Array<Types::BlockDeviceMapping>]
|
107
107
|
def block_device_mappings
|
108
|
-
data
|
108
|
+
data[:block_device_mappings]
|
109
109
|
end
|
110
110
|
|
111
111
|
# The description of the AMI that was provided during image creation.
|
112
112
|
# @return [String]
|
113
113
|
def description
|
114
|
-
data
|
114
|
+
data[:description]
|
115
115
|
end
|
116
116
|
|
117
117
|
# Specifies whether enhanced networking with ENA is enabled.
|
118
118
|
# @return [Boolean]
|
119
119
|
def ena_support
|
120
|
-
data
|
120
|
+
data[:ena_support]
|
121
121
|
end
|
122
122
|
|
123
123
|
# The hypervisor type of the image.
|
124
124
|
# @return [String]
|
125
125
|
def hypervisor
|
126
|
-
data
|
126
|
+
data[:hypervisor]
|
127
127
|
end
|
128
128
|
|
129
129
|
# The AWS account alias (for example, `amazon`, `self`) or the AWS
|
130
130
|
# account ID of the AMI owner.
|
131
131
|
# @return [String]
|
132
132
|
def image_owner_alias
|
133
|
-
data
|
133
|
+
data[:image_owner_alias]
|
134
134
|
end
|
135
135
|
|
136
136
|
# The name of the AMI that was provided during image creation.
|
137
137
|
# @return [String]
|
138
138
|
def name
|
139
|
-
data
|
139
|
+
data[:name]
|
140
140
|
end
|
141
141
|
|
142
142
|
# The device name of the root device (for example, `/dev/sda1` or
|
143
143
|
# `/dev/xvda`).
|
144
144
|
# @return [String]
|
145
145
|
def root_device_name
|
146
|
-
data
|
146
|
+
data[:root_device_name]
|
147
147
|
end
|
148
148
|
|
149
149
|
# The type of root device used by the AMI. The AMI can use an EBS volume
|
150
150
|
# or an instance store volume.
|
151
151
|
# @return [String]
|
152
152
|
def root_device_type
|
153
|
-
data
|
153
|
+
data[:root_device_type]
|
154
154
|
end
|
155
155
|
|
156
156
|
# Specifies whether enhanced networking with the Intel 82599 Virtual
|
157
157
|
# Function interface is enabled.
|
158
158
|
# @return [String]
|
159
159
|
def sriov_net_support
|
160
|
-
data
|
160
|
+
data[:sriov_net_support]
|
161
161
|
end
|
162
162
|
|
163
163
|
# The reason for the state change.
|
164
164
|
# @return [Types::StateReason]
|
165
165
|
def state_reason
|
166
|
-
data
|
166
|
+
data[:state_reason]
|
167
167
|
end
|
168
168
|
|
169
169
|
# Any tags assigned to the image.
|
170
170
|
# @return [Array<Types::Tag>]
|
171
171
|
def tags
|
172
|
-
data
|
172
|
+
data[:tags]
|
173
173
|
end
|
174
174
|
|
175
175
|
# The type of virtualization of the AMI.
|
176
176
|
# @return [String]
|
177
177
|
def virtualization_type
|
178
|
-
data
|
178
|
+
data[:virtualization_type]
|
179
179
|
end
|
180
180
|
|
181
181
|
# @!endgroup
|
@@ -245,6 +245,101 @@ module Aws::EC2
|
|
245
245
|
})
|
246
246
|
end
|
247
247
|
|
248
|
+
# @deprecated Use [Aws::EC2::Client] #wait_until instead
|
249
|
+
#
|
250
|
+
# Waiter polls an API operation until a resource enters a desired
|
251
|
+
# state.
|
252
|
+
#
|
253
|
+
# @note The waiting operation is performed on a copy. The original resource remains unchanged
|
254
|
+
#
|
255
|
+
# ## Basic Usage
|
256
|
+
#
|
257
|
+
# Waiter will polls until it is successful, it fails by
|
258
|
+
# entering a terminal state, or until a maximum number of attempts
|
259
|
+
# are made.
|
260
|
+
#
|
261
|
+
# # polls in a loop until condition is true
|
262
|
+
# resource.wait_until(options) {|resource| condition}
|
263
|
+
#
|
264
|
+
# ## Example
|
265
|
+
#
|
266
|
+
# instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
|
267
|
+
#
|
268
|
+
# ## Configuration
|
269
|
+
#
|
270
|
+
# You can configure the maximum number of polling attempts, and the
|
271
|
+
# delay (in seconds) between each polling attempt. The waiting condition is set
|
272
|
+
# by passing a block to {#wait_until}:
|
273
|
+
#
|
274
|
+
# # poll for ~25 seconds
|
275
|
+
# resource.wait_until(max_attempts:5,delay:5) {|resource|...}
|
276
|
+
#
|
277
|
+
# ## Callbacks
|
278
|
+
#
|
279
|
+
# You can be notified before each polling attempt and before each
|
280
|
+
# delay. If you throw `:success` or `:failure` from these callbacks,
|
281
|
+
# it will terminate the waiter.
|
282
|
+
#
|
283
|
+
# started_at = Time.now
|
284
|
+
# # poll for 1 hour, instead of a number of attempts
|
285
|
+
# proc = Proc.new do |attempts, response|
|
286
|
+
# throw :failure if Time.now - started_at > 3600
|
287
|
+
# end
|
288
|
+
#
|
289
|
+
# # disable max attempts
|
290
|
+
# instance.wait_until(before_wait:proc, max_attempts:nil) {...}
|
291
|
+
#
|
292
|
+
# ## Handling Errors
|
293
|
+
#
|
294
|
+
# When a waiter is successful, it returns the Resource. When a waiter
|
295
|
+
# fails, it raises an error.
|
296
|
+
#
|
297
|
+
# begin
|
298
|
+
# resource.wait_until(...)
|
299
|
+
# rescue Aws::Waiters::Errors::WaiterFailed
|
300
|
+
# # resource did not enter the desired state in time
|
301
|
+
# end
|
302
|
+
#
|
303
|
+
#
|
304
|
+
# @yield param [Resource] resource to be used in the waiting condition
|
305
|
+
#
|
306
|
+
# @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
|
307
|
+
# because the waiter has entered a state that it will not transition
|
308
|
+
# out of, preventing success.
|
309
|
+
#
|
310
|
+
# yet successful.
|
311
|
+
#
|
312
|
+
# @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
|
313
|
+
# while polling for a resource that is not expected.
|
314
|
+
#
|
315
|
+
# @raise [NotImplementedError] Raised when the resource does not
|
316
|
+
#
|
317
|
+
# @option options [Integer] :max_attempts (10) Maximum number of
|
318
|
+
# attempts
|
319
|
+
# @option options [Integer] :delay (10) Delay between each
|
320
|
+
# attempt in seconds
|
321
|
+
# @option options [Proc] :before_attempt (nil) Callback
|
322
|
+
# invoked before each attempt
|
323
|
+
# @option options [Proc] :before_wait (nil) Callback
|
324
|
+
# invoked before each wait
|
325
|
+
# @return [Resource] if the waiter was successful
|
326
|
+
def wait_until(options = {}, &block)
|
327
|
+
self_copy = self.dup
|
328
|
+
attempts = 0
|
329
|
+
options[:max_attempts] = 10 unless options.key?(:max_attempts)
|
330
|
+
options[:delay] ||= 10
|
331
|
+
options[:poller] = Proc.new do
|
332
|
+
attempts += 1
|
333
|
+
if block.call(self_copy)
|
334
|
+
[:success, self_copy]
|
335
|
+
else
|
336
|
+
self_copy.reload unless attempts == options[:max_attempts]
|
337
|
+
:retry
|
338
|
+
end
|
339
|
+
end
|
340
|
+
Aws::Waiters::Waiter.new(options).wait({})
|
341
|
+
end
|
342
|
+
|
248
343
|
# @!group Actions
|
249
344
|
|
250
345
|
# @example Request syntax with placeholder values
|