Sha256: d1f04eba3b04d6d2a80e5759f1773d0f4964726309c78f2d213b59bdd3c1e07e

Contents?: true

Size: 1.59 KB

Versions: 67

Compression:

Stored size: 1.59 KB

Contents

require 'fog/core/model'

module Fog
  module DNS
    class Dynect

      class Record < Fog::Model
        extend Fog::Deprecation

        identity  :id
        attribute :name,        :aliases => [:fqdn, 'fqdn']
        attribute :rdata
        attribute :serial_style
        attribute :ttl
        attribute :type,        :aliases => 'record_type'

        def destroy
          requires :identity, :name, :type, :zone
          service.delete_record(type, zone.identity, name, identity)
          true
        end

        def save
          requires :name, :type, :rdata, :zone

          options = {
            :ttl => ttl
          }
          options.delete_if {|key, value| value.nil?}

          data = service.post_record(type, zone.identity, name, rdata, options).body['data']
          # avoid overwriting zone object with zone string
          data = data.reject {|key, value| key == 'zone'}
          merge_attributes(data)

          zone.publish
          records = service.get_record(type, zone.identity, name).body['data']
          # data in format ['/REST/xRecord/domain/fqdn/identity]
          records.map! do |record|
            tokens = record.split('/')
            {
              :identity => tokens.last,
              :type     => tokens[2][0...-6] # everything before 'Record'
            }
          end
          record = records.detect {|record| record[:type] == type}
          merge_attributes(record)

          true
        end

        def zone
          @zone
        end

        private

        def zone=(new_zone)
          @zone = new_zone
        end

      end

    end
  end
end

Version data entries

67 entries across 67 versions & 7 rubygems

Version Path
fog-1.22.0 lib/fog/dynect/models/dns/record.rb
fog-1.21.0 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/dynect/models/dns/record.rb
fog-1.20.0 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/dynect/models/dns/record.rb
fog-1.19.0 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/dynect/models/dns/record.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/dynect/models/dns/record.rb