Sha256: 0deb6a8ab76a02ffa1468df53539c33b80499174b98ad92e414d9b1e72615280

Contents?: true

Size: 1.61 KB

Versions: 38

Compression:

Stored size: 1.61 KB

Contents

require 'fog/core/model'

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

        identity :id

        attribute :created_at,  :aliases => 'created-at'
        attribute :value,       :aliases => 'data'
        attribute :domain,      :aliases => 'fqdn'
        attribute :name,        :aliases => 'hostname'
        attribute :description, :aliases => 'notes'
        attribute :priority
        attribute :ttl
        attribute :type,        :aliases => 'host-type'
        attribute :updated_at,  :aliases => 'updated-at'
        attribute :zone_id,     :aliases => 'zone-id'

        def initialize(attributes={})
          super
        end

        def destroy
          requires :identity
          service.delete_host(identity)
          true
        end

        def zone
          @zone
        end

        def save
          requires :zone, :type, :value
          options = {}
          options[:hostname]  = name if name
          options[:notes]     = description if description
          options[:priority]  = priority if priority
          options[:ttl]       = ttl if ttl

          if persisted?
            options[:host_type] = type
            options[:data]      = value
            service.update_host(identity, options)
          else
            data = service.create_host(@zone.id, type, value, options)
            merge_attributes(data.body)
          end

          true
        end

        private

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

Version data entries

38 entries across 36 versions & 5 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/zerigo/models/dns/record.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/zerigo/models/dns/record.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/zerigo/models/dns/record.rb
fog-1.42.1 lib/fog/zerigo/models/dns/record.rb
fog-1.42.0 lib/fog/zerigo/models/dns/record.rb
fog-1.41.0 lib/fog/zerigo/models/dns/record.rb
fog-1.40.0 lib/fog/zerigo/models/dns/record.rb
fog-1.39.0 lib/fog/zerigo/models/dns/record.rb
fog-1.38.0 lib/fog/zerigo/models/dns/record.rb
fog-1.37.0 lib/fog/zerigo/models/dns/record.rb
fog-1.36.0 lib/fog/zerigo/models/dns/record.rb
fog-1.35.0 lib/fog/zerigo/models/dns/record.rb
fog-2.0.0.pre.0 lib/fog/zerigo/models/dns/record.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/zerigo/models/dns/record.rb
fog-1.34.0 lib/fog/zerigo/models/dns/record.rb
fog-1.33.0 lib/fog/zerigo/models/dns/record.rb
fog-1.32.0 lib/fog/zerigo/models/dns/record.rb
fog-1.31.0 lib/fog/zerigo/models/dns/record.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/zerigo/models/dns/record.rb
fog-1.30.0 lib/fog/zerigo/models/dns/record.rb