1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/hp/requests/dns/create_domain.rb

66 lines
2.1 KiB
Ruby
Raw Normal View History

2013-05-03 14:31:08 -04:00
module Fog
module HP
class DNS
# Create a new DNS domain
#
# ==== Parameters
# * 'name'<~String> - Name of the domain
# * 'email'<~String> - Email for the domain
# * options<~Hash>:
# * 'description'<~String> - Description for the domain
# * 'ttl'<~String> - TTL for the domain
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'id'<~String> - UUID of the domain
# * 'name'<~String> - Name of the domain
# * 'description'<~String> - Description for the domain
# * 'ttl'<~Integer> - TTL for the domain
# * 'email'<~String> - Email for the domain
# * 'serial'<~Integer> - Serial number for the domain
# * 'created_at'<~String> - created date time stamp
2013-05-03 14:31:08 -04:00
class Real
def create_domain(name, email, options={})
data = {
:name => name,
:email => email
}
l_options = [:description, :ttl]
l_options.select{|o| options[o]}.each do |key|
data[key] = options[key]
end
2013-05-03 14:31:08 -04:00
request(
:body => Fog::JSON.encode(data),
:expects => 200,
:method => 'POST',
:path => 'domains'
)
end
end
class Mock
def create_domain(name, email, options={})
2013-05-03 14:31:08 -04:00
response = Excon::Response.new
response.status = 200
data = {
'id' => Fog::HP::Mock.uuid.to_s,
'name' => name || 'domain1.com.',
'email' => email || 'nsadmin@example.org',
'description' => options[:description] || 'desc domain1.com.',
'ttl' => options[:ttl] || 3600,
'serial' => Fog::Mock.random_numbers(10).to_i,
'created_at' => '2012-01-01T13:32:20Z'
2013-05-03 14:31:08 -04:00
}
self.data[:domains][data['id']] = data
2013-05-03 14:31:08 -04:00
response.body = data
response
end
end
end
end
end