Class: Fog::DNS::Dynect::Records

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/dynect/models/dns/records.rb

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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 |records|
    (type, list) = records
    next if %w{soa_records ns_records}.include?(type)
    list.each do |record|
      data << {
        :identity => record['record_id'],
        :fqdn => record['fqdn'],
        :type => record['record_type'],
        :rdata => record['rdata']
      }
    end
  end

  load(data)
end

#get(record_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/dynect/models/dns/records.rb', line 31

def get(record_id)
  requires :zone

  # there isn't a way to look up by just id
  # must have type and domain for 'get_record' request
  # so we pick it from the list returned by 'all'

  list = all
  list.detect {|e| e.id == record_id}
end

#new(attributes = {}) ⇒ Object



42
43
44
45
# File 'lib/fog/dynect/models/dns/records.rb', line 42

def new(attributes = {})
  requires :zone
  super({:zone => zone}.merge!(attributes))
end