Sha256: a60ba7f64a702b5752945edf61dc8388c66f6f1b6381059a12ec4fad04dae59e

Contents?: true

Size: 1.6 KB

Versions: 19

Compression:

Stored size: 1.6 KB

Contents

require 'fog/core/model'

module Fog
  module DNS
    class Slicehost

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

        identity :id

        attribute :active
        attribute :value,       :aliases => ['ip', 'data']
        attribute :name
        attribute :description, :aliases => 'aux'
        attribute :ttl
        attribute :type,        :aliases => 'record_type'
        attribute :zone_id

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

        def active=(new_active)
          attributes[:active] = case new_active
          when false, 'N'
            false
          when true, 'Y'
            true
          end
        end

        def destroy
          requires :identity
          connection.delete_record(identity)
          true
        end

        def zone
          @zone
        end

        def save
          
          requires :name, :type, :value, :zone
          options = {}
          options[:active]  = active ? 'Y' : 'N'
          options[:aux]     = description if description
          options[:ttl]     = ttl if ttl
          if identity
            data = connection.update_record(identity, type, zone.id, name, value, options)
          else
            data = connection.create_record(type, zone.id, name, value, options)
          end
          merge_attributes(data.body)
          true
        end

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

      end

    end
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb
michiels-fog-1.3.1 lib/fog/slicehost/models/dns/record.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/slicehost/models/dns/record.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb
fog-1.3.1 lib/fog/slicehost/models/dns/record.rb
fog-1.3.0 lib/fog/slicehost/models/dns/record.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb
fog-1.2.0 lib/fog/slicehost/models/dns/record.rb
ktheory-fog-1.1.2 lib/fog/slicehost/models/dns/record.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/slicehost/models/dns/record.rb
fog-1.1.2 lib/fog/slicehost/models/dns/record.rb
fog_tractical-1.1.4 lib/fog/slicehost/models/dns/record.rb
fog_tractical-1.1.3 lib/fog/slicehost/models/dns/record.rb
fog-1.1.1 lib/fog/slicehost/models/dns/record.rb
fog-1.1.0 lib/fog/slicehost/models/dns/record.rb