mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
(DNSMadeEasy) added support for updating records via PUT
This commit is contained in:
parent
eddf6e4bab
commit
de10048edd
2 changed files with 20 additions and 14 deletions
|
@ -12,8 +12,7 @@ module Fog
|
|||
#
|
||||
# ==== Parameters
|
||||
# * domain<~String> Domain name.
|
||||
# * id<~Integer> Record id.
|
||||
# * data<~String> Record data
|
||||
# * record_id<~Integer> Record id.
|
||||
# * options<~Hash>
|
||||
# * name<~String> Record name.
|
||||
# * type<~String> Record type. Values: A, AAAA, CNAME, HTTPRED, MX, NS, PTR, SRV, TXT
|
||||
|
@ -42,14 +41,13 @@ module Fog
|
|||
# * redirectType<~String>
|
||||
# * hardLink<~Boolean>
|
||||
# * 'status'<~Integer> - 201 - record successfully created, 400 - record not valid, see errors in response content, 404 - domain not found
|
||||
def update_record(domain, id, options = {})
|
||||
delete_record(domain, id)
|
||||
|
||||
name = options.delete(:name) {|el|''}
|
||||
type = options.delete(:type)
|
||||
ip = options.delete(:ip)
|
||||
|
||||
create_record(domain, name, type, ip, options)
|
||||
def update_record(domain, record_id, options = {})
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => "PUT",
|
||||
:path => "/V1.2/domains/#{domain}/records/#{record_id}",
|
||||
:body => options.to_json
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -77,18 +77,26 @@ Shindo.tests('DNSMadeEasy::dns | DNS requests', ['dnsmadeeasy', 'dns']) do
|
|||
response.status == 201
|
||||
end
|
||||
|
||||
test("update a record - - check IP/TTL parameters") do
|
||||
test("update a record") do
|
||||
pending if Fog.mocking?
|
||||
|
||||
domain = @domain["name"]
|
||||
record_id = @record["id"]
|
||||
options = {:name => '', :type => 'A', :data => "2.3.4.5", :ttl => 600}
|
||||
result = false
|
||||
|
||||
response = DNSMadeEasy[:dns].update_record(domain, record_id, options)
|
||||
@record = response.body
|
||||
|
||||
if response.status == 201 && @record['data'] == '2.3.4.5' && @record['ttl'] == 600
|
||||
response.status == 200
|
||||
end
|
||||
|
||||
test("get record #{@record['id']} - check ip/ttl") do
|
||||
pending if Fog.mocking?
|
||||
|
||||
response = DNSMadeEasy[:dns].get_record(@domain["name"], @record['id'])
|
||||
record = response.body
|
||||
result = false
|
||||
|
||||
if response.status == 200 && record['data'] == '2.3.4.5' && record['ttl'] == 600
|
||||
result = true
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue