mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
create_record request
This commit is contained in:
parent
2006ff3259
commit
6c8fd4ec8a
3 changed files with 67 additions and 16 deletions
|
@ -10,6 +10,7 @@ module Fog
|
|||
request :create_domain
|
||||
request :get_domain
|
||||
request :delete_domain
|
||||
request :create_record
|
||||
|
||||
class Mock
|
||||
# TODO
|
||||
|
|
46
lib/fog/dns/requests/dnsimple/create_record.rb
Normal file
46
lib/fog/dns/requests/dnsimple/create_record.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
module Fog
|
||||
module DNSimple
|
||||
class DNS
|
||||
class Real
|
||||
|
||||
# Create a new host in the specified zone
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain<~String>
|
||||
# * name<~String>
|
||||
# * type<~String>
|
||||
# * content<~String>
|
||||
# * options<~Hash> - optional
|
||||
# * priority<~Integer>
|
||||
# * ttl<~Integer>
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>
|
||||
# * name<~String>
|
||||
# * ttl<~Integer>
|
||||
# * created_at<~String>
|
||||
# * special_type<~String>
|
||||
# * updated_at<~String>
|
||||
# * domain_id<~Integer>
|
||||
# * id<~Integer>
|
||||
# * content<~String>
|
||||
# * record_type<~String>
|
||||
# * prio<~Integer>
|
||||
def create_record(domain, name, type, content, options = {})
|
||||
|
||||
body = {
|
||||
"record" => {
|
||||
"name" => name,
|
||||
"record_type" => type,
|
||||
"content" => content } }
|
||||
|
||||
request( :body => body.to_json,
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:path => "/domains/#{domain}/records" )
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,8 +2,6 @@ Shindo.tests('DNSimple::dns | DNS requests', ['dnsimple', 'dns']) do
|
|||
|
||||
@domain = ''
|
||||
@domain_count = 0
|
||||
@new_domains = []
|
||||
@new_records = []
|
||||
|
||||
def generate_unique_domain( with_trailing_dot = false)
|
||||
#get time (with 1/100th of sec accuracy)
|
||||
|
@ -36,35 +34,41 @@ Shindo.tests('DNSimple::dns | DNS requests', ['dnsimple', 'dns']) do
|
|||
domain = generate_unique_domain
|
||||
response = DNSimple[:dns].create_domain(domain)
|
||||
if response.status == 201
|
||||
@new_domains << response.body
|
||||
@domain = response.body["domain"]
|
||||
end
|
||||
|
||||
response.status == 201
|
||||
end
|
||||
|
||||
test('get domain by id') do
|
||||
test("get domain by id") do
|
||||
pending if Fog.mocking?
|
||||
|
||||
id = @new_domains.first["domain"]["id"]
|
||||
response = DNSimple[:dns].get_domain(id)
|
||||
|
||||
response = DNSimple[:dns].get_domain(@domain["id"])
|
||||
response.status == 200
|
||||
end
|
||||
|
||||
test("delete #{@new_domains.count} domains created") do
|
||||
test("create an A resource record") do
|
||||
pending if Fog.mocking?
|
||||
|
||||
result = true
|
||||
domain = @domain["name"]
|
||||
name = "www"
|
||||
type = "A"
|
||||
content = "1.2.3.4"
|
||||
response = DNSimple[:dns].create_record(domain, name, type, content)
|
||||
|
||||
@new_domains.each do |domain|
|
||||
name = domain["domain"]["name"]
|
||||
response = DNSimple[:dns].delete_domain(name)
|
||||
if response.status != 200
|
||||
result= false;
|
||||
end
|
||||
if response.status == 201
|
||||
@record = response.body
|
||||
end
|
||||
|
||||
result
|
||||
response.status == 201
|
||||
|
||||
end
|
||||
|
||||
test("delete domain") do
|
||||
pending if Fog.mocking?
|
||||
|
||||
response = DNSimple[:dns].delete_domain(@domain["name"])
|
||||
response.status == 200
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue