mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00

all DNS functions are now working and tested. any functions that have optional parameters can now accept these comments cleaned up note, no mocks or test cases. will speak to geemus to learn more about how these work.
54 lines
1.6 KiB
Ruby
54 lines
1.6 KiB
Ruby
module Fog
|
|
module Slicehost
|
|
class Compute
|
|
class Real
|
|
|
|
require 'fog/slicehost/parsers/compute/create_zone'
|
|
|
|
# Create a new zone for Slicehost's DNS servers to serve/host
|
|
# ==== Parameters
|
|
# * origin<~String> - domain name to host (ie example.com)
|
|
# * 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'
|
|
#
|
|
# ==== 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 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
|
|
}
|
|
|
|
request(
|
|
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><origin>#{origin}</origin>#{optional_tags}</zone>},
|
|
:expects => 201,
|
|
:method => 'POST',
|
|
:parser => Fog::Parsers::Slicehost::Compute::CreateZone.new,
|
|
:path => 'zones.xml'
|
|
)
|
|
end
|
|
|
|
end
|
|
|
|
class Mock
|
|
|
|
def create_zone(origin, ttl, active)
|
|
Fog::Mock.not_implemented
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|