Sha256: 78f2c07ad6cb0004a35b6a11c58233270f742b7d3212ebd645dfb0e66e9279fd

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

module Fog
  module Dynect
    class DNS
      class Real
        # Get one or more node lists
        #
        # ==== Parameters
        # * zone<~String> - zone to lookup node lists for
        # * options<~Hash>
        #   * fqdn<~String> - fully qualified domain name of node to lookup

        def get_node_list(zone, options = {})
          requested_fqdn = options['fqdn'] || options[:fqdn]
          request(
            :expects  => 200,
            :idempotent => true,
            :method   => :get,
            :path     => ['AllRecord', zone, requested_fqdn].compact.join('/')
          )
        end
      end

      class Mock
        def get_node_list(zone, options = {})
          raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]

          response = Excon::Response.new
          response.status = 200

          data = [zone[:zone]]

          if fqdn = options[:fqdn]
            data = data | zone[:records].map { |type, records| records.select { |record| record[:fqdn] == fqdn } }.flatten.compact
          else
            data = data | zone[:records].map { |type, records| records.map { |record| record[:fqdn] } }.flatten
          end

          response.body = {
            "status" => "success",
            "data" => data,
            "job_id" => Fog::Dynect::Mock.job_id,
            "msgs" => [{
              "INFO" => "get_tree: Here is your zone tree",
              "SOURCE" => "BLL",
              "ERR_CD" => nil,
              "LVL" => "INFO"
            }]
          }

          response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-dynect-0.5.0 lib/fog/dynect/requests/dns/get_node_list.rb