1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/rackspace/models/dns/zone.rb

68 lines
1.6 KiB
Ruby
Raw Normal View History

2011-08-27 22:06:46 -04:00
require 'fog/core/model'
require 'fog/rackspace/models/dns/records'
2011-08-27 22:06:46 -04:00
module Fog
module DNS
class Rackspace
class Zone < Fog::Model
2011-08-28 15:41:48 -04:00
include Fog::DNS::Rackspace::Callback
2011-08-27 22:06:46 -04:00
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
2011-08-28 10:53:43 -04:00
response = connection.remove_domain(identity)
2011-08-27 22:06:46 -04:00
wait_for_job response.body['jobId'], Fog.timeout
true
end
2011-08-28 15:41:48 -04:00
def records
@records ||= begin
Fog::DNS::Rackspace::Records.new(
:zone => self,
:connection => connection
)
end
end
2011-08-27 22:06:46 -04:00
def save
if identity
update
else
create
end
true
end
private
def create
2011-08-28 10:53:43 -04:00
requires :domain, :email
2011-08-27 22:06:46 -04:00
data = { :name => domain, :email => email }
response = connection.create_domains([data])
response = wait_for_job response.body['jobId']
merge_attributes(response.body['request']['domains'].select {|domain| domain['name'] == self.domain})
2011-08-27 22:06:46 -04:00
end
def update
requires :ttl, :email
response = connection.modify_domain(identity, { :ttl => ttl, :comment => comment, :email => email})
wait_for_job response.body['jobId']
end
end
end
end
end