Sha256: 39b0b1816adec2b2c52c39df53415d270a88418a4124852e862c3e8cf460dd4f

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 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 :name
        attribute :value,       :aliases => "content"
        attribute :ttl
        attribute :created_at
        attribute :updated_at
        attribute :zone_id,     :aliases => "domain_id"
        attribute :type,        :aliases => "record_type"
        attribute :priority,    :aliases => "prio"

        def initialize(attributes={})
          super
        end

        def destroy
          service.delete_record(zone.domain, 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.domain, 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.domain, 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

9 entries across 9 versions & 2 rubygems

Version Path
gapinc-fog-1.12.1.2.1 lib/fog/dnsimple/models/dns/record.rb
fog-1.14.0 lib/fog/dnsimple/models/dns/record.rb
fog-1.13.0 lib/fog/dnsimple/models/dns/record.rb
gapinc-fog-1.12.1.2 lib/fog/dnsimple/models/dns/record.rb
gapinc-fog-1.12.1.1 lib/fog/dnsimple/models/dns/record.rb
gapinc-fog-1.12.1a lib/fog/dnsimple/models/dns/record.rb
gapinc-fog-1.12.1 lib/fog/dnsimple/models/dns/record.rb
fog-1.12.1 lib/fog/dnsimple/models/dns/record.rb
fog-1.12.0 lib/fog/dnsimple/models/dns/record.rb