enfcli 4.1.0.pre.beta → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/enfapi.rb +127 -169
- 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/captive.rb +375 -14
- 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 +6 -3
- data/lib/enfcli/version.rb +2 -2
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86826b25857a616c9ce13cf6bc4f7ee929e601bc8a70cc3d2510b73259ebd5e1
|
4
|
+
data.tar.gz: 77d3e2ab72a9ababd8926e3fd09d6f0155cc5464677d2b4fdb0ef33196b5bb24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12b1b10048964fda4775f2408a4ead3118c10307cf267757c261e0c4d1dcf88dad4a91cb14e3e3d52c13bbaf3aada2f534647a245fc6aaaea8f2f2e810c3e905
|
7
|
+
data.tar.gz: 79d93340b0b3818261b2f7f90527076878ecfc8d7485a79811e8cb9edb774a0b41855bbcdfd87f72f50de1271f40912d251eaae8c7f0980d0d3307d08c9e5456
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
enfcli (
|
4
|
+
enfcli (5.0.1)
|
5
5
|
clipboard
|
6
6
|
ffi
|
7
7
|
readline
|
@@ -21,7 +21,7 @@ GEM
|
|
21
21
|
diff-lcs (1.3)
|
22
22
|
domain_name (0.5.20190701)
|
23
23
|
unf (>= 0.0.5, < 1.0.0)
|
24
|
-
ffi (1.
|
24
|
+
ffi (1.13.1)
|
25
25
|
fuubar (2.5.0)
|
26
26
|
rspec-core (~> 3.0)
|
27
27
|
ruby-progressbar (~> 1.4)
|
@@ -32,13 +32,13 @@ GEM
|
|
32
32
|
io-console (0.5.6)
|
33
33
|
mime-types (3.3.1)
|
34
34
|
mime-types-data (~> 3.2015)
|
35
|
-
mime-types-data (3.
|
35
|
+
mime-types-data (3.2020.0512)
|
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.4)
|
42
42
|
io-console (~> 0.5)
|
43
43
|
rest-client (2.1.0)
|
44
44
|
http-accept (>= 1.7.0, < 2.0)
|
data/lib/enfapi.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright
|
2
|
+
# Copyright 2020 Xaptum,Inc
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -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
|
|
@@ -284,6 +195,89 @@ module EnfApi
|
|
284
195
|
json = EnfApi.to_json(profile_updates)
|
285
196
|
EnfApi::API.instance.put "/api/captive/v1/profile/#{id}", json
|
286
197
|
end
|
198
|
+
|
199
|
+
# Get the list of devices
|
200
|
+
## NO_TEST
|
201
|
+
def list_firmware_images()
|
202
|
+
url = "/api/captive/v1/firmware/release"
|
203
|
+
EnfApi::API.instance.get url
|
204
|
+
end
|
205
|
+
|
206
|
+
# Upload the firmware image
|
207
|
+
# Current version sends an empty body - captive server doesn't support
|
208
|
+
# sending the binary image yet.
|
209
|
+
## NO_TEST
|
210
|
+
def upload_firmware_image(version, image_name)
|
211
|
+
url = "/api/captive/v1/firmware/release/#{version}/#{image_name}"
|
212
|
+
EnfApi::API.instance.put url
|
213
|
+
end
|
214
|
+
|
215
|
+
# gets the details for a specific firmware version
|
216
|
+
## NO_TEST
|
217
|
+
def get_firmware_info(version)
|
218
|
+
url = "/api/captive/v1/firmware/release/#{version}"
|
219
|
+
EnfApi::API.instance.get url
|
220
|
+
end
|
221
|
+
|
222
|
+
# creates a new schedule object via POST
|
223
|
+
## NO_TEST
|
224
|
+
def create_schedule(sched_hash)
|
225
|
+
json = EnfApi.to_json(sched_hash)
|
226
|
+
EnfApi::API.instance.post "/api/captive/v1/schedule", json
|
227
|
+
end
|
228
|
+
|
229
|
+
# GETs a list of all existing schedules
|
230
|
+
## NO_TEST
|
231
|
+
def list_schedules
|
232
|
+
EnfApi::API.instance.get "/api/captive/v1/schedule"
|
233
|
+
end
|
234
|
+
|
235
|
+
# GETs the details of a specific schedule
|
236
|
+
## NO_TEST
|
237
|
+
def get_schedule(id)
|
238
|
+
EnfApi::API.instance.get "/api/captive/v1/schedule/#{id}"
|
239
|
+
end
|
240
|
+
|
241
|
+
# update the details of a specific schedule
|
242
|
+
## NO_TEST
|
243
|
+
def update_schedule(id, sched_hash)
|
244
|
+
json = EnfApi.to_json(sched_hash)
|
245
|
+
url = "/api/captive/v1/schedule/#{id}"
|
246
|
+
EnfApi::API.instance.put url, json
|
247
|
+
end
|
248
|
+
|
249
|
+
# DELETEs the specified schedule
|
250
|
+
## NO_TEST
|
251
|
+
def delete_schedule(id)
|
252
|
+
EnfApi::API.instance.delete "/api/captive/v1/schedule/#{id}"
|
253
|
+
end
|
254
|
+
|
255
|
+
# GET the list of existing update objects
|
256
|
+
## NO_TEST
|
257
|
+
def list_firmware_updates()
|
258
|
+
EnfApi::API.instance.get "/api/captive/v1/firmware/update"
|
259
|
+
end
|
260
|
+
|
261
|
+
# GET details of a specified firmware update task
|
262
|
+
## NO_TEST
|
263
|
+
def get_firmware_update(update_id)
|
264
|
+
EnfApi::API.instance.get "/api/captive/v1/firmware/update/#{update_id}"
|
265
|
+
end
|
266
|
+
|
267
|
+
# POSTs a new firmware-udpate object
|
268
|
+
## NO_TEST
|
269
|
+
def create_firmware_update(update_hash)
|
270
|
+
json = EnfApi.to_json(update_hash)
|
271
|
+
EnfApi::API.instance.post "/api/captive/v1/firmware/update", json
|
272
|
+
end
|
273
|
+
|
274
|
+
# uses PUT to modify an existing firmware update task
|
275
|
+
## NO_TEST
|
276
|
+
def modify_firmware_update(update_id, update_hash)
|
277
|
+
url = "/api/captive/v1/firmware/update/#{update_id}"
|
278
|
+
json = EnfApi.to_json(update_hash)
|
279
|
+
EnfApi::API.instance.put url, json
|
280
|
+
end
|
287
281
|
end
|
288
282
|
|
289
283
|
class NetworkManager
|
@@ -306,11 +300,11 @@ module EnfApi
|
|
306
300
|
@api = RestClient::Resource.new(host)
|
307
301
|
|
308
302
|
# Create request json
|
309
|
-
hash = { :
|
303
|
+
hash = { username: user, password: password }
|
310
304
|
json = to_json(hash)
|
311
305
|
|
312
306
|
# call api
|
313
|
-
@api["/api/xcr/
|
307
|
+
@api["/api/xcr/v3/xauth"].post(json, { content_type: :json, accept: :json }) { |response, request, result|
|
314
308
|
case response.code
|
315
309
|
when 200
|
316
310
|
# get resp from json
|
@@ -356,59 +350,59 @@ module EnfApi
|
|
356
350
|
# NOT READY API. MOVE ABOVE THIS LINE AFTER RSPEC OR INTO OWN CLASS
|
357
351
|
############################################################################################################################
|
358
352
|
def list_domain_nws(domain_id)
|
359
|
-
@api["/api/xcr/
|
353
|
+
@api["/api/xcr/v3/domains/#{domain_id}/nws"].get(@headers) { |response, request, result|
|
360
354
|
process_api_response response, request, result
|
361
355
|
}
|
362
356
|
end
|
363
357
|
|
364
358
|
def list_enfnws
|
365
|
-
@api["/api/xcr/
|
359
|
+
@api["/api/xcr/v3/enfnws"].get(@headers) { |response, request, result|
|
366
360
|
process_api_response response, request, result
|
367
361
|
}
|
368
362
|
end
|
369
363
|
|
370
364
|
def list_domains
|
371
|
-
@api["/api/xcr/
|
365
|
+
@api["/api/xcr/v3/domains"].get(@headers) { |response, request, result|
|
372
366
|
process_api_response response, request, result
|
373
367
|
}
|
374
368
|
end
|
375
369
|
|
376
370
|
def get_domain(domain_id)
|
377
|
-
@api["/api/xcr/
|
371
|
+
@api["/api/xcr/v3/domains/#{domain_id}"].get(@headers) { |response, request, result|
|
378
372
|
process_api_response response, request, result
|
379
373
|
}
|
380
374
|
end
|
381
375
|
|
382
376
|
def create_domain(domain_hash)
|
383
377
|
json = to_json(domain_hash)
|
384
|
-
@api["/api/xcr/
|
378
|
+
@api["/api/xcr/v3/domains"].post(json, @headers) { |response, request, result|
|
385
379
|
process_api_response response, request, result
|
386
380
|
}
|
387
381
|
end
|
388
382
|
|
389
383
|
def update_domain_rate_limits(domain_network, limit, limits_hash)
|
390
384
|
json = to_json(limits_hash)
|
391
|
-
@api["/api/xcr/
|
385
|
+
@api["/api/xcr/v3/domains/#{domain_network}/ep_rate_limits/#{limit}"].put(json, @headers) { |response, request, result|
|
392
386
|
process_api_response response, request, result
|
393
387
|
}
|
394
388
|
end
|
395
389
|
|
396
390
|
def update_network_rate_limits(network, limit, limits_hash)
|
397
391
|
json = to_json(limits_hash)
|
398
|
-
@api["/api/xcr/
|
392
|
+
@api["/api/xcr/v3/nws/#{network}/ep_rate_limits/#{limit}"].put(json, @headers) { |response, request, result|
|
399
393
|
process_api_response response, request, result
|
400
394
|
}
|
401
395
|
end
|
402
396
|
|
403
397
|
def update_ep_rate_limits(ipv6, limit, limits_hash)
|
404
398
|
json = to_json(limits_hash)
|
405
|
-
@api["/api/xcr/
|
399
|
+
@api["/api/xcr/v3/cxns/#{ipv6}/ep_rate_limits/#{limit}"].put(json, @headers) { |response, request, result|
|
406
400
|
process_api_response response, request, result
|
407
401
|
}
|
408
402
|
end
|
409
403
|
|
410
404
|
def get_domain_rate_limits(domain_network, filter = nil)
|
411
|
-
api_url = "/api/xcr/
|
405
|
+
api_url = "/api/xcr/v3/domains/#{domain_network}/ep_rate_limits"
|
412
406
|
api_url = "#{api_url}/#{filter}" if filter
|
413
407
|
|
414
408
|
@api[api_url].get(@headers) { |response, request, result|
|
@@ -417,7 +411,7 @@ module EnfApi
|
|
417
411
|
end
|
418
412
|
|
419
413
|
def get_network_rate_limits(network, filter = nil)
|
420
|
-
api_url = "/api/xcr/
|
414
|
+
api_url = "/api/xcr/v3/nws/#{network}/ep_rate_limits"
|
421
415
|
api_url = "#{api_url}/#{filter}" if filter
|
422
416
|
|
423
417
|
@api[api_url].get(@headers) { |response, request, result|
|
@@ -426,7 +420,7 @@ module EnfApi
|
|
426
420
|
end
|
427
421
|
|
428
422
|
def get_ep_rate_limits(ipv6, filter = nil)
|
429
|
-
api_url = "/api/xcr/
|
423
|
+
api_url = "/api/xcr/v3/cxns/#{ipv6}/ep_rate_limits"
|
430
424
|
api_url = "#{api_url}/#{filter}" if filter
|
431
425
|
|
432
426
|
@api[api_url].get(@headers) { |response, request, result|
|
@@ -436,105 +430,66 @@ module EnfApi
|
|
436
430
|
|
437
431
|
def update_domain_status(domain_network, status)
|
438
432
|
json = to_json(status)
|
439
|
-
@api["/api/xcr/
|
433
|
+
@api["/api/xcr/v3/domains/#{domain_network}/status"].put(json, @headers) { |response, request, result|
|
440
434
|
process_api_response response, request, result
|
441
435
|
}
|
442
436
|
end
|
443
437
|
|
444
|
-
def create_nw(nw_hash)
|
438
|
+
def create_nw(domain, nw_hash)
|
445
439
|
json = to_json(nw_hash)
|
446
|
-
|
447
|
-
@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|
|
448
441
|
process_api_response response, request, result
|
449
442
|
}
|
450
443
|
end
|
451
444
|
|
452
445
|
def update_nw(network_cidr, nw_hash)
|
453
446
|
json = to_json(nw_hash)
|
454
|
-
@api["/api/xcr/
|
447
|
+
@api["/api/xcr/v3/nws/#{network_cidr}"].put(json, @headers) { |response, request, result|
|
455
448
|
process_api_response response, request, result
|
456
449
|
}
|
457
450
|
end
|
458
451
|
|
459
452
|
def get_nw(network_cidr)
|
460
|
-
@api["/api/xcr/
|
453
|
+
@api["/api/xcr/v3/nws/#{network_cidr}"].get(@headers) { |response, request, result|
|
461
454
|
process_api_response response, request, result
|
462
455
|
}
|
463
456
|
end
|
464
457
|
|
465
|
-
def list_nw_connections(
|
466
|
-
@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|
|
467
460
|
process_api_response response, request, result
|
468
461
|
}
|
469
462
|
end
|
470
463
|
|
471
464
|
def list_endpoint_events(ipv6)
|
472
|
-
@api["/api/xcr/
|
465
|
+
@api["/api/xcr/v3/cxns/#{ipv6}/events"].get(@headers) { |response, request, result|
|
473
466
|
process_api_response response, request, result
|
474
467
|
}
|
475
468
|
end
|
476
469
|
|
477
470
|
def list_network_events(network_cidr)
|
478
|
-
@api["/api/xcr/
|
471
|
+
@api["/api/xcr/v3/nws/#{network_cidr}/events"].get(@headers) { |response, request, result|
|
479
472
|
process_api_response response, request, result
|
480
473
|
}
|
481
474
|
end
|
482
475
|
|
483
476
|
def get_endpoint(ipv6)
|
484
|
-
@api["/api/xcr/
|
477
|
+
@api["/api/xcr/v3/cxns/#{ipv6}"].get(@headers) { |response, request, result|
|
485
478
|
process_api_response response, request, result
|
486
479
|
}
|
487
480
|
end
|
488
481
|
|
489
482
|
def update_endpoint(ipv6, name)
|
490
|
-
hash = { :
|
483
|
+
hash = { ipv6: ipv6, name: name }
|
491
484
|
json = to_json(hash)
|
492
485
|
|
493
|
-
@api["/api/xcr/
|
486
|
+
@api["/api/xcr/v3/cxns/#{ipv6}"].put(json, @headers) { |response, request, result|
|
494
487
|
process_api_response response, request, result
|
495
488
|
}
|
496
489
|
end
|
497
490
|
|
498
491
|
def activate_enfnw(subnet)
|
499
|
-
@api["/api/xcr/
|
500
|
-
process_api_response response, request, result
|
501
|
-
}
|
502
|
-
end
|
503
|
-
|
504
|
-
def list_domain_users(domain_network)
|
505
|
-
@api["/api/xcr/v2/domains/#{domain_network}/users"].get(@headers) { |response, request, result|
|
506
|
-
process_api_response response, request, result
|
507
|
-
}
|
508
|
-
end
|
509
|
-
|
510
|
-
def list_domain_invites(domain_network)
|
511
|
-
@api["/api/xcr/v2/domains/#{domain_network}/invites"].get(@headers) { |response, request, result|
|
512
|
-
process_api_response response, request, result
|
513
|
-
}
|
514
|
-
end
|
515
|
-
|
516
|
-
def invite(domain_network, hash)
|
517
|
-
json = to_json(hash)
|
518
|
-
@api["/api/xcr/v2/domains/#{domain_network}/invites"].post(json, @headers) { |response, request, result|
|
519
|
-
process_api_response response, request, result
|
520
|
-
}
|
521
|
-
end
|
522
|
-
|
523
|
-
def cancel_invite(email)
|
524
|
-
@api["/api/xcr/v2/invites/#{email}"].delete(@headers) { |response, request, result|
|
525
|
-
process_api_response response, request, result
|
526
|
-
}
|
527
|
-
end
|
528
|
-
|
529
|
-
def resend_invite(email)
|
530
|
-
@api["/api/xcr/v2/invites/#{email}"].put("{}", @headers) { |response, request, result|
|
531
|
-
process_api_response response, request, result
|
532
|
-
}
|
533
|
-
end
|
534
|
-
|
535
|
-
def update_user_status(user_id, status)
|
536
|
-
json = to_json(status)
|
537
|
-
@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|
|
538
493
|
process_api_response response, request, result
|
539
494
|
}
|
540
495
|
end
|
@@ -569,21 +524,24 @@ module EnfApi
|
|
569
524
|
rescue JSON::ParserError => e
|
570
525
|
raise EnfApi::ERROR, "Not Found"
|
571
526
|
end
|
527
|
+
when 500
|
528
|
+
begin
|
529
|
+
JSON.parse(response.body)
|
530
|
+
raise EnfApi::ERROR, api_error_msg(from_json(response.body))
|
531
|
+
rescue JSON::ParserError => e
|
532
|
+
raise EnfApi::ERROR, "Server error was received without details."
|
533
|
+
end
|
572
534
|
else
|
573
535
|
raise EnfApi::ERROR, "Unexpected error! Please try again!"
|
574
536
|
end
|
575
537
|
end
|
576
538
|
|
577
539
|
def from_json(string)
|
578
|
-
|
579
|
-
JSON.parse(string, { :symbolize_names => true })
|
580
|
-
rescue
|
581
|
-
raise EnfApi::ERROR, "Unable to parse api response json!"
|
582
|
-
end
|
540
|
+
EnfApi::from_json(string)
|
583
541
|
end
|
584
542
|
|
585
543
|
def to_json(hash)
|
586
|
-
|
544
|
+
EnfApi::to_json(hash)
|
587
545
|
end
|
588
546
|
|
589
547
|
def api_error_msg(err)
|