mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
47 lines
913 B
Ruby
47 lines
913 B
Ruby
module Fog
|
|
module AWS
|
|
class EC2
|
|
|
|
class Address < Fog::Model
|
|
|
|
attribute :instance_id, 'instanceId'
|
|
attribute :public_ip, 'publicIp'
|
|
|
|
def addresses
|
|
@addresses
|
|
end
|
|
|
|
def initialize(new_attributes = {})
|
|
new_attributes = {
|
|
:instance_id => ''
|
|
}.merge!(new_attributes)
|
|
super(new_attributes)
|
|
end
|
|
|
|
def destroy
|
|
connection.release_address(@public_ip)
|
|
true
|
|
end
|
|
|
|
def reload
|
|
new_attributes = addresses.all(@public_ip).first.attributes
|
|
merge_attributes(new_attributes)
|
|
end
|
|
|
|
def save
|
|
data = connection.allocate_address
|
|
@public_ip = data.body['publicIp']
|
|
true
|
|
end
|
|
|
|
private
|
|
|
|
def addresses=(new_addresses)
|
|
@addresses = new_addresses
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|