Sha256: cbbf0ab400c6143f3f9aa7468d059b4954a7921c236a65bc5cb64899c61c890b

Contents?: true

Size: 1.47 KB

Versions: 30

Compression:

Stored size: 1.47 KB

Contents

require 'fog/core/model'

module Fog
  module DNS
    class DNSimple
      class Record < Fog::Model
        extend Fog::Deprecation
        deprecate :ip, :value
        deprecate :ip=, :value=

        identity :id

        attribute :zone_id,     :aliases => "domain_id"
        attribute :name
        attribute :value,       :aliases => "content"
        attribute :ttl
        attribute :priority,    :aliases => "prio"
        attribute :type,        :aliases => "record_type"
        attribute :created_at
        attribute :updated_at

        def initialize(attributes={})
          super
        end

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

        def zone
          @zone
        end

        def save
          requires :name, :type, :value
          options = {}
          options[:prio] = priority if priority
          options[:ttl]  = ttl if ttl

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

          merge_attributes(data.body["record"])
          true
        end

        private

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

Version data entries

30 entries across 30 versions & 4 rubygems

Version Path
fog-1.38.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.37.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.36.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.35.0 lib/fog/dnsimple/models/dns/record.rb
fog-2.0.0.pre.0 lib/fog/dnsimple/models/dns/record.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/dnsimple/models/dns/record.rb
fog-1.34.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.33.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.32.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.31.0 lib/fog/dnsimple/models/dns/record.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/dnsimple/models/dns/record.rb
fog-1.30.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.29.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.28.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.27.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.26.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.25.0 lib/fog/dnsimple/models/dns/record.rb
nsidc-fog-1.24.1 lib/fog/dnsimple/models/dns/record.rb
fog-1.24.0 lib/fog/dnsimple/models/dns/record.rb
ns-fog-1.22.11 lib/fog/dnsimple/models/dns/record.rb