dnsmadeeasy-rest-api 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dnsmadeeasy-rest-api.gemspec +1 -1
- data/lib/dnsmadeeasy-rest-api.rb +46 -0
- data/spec/lib/dnsmadeeasyapi-rest-api_spec.rb +86 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95e48aae6489a7c19d5eee16d0ca0c95c01aa008
|
4
|
+
data.tar.gz: 996ecf8de372b80ee847ce9dab8b1b399acc4c98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2409092505b38aeed75b5ccff9a73aa27eefcc7e5b9ddadcf556c02f54424a742b5b3a2a6a67e06a0c41ada3dcc2291cea2c8383ae56386e54954789ac7e349
|
7
|
+
data.tar.gz: 0c8878d7d29658379fbce1f234016c16948e10fb342f411d5f7b252c4892d87321dd842bf27596b588a8fd545ea1d0c540091cfa1d06230d250d5538f26057ab
|
data/lib/dnsmadeeasy-rest-api.rb
CHANGED
@@ -164,6 +164,52 @@ class DnsMadeEasy
|
|
164
164
|
put "/dns/managed/#{get_id_by_domain(domain)}/records/updateMulti/", body
|
165
165
|
end
|
166
166
|
|
167
|
+
# -----------------------------------
|
168
|
+
# ------------- FAILOVER -------------
|
169
|
+
# -----------------------------------
|
170
|
+
|
171
|
+
def get_failover_config(record_id)
|
172
|
+
get "/monitor/#{record_id}"
|
173
|
+
end
|
174
|
+
|
175
|
+
def update_failover_config(record_id, ips, desc, protocol='TCP', options = {})
|
176
|
+
protocolIds = {
|
177
|
+
'TCP' => 1,
|
178
|
+
'UDP' => 2,
|
179
|
+
'HTTP' => 3,
|
180
|
+
'DNS' => 4,
|
181
|
+
'SMTP' => 5,
|
182
|
+
'HTTPS' => 6
|
183
|
+
}
|
184
|
+
|
185
|
+
body = {
|
186
|
+
'protocolId' => protocolIds[protocol],
|
187
|
+
'port' => 80,
|
188
|
+
'systemDescription' => desc,
|
189
|
+
'sensitivity' => 5,
|
190
|
+
'failover' => true,
|
191
|
+
'monitor' => false,
|
192
|
+
'maxEmails' => 1,
|
193
|
+
'autoFailover' => false,
|
194
|
+
'source' => 1
|
195
|
+
}
|
196
|
+
|
197
|
+
body = body.merge(options)
|
198
|
+
|
199
|
+
ip_config = {}
|
200
|
+
(0.. ips.length-1).each do |idx|
|
201
|
+
ip_config["ip#{idx+1}"] = ips[idx]
|
202
|
+
end
|
203
|
+
|
204
|
+
body = body.merge(ip_config)
|
205
|
+
|
206
|
+
put "/monitor/#{record_id}", body
|
207
|
+
end
|
208
|
+
|
209
|
+
def disable_failover(record_id)
|
210
|
+
put "/monitor/#{record_id}", { 'failover' => false, 'monitor' => false }
|
211
|
+
end
|
212
|
+
|
167
213
|
private
|
168
214
|
|
169
215
|
def get(path)
|
@@ -334,6 +334,92 @@ describe DnsMadeEasy do
|
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
337
|
+
describe '#get_failover_config' do
|
338
|
+
let(:response) do
|
339
|
+
'{
|
340
|
+
"port":80,
|
341
|
+
"source":1,
|
342
|
+
"failover":true,
|
343
|
+
"ip1":"1.1.1.1",
|
344
|
+
"ip2":"2.2.2.2",
|
345
|
+
"protocolId":3,
|
346
|
+
"sourceId":104620,
|
347
|
+
"monitor":true,
|
348
|
+
"sensitivity":5,
|
349
|
+
"systemDescription":"Test",
|
350
|
+
"maxEmails":1,
|
351
|
+
"ip1Failed":0,
|
352
|
+
"ip2Failed":0,
|
353
|
+
"ip3Failed":0,
|
354
|
+
"ip4Failed":0,
|
355
|
+
"ip5Failed":0,
|
356
|
+
"recordId":21,
|
357
|
+
"autoFailover":false
|
358
|
+
}'
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'gets the failover config for a failover enabled record' do
|
362
|
+
stub_request(:get, "https://api.dnsmadeeasy.com/V2.0/monitor/21").
|
363
|
+
with(headers: request_headers).
|
364
|
+
to_return(status: 200, body: response, headers: {})
|
365
|
+
|
366
|
+
expect(subject.get_failover_config(21)).to eq({
|
367
|
+
'port' => 80,
|
368
|
+
'source' => 1,
|
369
|
+
'failover' => true,
|
370
|
+
'ip1' => '1.1.1.1',
|
371
|
+
'ip2' => '2.2.2.2',
|
372
|
+
'protocolId' => 3,
|
373
|
+
'sourceId' => 104620,
|
374
|
+
'monitor' => true,
|
375
|
+
'sensitivity' => 5,
|
376
|
+
'systemDescription' => 'Test',
|
377
|
+
'maxEmails' => 1,
|
378
|
+
'ip1Failed' => 0,
|
379
|
+
'ip2Failed' => 0,
|
380
|
+
'ip3Failed' => 0,
|
381
|
+
'ip4Failed' => 0,
|
382
|
+
'ip5Failed' => 0,
|
383
|
+
'recordId' => 21,
|
384
|
+
'autoFailover' => false
|
385
|
+
})
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
describe '#disable_failover' do
|
390
|
+
let(:response) { "{}" }
|
391
|
+
let(:body) { '{"failover":false,"monitor":false}' }
|
392
|
+
|
393
|
+
it 'disables the failover config for a failover enabled record' do
|
394
|
+
stub_request(:put, "https://api.dnsmadeeasy.com/V2.0/monitor/21").
|
395
|
+
with(headers: request_headers, body: body).
|
396
|
+
to_return(status: 200, body: response, headers: {})
|
397
|
+
|
398
|
+
expect(subject.disable_failover(21)).to eq({})
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
describe '#update_failover_config' do
|
403
|
+
let(:response) { "{}" }
|
404
|
+
let(:body) do
|
405
|
+
'{"protocolId":3,"port":80,"systemDescription":"Test","sensitivity":3,"failover":true,"monitor":false,"maxEmails":1,"autoFailover":false,"source":1,"httpFqdn":"example.com","httpFile":"/magic","httpQueryString":"more-magic","ip1":"1.1.1.1","ip2":"2.2.2.2"}'
|
406
|
+
end
|
407
|
+
|
408
|
+
it "updates the failover config" do
|
409
|
+
stub_request(:put, "https://api.dnsmadeeasy.com/V2.0/monitor/21").
|
410
|
+
with(headers: request_headers, body: body).
|
411
|
+
to_return(status: 200, body: response, headers: {})
|
412
|
+
|
413
|
+
expect(subject.update_failover_config(21, ['1.1.1.1', '2.2.2.2'], 'Test', 'HTTP', {
|
414
|
+
'port' => 80,
|
415
|
+
'httpFqdn' => 'example.com',
|
416
|
+
'httpFile' => '/magic',
|
417
|
+
'httpQueryString' => 'more-magic',
|
418
|
+
'sensitivity' => 3
|
419
|
+
})).to eq({})
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
337
423
|
describe "#request" do
|
338
424
|
before do
|
339
425
|
stub_request(:get, "https://api.dnsmadeeasy.com/V2.0/some_path").
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dnsmadeeasy-rest-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnoud Vermeer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|