mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
cleaned up the Zerigo DNS calls. Also, added comments detailing parameters and return values
This commit is contained in:
parent
8837931a0e
commit
df44afd837
15 changed files with 196 additions and 64 deletions
|
@ -6,18 +6,15 @@ module Fog
|
|||
class CreateHost < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@host = {}
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'id', 'priority', 'ttl', 'zone-id'
|
||||
@host[name] = @value.to_i
|
||||
@response[name] = @value.to_i
|
||||
when 'data', 'fqdn', 'host-type', 'hostname', 'notes', 'zone-id', 'created-at', 'updated-at'
|
||||
@host[name] = @value
|
||||
when 'host'
|
||||
@response['host'] = @host
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ module Fog
|
|||
class GetHost < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@host = {}
|
||||
@response = { 'hosts' => [] }
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
|
@ -17,8 +16,7 @@ module Fog
|
|||
when 'data', 'fqdn', 'host-type', 'hostname', 'notes', 'zone-id', 'created-at', 'updated-at'
|
||||
@host[name] = @value
|
||||
when 'host'
|
||||
@response['hosts'] << @host
|
||||
@host = {}
|
||||
@response['host'] = @host
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ module Fog
|
|||
|
||||
require 'fog/zerigo/parsers/compute/count_hosts'
|
||||
|
||||
# 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
|
||||
# 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>:
|
||||
|
@ -15,7 +15,7 @@ module Fog
|
|||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Zerigo::Compute::CountZones.new,
|
||||
:parser => Fog::Parsers::Zerigo::Compute::CountHosts.new,
|
||||
:path => "/api/1.1/zones/#{zone_id}/hosts/count.xml"
|
||||
)
|
||||
end
|
||||
|
|
|
@ -5,14 +5,47 @@ module Fog
|
|||
|
||||
require 'fog/zerigo/parsers/compute/create_host'
|
||||
|
||||
# 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
|
||||
# Create a new host in the specified zone
|
||||
#
|
||||
# ==== Parameters
|
||||
# * zone_id<~Integer>
|
||||
# * host_type<~String>
|
||||
# * data<~String>
|
||||
# * options<~Hash> - optional paramaters
|
||||
# * 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>:
|
||||
# * 'count'<~Integer>
|
||||
def create_host( zone_id, hostname, host-type, data, options)
|
||||
# * '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>
|
||||
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 => 200,
|
||||
:method => 'POST',
|
||||
:parser => Fog::Parsers::Zerigo::Compute::CreateHost.new,
|
||||
|
@ -24,7 +57,7 @@ module Fog
|
|||
|
||||
class Mock
|
||||
|
||||
def create_host( host_id)
|
||||
def create_host( zone_id, host_type, data, options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
|
||||
require 'fog/zerigo/parsers/compute/create_zone'
|
||||
|
||||
# Create a new zone for Slicehost's DNS servers to serve/host
|
||||
# Create a new zone for Zerigo's DNS servers to serve/host
|
||||
# ==== Parameters
|
||||
#
|
||||
# * domain<~String>
|
||||
|
@ -26,10 +26,24 @@ module Fog
|
|||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'origin'<~String> - as above
|
||||
# * 'id'<~Integer> - Id of zone/domain - used in future API calls
|
||||
# * 'ttl'<~Integer> - as above
|
||||
# * 'active'<~String> - as above
|
||||
# * '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>
|
||||
def create_zone( domain, default_ttl, ns_type, options = {})
|
||||
|
||||
optional_tags= ''
|
||||
|
|
|
@ -3,9 +3,10 @@ module Fog
|
|||
class Compute
|
||||
class Real
|
||||
|
||||
# Delete a zone from Zerigo
|
||||
# Delete a host record
|
||||
#
|
||||
# ==== Parameters
|
||||
# * zone_id<~Integer> - Id of zone to delete
|
||||
# * host_id<~Integer> - Id of host record to delete
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>: - HTTP status code will be result
|
||||
|
|
|
@ -4,6 +4,7 @@ module Fog
|
|||
class Real
|
||||
|
||||
# Delete a zone from Zerigo
|
||||
#
|
||||
# ==== Parameters
|
||||
# * zone_id<~Integer> - Id of zone to delete
|
||||
#
|
||||
|
|
|
@ -5,15 +5,28 @@ module Fog
|
|||
|
||||
require 'fog/zerigo/parsers/compute/find_hosts'
|
||||
|
||||
# Get list of all DNS zones hosted on Slicehost (for this account)
|
||||
# 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<~Array>:
|
||||
# * 'origin'<~String> - domain name to host (ie example.com)
|
||||
# * 'id'<~Integer> - Id of the zone
|
||||
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
|
||||
# * 'active'<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
|
||||
# * 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>
|
||||
def find_hosts( fqdn, zone_id = nil)
|
||||
if zone_id.nil?
|
||||
#look for matching host across all zones
|
||||
|
@ -21,7 +34,7 @@ module Fog
|
|||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Zerigo::Compute::FindHosts.new,
|
||||
:path => "/api/1.1/hosts.xml"
|
||||
:path => "/api/1.1/hosts.xml?fqdn=#{fqdn}"
|
||||
)
|
||||
else
|
||||
#look for hosts in a specific zone
|
||||
|
@ -29,7 +42,7 @@ module Fog
|
|||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Zerigo::Compute::FindHosts.new,
|
||||
:path => "/api/1.1/zones/#{zone_id}/hosts.xml"
|
||||
:path => "/api/1.1/zones/#{zone_id}/hosts.xml?fqdn=#{fqdn}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,19 +3,31 @@ module Fog
|
|||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/zerigo/parsers/compute/get_hosts'
|
||||
require 'fog/zerigo/parsers/compute/get_host'
|
||||
|
||||
# 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
|
||||
# get details about a given host record
|
||||
#
|
||||
# ==== Parameters
|
||||
# * host_id<~Integer> - ID of the host record to retrieve
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * 'count'<~Integer>
|
||||
# * 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>
|
||||
def get_host( host_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Zerigo::Compute::GetZone.new,
|
||||
:parser => Fog::Parsers::Zerigo::Compute::GetHost.new,
|
||||
:path => "/api/1.1/hosts/#{host_id}.xml"
|
||||
)
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
|
||||
require 'fog/zerigo/parsers/compute/get_zone'
|
||||
|
||||
# Get details of a DNS zone. This response is similar to list_zones, with the
|
||||
# Get details of a DNS zone. The response is similar to list_zones, with the
|
||||
# addition of hosts-count and possibly hosts.
|
||||
#
|
||||
# ==== Parameters
|
||||
|
@ -14,10 +14,24 @@ module Fog
|
|||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'origin'<~String> - domain name to host (ie example.com)
|
||||
# * 'id'<~Integer> - Id of the zone
|
||||
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
|
||||
# * 'active'<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
|
||||
# * '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>
|
||||
def get_zone(zone)
|
||||
request(
|
||||
:expects => 200,
|
||||
|
|
|
@ -9,7 +9,7 @@ module Fog
|
|||
# beginning of the current period through the time of the API call.
|
||||
#
|
||||
# ==== Parameters
|
||||
# * zone<~Integer> - the zone ID
|
||||
# * zone_id<~Integer> - the zone ID
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
|
|
|
@ -7,13 +7,23 @@ module Fog
|
|||
|
||||
# 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
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'origin'<~String> - domain name to host (ie example.com)
|
||||
# * 'id'<~Integer> - Id of the zone
|
||||
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
|
||||
# * 'active'<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
|
||||
# * 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>
|
||||
def list_hosts( zone_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
|
|
|
@ -9,11 +9,26 @@ module Fog
|
|||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'origin'<~String> - domain name to host (ie example.com)
|
||||
# * 'id'<~Integer> - Id of the zone
|
||||
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
|
||||
# * 'active'<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
|
||||
# * 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>
|
||||
def list_zones
|
||||
request(
|
||||
:expects => 200,
|
||||
|
|
|
@ -5,14 +5,41 @@ module Fog
|
|||
|
||||
require 'fog/zerigo/parsers/compute/update_host'
|
||||
|
||||
# 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
|
||||
# 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>:
|
||||
# * 'count'<~Integer>
|
||||
#
|
||||
def update_host( host_id, options = {})
|
||||
|
||||
optional_tags= ''
|
||||
options.each { |option, value|
|
||||
case option
|
||||
when :host_type
|
||||
optional_tags+= "<host-type>#{host_type}</host-type>"
|
||||
when :data
|
||||
optional_tags+= "<data>#{data}</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',
|
||||
:parser => Fog::Parsers::Zerigo::Compute::UpdateHost.new,
|
||||
|
|
|
@ -26,10 +26,7 @@ module Fog
|
|||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'origin'<~String> - as above
|
||||
# * 'id'<~Integer> - Id of zone/domain - used in future API calls
|
||||
# * 'ttl'<~Integer> - as above
|
||||
# * 'active'<~String> - as above
|
||||
#
|
||||
def update_zone( zone_id, options = {})
|
||||
|
||||
optional_tags= ''
|
||||
|
@ -64,10 +61,10 @@ module Fog
|
|||
|
||||
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',
|
||||
:expects => 200,
|
||||
:method => 'PUT',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::UpdateZone.new,
|
||||
:path => '/api/1.1/zones.xml'
|
||||
:path => "/api/1.1/zones/#{zone_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -75,7 +72,7 @@ module Fog
|
|||
|
||||
class Mock
|
||||
|
||||
def update_zone(domain, default_ttl, ns_type, options = {})
|
||||
def update_zone(zone_id, options = {})
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue