2011-06-16 17:51:13 -04:00
|
|
|
require 'fog/core/model'
|
2011-08-24 20:52:11 -04:00
|
|
|
require 'fog/dynect/models/dns/records'
|
2011-06-16 17:51:13 -04:00
|
|
|
|
|
|
|
module Fog
|
2011-07-14 20:22:43 -04:00
|
|
|
module DNS
|
|
|
|
class Dynect
|
2011-06-16 17:51:13 -04:00
|
|
|
|
|
|
|
class Zone < Fog::Model
|
|
|
|
|
2011-07-14 20:22:43 -04:00
|
|
|
identity :domain
|
|
|
|
|
|
|
|
attribute :domain, :aliases => 'zone'
|
|
|
|
attribute :email, :aliases => 'rname'
|
2011-06-17 06:51:37 -04:00
|
|
|
attribute :serial
|
|
|
|
attribute :serial_style
|
2011-07-14 20:22:43 -04:00
|
|
|
attribute :ttl
|
|
|
|
attribute :type, :aliases => 'zone_type'
|
|
|
|
|
|
|
|
def initialize(attributes={})
|
|
|
|
self.ttl ||= 3600
|
|
|
|
super
|
|
|
|
end
|
2011-06-16 17:51:13 -04:00
|
|
|
|
|
|
|
def destroy
|
2011-07-14 20:22:43 -04:00
|
|
|
requires :domain
|
|
|
|
connection.delete_zone(domain)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
undef_method :domain=
|
|
|
|
def domain=(new_domain)
|
|
|
|
attributes[:domain] = new_domain.split('/').last
|
|
|
|
end
|
|
|
|
|
|
|
|
def publish
|
|
|
|
requires :identity
|
|
|
|
data = connection.put_zone(identity, :publish => true)
|
|
|
|
true
|
2011-06-16 17:51:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def records
|
2011-07-14 20:22:43 -04:00
|
|
|
@records ||= Fog::DNS::Dynect::Records.new(:zone => self, :connection => connection)
|
2011-06-16 17:51:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def nameservers
|
2011-06-19 04:09:58 -04:00
|
|
|
raise 'nameservers Not Implemented'
|
2011-06-16 17:51:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2011-07-14 20:22:43 -04:00
|
|
|
requires :domain, :email, :ttl
|
|
|
|
data = connection.post_zone(email, ttl, domain).body['data']
|
|
|
|
merge_attributes(data)
|
|
|
|
true
|
2011-06-16 17:51:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|