Sha256: 1ccc8a39e40b60017416e4a7e827c1baef9cf325d8661d7ad8574db7be3d9125

Contents?: true

Size: 1.66 KB

Versions: 10

Compression:

Stored size: 1.66 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
          data = unless identity
            connection.create_host(@zone.id, type, value, options)
          else
            options[:host_type] = type
            options[:data]      = value
            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

10 entries across 10 versions & 4 rubygems

Version Path
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/zerigo/models/dns/record.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/zerigo/models/dns/record.rb
fog-1.1.2 lib/fog/zerigo/models/dns/record.rb
fog_tractical-1.1.4 lib/fog/zerigo/models/dns/record.rb
fog_tractical-1.1.3 lib/fog/zerigo/models/dns/record.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/zerigo/models/dns/record.rb
fog-1.1.1 lib/fog/zerigo/models/dns/record.rb
fog-1.1.0 lib/fog/zerigo/models/dns/record.rb
brightbox-cli-0.15.0 lib/brightbox-cli/vendor/fog/lib/fog/zerigo/models/dns/record.rb
tag-fog-1.0.1 lib/fog/zerigo/models/dns/record.rb