1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Added the remaining crud operations for zones

This commit is contained in:
ggoodale 2011-02-16 23:27:23 -08:00
parent 356b11af38
commit bc85596cb4
5 changed files with 124 additions and 3 deletions

View file

@ -15,6 +15,9 @@ module Fog
request :create_record
request :update_record
request :delete_record
request :create_zone
request :update_zone
request :delete_zone
request :get_record
request :get_records
request :get_zone

View file

@ -43,12 +43,20 @@ module Fog
]
end
def save
raise Fog::Errors::Error.new('Not implemented')
def destroy
requires :identity
connection.delete_zone(identity)
true
end
def save
requires :name, :ttl
options = attributes.inject({}) {|h, kv| h[kv[0]] = kv[1]; h}
data = identity.nil? ? connection.create_zone(options) : connection.update_zone(identity, options)
merge_attributes(data.body)
true
end
end
end
end
end

View file

@ -0,0 +1,49 @@
module Fog
module Bluebox
class DNS
class Real
# Create a new DNS zone
# ==== Parameters
# * 'name'<~String> - The name of the zone
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds
# * 'retry'<~Integer> - Retry interval for the domain, in seconds
# * 'refresh'<~Integer> - Refresh interval for the zone
# * 'minimum'<~Integer> - Minimum refresh interval for the zone
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'name'<~String> - The name of the zone
# * 'serial'<~Integer> - Serial number of the zone
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds
# * 'retry'<~Integer> - Retry interval for the domain, in seconds
# * 'record-count'<~Integer> - Number of records in the zone
# * 'id'<~String> - Id for the zone
# * 'refresh'<~Integer> - Refresh interval for the zone
# * 'minimum'<~Integer> - Minimum refresh interval for the zone
def create_zone(options)
body = %Q{<?xml version="1.0" encoding="UTF-8"?><domain><name>#{options[:name]}</name><ttl>#{options[:ttl]}</ttl>}
body += %Q{<retry>#{options[:retry]}</retry>} if options[:retry]
body += %Q{<refresh>#{options[:retry]}</refresh>} if options[:refresh]
body += %Q{<minimum>#{options[:minimum]}</minimum>} if options[:minimum]
body += %Q{</domain>}
request(
:body => body,
:expects => 202,
:method => 'POST',
:path => "/api/domains.xml"
)
end
end
class Mock
def create_zone(options)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,31 @@
module Fog
module Bluebox
class DNS
class Real
# Delete a zone from DNS
# ==== Parameters
# * zone_id<~Integer> - Id of zone to delete
#
# ==== Returns
# * response<~Excon::Response>: - HTTP status code will be result
def delete_zone(zone_id)
request(
:expects => 200,
:method => 'DELETE',
:path => "/api/domains/#{zone_id}.xml"
)
end
end
class Mock
def delete_zone(zone_id)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -0,0 +1,30 @@
module Fog
module Bluebox
class DNS
class Real
# Updates an existing DNS zone
def update_zone(zone_id, options)
body = %Q{<?xml version="1.0" encoding="UTF-8"?><domain>}
options.each {|k,v| body += "<#{k}>#{v}</#{k}>"}
body += "</domain>"
request(
:body => body,
:expects => 202,
:method => 'PUT',
:path => "/api/domains/#{zone_id}.xml"
)
end
end
class Mock
def create_record(zone_id, type, domain, content)
Fog::Mock.not_implemented
end
end
end
end
end