Sha256: 3a878100852eadce426099d113a26a3b590cc7898c91d4ede41dec3910f4a025

Contents?: true

Size: 1.59 KB

Versions: 65

Compression:

Stored size: 1.59 KB

Contents

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

module Fog
  module DNS
    class Rackspace

      class Zone < Fog::Model
        include Fog::DNS::Rackspace::Callback

        identity :id

        attribute :email,       :aliases => 'emailAddress'
        attribute :domain,      :aliases => 'name'
        attribute :created
        attribute :updated
        attribute :account_id,  :aliases => 'accountId'
        attribute :ttl
        attribute :nameservers
        attribute :comment

        def destroy
          response = service.remove_domain(identity)
          wait_for_job response.body['jobId'], Fog.timeout
          true
        end

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

        def save
          if persisted?
            update
          else
            create
          end
          true
        end

        private

        def create
          requires :domain, :email

          data = { :name => domain, :email => email }
          response = service.create_domains([data])

          response = wait_for_job response.body['jobId']
          merge_attributes(response.body['response']['domains'].select {|domain| domain['name'] == self.domain}.first)
        end

        def update
          requires :ttl, :email

          response = service.modify_domain(identity, { :ttl => ttl, :comment => comment, :email => email})
          wait_for_job response.body['jobId']
        end
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 6 rubygems

Version Path
fog-1.22.0 lib/fog/rackspace/models/dns/zone.rb
fog-1.21.0 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/rackspace/models/dns/zone.rb
fog-1.20.0 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/rackspace/models/dns/zone.rb
fog-1.19.0 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/rackspace/models/dns/zone.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/rackspace/models/dns/zone.rb