Method: Fog::DNS::AWS::Mock#get_hosted_zone

Defined in:
lib/fog/aws/requests/dns/get_hosted_zone.rb

#get_hosted_zone(zone_id) ⇒ Object

[View source]

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/aws/requests/dns/get_hosted_zone.rb', line 42

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
    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