Sha256: 91a4f6c1ec418481f7abf205d6790ee6dd32735d4357984fb64ebdc7279b4fc4

Contents?: true

Size: 1.56 KB

Versions: 17

Compression:

Stored size: 1.56 KB

Contents

require 'fog/core/model'

module Fog
  module Zerigo
    class DNS

      class Record < Fog::Model

        identity :id

        attribute :created_at,  :aliases => 'created-at'
        attribute :ip,          :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, :ip
          options = {}
          options[:hostname]  = name if name
          options[:notes]     = description if description
          options[:priority]  = priority if priority
          options[:ttl]       = ttl if ttl
          data = unless identity
            connection.create_host(@zone.id, type, ip, options)
          else
            options[:host_type] = type
            options[:data]      = data
            connection.update_host(identity, options)
          end
          merge_attributes(data.body)
          true
        end

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

      end

    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
fog-0.8.2 lib/fog/dns/models/zerigo/record.rb
fog-0.8.1 lib/fog/dns/models/zerigo/record.rb
fog-0.8.0 lib/fog/dns/models/zerigo/record.rb
fog-0.7.2 lib/fog/dns/models/zerigo/record.rb
fog-0.7.1 lib/fog/dns/models/zerigo/record.rb
fog-0.7.0 lib/fog/dns/models/zerigo/record.rb
fog-0.6.0 lib/fog/dns/models/zerigo/record.rb
fog-0.5.3 lib/fog/dns/models/zerigo/record.rb
fog-0.5.2 lib/fog/dns/models/zerigo/record.rb
fog-0.5.1 lib/fog/dns/models/zerigo/record.rb
fog-0.5.0 lib/fog/dns/models/zerigo/record.rb
phpfog-fog-0.4.1.3 lib/fog/dns/models/zerigo/record.rb
phpfog-fog-0.4.1.2 lib/fog/dns/models/zerigo/record.rb
phpfog-fog-0.4.1.1 lib/fog/dns/models/zerigo/record.rb
phpfog-fog-0.4.1 lib/fog/dns/models/zerigo/record.rb
fog-0.4.1 lib/fog/dns/models/zerigo/record.rb
fog-0.4.0 lib/fog/zerigo/models/dns/record.rb