1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/models/ec2/address.rb

48 lines
913 B
Ruby
Raw Normal View History

2009-08-13 01:33:35 -04:00
module Fog
module AWS
class EC2
class Address < Fog::Model
attribute :instance_id, 'instanceId'
attribute :public_ip, 'publicIp'
2009-08-13 01:33:35 -04:00
def addresses
@addresses
end
2009-09-23 01:47:45 -04:00
def initialize(new_attributes = {})
new_attributes = {
:instance_id => ''
}.merge!(new_attributes)
super(new_attributes)
end
2009-09-20 12:21:03 -04:00
def destroy
2009-08-13 01:33:35 -04:00
connection.release_address(@public_ip)
true
2009-08-13 01:33:35 -04:00
end
2009-09-19 15:31:15 -04:00
def reload
new_attributes = addresses.all(@public_ip).first.attributes
merge_attributes(new_attributes)
end
2009-08-13 01:33:35 -04:00
def save
data = connection.allocate_address
@public_ip = data.body['publicIp']
true
2009-08-13 01:33:35 -04:00
end
private
def addresses=(new_addresses)
@addresses = new_addresses
end
2009-08-13 01:33:35 -04:00
end
end
end
end