enfcli 4.2.2.pre.alpha → 5.0.0.pre.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/lib/enfapi.rb +36 -168
- data/lib/enfapi/dns.rb +95 -0
- data/lib/enfapi/firewall.rb +37 -0
- data/lib/enfapi/user.rb +75 -0
- data/lib/enfcli.rb +51 -24
- data/lib/enfcli/commands/user.rb +198 -153
- data/lib/enfcli/commands/xcr.rb +67 -48
- data/lib/enfcli/commands/xdns.rb +17 -10
- data/lib/enfcli/commands/xfw.rb +1 -1
- data/lib/enfcli/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29f4309503935f6931b068e80a850488b2f8833474734c05e8455a04f84293e0
|
|
4
|
+
data.tar.gz: 2488271b45ee7c7e5b96cc95546d2f625fb1c503d9ad6720f62649073d4a1874
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 033366cb4db237f61526ddf357bbdfd57d60b482398d21eee798413b5afc91b51a6baae60526b957f07a80f01dea5b47372d72193d40b0af20a98fb88de1cd51
|
|
7
|
+
data.tar.gz: e7bd3d1c7da7a861a89f242bd5a2d2f898e5e5b4f848c2412fa9a1b5acb7ac73fb5c679979e80b9b7d1e81ba87de761f157141d49eda2d6c3c5d55b1b315c249
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
enfcli (
|
|
4
|
+
enfcli (5.0.0.pre.alpha)
|
|
5
5
|
clipboard
|
|
6
6
|
ffi
|
|
7
7
|
readline
|
|
@@ -15,7 +15,7 @@ GEM
|
|
|
15
15
|
addressable (2.7.0)
|
|
16
16
|
public_suffix (>= 2.0.2, < 5.0)
|
|
17
17
|
bump (0.8.0)
|
|
18
|
-
clipboard (1.3.
|
|
18
|
+
clipboard (1.3.3)
|
|
19
19
|
crack (0.4.3)
|
|
20
20
|
safe_yaml (~> 1.0.0)
|
|
21
21
|
diff-lcs (1.3)
|
|
@@ -29,16 +29,16 @@ GEM
|
|
|
29
29
|
http-accept (1.7.0)
|
|
30
30
|
http-cookie (1.0.3)
|
|
31
31
|
domain_name (~> 0.5)
|
|
32
|
-
io-console (0.5.
|
|
32
|
+
io-console (0.5.5)
|
|
33
33
|
mime-types (3.3.1)
|
|
34
34
|
mime-types-data (~> 3.2015)
|
|
35
|
-
mime-types-data (3.
|
|
35
|
+
mime-types-data (3.2019.1009)
|
|
36
36
|
netrc (0.11.0)
|
|
37
37
|
public_suffix (4.0.3)
|
|
38
38
|
rake (10.5.0)
|
|
39
39
|
readline (0.0.2)
|
|
40
40
|
reline
|
|
41
|
-
reline (0.1.
|
|
41
|
+
reline (0.1.2)
|
|
42
42
|
io-console (~> 0.5)
|
|
43
43
|
rest-client (2.1.0)
|
|
44
44
|
http-accept (>= 1.7.0, < 2.0)
|
|
@@ -68,8 +68,8 @@ GEM
|
|
|
68
68
|
thor (0.20.3)
|
|
69
69
|
unf (0.1.4)
|
|
70
70
|
unf_ext
|
|
71
|
-
unf_ext (0.0.7.
|
|
72
|
-
unicode-display_width (1.
|
|
71
|
+
unf_ext (0.0.7.6)
|
|
72
|
+
unicode-display_width (1.6.1)
|
|
73
73
|
vcr (5.0.0)
|
|
74
74
|
webmock (3.7.6)
|
|
75
75
|
addressable (>= 2.3.6)
|
data/lib/enfapi.rb
CHANGED
|
@@ -30,6 +30,14 @@ module EnfApi
|
|
|
30
30
|
JSON.generate(hash)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
def self.from_json(string)
|
|
34
|
+
begin
|
|
35
|
+
JSON.parse(string, { symbolize_names: true })
|
|
36
|
+
rescue
|
|
37
|
+
raise EnfApi::ERROR, "Unable to parse api response json!"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
33
41
|
def self.url_encode(str)
|
|
34
42
|
CGI.escape(str).gsub("+", "%20")
|
|
35
43
|
end
|
|
@@ -40,103 +48,6 @@ module EnfApi
|
|
|
40
48
|
end
|
|
41
49
|
end
|
|
42
50
|
|
|
43
|
-
class Dns
|
|
44
|
-
include Singleton
|
|
45
|
-
|
|
46
|
-
def initialize
|
|
47
|
-
@version = "2019-05-27"
|
|
48
|
-
@xdns_base_url = "/api/xdns/#{@version}"
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def list_zones(domain)
|
|
52
|
-
EnfApi::API.instance.get "#{@xdns_base_url}/zones?enf_domain=#{domain}"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def create_dns_zone(new_zone)
|
|
56
|
-
json = EnfApi::to_json(new_zone)
|
|
57
|
-
EnfApi::API.instance.post "#{@xdns_base_url}/zones", json
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def update_dns_zone(zone_id, updated_zone)
|
|
61
|
-
json = EnfApi::to_json(updated_zone)
|
|
62
|
-
EnfApi::API.instance.put "#{@xdns_base_url}/zones/#{zone_id}", json
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def delete_dns_zone(zone_id)
|
|
66
|
-
EnfApi::API.instance.delete "#{@xdns_base_url}/zones/#{zone_id}"
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def add_networks_to_zone(zone_id, add_networks)
|
|
70
|
-
json = EnfApi::to_json(add_networks)
|
|
71
|
-
EnfApi::API.instance.post "#{@xdns_base_url}/zones/#{zone_id}/networks", json
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def replace_networks_in_zone(zone_id, replace_networks)
|
|
75
|
-
json = EnfApi::to_json(replace_networks)
|
|
76
|
-
EnfApi::API.instance.put "#{@xdns_base_url}/zones/#{zone_id}/networks", json
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def list_networks_in_zone(zone_id)
|
|
80
|
-
EnfApi::API.instance.get "#{@xdns_base_url}/zones/#{zone_id}/networks"
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def delete_networks_from_zone(zone_id, delete_networks)
|
|
84
|
-
EnfApi::API.instance.delete "#{@xdns_base_url}/zones/#{zone_id}/networks?delete=#{delete_networks}"
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def list_zones_in_network(network)
|
|
88
|
-
EnfApi::API.instance.get "#{@xdns_base_url}/networks/#{network}/zones"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def provision_server(network, new_server)
|
|
92
|
-
json = EnfApi::to_json(new_server)
|
|
93
|
-
EnfApi::API.instance.post "#{@xdns_base_url}/networks/#{network}/servers", json
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def list_servers(network)
|
|
97
|
-
EnfApi::API.instance.get "#{@xdns_base_url}/networks/#{network}/servers"
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def delete_server(network, server_ipv6)
|
|
101
|
-
EnfApi::API.instance.delete "#{@xdns_base_url}/networks/#{network}/servers/#{server_ipv6}"
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def create_dns_record(zone_id, new_record)
|
|
105
|
-
json = EnfApi::to_json(new_record)
|
|
106
|
-
EnfApi::API.instance.post "#{@xdns_base_url}/zones/#{zone_id}/records", json
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def list_dns_records(zone_id)
|
|
110
|
-
EnfApi::API.instance.get "#{@xdns_base_url}/zones/#{zone_id}/records"
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def query(network, type, name)
|
|
114
|
-
EnfApi::API.instance.get "#{@xdns_base_url}/networks/#{network}/query/#{type}/#{name}"
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def delete_dns_record(record_id)
|
|
118
|
-
EnfApi::API.instance.delete "#{@xdns_base_url}/records/#{record_id}"
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
class Firewall
|
|
123
|
-
include Singleton
|
|
124
|
-
|
|
125
|
-
def list_firewall_rules(network)
|
|
126
|
-
EnfApi::API.instance.get "/api/xfw/v1/#{network}/rule"
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def add_firewall_rule(network, rule)
|
|
130
|
-
rule_json = EnfApi::to_json(rule)
|
|
131
|
-
EnfApi::API.instance.post "/api/xfw/v1/#{network}/rule", rule_json
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def delete_firewall_rules(network, id = nil)
|
|
135
|
-
# Same method to call to delete all firewall rules in a network. if id is nil
|
|
136
|
-
EnfApi::API.instance.delete "/api/xfw/v1/#{network}/rule/#{id}"
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
51
|
class Iam
|
|
141
52
|
include Singleton
|
|
142
53
|
|
|
@@ -389,11 +300,11 @@ module EnfApi
|
|
|
389
300
|
@api = RestClient::Resource.new(host)
|
|
390
301
|
|
|
391
302
|
# Create request json
|
|
392
|
-
hash = { :
|
|
303
|
+
hash = { username: user, password: password }
|
|
393
304
|
json = to_json(hash)
|
|
394
305
|
|
|
395
306
|
# call api
|
|
396
|
-
@api["/api/xcr/
|
|
307
|
+
@api["/api/xcr/v3/xauth"].post(json, { content_type: :json, accept: :json }) { |response, request, result|
|
|
397
308
|
case response.code
|
|
398
309
|
when 200
|
|
399
310
|
# get resp from json
|
|
@@ -439,59 +350,59 @@ module EnfApi
|
|
|
439
350
|
# NOT READY API. MOVE ABOVE THIS LINE AFTER RSPEC OR INTO OWN CLASS
|
|
440
351
|
############################################################################################################################
|
|
441
352
|
def list_domain_nws(domain_id)
|
|
442
|
-
@api["/api/xcr/
|
|
353
|
+
@api["/api/xcr/v3/domains/#{domain_id}/nws"].get(@headers) { |response, request, result|
|
|
443
354
|
process_api_response response, request, result
|
|
444
355
|
}
|
|
445
356
|
end
|
|
446
357
|
|
|
447
358
|
def list_enfnws
|
|
448
|
-
@api["/api/xcr/
|
|
359
|
+
@api["/api/xcr/v3/enfnws"].get(@headers) { |response, request, result|
|
|
449
360
|
process_api_response response, request, result
|
|
450
361
|
}
|
|
451
362
|
end
|
|
452
363
|
|
|
453
364
|
def list_domains
|
|
454
|
-
@api["/api/xcr/
|
|
365
|
+
@api["/api/xcr/v3/domains"].get(@headers) { |response, request, result|
|
|
455
366
|
process_api_response response, request, result
|
|
456
367
|
}
|
|
457
368
|
end
|
|
458
369
|
|
|
459
370
|
def get_domain(domain_id)
|
|
460
|
-
@api["/api/xcr/
|
|
371
|
+
@api["/api/xcr/v3/domains/#{domain_id}"].get(@headers) { |response, request, result|
|
|
461
372
|
process_api_response response, request, result
|
|
462
373
|
}
|
|
463
374
|
end
|
|
464
375
|
|
|
465
376
|
def create_domain(domain_hash)
|
|
466
377
|
json = to_json(domain_hash)
|
|
467
|
-
@api["/api/xcr/
|
|
378
|
+
@api["/api/xcr/v3/domains"].post(json, @headers) { |response, request, result|
|
|
468
379
|
process_api_response response, request, result
|
|
469
380
|
}
|
|
470
381
|
end
|
|
471
382
|
|
|
472
383
|
def update_domain_rate_limits(domain_network, limit, limits_hash)
|
|
473
384
|
json = to_json(limits_hash)
|
|
474
|
-
@api["/api/xcr/
|
|
385
|
+
@api["/api/xcr/v3/domains/#{domain_network}/ep_rate_limits/#{limit}"].put(json, @headers) { |response, request, result|
|
|
475
386
|
process_api_response response, request, result
|
|
476
387
|
}
|
|
477
388
|
end
|
|
478
389
|
|
|
479
390
|
def update_network_rate_limits(network, limit, limits_hash)
|
|
480
391
|
json = to_json(limits_hash)
|
|
481
|
-
@api["/api/xcr/
|
|
392
|
+
@api["/api/xcr/v3/nws/#{network}/ep_rate_limits/#{limit}"].put(json, @headers) { |response, request, result|
|
|
482
393
|
process_api_response response, request, result
|
|
483
394
|
}
|
|
484
395
|
end
|
|
485
396
|
|
|
486
397
|
def update_ep_rate_limits(ipv6, limit, limits_hash)
|
|
487
398
|
json = to_json(limits_hash)
|
|
488
|
-
@api["/api/xcr/
|
|
399
|
+
@api["/api/xcr/v3/cxns/#{ipv6}/ep_rate_limits/#{limit}"].put(json, @headers) { |response, request, result|
|
|
489
400
|
process_api_response response, request, result
|
|
490
401
|
}
|
|
491
402
|
end
|
|
492
403
|
|
|
493
404
|
def get_domain_rate_limits(domain_network, filter = nil)
|
|
494
|
-
api_url = "/api/xcr/
|
|
405
|
+
api_url = "/api/xcr/v3/domains/#{domain_network}/ep_rate_limits"
|
|
495
406
|
api_url = "#{api_url}/#{filter}" if filter
|
|
496
407
|
|
|
497
408
|
@api[api_url].get(@headers) { |response, request, result|
|
|
@@ -500,7 +411,7 @@ module EnfApi
|
|
|
500
411
|
end
|
|
501
412
|
|
|
502
413
|
def get_network_rate_limits(network, filter = nil)
|
|
503
|
-
api_url = "/api/xcr/
|
|
414
|
+
api_url = "/api/xcr/v3/nws/#{network}/ep_rate_limits"
|
|
504
415
|
api_url = "#{api_url}/#{filter}" if filter
|
|
505
416
|
|
|
506
417
|
@api[api_url].get(@headers) { |response, request, result|
|
|
@@ -509,7 +420,7 @@ module EnfApi
|
|
|
509
420
|
end
|
|
510
421
|
|
|
511
422
|
def get_ep_rate_limits(ipv6, filter = nil)
|
|
512
|
-
api_url = "/api/xcr/
|
|
423
|
+
api_url = "/api/xcr/v3/cxns/#{ipv6}/ep_rate_limits"
|
|
513
424
|
api_url = "#{api_url}/#{filter}" if filter
|
|
514
425
|
|
|
515
426
|
@api[api_url].get(@headers) { |response, request, result|
|
|
@@ -519,105 +430,66 @@ module EnfApi
|
|
|
519
430
|
|
|
520
431
|
def update_domain_status(domain_network, status)
|
|
521
432
|
json = to_json(status)
|
|
522
|
-
@api["/api/xcr/
|
|
433
|
+
@api["/api/xcr/v3/domains/#{domain_network}/status"].put(json, @headers) { |response, request, result|
|
|
523
434
|
process_api_response response, request, result
|
|
524
435
|
}
|
|
525
436
|
end
|
|
526
437
|
|
|
527
|
-
def create_nw(nw_hash)
|
|
438
|
+
def create_nw(domain, nw_hash)
|
|
528
439
|
json = to_json(nw_hash)
|
|
529
|
-
|
|
530
|
-
@api["/api/xcr/v2/domains/#{domain_id}/nws"].post(json, @headers) { |response, request, result|
|
|
440
|
+
@api["/api/xcr/v3/domains/#{domain}/nws"].post(json, @headers) { |response, request, result|
|
|
531
441
|
process_api_response response, request, result
|
|
532
442
|
}
|
|
533
443
|
end
|
|
534
444
|
|
|
535
445
|
def update_nw(network_cidr, nw_hash)
|
|
536
446
|
json = to_json(nw_hash)
|
|
537
|
-
@api["/api/xcr/
|
|
447
|
+
@api["/api/xcr/v3/nws/#{network_cidr}"].put(json, @headers) { |response, request, result|
|
|
538
448
|
process_api_response response, request, result
|
|
539
449
|
}
|
|
540
450
|
end
|
|
541
451
|
|
|
542
452
|
def get_nw(network_cidr)
|
|
543
|
-
@api["/api/xcr/
|
|
453
|
+
@api["/api/xcr/v3/nws/#{network_cidr}"].get(@headers) { |response, request, result|
|
|
544
454
|
process_api_response response, request, result
|
|
545
455
|
}
|
|
546
456
|
end
|
|
547
457
|
|
|
548
|
-
def list_nw_connections(
|
|
549
|
-
@api["/api/xcr/
|
|
458
|
+
def list_nw_connections(network_cidr, file = nil)
|
|
459
|
+
@api["/api/xcr/v3/nws/#{network_cidr}/cxns"].get(@headers) { |response, request, result|
|
|
550
460
|
process_api_response response, request, result
|
|
551
461
|
}
|
|
552
462
|
end
|
|
553
463
|
|
|
554
464
|
def list_endpoint_events(ipv6)
|
|
555
|
-
@api["/api/xcr/
|
|
465
|
+
@api["/api/xcr/v3/cxns/#{ipv6}/events"].get(@headers) { |response, request, result|
|
|
556
466
|
process_api_response response, request, result
|
|
557
467
|
}
|
|
558
468
|
end
|
|
559
469
|
|
|
560
470
|
def list_network_events(network_cidr)
|
|
561
|
-
@api["/api/xcr/
|
|
471
|
+
@api["/api/xcr/v3/nws/#{network_cidr}/events"].get(@headers) { |response, request, result|
|
|
562
472
|
process_api_response response, request, result
|
|
563
473
|
}
|
|
564
474
|
end
|
|
565
475
|
|
|
566
476
|
def get_endpoint(ipv6)
|
|
567
|
-
@api["/api/xcr/
|
|
477
|
+
@api["/api/xcr/v3/cxns/#{ipv6}"].get(@headers) { |response, request, result|
|
|
568
478
|
process_api_response response, request, result
|
|
569
479
|
}
|
|
570
480
|
end
|
|
571
481
|
|
|
572
482
|
def update_endpoint(ipv6, name)
|
|
573
|
-
hash = { :
|
|
483
|
+
hash = { ipv6: ipv6, name: name }
|
|
574
484
|
json = to_json(hash)
|
|
575
485
|
|
|
576
|
-
@api["/api/xcr/
|
|
486
|
+
@api["/api/xcr/v3/cxns/#{ipv6}"].put(json, @headers) { |response, request, result|
|
|
577
487
|
process_api_response response, request, result
|
|
578
488
|
}
|
|
579
489
|
end
|
|
580
490
|
|
|
581
491
|
def activate_enfnw(subnet)
|
|
582
|
-
@api["/api/xcr/
|
|
583
|
-
process_api_response response, request, result
|
|
584
|
-
}
|
|
585
|
-
end
|
|
586
|
-
|
|
587
|
-
def list_domain_users(domain_network)
|
|
588
|
-
@api["/api/xcr/v2/domains/#{domain_network}/users"].get(@headers) { |response, request, result|
|
|
589
|
-
process_api_response response, request, result
|
|
590
|
-
}
|
|
591
|
-
end
|
|
592
|
-
|
|
593
|
-
def list_domain_invites(domain_network)
|
|
594
|
-
@api["/api/xcr/v2/domains/#{domain_network}/invites"].get(@headers) { |response, request, result|
|
|
595
|
-
process_api_response response, request, result
|
|
596
|
-
}
|
|
597
|
-
end
|
|
598
|
-
|
|
599
|
-
def invite(domain_network, hash)
|
|
600
|
-
json = to_json(hash)
|
|
601
|
-
@api["/api/xcr/v2/domains/#{domain_network}/invites"].post(json, @headers) { |response, request, result|
|
|
602
|
-
process_api_response response, request, result
|
|
603
|
-
}
|
|
604
|
-
end
|
|
605
|
-
|
|
606
|
-
def cancel_invite(email)
|
|
607
|
-
@api["/api/xcr/v2/invites/#{email}"].delete(@headers) { |response, request, result|
|
|
608
|
-
process_api_response response, request, result
|
|
609
|
-
}
|
|
610
|
-
end
|
|
611
|
-
|
|
612
|
-
def resend_invite(email)
|
|
613
|
-
@api["/api/xcr/v2/invites/#{email}"].put("{}", @headers) { |response, request, result|
|
|
614
|
-
process_api_response response, request, result
|
|
615
|
-
}
|
|
616
|
-
end
|
|
617
|
-
|
|
618
|
-
def update_user_status(user_id, status)
|
|
619
|
-
json = to_json(status)
|
|
620
|
-
@api["/api/xcr/v2/users/#{user_id}/status"].put(json, @headers) { |response, request, result|
|
|
492
|
+
@api["/api/xcr/v3/enfnws/#{subnet}"].put("", @headers) { |response, request, result|
|
|
621
493
|
process_api_response response, request, result
|
|
622
494
|
}
|
|
623
495
|
end
|
|
@@ -665,15 +537,11 @@ module EnfApi
|
|
|
665
537
|
end
|
|
666
538
|
|
|
667
539
|
def from_json(string)
|
|
668
|
-
|
|
669
|
-
JSON.parse(string, { :symbolize_names => true })
|
|
670
|
-
rescue
|
|
671
|
-
raise EnfApi::ERROR, "Unable to parse api response json!"
|
|
672
|
-
end
|
|
540
|
+
EnfApi::from_json(string)
|
|
673
541
|
end
|
|
674
542
|
|
|
675
543
|
def to_json(hash)
|
|
676
|
-
|
|
544
|
+
EnfApi::to_json(hash)
|
|
677
545
|
end
|
|
678
546
|
|
|
679
547
|
def api_error_msg(err)
|
data/lib/enfapi/dns.rb
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright 2020 Xaptum,Inc
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
module EnfApi
|
|
17
|
+
class Dns
|
|
18
|
+
include Singleton
|
|
19
|
+
|
|
20
|
+
def initialize
|
|
21
|
+
@version = "v1"
|
|
22
|
+
@xdns_base_url = "/api/xdns/#{@version}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def list_zones(domain)
|
|
26
|
+
EnfApi::API.instance.get "#{@xdns_base_url}/zones?enf_domain=#{domain}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create_dns_zone(new_zone)
|
|
30
|
+
json = EnfApi::to_json(new_zone)
|
|
31
|
+
EnfApi::API.instance.post "#{@xdns_base_url}/zones", json
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def update_dns_zone(zone_id, updated_zone)
|
|
35
|
+
json = EnfApi::to_json(updated_zone)
|
|
36
|
+
EnfApi::API.instance.put "#{@xdns_base_url}/zones/#{zone_id}", json
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def delete_dns_zone(zone_id)
|
|
40
|
+
EnfApi::API.instance.delete "#{@xdns_base_url}/zones/#{zone_id}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def add_networks_to_zone(zone_id, add_networks)
|
|
44
|
+
json = EnfApi::to_json(add_networks)
|
|
45
|
+
EnfApi::API.instance.post "#{@xdns_base_url}/zones/#{zone_id}/networks", json
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def replace_networks_in_zone(zone_id, replace_networks)
|
|
49
|
+
json = EnfApi::to_json(replace_networks)
|
|
50
|
+
EnfApi::API.instance.put "#{@xdns_base_url}/zones/#{zone_id}/networks", json
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def list_networks_in_zone(zone_id)
|
|
54
|
+
EnfApi::API.instance.get "#{@xdns_base_url}/zones/#{zone_id}/networks"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def delete_networks_from_zone(zone_id, delete_networks)
|
|
58
|
+
EnfApi::API.instance.delete "#{@xdns_base_url}/zones/#{zone_id}/networks?delete=#{delete_networks}"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def list_zones_in_network(network)
|
|
62
|
+
EnfApi::API.instance.get "#{@xdns_base_url}/networks/#{network}/zones"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def provision_server(network, new_server)
|
|
66
|
+
json = EnfApi::to_json(new_server)
|
|
67
|
+
EnfApi::API.instance.post "#{@xdns_base_url}/networks/#{network}/servers", json
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def list_servers(network)
|
|
71
|
+
EnfApi::API.instance.get "#{@xdns_base_url}/networks/#{network}/servers"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def delete_server(network, server_ipv6)
|
|
75
|
+
EnfApi::API.instance.delete "#{@xdns_base_url}/networks/#{network}/servers/#{server_ipv6}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def create_dns_record(zone_id, new_record)
|
|
79
|
+
json = EnfApi::to_json(new_record)
|
|
80
|
+
EnfApi::API.instance.post "#{@xdns_base_url}/zones/#{zone_id}/records", json
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def list_dns_records(zone_id)
|
|
84
|
+
EnfApi::API.instance.get "#{@xdns_base_url}/zones/#{zone_id}/records"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def query(network, type, name)
|
|
88
|
+
EnfApi::API.instance.get "#{@xdns_base_url}/networks/#{network}/query/#{type}/#{name}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def delete_dns_record(record_id)
|
|
92
|
+
EnfApi::API.instance.delete "#{@xdns_base_url}/records/#{record_id}"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|