From 5cb43829c0edeb7885f8466597b484f8fc37fbf7 Mon Sep 17 00:00:00 2001 From: Tameem Iftikhar Date: Tue, 27 Sep 2016 11:26:14 -0400 Subject: [PATCH] F rage4 bulk update endpoint (#3917) Add new api endpoint to fog for bulk updates of priority in rage4 class --- lib/fog/rage4/dns.rb | 1 + .../rage4/requests/dns/bulk_update_records.rb | 38 +++++++++++++++++++ tests/rage4/requests/dns/dns_tests.rb | 12 ++++++ 3 files changed, 51 insertions(+) create mode 100644 lib/fog/rage4/requests/dns/bulk_update_records.rb diff --git a/lib/fog/rage4/dns.rb b/lib/fog/rage4/dns.rb index 86352b8ba..47852422c 100644 --- a/lib/fog/rage4/dns.rb +++ b/lib/fog/rage4/dns.rb @@ -27,6 +27,7 @@ module Fog request :list_geo_regions request :create_record request :update_record + request :bulk_update_records request :list_records request :delete_record request :set_record_failover diff --git a/lib/fog/rage4/requests/dns/bulk_update_records.rb b/lib/fog/rage4/requests/dns/bulk_update_records.rb new file mode 100644 index 000000000..cded10f99 --- /dev/null +++ b/lib/fog/rage4/requests/dns/bulk_update_records.rb @@ -0,0 +1,38 @@ +module Fog + module DNS + class Rage4 + class Real + # Updates existing records in bulk + # ==== Parameters + # * zone_id <~Integer> Need to specify the zone id + # * options <~Hash> Options should contain the body for the post + # in the following format. + # data = [{:id=>, :priority=>2}, {:id=>, :priority=>2}] + # options => { :body => data.to_json } + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'status'<~Boolean> + # * 'id'<~Integer> + # * 'error'<~String> + +# https://secure.rage4.com//rapi/SetRecordState// + + def bulk_update_records(zone_id, options = {}) + path = "/rapi/SetRecordState/#{zone_id}" + body = options[:body] if options[:body].present? + + request( + :expects => 200, + :method => 'POST', + :body => body, + :path => path, + :headers => { + 'Content-Type' => "application/json; charset=UTF-8", + }, + ) + end + end + end + end +end diff --git a/tests/rage4/requests/dns/dns_tests.rb b/tests/rage4/requests/dns/dns_tests.rb index 7d8f717e6..b884f6f94 100644 --- a/tests/rage4/requests/dns/dns_tests.rb +++ b/tests/rage4/requests/dns/dns_tests.rb @@ -107,6 +107,18 @@ Shindo.tests('Fog::DNS[:rage4] | DNS requests', ['rage4', 'dns']) do end + test("bulk_update_records") do + pending if Fog.mocking? + + data = { :id => @record_id, :priority => 1 } + response = Fog::DNS[:rage4].bulk_update_records(@zone_id, { :body => data.to_json } ) + + returns(200) { response.status } + returns(true) {response.body['status']} + returns(@domain_id) {response.body['id']} + returns("") {response.body['error'] } + end + test("show_current_usage") do pending if Fog.mocking?