Sha256: c0ac7623b270114ad9db559545ce0f2c0dd4a8c82bbe65555ac87fc6c8e331f9

Contents?: true

Size: 1.89 KB

Versions: 37

Compression:

Stored size: 1.89 KB

Contents

module Fog
  module AWS
    class DNS
      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)
          # AWS methods return zone_ids that looks like '/hostedzone/id'.  Let the caller either use
          # that form or just the actual id (which is what this request needs)
          zone_id = zone_id.sub('/hostedzone/', '')

          request({
            :expects => 200,
            :idempotent => true,
            :method  => 'GET',
            :parser  => Fog::Parsers::AWS::DNS::GetHostedZone.new,
            :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
            raise Fog::AWS::DNS::NotFound.new("NoSuchHostedZone => A hosted zone with the specified hosted zone ID does not exist.")
          end
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.29.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.28.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.27.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.26.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.25.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.24.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.23.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.22.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.21.1 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.21.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.20.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.19.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.18.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.17.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.16.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.15.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.14.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.13.0 lib/fog/aws/requests/dns/get_hosted_zone.rb
fog-aws-3.12.0 lib/fog/aws/requests/dns/get_hosted_zone.rb