Class: Fog::DNS::Zerigo::Zone

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

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

Methods included from Attributes::InstanceMethods

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

Constructor Details

#initialize(attributes = {}) ⇒ Zone

<custom-nameservers>ns1.example.com,ns2.example.com</custom-nameservers> <custom-ns type=“boolean”>true</custom-ns> <hostmaster>[email protected]</hostmaster> <notes nil=“true”/> <ns1 nil=“true”/> <nx-ttl nil=“true”></nx-ttl> <slave-nameservers nil=“true”/> <tag-list>one two</tag-list> <hosts-count>1</hosts-count>



28
29
30
31
32
# File 'lib/fog/dns/models/zerigo/zone.rb', line 28

def initialize(attributes={})
  self.type ||= 'pri_sec'
  self.ttl  ||= 3600
  super
end

Instance Method Details

#destroyObject



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

def destroy
  requires :identity
  connection.delete_zone(identity)
  true
end

#nameserversObject



49
50
51
52
53
54
55
56
57
# File 'lib/fog/dns/models/zerigo/zone.rb', line 49

def nameservers
  [
    'a.ns.zerigo.net',
    'b.ns.zerigo.net',
    'c.ns.zerigo.net',
    'd.ns.zerigo.net',
    'e.ns.zerigo.net'
  ]
end

#recordsObject



40
41
42
43
44
45
46
47
# File 'lib/fog/dns/models/zerigo/zone.rb', line 40

def records
  @records ||= begin
    Fog::DNS::Zerigo::Records.new(
      :zone       => self,
      :connection => connection
    )
  end
end

#saveObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fog/dns/models/zerigo/zone.rb', line 59

def save
  requires :domain, :type, :ttl
  options = {}
  # * options<~Hash> - optional paramaters
  #   * ns1<~String> - required if ns_type == sec
  #   * nx_ttl<~Integer> -
  #   * slave_nameservers<~String> - required if ns_type == pri
  #   * axfr_ips<~String> - comma-separated list of IPs or IP blocks allowed to perform AXFRs
  #   * custom_nameservers<~String> - comma-separated list of custom nameservers
  #   * custom_ns<~String> - indicates if vanity (custom) nameservers are enabled for this domain
  #   * hostmaster<~String> - email of the DNS administrator or hostmaster
  #   * notes<~String> - notes about the domain
  #   * restrict_axfr<~String> - indicates if AXFR transfers should be restricted to IPs in axfr-ips
  #   * tag_list<~String> - List of all tags associated with this domain
  data = unless identity
    connection.create_zone(domain, ttl, type, options)
  else
    options[:default_ttl] = ttl
    options[:ns_type]     = type
    connection.update_zone(identity, options)
  end
  merge_attributes(data.body)
  true
end