Class: Fog::DNS::Zerigo::Records

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

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object

List all domains

Parameters:

  • options (Hash) (defaults to: {})

    Options to pass to the underlying API call

Options Hash (options):

  • :fqdn (String)

    search for the given fqdn



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/zerigo/models/dns/records.rb', line 15

def all(options = {})
  requires :zone
  if options[:fqdn]
    hosts = service.find_hosts(options[:fqdn], zone.id).body['hosts']
    load(hosts)
  else
    parent = zone.collection.get(zone.identity)
    if parent
      merge_attributes(parent.records.attributes)
      load(parent.records.map {|record| record.attributes})
    else
      nil
    end
  end
end

#get(record_id) ⇒ Object



31
32
33
34
35
36
# File 'lib/fog/zerigo/models/dns/records.rb', line 31

def get(record_id)
  data = service.get_host(record_id).body
  new(data)
rescue Fog::Service::NotFound
  nil
end

#new(attributes = {}) ⇒ Object



38
39
40
41
# File 'lib/fog/zerigo/models/dns/records.rb', line 38

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