Sha256: 17ac464b03d3cf13c57c08ba94574223fb6d9def7f433e85c83b4f9b16fcab98

Contents?: true

Size: 1.65 KB

Versions: 25

Compression:

Stored size: 1.65 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={})
          self.ttl    ||= 3600
          super
        end

        def destroy
          requires :identity
          connection.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 identity
            options[:host_type] = type
            options[:data]      = value
            connection.update_host(identity, options)
          else
            data = connection.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

25 entries across 25 versions & 11 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/zerigo/models/dns/record.rb
fog-nirvanix-1.8.1 lib/fog/zerigo/models/dns/record.rb
fog-parser-fix-1.6.1 lib/fog/zerigo/models/dns/record.rb
fog-test-again-1.6.0 lib/fog/zerigo/models/dns/record.rb
fog-parser-fix-1.6.0 lib/fog/zerigo/models/dns/record.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/zerigo/models/dns/record.rb
fog-sgonyea-1.8.1 lib/fog/zerigo/models/dns/record.rb
fog-1.8.0 lib/fog/zerigo/models/dns/record.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/zerigo/models/dns/record.rb
fog-1.7.0 lib/fog/zerigo/models/dns/record.rb
fog-1.6.0 lib/fog/zerigo/models/dns/record.rb
fog-1.5.0 lib/fog/zerigo/models/dns/record.rb
fog-1.4.0 lib/fog/zerigo/models/dns/record.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/zerigo/models/dns/record.rb
michiels-fog-1.3.1 lib/fog/zerigo/models/dns/record.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/zerigo/models/dns/record.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/zerigo/models/dns/record.rb
fog-1.3.1 lib/fog/zerigo/models/dns/record.rb
fog-1.3.0 lib/fog/zerigo/models/dns/record.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/zerigo/models/dns/record.rb