Class: Aws::EC2::ClassicAddress
- Inherits:
-
Object
- Object
- Aws::EC2::ClassicAddress
- Defined in:
- gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#allocation_id ⇒ String
The ID representing the allocation of the address.
-
#association_id ⇒ String
The ID representing the association of the address with an instance.
-
#carrier_ip ⇒ String
The carrier IP address associated.
-
#customer_owned_ip ⇒ String
The customer-owned IP address.
-
#customer_owned_ipv_4_pool ⇒ String
The ID of the customer-owned address pool.
-
#domain ⇒ String
The network (
vpc). -
#instance_id ⇒ String
The ID of the instance that the address is associated with (if any).
-
#network_border_group ⇒ String
The name of the unique set of Availability Zones, Local Zones, or Wavelength Zones from which Amazon Web Services advertises IP addresses.
-
#network_interface_id ⇒ String
The ID of the network interface.
-
#network_interface_owner_id ⇒ String
The ID of the Amazon Web Services account that owns the network interface.
-
#private_ip_address ⇒ String
The private IP address associated with the Elastic IP address.
-
#public_ip ⇒ String
-
#public_ipv_4_pool ⇒ String
The ID of an address pool.
-
#service_managed ⇒ String
The service that manages the elastic IP address.
-
#subnet_id ⇒ String
The ID of the subnet where the IP address is allocated.
-
#tags ⇒ Array<Types::Tag>
Any tags assigned to the Elastic IP address.
Actions collapse
-
#associate(options = {}) ⇒ Types::AssociateAddressResult
-
#disassociate(options = {}) ⇒ EmptyStructure
-
#release(options = {}) ⇒ EmptyStructure
Instance Method Summary collapse
-
#client ⇒ Client
-
#data ⇒ Types::Address
Returns the data for this ClassicAddress.
-
#data_loaded? ⇒ Boolean
Returns
trueif this resource is loaded. -
#initialize(*args) ⇒ ClassicAddress
constructor
A new instance of ClassicAddress.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current ClassicAddress.
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::EC2::Client] #wait_until instead
Constructor Details
#initialize(public_ip, options = {}) ⇒ ClassicAddress #initialize(options = {}) ⇒ ClassicAddress
Returns a new instance of ClassicAddress.
22 23 24 25 26 27 28 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 22 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @public_ip = extract_public_ip(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#allocation_id ⇒ String
The ID representing the allocation of the address.
39 40 41 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 39 def allocation_id data[:allocation_id] end |
#associate(options = {}) ⇒ Types::AssociateAddressResult
307 308 309 310 311 312 313 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 307 def associate( = {}) = .merge(public_ip: @public_ip) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.associate_address() end resp.data end |
#association_id ⇒ String
The ID representing the association of the address with an instance.
45 46 47 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 45 def association_id data[:association_id] end |
#carrier_ip ⇒ String
The carrier IP address associated. This option is only available for network interfaces which reside in a subnet in a Wavelength Zone (for example an EC2 instance).
110 111 112 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 110 def carrier_ip data[:carrier_ip] end |
#client ⇒ Client
135 136 137 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 135 def client @client end |
#customer_owned_ip ⇒ String
The customer-owned IP address.
96 97 98 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 96 def customer_owned_ip data[:customer_owned_ip] end |
#customer_owned_ipv_4_pool ⇒ String
The ID of the customer-owned address pool.
102 103 104 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 102 def customer_owned_ipv_4_pool data[:customer_owned_ipv_4_pool] end |
#data ⇒ Types::Address
Returns the data for this Aws::EC2::ClassicAddress. Calls
Aws::EC2::Client#describe_addresses if #data_loaded? is false.
157 158 159 160 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 157 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
165 166 167 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 165 def data_loaded? !!@data end |
#disassociate(options = {}) ⇒ EmptyStructure
330 331 332 333 334 335 336 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 330 def disassociate( = {}) = .merge(public_ip: data[:public_ip]) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.disassociate_address() end resp.data end |
#domain ⇒ String
The network (vpc).
51 52 53 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 51 def domain data[:domain] end |
#instance_id ⇒ String
The ID of the instance that the address is associated with (if any).
128 129 130 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 128 def instance_id data[:instance_id] end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::EC2::ClassicAddress.
Returns self making it possible to chain methods.
classic_address.reload.data
145 146 147 148 149 150 151 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 145 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_addresses(public_ips: [@public_ip]) end @data = resp.addresses[0] self end |
#network_border_group ⇒ String
The name of the unique set of Availability Zones, Local Zones, or Wavelength Zones from which Amazon Web Services advertises IP addresses.
90 91 92 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 90 def network_border_group data[:network_border_group] end |
#network_interface_id ⇒ String
The ID of the network interface.
57 58 59 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 57 def network_interface_id data[:network_interface_id] end |
#network_interface_owner_id ⇒ String
The ID of the Amazon Web Services account that owns the network interface.
64 65 66 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 64 def network_interface_owner_id data[:network_interface_owner_id] end |
#private_ip_address ⇒ String
The private IP address associated with the Elastic IP address.
70 71 72 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 70 def private_ip_address data[:private_ip_address] end |
#public_ip ⇒ String
33 34 35 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 33 def public_ip @public_ip end |
#public_ipv_4_pool ⇒ String
The ID of an address pool.
82 83 84 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 82 def public_ipv_4_pool data[:public_ipv_4_pool] end |
#release(options = {}) ⇒ EmptyStructure
360 361 362 363 364 365 366 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 360 def release( = {}) = .merge(public_ip: data[:public_ip]) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.release_address() end resp.data end |
#service_managed ⇒ String
The service that manages the elastic IP address.
122 123 124 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 122 def service_managed data[:service_managed] end |
#subnet_id ⇒ String
The ID of the subnet where the IP address is allocated.
116 117 118 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 116 def subnet_id data[:subnet_id] end |
#tags ⇒ Array<Types::Tag>
Any tags assigned to the Elastic IP address.
76 77 78 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 76 def data[:tags] end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::EC2::Client] #wait_until instead
The waiting operation is performed on a copy. The original resource remains unchanged.
Waiter polls an API operation until a resource enters a desired state.
Basic Usage
Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop until condition is true
resource.wait_until() {|resource| condition}
Example
instance.wait_until(max_attempts:10, delay:5) do |instance|
instance.state.name == 'running'
end
Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:
# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}
Callbacks
You can be notified before each polling attempt and before each
delay. If you throw :success or :failure from these callbacks,
it will terminate the waiter.
started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
# disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}
Handling Errors
When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.
begin
resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
attempts attempt in seconds invoked before each attempt invoked before each wait
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'gems/aws-sdk-ec2/lib/aws-sdk-ec2/classic_address.rb', line 249 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do Aws::Waiters::Waiter.new().wait({}) end end |