lib/zerigodns/zone.rb in zerigodns-1.0.2 vs lib/zerigodns/zone.rb in zerigodns-1.1.0
- old
+ new
@@ -1,11 +1,14 @@
-class ZerigoDNS::Zone < ZerigoDNS::Base
+class ZerigoDNS::Zone < ZerigoDNS::Client
+ include ZerigoDNS::Resource
+
class <<self
+
# Get count of all zones
# @return [Fixnum] Count of all zones
def count
- get(:count).to_i
+ get('zones/count.xml').body['count'].to_i
end
# Find zone by domain name
# @param [String, #read] domain the domain to retrieve
# @raise ActiveResource::ResourceNotFound if the domain is not present.
@@ -17,16 +20,17 @@
# Find or Create Zone
# @param [String, #read] domain name of domain to create
# @return [Zone] the zone found or created.
def find_or_create(domain)
find_by_domain(domain)
- rescue ActiveResource::ResourceNotFound
+ rescue ZerigoDNS::Client::ResponseError => e
+ raise unless e.response.code.not_found?
create(:domain=> domain, :ns_type=>'pri_sec')
end
end
# Get count of all hosts belonging to this zone
# @return [Fixnum] Count of all hosts belonging to this zone.
def count_hosts
- get('hosts/count').to_i
+ get("zones/#{id}/hosts/count.xml").body['count'].to_i
end
end