2012-03-10 17:02:28 -05:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/dreamhost/models/dns/record'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module DNS
|
|
|
|
class Dreamhost
|
|
|
|
|
|
|
|
class Records < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::DNS::Dreamhost::Record
|
|
|
|
|
|
|
|
def all(filter = {})
|
|
|
|
clear
|
|
|
|
if filter[:zone]
|
2013-01-19 17:39:33 -05:00
|
|
|
data = service.list_records.body['data'].find_all { |r| r['zone'] == filter[:zone] }
|
2012-03-10 17:02:28 -05:00
|
|
|
else
|
2013-01-19 17:39:33 -05:00
|
|
|
data = service.list_records.body['data']
|
2012-03-10 17:02:28 -05:00
|
|
|
end
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(record_name)
|
2013-01-19 17:39:33 -05:00
|
|
|
data = service.get_record(record_name).body['data'].find { |r| r['record'] == record_name }
|
2012-03-10 17:02:28 -05:00
|
|
|
new(data)
|
|
|
|
rescue Excon::Errors::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|