class Fog::DNS::Zerigo::Real
Public Class Methods
# File lib/fog/zerigo/dns.rb, line 69 def initialize(options={}) @zerigo_email = options[:zerigo_email] @zerigo_token = options[:zerigo_token] @connection_options = options[:connection_options] || {} @host = options[:host] || "ns.zerigo.com" @persistent = options[:persistent] || false @port = options[:port] || 80 @scheme = options[:scheme] || 'http' @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end
Public Instance Methods
total number of hosts available for the specified zone. It is the same value as provided in the X-Query-Count header in the #list_hosts API method
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>
-
'count'<~Integer>
-
-
'status'<~Integer> - 200 indicates success
-
# File lib/fog/zerigo/requests/dns/count_hosts.rb, line 15 def count_hosts(zone_id) request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Zerigo::CountHosts.new, :path => "/api/1.1/zones/#{zone_id}/hosts/count.xml" ) end
Total number of zones hosted Zerigo for this account. It is the same value as provided in the X-Query-Count header in the #list_zones API method
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>
-
'count'<~Integer>
-
-
'status'<~Integer> - 200 indicates success
-
# File lib/fog/zerigo/requests/dns/count_zones.rb, line 15 def count_zones request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Zerigo::CountZones.new, :path => "/api/1.1/zones/count.xml" ) end
Create a new host in the specified zone
Parameters¶ ↑
-
zone_id<~Integer>
-
host_type<~String>
-
data<~String>
-
options<~Hash> - optional parameters
-
hostname<~String> - Note: normally this is set/required!!
-
notes<~String>
-
priority<~Integer> - Note: required for MX or SRV records
-
ttl<~Integer>
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>
-
'created-at'<~String>
-
'data'<~String>
-
'fqdn'<~String>
-
'host-type'<~String>
-
'hostname'<~String>
-
'id'<~Integer>
-
'notes'<~String>
-
'priority'<~Integer>
-
'ttl'<~Integer>
-
'updated-at'<~String>
-
'zone-id'<~String>
-
-
'status'<~Integer> - 201 if successful
-
# File lib/fog/zerigo/requests/dns/create_host.rb, line 33 def create_host(zone_id, host_type, data, options = {}) optional_tags= '' options.each { |option, value| case option when :hostname optional_tags+= "<hostname>#{value}</hostname>" when :notes optional_tags+= "<notes>#{value}</notes>" when :priority optional_tags+= "<priority>#{value}</priority>" when :ttl optional_tags+= "<ttl>#{value}</ttl>" end } request( :body => %Q{<?xml version="1.0" encoding="UTF-8"?><host><host-type>#{host_type}</host-type><data>#{data}</data>#{optional_tags}</host>}, :expects => 201, :method => 'POST', :parser => Fog::Parsers::DNS::Zerigo::CreateHost.new, :path => "/api/1.1/zones/#{zone_id}/hosts.xml" ) end
Create a new zone for Zerigo's DNS servers to serve/host
Parameters¶ ↑
-
domain<~String>
-
default_ttl<~Integer>
-
ns_type<~String>
-
options<~Hash> - optional paramaters
-
ns1<~String> - required if ns_type == sec
-
nx_ttl<~Integer> -
-
slave_nameservers<~String> - required if ns_type == pri
-
axfr_ips<~String> - comma-separated list of IPs or IP blocks allowed to perform AXFRs
-
custom_nameservers<~String> - comma-separated list of custom nameservers
-
custom_ns<~String> - indicates if vanity (custom) nameservers are enabled for this domain
-
hostmaster<~String> - email of the DNS administrator or hostmaster
-
notes<~String> - notes about the domain
-
restrict_axfr<~String> - indicates if AXFR transfers should be restricted to IPs in axfr-ips
-
tag_list<~String> - List of all tags associated with this domain
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'id'<~Integer> - zone ID to use for future calls
-
'default-ttl'<~Integer>
-
'nx-ttl'<~Integer>
-
'hosts-count'<~Integer>
-
'created-at'<~String>
-
'custom-nameservers'<~String>
-
'custom-ns'<~String>
-
'domain'<~String>
-
'hostmaster'<~String>
-
'notes'<~String>
-
'ns1'<~String>
-
'ns-type'<~String>
-
'slave-nameservers'<~String>
-
'tag-list'<~String>
-
'updated-at'<~String>
-
'hosts'<~String>
-
'axfr-ips'<~String>
-
'restrict-axfr'<~String>
-
-
'status'<~Integer> - 201 if successful
-
# File lib/fog/zerigo/requests/dns/create_zone.rb, line 48 def create_zone(domain, default_ttl, ns_type, options = {}) optional_tags= '' options.each { |option, value| case option when :ns1 optional_tags+= "<ns1>#{value}</ns1>" when :nx_ttl optional_tags+= "<nx-ttl type='interger'>#{value}</nx-ttl>" when :slave_nameservers optional_tags+= "<slave-nameservers>#{value}</slave-nameservers>" when :axfr_ips optional_tags+= "<axfr-ips>#{value}</axfr-ips>" when :custom_nameservers optional_tags+= "<custom-nameservers>#{value}</custom-nameservers>" when :custom_ns optional_tags+= "<custom-ns>#{value}</custom-ns>" when :hostmaster optional_tags+= "<hostmaster>#{value}</hostmaster>" when :notes optional_tags+= "<notes>#{value}</notes>" when :restrict_axfr optional_tags+= "<restrict-axfr>#{value}</restrict-axfr>" when :tag_list optional_tags+= "<tag-list>#{value}</tag-list>" end } request( :body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><domain>#{domain}</domain><default-ttl type="integer">#{default_ttl}</default-ttl><ns-type>#{ns_type}</ns-type>#{optional_tags}</zone>}, :expects => 201, :method => 'POST', :parser => Fog::Parsers::DNS::Zerigo::CreateZone.new, :path => '/api/1.1/zones.xml' ) end
Delete a host record
Parameters¶ ↑
-
host_id<~Integer> - Id of host record to delete
Returns¶ ↑
-
response<~Excon::Response>:
-
'status'<~Integer> - 200 indicates success
-
# File lib/fog/zerigo/requests/dns/delete_host.rb, line 12 def delete_host(host_id) request( :expects => 200, :method => 'DELETE', :path => "/api/1.1/hosts/#{host_id}.xml" ) end
Delete a zone from Zerigo
Parameters¶ ↑
-
zone_id<~Integer> - Id of zone to delete
Returns¶ ↑
-
response<~Excon::Response>:
-
'status'<~Integer> - 200 indicates success
-
# File lib/fog/zerigo/requests/dns/delete_zone.rb, line 13 def delete_zone(zone_id) request( :expects => 200, :method => 'DELETE', :path => "/api/1.1/zones/#{zone_id}.xml" ) end
Get list of all the host records that match the FQDN. If desired, can limit search to a specific zone
Parameters¶ ↑
-
fqdn<~String> - domain to look for
-
zone_id<~Integer> - if want to limit search to specific zone
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'hosts'<~Hash>
-
'created-at'<~String>
-
'data'<~String>
-
'fqdn'<~String>
-
'host-type'<~String>
-
'hostname'<~String>
-
'id'<~Integer>
-
'notes'<~String>
-
'priority'<~Integer>
-
'ttl'<~Integer>
-
'updated-at'<~String>
-
'zone-id'<~String>
-
-
-
'status'<~Integer> - 200 indicated success
-
# File lib/fog/zerigo/requests/dns/find_hosts.rb, line 31 def find_hosts(fqdn, zone_id = nil) if zone_id.nil? #look for matching host across all zones request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Zerigo::FindHosts.new, :path => "/api/1.1/hosts.xml?fqdn=#{fqdn}" ) else #look for hosts in a specific zone request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Zerigo::FindHosts.new, :path => "/api/1.1/zones/#{zone_id}/hosts.xml?fqdn=#{fqdn}" ) end end
get details about a given host record
Parameters¶ ↑
-
host_id<~Integer> - ID of the host record to retrieve
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'created-at'<~String>
-
'data'<~String>
-
'fqdn'<~String>
-
'host-type'<~String>
-
'hostname'<~String>
-
'id'<~Integer>
-
'notes'<~String>
-
'priority'<~Integer>
-
'ttl'<~Integer>
-
'updated-at'<~String>
-
'zone-id'<~String>
-
-
'status'<~Integer> - 200 indicates success
-
# File lib/fog/zerigo/requests/dns/get_host.rb, line 26 def get_host(host_id) request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Zerigo::GetHost.new, :path => "/api/1.1/hosts/#{host_id}.xml" ) end
Get details of a DNS zone. The response is similar to #list_zones, with the addition of hosts-count and possibly hosts.
Parameters¶ ↑
-
zone<~String> - Either the zone ID or the zone name (ie sample-domain.com)
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'default-ttl'<~Integer>
-
'id'<~Integer>
-
'nx-ttl'<~Integer>
-
'hosts-count'<~Integer>
-
'created-at'<~String>
-
'custom-nameservers'<~String>
-
'custom-ns'<~String>
-
'domain'<~String>
-
'hostmaster'<~String>
-
'notes'<~String>
-
'ns1'<~String>
-
'ns-type'<~String>
-
'slave-nameservers'<~String>
-
'tag-list'<~String>
-
'updated-at'<~String>
-
'hosts'<~Array> - a list of all host records. For the format of host info, see #get_host()
-
'axfr-ips'<~String>
-
'restrict-axfr'<~String>
-
-
'status'<~Integer> - 200 indicates success
-
# File lib/fog/zerigo/requests/dns/get_zone.rb, line 36 def get_zone(zone_id_or_domain) request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Zerigo::GetZone.new, :path => "/api/1.1/zones/#{zone_id_or_domain}.xml" ) end
returns current traffic statistics about this zone. Queries is measured from the beginning of the current period through the time of the API call.
Parameters¶ ↑
-
zone_id<~Integer> - the zone ID
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'domain'<~String> - domain name (ie example.com)
-
'id'<~Integer> - Id of the zone
-
'period-being'<~String> - date in following format 2010-07-01
-
'period-end'<~String> - date
-
'queries'<~Integer> - # of queries for the zone during period
-
-
'status'<~Integer> - 200 indicates success
-
# File lib/fog/zerigo/requests/dns/get_zone_stats.rb, line 23 def get_zone_stats(zone_id) request( :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Zerigo::GetZoneStats.new, :path => "/api/1.1/zones/#{zone_id}/stats.xml" ) end
Get list of all DNS zones hosted on Slicehost (for this account)
Parameters¶ ↑
-
zone_id<~Integer> - the zone ID of the zone from which to get the host records for
-
'options'<~Hash> - optional parameters
-
'page' <~Integer>
-
'per_page' <~Integer>
-
'fqdn' <~String>
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'hosts'<~Array>
-
'created-at'<~String>
-
'data'<~String>
-
'fqdn'<~String>
-
'host-type'<~String>
-
'hostname'<~String>
-
'id'<~Integer>
-
'notes'<~String>
-
'priority'<~Integer>
-
'ttl'<~Integer>
-
'updated-at'<~String>
-
'zone-id'<~String>
-
-
-
-
'status'<~Integer> - 200 indicates success
# File lib/fog/zerigo/requests/dns/list_hosts.rb, line 31 def list_hosts(zone_id, options={}) request( :query => options, :expects => 200, :method => "GET", :parser => Fog::Parsers::DNS::Zerigo::ListHosts.new, :path => "/api/1.1/zones/#{zone_id}/hosts.xml" ) end
Get list of all DNS zones hosted on Slicehost (for this account)
Parameters¶ ↑
-
options<~Hash>
-
page<~Integer> - Indicates where to begin in your list of zones.
-
per_page<~Integer> - The maximum number of zones to be included in the response body
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'zones'<~Array>
-
'default-ttl'<~Integer>
-
'id'<~Integer>
-
'nx-ttl'<~Integer>
-
'hosts-count'<~Integer>
-
'created-at'<~String>
-
'custom-nameservers'<~String>
-
'custom-ns'<~String>
-
'domain'<~String>
-
'hostmaster'<~String>
-
'notes'<~String>
-
'ns1'<~String>
-
'ns-type'<~String>
-
'slave-nameservers'<~String>
-
'tag-list'<~String>
-
'updated-at'<~String>
-
'hosts'<~String>
-
'axfr-ips'<~String>
-
'restrict-axfr'<~String>
-
-
-
'status'<~Integer> - 200 indicates success
-
# File lib/fog/zerigo/requests/dns/list_zones.rb, line 37 def list_zones(options = {}) request( :query => options, :expects => 200, :method => 'GET', :parser => Fog::Parsers::DNS::Zerigo::ListZones.new, :path => '/api/1.1/zones.xml' ) end
# File lib/fog/zerigo/dns.rb, line 81 def reload @connection.reset end
# File lib/fog/zerigo/dns.rb, line 85 def request(params) params[:headers] ||= {} key= "#{@zerigo_email}:#{@zerigo_token}" params[:headers].merge!({ 'Authorization' => "Basic #{Base64.encode64(key).delete("\r\n")}" }) case params[:method] when 'DELETE', 'GET', 'HEAD' params[:headers]['Accept'] = 'application/xml' when 'POST', 'PUT' params[:headers]['Content-Type'] = 'application/xml' end begin response = @connection.request(params) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::DNS::Zerigo::NotFound.slurp(error) else error end end response end
Update a host record
Parameters¶ ↑
-
host_id<~Integer> - host ID of the record to update
-
options<~Hash> - optional paramaters
-
host_type<~String>
-
data<~String>
-
hostname<~String> - Note: normally this is set/required!!
-
notes<~String>
-
priority<~Integer> - Note: required for MX or SRV records
-
ttl<~Integer>
-
Returns¶ ↑
-
response<~Excon::Response>:
-
'status'<~Integer> - 200 for success
-
# File lib/fog/zerigo/requests/dns/update_host.rb, line 20 def update_host(host_id, options = {}) optional_tags= '' options.each { |option, value| case option when :host_type optional_tags+= "<host-type>#{value}</host-type>" when :data optional_tags+= "<data>#{value}</data>" when :hostname optional_tags+= "<hostname>#{value}</hostname>" when :notes optional_tags+= "<notes>#{value}</notes>" when :priority optional_tags+= "<priority>#{value}</priority>" when :ttl optional_tags+= "<ttl>#{value}</ttl>" end } request( :body => %Q{<?xml version="1.0" encoding="UTF-8"?><host>#{optional_tags}</host>}, :expects => 200, :method => 'PUT', :path => "/api/1.1/hosts/#{host_id}.xml" ) end
Update the parameters of a zone
Parameters¶ ↑
-
zone_id<~Integer>
-
options<~Hash> - optional paramaters
-
default_ttl<~Integer>
-
ns_type<~String>
-
ns1<~String> - required if ns_type == sec
-
nx_ttl<~Integer> -
-
slave_nameservers<~String> - required if ns_type == pri
-
axfr_ips<~String> - comma-separated list of IPs or IP blocks allowed to perform AXFRs
-
custom_nameservers<~String> - comma-separated list of custom nameservers
-
custom_ns<~String> - indicates if vanity (custom) nameservers are enabled for this domain
-
hostmaster<~String> - email of the DNS administrator or hostmaster
-
notes<~String> - notes about the domain
-
restrict_axfr<~String> - indicates if AXFR transfers should be restricted to IPs in axfr-ips
-
tag_list<~String> - List of all tags associated with this domain
-
Returns¶ ↑
-
response<~Excon::Response>:
-
'status'<~Integer> - 200 for success
-
# File lib/fog/zerigo/requests/dns/update_zone.rb, line 26 def update_zone(zone_id, options = {}) optional_tags= '' options.each { |option, value| case option when :default_ttl optional_tags+= "<default-ttl>#{value}</default-ttl>" when :ns_type optional_tags+= "<ns-type>#{value}</ns-type>" when :ns1 optional_tags+= "<ns1>#{value}</ns1>" when :nx_ttl optional_tags+= "<nx-ttl type='interger'>#{value}</nx-ttl>" when :slave_nameservers optional_tags+= "<slave-nameservers>#{value}</slave-nameservers>" when :axfr_ips optional_tags+= "<axfr-ips>#{value}</axfr-ips>" when :custom_nameservers optional_tags+= "<custom-nameservers>#{value}</custom-nameservers>" when :custom_ns optional_tags+= "<custom-ns>#{value}</custom-ns>" when :hostmaster optional_tags+= "<hostmaster>#{value}</hostmaster>" when :notes optional_tags+= "<notes>#{value}</notes>" when :restrict_axfr optional_tags+= "<restrict-axfr>#{value}</restrict-axfr>" when :tag_list optional_tags+= "<tag-list>#{value}</tag-list>" end } request( :body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone>#{optional_tags}</zone>}, :expects => 200, :method => 'PUT', :path => "/api/1.1/zones/#{zone_id}.xml" ) end