2011-02-24 20:14:50 -05:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 20:56:22 -04:00
|
|
|
require 'fog/dnsimple/models/dns/record'
|
2011-02-24 20:14:50 -05:00
|
|
|
|
|
|
|
module Fog
|
2011-06-15 20:25:01 -04:00
|
|
|
module DNS
|
|
|
|
class DNSimple
|
2011-02-24 20:14:50 -05:00
|
|
|
|
|
|
|
class Records < Fog::Collection
|
|
|
|
|
|
|
|
attribute :zone
|
|
|
|
|
2011-06-15 20:25:01 -04:00
|
|
|
model Fog::DNS::DNSimple::Record
|
2011-02-24 20:14:50 -05:00
|
|
|
|
|
|
|
def all
|
|
|
|
requires :zone
|
2011-03-09 19:01:46 -05:00
|
|
|
clear
|
2012-12-22 18:28:30 -05:00
|
|
|
data = service.list_records(zone.id).body.map {|record| record['record']}
|
2011-03-10 15:24:41 -05:00
|
|
|
load(data)
|
2011-02-24 20:14:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(record_id)
|
2011-03-09 18:26:21 -05:00
|
|
|
requires :zone
|
2012-12-22 18:28:30 -05:00
|
|
|
data = service.get_record(zone.id, record_id).body["record"]
|
2011-03-09 18:26:21 -05:00
|
|
|
new(data)
|
|
|
|
rescue Excon::Errors::NotFound
|
2011-02-24 20:14:50 -05:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def new(attributes = {})
|
|
|
|
requires :zone
|
|
|
|
super({ :zone => zone }.merge!(attributes))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|