2010-12-14 00:04:23 -05:00
|
|
|
module Fog
|
2011-06-15 20:25:01 -04:00
|
|
|
module DNS
|
|
|
|
class AWS
|
2010-12-14 00:04:23 -05:00
|
|
|
class Real
|
|
|
|
|
2011-08-24 21:00:45 -04:00
|
|
|
require 'fog/aws/parsers/dns/create_hosted_zone'
|
2010-12-14 00:04:23 -05:00
|
|
|
|
|
|
|
# Creates a new hosted zone
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * name<~String> - The name of the domain. Must be a fully-specified domain that ends with a period
|
|
|
|
# * options<~Hash>
|
2011-01-26 02:08:22 -05:00
|
|
|
# * caller_ref<~String> - unique string that identifies the request & allows failed
|
2010-12-14 00:04:23 -05:00
|
|
|
# calls to be retried without the risk of executing the operation twice
|
2011-12-06 00:24:07 -05:00
|
|
|
# * comment<~String> -
|
2010-12-14 00:04:23 -05:00
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'HostedZone'<~Hash>:
|
2011-01-26 02:08:22 -05:00
|
|
|
# * 'Id'<~String> -
|
|
|
|
# * 'Name'<~String> -
|
2010-12-14 00:04:23 -05:00
|
|
|
# * 'CallerReference'<~String>
|
2011-01-26 02:08:22 -05:00
|
|
|
# * 'Comment'<~String> -
|
2010-12-14 00:04:23 -05:00
|
|
|
# * 'ChangeInfo'<~Hash> -
|
|
|
|
# * 'Id'<~String>
|
|
|
|
# * 'Status'<~String>
|
|
|
|
# * 'SubmittedAt'<~String>
|
|
|
|
# * 'NameServers'<~Array>
|
|
|
|
# * 'NameServer'<~String>
|
|
|
|
# * status<~Integer> - 201 when successful
|
2010-12-17 19:48:38 -05:00
|
|
|
def create_hosted_zone(name, options = {})
|
2010-12-14 00:04:23 -05:00
|
|
|
|
|
|
|
optional_tags = ''
|
2010-12-17 18:08:56 -05:00
|
|
|
if options[:caller_ref]
|
2011-12-06 00:24:07 -05:00
|
|
|
optional_tags += "<CallerReference>#{options[:caller_ref]}</CallerReference>"
|
2010-12-17 18:08:56 -05:00
|
|
|
else
|
|
|
|
#make sure we have a unique call reference
|
2010-12-14 00:04:23 -05:00
|
|
|
caller_ref = "ref-#{rand(1000000).to_s}"
|
2011-12-06 00:24:07 -05:00
|
|
|
optional_tags += "<CallerReference>#{caller_ref}</CallerReference>"
|
2010-12-14 00:04:23 -05:00
|
|
|
end
|
2010-12-17 18:08:56 -05:00
|
|
|
if options[:comment]
|
2011-12-06 00:24:07 -05:00
|
|
|
optional_tags += "<HostedZoneConfig><Comment>#{options[:comment]}</Comment></HostedZoneConfig>"
|
2010-12-17 18:08:56 -05:00
|
|
|
end
|
2011-01-26 02:08:22 -05:00
|
|
|
|
2010-12-14 00:04:23 -05:00
|
|
|
request({
|
2011-12-06 00:24:07 -05:00
|
|
|
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/"><Name>#{name}</Name>#{optional_tags}</CreateHostedZoneRequest>},
|
|
|
|
:parser => Fog::Parsers::DNS::AWS::CreateHostedZone.new,
|
|
|
|
:expects => 201,
|
|
|
|
:method => 'POST',
|
|
|
|
:path => "hostedzone"
|
2010-12-14 00:04:23 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|