2010-12-09 14:14:48 -05:00
|
|
|
module Fog
|
2011-06-15 17:25:01 -07:00
|
|
|
module DNS
|
|
|
|
class Slicehost
|
2010-12-09 14:14:48 -05:00
|
|
|
class Real
|
|
|
|
|
2011-08-24 19:47:21 -05:00
|
|
|
require 'fog/slicehost/parsers/dns/create_zone'
|
2010-12-09 14:14:48 -05:00
|
|
|
|
|
|
|
# Create a new zone for Slicehost's DNS servers to serve/host
|
|
|
|
# ==== Parameters
|
|
|
|
# * origin<~String> - domain name to host (ie example.com)
|
2010-12-10 11:56:49 -05:00
|
|
|
# * options<~Hash> - optional paramaters
|
|
|
|
# * ttl<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
|
|
|
|
# * active<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
|
2010-12-09 14:14:48 -05:00
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
2010-12-10 11:56:49 -05:00
|
|
|
# * 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 create_zone(origin, options = {})
|
|
|
|
|
|
|
|
optional_tags= ''
|
|
|
|
options.each { |option, value|
|
|
|
|
case option
|
|
|
|
when :ttl
|
|
|
|
optional_tags+= "<ttl type='interger'>#{value}</ttl>"
|
|
|
|
when :active
|
|
|
|
optional_tags+= "<active>#{value}</active>"
|
|
|
|
end
|
|
|
|
}
|
2011-09-22 19:33:45 -05:00
|
|
|
|
2010-12-09 14:14:48 -05:00
|
|
|
request(
|
2010-12-10 11:56:49 -05:00
|
|
|
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><origin>#{origin}</origin>#{optional_tags}</zone>},
|
2010-12-09 14:14:48 -05:00
|
|
|
:expects => 201,
|
|
|
|
:method => 'POST',
|
2011-06-15 17:25:01 -07:00
|
|
|
:parser => Fog::Parsers::DNS::Slicehost::CreateZone.new,
|
2010-12-09 14:14:48 -05:00
|
|
|
:path => 'zones.xml'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|