2010-12-14 00:04:23 -05:00
module Fog
2011-06-15 17:25:01 -07:00
module DNS
class AWS
2010-12-14 00:04:23 -05:00
class Real
2011-08-24 20:00:45 -05:00
require 'fog/aws/parsers/dns/get_hosted_zone'
2010-12-14 00:04:23 -05:00
# retrieve information about a hosted zone
#
# ==== Parameters
# * zone_id<~String> - The ID of the hosted zone
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'HostedZone'<~Hash>:
2011-12-05 21:24:07 -08:00
# * 'Id'<~String> -
# * 'Name'<~String> -
2010-12-14 00:04:23 -05:00
# * 'CallerReference'<~String>
2011-12-05 21:24:07 -08:00
# * 'Comment'<~String> -
2010-12-14 00:04:23 -05:00
# * 'NameServers'<~Array>
# * 'NameServer'<~String>
2012-06-07 14:56:00 -07:00
# * status<~Integer> - 200 when successful
2010-12-17 16:48:38 -08:00
def get_hosted_zone ( zone_id )
2010-12-14 00:04:23 -05:00
2011-12-05 21:24:07 -08:00
# AWS methods return zone_ids that looks like '/hostedzone/id'. Let the caller either use
2010-12-14 00:04:23 -05:00
# that form or just the actual id (which is what this request needs)
zone_id = zone_id . sub ( '/hostedzone/' , '' )
request ( {
2011-12-05 21:24:07 -08:00
:expects = > 200 ,
:parser = > Fog :: Parsers :: DNS :: AWS :: GetHostedZone . new ,
:method = > 'GET' ,
:path = > " hostedzone/ #{ zone_id } "
2010-12-14 00:04:23 -05:00
} )
end
end
2012-06-07 10:46:35 -07:00
class Mock
def get_hosted_zone ( zone_id )
response = Excon :: Response . new
if ( zone = self . data [ :zones ] [ zone_id ] )
2012-06-07 14:56:00 -07:00
response . status = 200
2012-06-07 10:46:35 -07:00
response . body = {
'HostedZone' = > {
2012-06-07 15:28:07 -07:00
'Id' = > zone [ :id ] ,
2012-06-07 10:46:35 -07:00
'Name' = > zone [ :name ] ,
'CallerReference' = > zone [ :reference ] ,
'Comment' = > zone [ :comment ]
} ,
'NameServers' = > Fog :: AWS :: Mock . nameservers
}
response
else
response . status = 404
response . body = " <?xml version= \" 1.0 \" ?><Response><Errors><Error><Code>NoSuchHostedZone</Code><Message>A hosted zone with the specified hosted zone ID does not exist.</Message></Error></Errors><RequestID> #{ Fog :: AWS :: Mock . request_id } </RequestID></Response> "
raise ( Excon :: Errors . status_error ( { :expects = > 200 } , response ) )
end
end
end
2010-12-14 00:04:23 -05:00
end
end
end