module Fog
module Slicehost
class DNS
class Real
require 'fog/dns/parsers/slicehost/create_record'
# Create a new record in a DNS zone - or update an existing one
# ==== Parameters
# * record_type<~String> - type of DNS record to create (A, CNAME, etc)
# * zone_id<~Integer> - ID of the zone to update
# * name<~String> - host name this DNS record is for
# * data<~String> - data for the DNS record (ie for an A record, the IP address)
# * options<~Hash> - extra parameters that are not mandatory
# * ttl<~Integer> - time to live in seconds
# * active<~String> - whether this record is active or not ('Y' or 'N')
# * aux<~String> - extra data required by the record
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'name'<~String> - as above
# * 'id'<~Integer> - Id of zone/domain - used in future API calls for this zone
# * 'ttl'<~Integer> - as above
# * 'data'<~String> - as above
# * 'active'<~String> - as above
# * 'aux'<~String> - as above
def create_record(record_type, zone_id, name, data, options = {})
optional_tags= ''
options.each { |option, value|
case option
when :ttl
optional_tags+= "#{value}"
when :active
optional_tags+= "#{value}"
when :aux
optional_tags+= "#{value}"
end
}
request(
:body => %Q{#{record_type}#{zone_id}#{name}#{data}#{optional_tags}},
:expects => 201,
:method => 'POST',
:parser => Fog::Parsers::Slicehost::DNS::CreateRecord.new,
:path => 'records.xml'
)
end
end
end
end
end