Sha256: 758728cade3906005396546d7a3cdacb91abc9ca8f8984d06b185bdf1eca6fca

Contents?: true

Size: 1.87 KB

Versions: 12

Compression:

Stored size: 1.87 KB

Contents

require 'fog/core/model'

module Fog
  module DNS
    class Linode

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

        identity :id,         :aliases => ['ResourceID', 'RESOURCEID']

        attribute :value,     :aliases => 'TARGET'
        attribute :name,      :aliases => 'NAME'
        attribute :priority,  :aliases => 'PRIORITY'
        attribute :ttl,       :aliases => 'TTL_SEC'
        attribute :type,      :aliases => 'TYPE'
        attribute :zone_id,   :aliases => 'DOMAINID'

        # "PROTOCOL":"",
        # "WEIGHT":0,
        # "PORT":0,

        def initialize(attributes={})
          self.ttl    ||= 3600
          super
        end

        def destroy
          requires :identity, :zone
          service.domain_resource_delete(zone.id, identity)
          true
        end

        def zone
          @zone
        end

        def save
          requires :type, :zone
          options = {}
          # * options<~Hash>
          #   * weight<~Integer>: default: 5
          #   * port<~Integer>: default: 80
          #   * protocol<~String>: The protocol to append to an SRV record. Ignored on other record
          #                        types. default: udp
          options[:name]      = name if name
          options[:priority]  = priority if priority
          options[:target]    = value if value
          options[:ttl_sec]   = ttl if ttl
          response = unless identity
            service.domain_resource_create(zone.identity, type, options)
          else
            options[:type] = type if type
            service.domain_resource_update(zone.identity, identity, options)
          end
          merge_attributes(response.body['DATA'])
          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/linode/models/dns/record.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/linode/models/dns/record.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/linode/models/dns/record.rb
fog-1.11.1 lib/fog/linode/models/dns/record.rb
fog-1.11.0 lib/fog/linode/models/dns/record.rb
fog-1.10.1 lib/fog/linode/models/dns/record.rb
fog-test-me-1.10.0 lib/fog/linode/models/dns/record.rb
fog-1.10.0 lib/fog/linode/models/dns/record.rb
fog-1.9.0 lib/fog/linode/models/dns/record.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/linode/models/dns/record.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/linode/models/dns/record.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/linode/models/dns/record.rb