From a0fe9ca2cc2fc178baae1fc272bb9c1e4cfeec92 Mon Sep 17 00:00:00 2001 From: Tei Date: Tue, 4 Jul 2017 23:19:21 +0900 Subject: [PATCH] add get_nameserver_config to Lumberg::Whm::Dns. (#113) add get_nameserver_config to Lumberg::Whm::Dns. Bump version to 4.1.0 --- lib/lumberg/version.rb | 2 +- lib/lumberg/whm/dns.rb | 8 +++++ .../whm/dns/get_nameserver_config.yml | 29 +++++++++++++++++++ spec/whm/dns_spec.rb | 13 +++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 spec/vcr_cassettes/whm/dns/get_nameserver_config.yml diff --git a/lib/lumberg/version.rb b/lib/lumberg/version.rb index 3b87cac4..86a581fa 100644 --- a/lib/lumberg/version.rb +++ b/lib/lumberg/version.rb @@ -1,3 +1,3 @@ module Lumberg - VERSION = '4.0.0' + VERSION = '4.1.0' end diff --git a/lib/lumberg/whm/dns.rb b/lib/lumberg/whm/dns.rb index 71baeba1..ef7251f6 100644 --- a/lib/lumberg/whm/dns.rb +++ b/lib/lumberg/whm/dns.rb @@ -52,6 +52,14 @@ def get_zone_record(options = {}) server.perform_request('getzonerecord', options) end + # Retrieves the default nameservers + # + # ==== Required + # * :"api.version".to_sym - PENDING + def get_nameserver_config(options = {}) + server.perform_request('get_nameserver_config', options.merge(response_key: 'data')) + end + # Displays the DNS zone configuration for a specific domain # # ==== Required diff --git a/spec/vcr_cassettes/whm/dns/get_nameserver_config.yml b/spec/vcr_cassettes/whm/dns/get_nameserver_config.yml new file mode 100644 index 00000000..2aa94a56 --- /dev/null +++ b/spec/vcr_cassettes/whm/dns/get_nameserver_config.yml @@ -0,0 +1,29 @@ +--- +http_interactions: +- request: + method: get + uri: https://myhost.com:2087/json-api/get_nameserver_config?api.version=1 + body: + encoding: US-ASCII + string: '' + headers: + Authorization: + - WHM root:iscool + response: + status: + code: 200 + message: OK + headers: + Server: + - cpsrvd/11.28.64 + Transfer-Encoding: + - chunked + Content-Type: + - text/plain + body: + encoding: UTF-8 + string: ! '{"data":{"nameservers": ["ns1.example.com", "ns2.example.com"]},"metadata":{"result":1,"reason":"OK","version":1,"command":"get_nameserver_config"}}' + http_version: '1.1' + recorded_at: Tue, 04 Jul 2017 11:32:20 GMT +recorded_with: VCR 2.9.3 +... diff --git a/spec/whm/dns_spec.rb b/spec/whm/dns_spec.rb index 03cb5577..e864e57f 100644 --- a/spec/whm/dns_spec.rb +++ b/spec/whm/dns_spec.rb @@ -83,6 +83,19 @@ module Lumberg end end + + describe "#get_nameserver_config" do + use_vcr_cassette "whm/dns/get_nameserver_config" + + it "returns the nameservers" do + result = @dns.get_nameserver_config("api.version".to_sym => 1) + nameservers = result[:params][:nameservers] + nameservers.size.should == 2 + nameservers.should be_include('ns1.example.com') + nameservers.should be_include('ns2.example.com') + end + end + describe "#dumpzone" do use_vcr_cassette "whm/dns/dumpzone"