Sha256: 013e7487e4352a02e05aa644981529dcaade2b245aed3485b3fe5989b1f7aa82

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

class ZerigoDNS::ZoneTemplate < ZerigoDNS::Base
  
  # Get count of zone templates
  # @return [Fixnum] the count of zone templates
  def self.count
    get(:count).to_i
  end
  
  # Get count of host templates
  # @return [Fixnum] the count of host templates for this zone template
  def count_host_templates
    get('host_templates/count').to_i
  end
  
  # Create a zone using the zone template
  # @param [Hash, #read] attrs Attributes of the zone to be created
  # @option attrs domain [String, #read] The domain name
  # @option attrs follow_template [String, #read] ('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.
  # @return [Zone] The created zone
  def create_zone attrs
    ZerigoDNS::Zone.create({follow_template: 'follow', zone_template_id: id}.merge(attrs))
  end
  
  # List all host templates of this zone template
  # @return [Array] An array of host templates
  def host_templates
    @host_templates ||= ZerigoDNS::HostTemplate.find(:all, params: {zone_template_id: id})
  end
  
  # Create a host template for this template
  # @param [Hash, #read] attrs Attributes of the host template to be created
  def create_host_template attrs={}
    ZerigoDNS::HostTemplate.create(attrs.merge(zone_template_id: id))
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zerigodns-1.0.2 lib/zerigodns/zone_template.rb
zerigodns-1.0.1 lib/zerigodns/zone_template.rb
zerigodns-1.0.0 lib/zerigodns/zone_template.rb