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

Slight tweaks to param names; added update support

This commit is contained in:
ggoodale 2011-01-24 18:35:51 -08:00
parent c823ab8f7f
commit 181a7849dd
4 changed files with 47 additions and 8 deletions

View file

@ -13,6 +13,7 @@ module Fog
request_path 'fog/dns/requests/bluebox'
request :create_record
request :update_record
request :delete_record
request :get_record
request :get_records
@ -59,9 +60,9 @@ module Fog
@bluebox_customer_id = options[:bluebox_customer_id]
@bluebox_api_key = options[:bluebox_api_key]
@host = options[:host] || "boxpanel.bluebox.net"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@host = options[:bluebox_host] || "boxpanel.bluebox.net"
@port = options[:bluebox_port] || 443
@scheme = options[:bluebox_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
end

View file

@ -29,8 +29,12 @@ module Fog
end
def save
requires :zone, :type, :domain, :content
data = connection.create_record(@zone.id, type, domain, content)
requires :zone, :type, :name, :content
data = unless identity
connection.create_record(@zone.id, type, name, content)
else
connection.update_record(@zone.id, identity, {:type => type, :name => name, :content => content})
end
merge_attributes(data.body)
true
end

View file

@ -17,9 +17,9 @@ module Fog
# * 'data'<~String> - as above
# * 'active'<~String> - as above
# * 'aux'<~String> - as above
def create_record(zone_id, type, domain, content)
def create_record(zone_id, type, name, content)
request(
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><record><type>#{type}</type><name>#{domain}</name><content>#{content}</content></record>},
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><record><type>#{type}</type><name>#{name}</name><content>#{content}</content></record>},
:expects => 202,
:method => 'POST',
:path => "/api/domains/#{zone_id}/records.xml"
@ -30,7 +30,7 @@ module Fog
class Mock
def create_record(zone_id, type, domain, content)
def create_record(zone_id, type, name, content)
Fog::Mock.not_implemented
end

View file

@ -0,0 +1,34 @@
module Fog
module Bluebox
class DNS
class Real
# Updates an existing record in a DNS zone
# ==== Parameters
# * type<~String> - type of DNS record (A, CNAME, etc)
# * name<~String> - host name for this DNS record
# * content<~String> - data for the DNS record (ie for an A record, the IP address)
def update_record(zone_id, record_id, options)
body = %Q{<?xml version="1.0" encoding="UTF-8"?><record>}
options.each {|k,v| body += "<#{k}>#{v}</#{k}>"}
body += "</record>"
request(
:body => body,
:expects => 202,
:method => 'PUT',
:path => "/api/domains/#{zone_id}/records/#{record_id}.xml"
)
end
end
class Mock
def create_record(zone_id, type, domain, content)
Fog::Mock.not_implemented
end
end
end
end
end