Sha256: d0d9ab2fe47d6eeca54c68323f7bf3287a4a2710eb4a1208328023fe3c414131

Contents?: true

Size: 1.82 KB

Versions: 43

Compression:

Stored size: 1.82 KB

Contents

require 'fog/core/model'

module Fog
  module DNS
    class Rage4
      class Record < Fog::Model
        identity :id

        attribute :name
        attribute :value,       :aliases => "content"
        attribute :ttl
        attribute :zone_id,     :aliases => "domain_id"
        attribute :type,        :aliases => "record_type"
        attribute :priority,    :aliases => "priority"
        attribute :domain_id
        attribute :geo_region_id
        attribute :failover_enabled
        attribute :failover_content
        attribute :geo_lat
        attribute :geo_long
        attribute :geo_lock
        attribute :is_active
        attribute :udp_limit

        def initialize(attributes={})
          super
        end

        def domain
          name
        end

        def destroy
          service.delete_record(id)
          true
        end

        def zone
          @zone
        end

        def save
          requires :name, :type, :value
          options = {}
          options[:priority] = priority if priority
          options[:ttl]  = ttl if ttl
          options[:geozone] = geo_region_id if geo_region_id
          options[:geolock] = geo_lock if geo_lock
          options[:geolat] = geo_lat if geo_lat
          options[:geolong] = geo_long if geo_long
          options[:udplimit] = udp_limit if udp_limit

          # decide whether its a new record or update of an existing
          if id.nil?
            data = service.create_record(zone.id, name, value, type, options)
          else
            data = service.update_record(id, name, value, type, options)
          end

          merge_attributes(options)
          merge_attributes(:name =>  name, :value => value, :type => type)
          true
        end

        private

        def zone=(new_zone)
          @zone = new_zone
        end
      end
    end
  end
end

Version data entries

43 entries across 41 versions & 6 rubygems

Version Path
fog-1.33.0 lib/fog/rage4/models/dns/record.rb
fog-1.32.0 lib/fog/rage4/models/dns/record.rb
fog-1.31.0 lib/fog/rage4/models/dns/record.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/rage4/models/dns/record.rb
fog-1.30.0 lib/fog/rage4/models/dns/record.rb
fog-1.29.0 lib/fog/rage4/models/dns/record.rb
fog-1.28.0 lib/fog/rage4/models/dns/record.rb
fog-1.27.0 lib/fog/rage4/models/dns/record.rb
fog-1.26.0 lib/fog/rage4/models/dns/record.rb
fog-1.25.0 lib/fog/rage4/models/dns/record.rb
nsidc-fog-1.24.1 lib/fog/rage4/models/dns/record.rb
fog-1.24.0 lib/fog/rage4/models/dns/record.rb
ns-fog-1.22.11 lib/fog/rage4/models/dns/record.rb
ns-fog-1.22.10 lib/fog/rage4/models/dns/record.rb
ns-fog-1.22.9 lib/fog/rage4/models/dns/record.rb
ns-fog-1.22.8 lib/fog/rage4/models/dns/record.rb
ns-fog-1.22.7 lib/fog/rage4/models/dns/record.rb
ns-fog-1.22.6 lib/fog/rage4/models/dns/record.rb
fog-1.23.0 lib/fog/rage4/models/dns/record.rb
ns-fog-1.22.4 lib/fog/rage4/models/dns/record.rb