Class: ZerigoDNS::ZoneTemplate

Inherits:
Base
  • Object
show all
Defined in:
lib/zerigodns/zone_template.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#load

Class Method Details

.countFixnum

Get count of zone templates

Returns:

  • (Fixnum)

    the count of zone templates



5
6
7
# File 'lib/zerigodns/zone_template.rb', line 5

def self.count
  get(:count).to_i
end

Instance Method Details

#count_host_templatesFixnum

Get count of host templates

Returns:

  • (Fixnum)

    the count of host templates for this zone template



11
12
13
# File 'lib/zerigodns/zone_template.rb', line 11

def count_host_templates
  get('host_templates/count').to_i
end

#create_host_template(attrs = {}) ⇒ Object

Create a host template for this template

Parameters:

  • attrs (Hash, #read) (defaults to: {})

    Attributes of the host template to be created



36
37
38
# File 'lib/zerigodns/zone_template.rb', line 36

def create_host_template attrs={}
  ZerigoDNS::HostTemplate.create(attrs.merge(zone_template_id: id))
end

#create_zone(attrs) ⇒ Zone

Create a zone using the zone template

Parameters:

  • attrs (Hash, #read)

    Attributes of the zone to be created

Options Hash (attrs):

  • domain (String, #read)

    The domain name

  • follow_template (String, #read) — default: 'follow'
    • ‘follow’ The zone will reflect updates made to the template.

    • ‘no’ The zone will be a one-time copy of the template.

    Due to a problem with XML conversion, the value assigned to follow_template must be a string and not a symbol.

Returns:

  • (Zone)

    The created zone



24
25
26
# File 'lib/zerigodns/zone_template.rb', line 24

def create_zone attrs
  ZerigoDNS::Zone.create({follow_template: 'follow', zone_template_id: id}.merge(attrs))
end

#host_templatesArray

List all host templates of this zone template

Returns:

  • (Array)

    An array of host templates



30
31
32
# File 'lib/zerigodns/zone_template.rb', line 30

def host_templates
  @host_templates ||= ZerigoDNS::HostTemplate.find(:all, params: {zone_template_id: id})
end