Class: Fog::AWS::EC2::Addresses
Instance Method Summary
collapse
Methods inherited from Collection
#_dump, _load, aliases, attribute, attributes, #attributes, #connection, #connection=, #create, #inspect, #load, #merge_attributes, model, #model, #reload, #table, #to_json
Constructor Details
#initialize(attributes) ⇒ Addresses
Returns a new instance of Addresses.
31
32
33
34
|
# File 'lib/fog/aws/models/ec2/addresses.rb', line 31
def initialize(attributes)
@public_ip ||= []
super
end
|
Instance Method Details
#all(public_ip = @public_ip) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/fog/aws/models/ec2/addresses.rb', line 36
def all(public_ip = @public_ip)
@public_ip = public_ip
data = connection.describe_addresses(public_ip).body
load(
data['addressesSet'].map do |address|
address.reject {|key, value| value.nil? || value.empty? }
end
)
if server
self.replace(self.select {|address| address.server_id == server.id})
end
self
end
|
#get(public_ip) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/fog/aws/models/ec2/addresses.rb', line 50
def get(public_ip)
if public_ip
all(public_ip).first
end
rescue Excon::Errors::BadRequest
nil
end
|
#new(attributes = {}) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/fog/aws/models/ec2/addresses.rb', line 58
def new(attributes = {})
if server
super({ :server => server }.merge!(attributes))
else
super(attributes)
end
end
|