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

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

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

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



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

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



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

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

#new(attributes = {}) ⇒ Object



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

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