Sha256: 7c063a74bbfda328840379729a2dded22a942203a4a41f09544c99c5f9ddc363

Contents?: true

Size: 1.92 KB

Versions: 53

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

53 entries across 53 versions & 3 rubygems

Version Path
fog-maestrodev-1.15.0.20130927082724 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-maestrodev-1.15.0.20130829165835 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.15.0 lib/fog/dnsmadeeasy/models/dns/record.rb
gapinc-fog-1.14.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-maestrodev-1.14.0.20130806165225 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.14.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.13.0 lib/fog/dnsmadeeasy/models/dns/record.rb
gapinc-fog-1.12.1.2 lib/fog/dnsmadeeasy/models/dns/record.rb
gapinc-fog-1.12.1.1 lib/fog/dnsmadeeasy/models/dns/record.rb
gapinc-fog-1.12.1a lib/fog/dnsmadeeasy/models/dns/record.rb
gapinc-fog-1.12.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.12.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.12.0 lib/fog/dnsmadeeasy/models/dns/record.rb