Class: ZerigoDNS::Zone

Inherits:
Client
  • Object
show all
Includes:
Resource
Defined in:
lib/zerigodns/zone.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 all zones

Returns:

  • (Fixnum)

    Count of all zones



8
9
10
# File 'lib/zerigodns/zone.rb', line 8

def count
  get('zones/count.xml').body['count'].to_i
end

.find_by_domain(domain) ⇒ Zone

Find zone by domain name

Parameters:

  • domain (String, #read)

    the domain to retrieve

Returns:

  • (Zone)

    the domain retrieved.

Raises:

  • ActiveResource::ResourceNotFound if the domain is not present.



16
17
18
# File 'lib/zerigodns/zone.rb', line 16

def find_by_domain(domain)
  find(domain)
end

.find_or_create(domain) ⇒ Zone

Find or Create Zone

Parameters:

  • domain (String, #read)

    name of domain to create

Returns:

  • (Zone)

    the zone found or created.



23
24
25
26
27
28
# File 'lib/zerigodns/zone.rb', line 23

def find_or_create(domain)
  find_by_domain(domain)
rescue ZerigoDNS::Client::ResponseError => e
  raise unless e.response.code.not_found?
  create(:domain=> domain, :ns_type=>'pri_sec')
end

Instance Method Details

#count_hostsFixnum

Get count of all hosts belonging to this zone

Returns:

  • (Fixnum)

    Count of all hosts belonging to this zone.



33
34
35
# File 'lib/zerigodns/zone.rb', line 33

def count_hosts
  get("zones/#{id}/hosts/count.xml").body['count'].to_i
end