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-2.3.0 lib/fog/rage4/models/dns/record.rb
fog-ifeel-2.2.0 lib/fog/rage4/models/dns/record.rb
fog-2.2.0 lib/fog/rage4/models/dns/record.rb
fog-2.1.0 lib/fog/rage4/models/dns/record.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/rage4/models/dns/record.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/rage4/models/dns/record.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/rage4/models/dns/record.rb
fog-1.42.1 lib/fog/rage4/models/dns/record.rb
fog-2.0.0 lib/fog/rage4/models/dns/record.rb
fog-1.42.0 lib/fog/rage4/models/dns/record.rb
fog-1.41.0 lib/fog/rage4/models/dns/record.rb
fog-1.40.0 lib/fog/rage4/models/dns/record.rb
fog-1.39.0 lib/fog/rage4/models/dns/record.rb
fog-1.38.0 lib/fog/rage4/models/dns/record.rb
fog-1.37.0 lib/fog/rage4/models/dns/record.rb
fog-1.36.0 lib/fog/rage4/models/dns/record.rb
fog-1.35.0 lib/fog/rage4/models/dns/record.rb
fog-2.0.0.pre.0 lib/fog/rage4/models/dns/record.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/rage4/models/dns/record.rb
fog-1.34.0 lib/fog/rage4/models/dns/record.rb