2014-12-30 17:25:09 -05:00
|
|
|
module Fog
|
|
|
|
module DNS
|
2015-01-02 12:34:40 -05:00
|
|
|
class AWS
|
2014-12-30 17:25:09 -05:00
|
|
|
class Real
|
|
|
|
require 'fog/aws/parsers/dns/get_hosted_zone'
|
|
|
|
|
|
|
|
# retrieve information about a hosted zone
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * zone_id<~String> - The ID of the hosted zone
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'HostedZone'<~Hash>:
|
|
|
|
# * 'Id'<~String> -
|
|
|
|
# * 'Name'<~String> -
|
|
|
|
# * 'CallerReference'<~String>
|
|
|
|
# * 'Comment'<~String> -
|
|
|
|
# * 'NameServers'<~Array>
|
|
|
|
# * 'NameServer'<~String>
|
|
|
|
# * status<~Integer> - 200 when successful
|
|
|
|
def get_hosted_zone(zone_id)
|
2015-01-02 12:34:40 -05:00
|
|
|
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
|
2014-12-30 17:25:09 -05:00
|
|
|
# that form or just the actual id (which is what this request needs)
|
|
|
|
zone_id = zone_id.sub('/hostedzone/', '')
|
|
|
|
|
|
|
|
request({
|
|
|
|
:expects => 200,
|
2015-01-26 07:24:53 -05:00
|
|
|
:idempotent => true,
|
2014-12-30 17:25:09 -05:00
|
|
|
:method => 'GET',
|
2015-01-26 07:24:53 -05:00
|
|
|
:parser => Fog::Parsers::DNS::AWS::GetHostedZone.new,
|
2014-12-30 17:25:09 -05:00
|
|
|
:path => "hostedzone/#{zone_id}"
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
def get_hosted_zone(zone_id)
|
|
|
|
response = Excon::Response.new
|
|
|
|
if (zone = self.data[:zones][zone_id])
|
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'HostedZone' => {
|
|
|
|
'Id' => zone[:id],
|
|
|
|
'Name' => zone[:name],
|
|
|
|
'CallerReference' => zone[:reference],
|
|
|
|
'Comment' => zone[:comment]
|
|
|
|
},
|
|
|
|
'NameServers' => Fog::AWS::Mock.nameservers
|
|
|
|
}
|
|
|
|
response
|
|
|
|
else
|
2015-02-19 19:20:16 -05:00
|
|
|
raise Fog::DNS::AWS::NotFound.new("NoSuchHostedZone => A hosted zone with the specified hosted zone ID does not exist.")
|
2014-12-30 17:25:09 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|