2011-08-27 22:06:46 -04:00
|
|
|
require 'fog/core/collection'
|
2011-08-29 11:37:01 -04:00
|
|
|
require 'fog/rackspace/models/dns/zone'
|
2011-08-27 22:06:46 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module DNS
|
|
|
|
class Rackspace
|
|
|
|
class Zones < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::DNS::Rackspace::Zone
|
|
|
|
|
|
|
|
def all
|
|
|
|
clear
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.list_domains.body['domains']
|
2011-08-27 22:06:46 -04:00
|
|
|
load(data)
|
|
|
|
end
|
2013-01-28 13:15:56 -05:00
|
|
|
|
|
|
|
# Returns all domains containing the given substring. Still limited
|
|
|
|
# by the 100-domain pagination limit. Returns an empty array if
|
|
|
|
# no matches.
|
|
|
|
def find(substring)
|
|
|
|
clear
|
|
|
|
data = service.list_domains(:name => substring).body['domains']
|
|
|
|
load(data)
|
|
|
|
end
|
2011-08-27 22:06:46 -04:00
|
|
|
|
|
|
|
def get(zone_id)
|
|
|
|
if zone_id.nil? or zone_id.to_s.empty?
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.list_domain_details(zone_id).body
|
2011-08-27 22:06:46 -04:00
|
|
|
new(data)
|
|
|
|
rescue Fog::Rackspace::Errors::NotFound
|
|
|
|
nil
|
|
|
|
#Accessing a valid (but other customer's) id returns a 503 error
|
|
|
|
rescue Fog::Rackspace::Errors::ServiceUnavailable
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|