Sha256: 8a98bf0abbbe1d38fe8d04be74a2b78ee528d9376b7531245961dc5869931b7f

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'fog/dynect/models/dns/record'

module Fog
  module DNS
    class Dynect
      class Records < Fog::Collection
        attribute :zone

        model Fog::DNS::Dynect::Record

        def all(options = {})
          requires :zone
          data = []
          service.get_all_records(zone.domain, options).body['data'].each do |records|
            (type, list) = records
            list.each do |record|
              data << {
                :identity => record['record_id'],
                :fqdn => record['fqdn'],
                :type => record['record_type'],
                :rdata => record['rdata'],
                :ttl => record['ttl']
              }
            end
          end

          load(data)
        end

        def get(record_id)
          requires :zone

          # there isn't a way to look up by just id
          # must have type and domain for 'get_record' request
          # so we pick it from the list returned by 'all'

          list = all
          list.detect {|e| e.id == record_id}
        end

        def new(attributes = {})
          requires :zone
          super({:zone => zone}.merge!(attributes))
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-dynect-0.4.0 lib/fog/dynect/models/dns/records.rb
fog-dynect-0.3.0 lib/fog/dynect/models/dns/records.rb
fog-dynect-0.2.0 lib/fog/dynect/models/dns/records.rb