mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
47 lines
1.3 KiB
Ruby
47 lines
1.3 KiB
Ruby
require 'fog/core/collection'
|
|
require 'fog/aws/models/dns/record'
|
|
|
|
module Fog
|
|
module AWS
|
|
class DNS
|
|
|
|
class Records < Fog::Collection
|
|
|
|
attribute :is_truncated, :aliases => ['IsTruncated']
|
|
attribute :max_items, :aliases => ['MaxItems']
|
|
attribute :name
|
|
attribute :next_record_name, :aliases => ['NextRecordName']
|
|
attribute :next_record_type, :aliases => ['NextRecordType']
|
|
attribute :type
|
|
|
|
attribute :zone
|
|
|
|
model Fog::AWS::DNS::Record
|
|
|
|
def all(options = {})
|
|
requires :zone
|
|
options['MaxItems'] ||= max_items
|
|
options['Name'] ||= name
|
|
options['Type'] ||= type
|
|
data = connection.list_resource_record_sets(zone.id, options).body
|
|
merge_attributes(data.reject {|key, value| !['IsTruncated', 'MaxItems', 'NextRecordName', 'NextRecordType'].include?(key)})
|
|
load(data['ResourceRecordSets'])
|
|
end
|
|
|
|
def get(record_id)
|
|
data = connection.get_change(record_id).body
|
|
new(data)
|
|
rescue Excon::Errors::BadRequest
|
|
nil
|
|
end
|
|
|
|
def new(attributes = {})
|
|
requires :zone
|
|
super({ :zone => zone }.merge!(attributes))
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|