Sha256: 6863266f087ad492e8c05a67a2e2e979564047bbc2c2347c50ec3a78a2f6c14a

Contents?: true

Size: 1.59 KB

Versions: 39

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

39 entries across 37 versions & 6 rubygems

Version Path
fog-rackspace-0.1.6 lib/fog/rackspace/models/dns/zone.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/dns/zone.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/dns/zone.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/models/dns/zone.rb
fog-rackspace-0.1.5 lib/fog/rackspace/models/dns/zone.rb
fog-rackspace-0.1.4 lib/fog/rackspace/models/dns/zone.rb
fog-rackspace-0.1.3 lib/fog/rackspace/models/dns/zone.rb
fog-rackspace-0.1.2 lib/fog/rackspace/models/dns/zone.rb
fog-rackspace-0.1.1 lib/fog/rackspace/models/dns/zone.rb
fog-rackspace-0.1.0 lib/fog/rackspace/models/dns/zone.rb
fog-1.37.0 lib/fog/rackspace/models/dns/zone.rb
fog-1.36.0 lib/fog/rackspace/models/dns/zone.rb
fog-1.35.0 lib/fog/rackspace/models/dns/zone.rb
fog-2.0.0.pre.0 lib/fog/rackspace/models/dns/zone.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/rackspace/models/dns/zone.rb
fog-1.34.0 lib/fog/rackspace/models/dns/zone.rb
fog-1.33.0 lib/fog/rackspace/models/dns/zone.rb
fog-1.32.0 lib/fog/rackspace/models/dns/zone.rb
fog-1.31.0 lib/fog/rackspace/models/dns/zone.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/rackspace/models/dns/zone.rb