module Fog
module Zerigo
class DNS
class Real
require 'fog/zerigo/parsers/dns/create_host'
# Create a new host in the specified zone
#
# ==== Parameters
# * zone_id<~Integer>
# * host_type<~String>
# * data<~String>
# * options<~Hash> - optional paramaters
# * hostname<~String> - Note: normally this is set/required!!
# * notes<~String>
# * priority<~Integer> - Note: required for MX or SRV records
# * ttl<~Integer>
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>
# * 'created-at'<~String>
# * 'data'<~String>
# * 'fqdn'<~String>
# * 'host-type'<~String>
# * 'hostname'<~String>
# * 'id'<~Integer>
# * 'notes'<~String>
# * 'priority'<~Integer>
# * 'ttl'<~Integer>
# * 'updated-at'<~String>
# * 'zone-id'<~String>
# * 'status'<~Integer> - 201 if successful
def create_host(zone_id, host_type, data, options = {})
optional_tags= ''
options.each { |option, value|
case option
when :hostname
optional_tags+= "#{value}"
when :notes
optional_tags+= "#{value}"
when :priority
optional_tags+= "#{value}"
when :ttl
optional_tags+= "#{value}"
end
}
request(
:body => %Q{#{host_type}#{data}#{optional_tags}},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Zerigo::DNS::CreateHost.new,
:path => "/api/1.1/zones/#{zone_id}/hosts.xml"
)
end
end
class Mock
def create_host( zone_id, host_type, data, options = {})
Fog::Mock.not_implemented
end
end
end
end
end