Sha256: 2d0ca61a7b356e667472ec7f1d82a3ccaaef428053a5342737fdae12ed7b663a

Contents?: true

Size: 690 Bytes

Versions: 10

Compression:

Stored size: 690 Bytes

Contents

require 'glare/domain/cf_zones'

module Glare
  class Domain
    class Zone
      def initialize(client, fqdn)
        @client = client
        @fqdn = fqdn
      end

      def records(type)
        api_result = record_search(type)
        CfDnsRecords.from_result(api_result)
      end

      def id
        return @id if @id
        zone_search = @client.get('/zones', name: registered_domain)
        @id = CfZones.from_result(zone_search).first_id
      end

      private

      def registered_domain
        PublicSuffix.parse(@fqdn).domain
      end

      def record_search(type)
        @client.get("/zones/#{id}/dns_records", name: @fqdn, type: type)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
glare-1.1.0 lib/glare/domain/zone.rb
glare-1.0.0 lib/glare/domain/zone.rb
glare-0.9.0 lib/glare/domain/zone.rb
glare-0.8.0 lib/glare/domain/zone.rb
glare-0.7.0 lib/glare/domain/zone.rb
glare-0.6.0 lib/glare/domain/zone.rb
glare-0.4.0 lib/glare/domain/zone.rb
glare-0.2.2 lib/glare/domain/zone.rb
glare-0.2.1 lib/glare/domain/zone.rb
glare-0.2.0 lib/glare/domain/zone.rb