Sha256: bece2c54841dd3477e4723fe3ddf561087c6b24fa55d4a411f41a58838f19621

Contents?: true

Size: 1.92 KB

Versions: 18

Compression:

Stored size: 1.92 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={})
          super
        end

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

        def zone
          @zone
        end

        def save
          self.ttl ||= 1800
          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 = service.create_record(zone.domain, name, type, value, options).body
            merge_attributes(data)
          else
            options.merge!(:name => name, :type => type, :data => value)
            service.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

18 entries across 18 versions & 4 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.28.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.27.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.26.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.25.0 lib/fog/dnsmadeeasy/models/dns/record.rb
nsidc-fog-1.24.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.24.0 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.11 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.10 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.9 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.8 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.7 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.6 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.23.0 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.4 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.3 lib/fog/dnsmadeeasy/models/dns/record.rb
ns-fog-1.22.2 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.22.1 lib/fog/dnsmadeeasy/models/dns/record.rb