Class: ZerigoDNS::ZoneTemplate

Inherits:
Client
  • Object
show all
Includes:
Resource
Defined in:
lib/zerigodns/zone_template.rb

Constant Summary

Constants inherited from Client

Client::ACTIONS, Client::ResponseError

Instance Attribute Summary

Attributes inherited from Client

#response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource

included

Methods inherited from Client

connection

Class Method Details

.countFixnum

Get count of zone templates

Returns:

  • (Fixnum)

    the count of zone templates



7
8
9
# File 'lib/zerigodns/zone_template.rb', line 7

def self.count
  get('zone_templates/count.xml').body['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



13
14
15
# File 'lib/zerigodns/zone_template.rb', line 13

def count_host_templates
  get("zone_templates/#{id}/host_templates/count.xml").body['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



38
39
40
# File 'lib/zerigodns/zone_template.rb', line 38

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



26
27
28
# File 'lib/zerigodns/zone_template.rb', line 26

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



32
33
34
# File 'lib/zerigodns/zone_template.rb', line 32

def host_templates
  @host_templates ||= ZerigoDNS::HostTemplate.all(zone_template_id: id)
end