Sha256: 6c0f3743bea2968458cd6947e8503c74d800ff19e0d8393eb4b5a28bc2e0c6af

Contents?: true

Size: 1.92 KB

Versions: 12

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={})
          self.ttl ||= 1800
          super
        end

        def destroy
          service.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 = 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

12 entries across 12 versions & 5 rubygems

Version Path
hpfog-0.0.20 lib/fog/dnsmadeeasy/models/dns/record.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/dnsmadeeasy/models/dns/record.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.11.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.11.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.10.1 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-test-me-1.10.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.10.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-1.9.0 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/dnsmadeeasy/models/dns/record.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/dnsmadeeasy/models/dns/record.rb