Sha256: c6f579a3699af615211f68ad423dd2d22b422a08c5151b29e3c30aa5a9d058c0

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

require 'fog/core/model'
require 'fog/dns/models/slicehost/records'

module Fog
  module DNS
    class Slicehost

      class Zone < Fog::Model

        identity :id

        attribute :active
        attribute :domain, :aliases => 'origin'
        attribute :ttl

        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_zone(identity)
          true
        end

        def records
          @records ||= begin
            Fog::DNS::Slicehost::Records.new(
              :zone       => self,
              :connection => connection
            )
          end
        end

        def nameservers
          [
            'ns1.slicehost.net',
            'ns2.slicehost.net',
            'ns3.slicehost.net'
          ]
        end

        def save
          raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
          requires :active, :domain, :ttl
          options = {}
          options[:active]  = active ? 'Y' : 'N'
          options[:ttl]     = ttl
          data = connection.create_zone(domain, options)
          merge_attributes(data.body)
          true
        end

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
brightbox-cli-0.13.1 lib/brightbox-cli/vendor/fog/lib/fog/dns/models/slicehost/zone.rb
brightbox-cli-0.13.0 lib/brightbox-cli/vendor/fog/lib/fog/dns/models/slicehost/zone.rb
fog-0.11.0 lib/fog/dns/models/slicehost/zone.rb
fog-0.10.0 lib/fog/dns/models/slicehost/zone.rb
fog4encbs-0.9.0.1 lib/fog/dns/models/slicehost/zone.rb
fog4encbs-0.9.0 lib/fog/dns/models/slicehost/zone.rb
fog-0.9.0 lib/fog/dns/models/slicehost/zone.rb