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/rackspace/models/load_balancers/virtual_ips.rb
2013-01-07 21:01:20 +00:00

32 lines
899 B
Ruby

require 'fog/core/collection'
require 'fog/rackspace/models/load_balancers/virtual_ip'
module Fog
module Rackspace
class LoadBalancers
class VirtualIps < Fog::Collection
model Fog::Rackspace::LoadBalancers::VirtualIp
attr_accessor :load_balancer
def all
data = all_raw
load(data)
end
#HACK - This method is somewhat hacky since there isn't a way to retrieve a single virtual IP. Hopefully long term a method will
# be added that allows a single virtual IP to be returned
def get(virtual_ip_id)
data = all_raw.select { |virtual_ip| virtual_ip['id'] == virtual_ip_id }.first
data && new(data)
end
private
def all_raw
requires :load_balancer
service.list_virtual_ips(load_balancer.id).body['virtualIps']
end
end
end
end
end