Sha256: 97b0f81308449ae3a35c9fb3d9f1a2b1c0d368d732c1388355124f442254c94a

Contents?: true

Size: 1.94 KB

Versions: 32

Compression:

Stored size: 1.94 KB

Contents

require 'fog/core/model'

module Fog
  module DNS
    class DNSMadeEasy

      class Record < Fog::Model
        extend Fog::Deprecation
        deprecate :ip, :value
        deprecate :ip=, :value=
        
        identity :id

        attribute :name
        attribute :type
        attribute :ttl
        attribute :gtd_location,  :aliases => "gtdLocation"
        attribute :password
        attribute :description
        attribute :keywords
        attribute :title
        attribute :redirect_type, :aliases => "redirectType"
        attribute :hard_link, :aliases => "hardLink"

        attribute :value,          :aliases => "data"
  
        def initialize(attributes={})
          self.ttl ||= 1800
          super
        end

        def destroy
          connection.delete_record(zone.domain, identity)
          true
        end

        def zone
          @zone
        end

        def save
          requires :name, :type, :value, :ttl
          options = {}
          options[:ttl]  = ttl if ttl
          options[:gtdLocation]  = gtd_location if gtd_location

          if type.upcase == 'A'
            options[:password]  = password if password
          end

          if type.upcase == 'HTTPRED'
            options[:description]  = description if description
            options[:keywords]  = keywords if keywords
            options[:title]  = title if title
            options[:redirectType]  = redirect_type if redirect_type
            options[:hardLink]  = hard_link if hard_link
          end

          if id.nil?
            data = connection.create_record(zone.domain, name, type, value, options).body
            merge_attributes(data)
          else
            options.merge!(:name => name, :type => type, :data => value)
            connection.update_record(zone.domain, id, options).body
          end

          true
        end

        private

        def zone=(new_zone)
          @zone = new_zone
        end

      end

    end
  end
end

Version data entries

32 entries across 32 versions & 12 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-nirvanix-1.8.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-parser-fix-1.6.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-test-again-1.6.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-parser-fix-1.6.0 lib/fog/dnsmadeeasy/models/dns/record.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/dnsmadeeasy/models/dns/record.rb
fog-sgonyea-1.8.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.8.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.7.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.6.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.5.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.4.0 lib/fog/dnsmadeeasy/models/dns/record.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/dnsmadeeasy/models/dns/record.rb
michiels-fog-1.3.1 lib/fog/dnsmadeeasy/models/dns/record.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/dnsmadeeasy/models/dns/record.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.3.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.3.0 lib/fog/dnsmadeeasy/models/dns/record.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/dnsmadeeasy/models/dns/record.rb