class Fog::DNS::Dynect::Records

Public Instance Methods

all(options = {}) click to toggle source
# File lib/fog/dynect/models/dns/records.rb, line 12
def all(options = {})
  requires :zone
  data = []
  service.get_all_records(zone.domain, options).body['data'].each do |url|
    (_, _, t, _, fqdn, id) = url.split('/')
    type = t.gsub(/Record$/, '')

    # leave out the default, read only records
    # by putting this here we don't make the secondary request for these records
    next if ['NS', 'SOA'].include?(type)

    record = service.get_record(type, zone.domain, fqdn, 'record_id' => id).body['data']

    data << {
      :identity => record['record_id'],
      :fqdn => record['fqdn'],
      :type => record['record_type'],
      :rdata => record['rdata']
    }
  end

  load(data)
end
get(record_id) click to toggle source
# File lib/fog/dynect/models/dns/records.rb, line 36
def get(record_id)
  requires :zone

  list = service.get_all_records(zone.domain, {}).body['data']
  url = list.find { |e| e =~ /\/#{record_id}$/ }
  return unless url
  (_, _, t, _, fqdn, id) = url.split('/')
  type = t.gsub(/Record$/, '')
  record = service.get_record(type, zone.domain, fqdn, 'record_id' => id).body['data']

  new({
    :identity => record['record_id'],
    :fqdn => record['fqdn'],
    :type => record['record_type'],
    :rdata => record['rdata']
  })
end
new(attributes = {}) click to toggle source
Calls superclass method
# File lib/fog/dynect/models/dns/records.rb, line 54
def new(attributes = {})
  requires :zone
  super({:zone => zone}.merge!(attributes))
end