cisco-axl 1.0.1

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.
package/test/tests.js ADDED
@@ -0,0 +1,89 @@
1
+ const axlService = require("../index");
2
+ const emoji = require("node-emoji");
3
+
4
+ // Set up new AXL service
5
+ let service = new axlService(
6
+ "10.10.20.1",
7
+ "administrator",
8
+ "ciscopsdt",
9
+ "14.0"
10
+ );
11
+
12
+ var check = emoji.get("heavy_check_mark");
13
+ var cat = emoji.get("smiley_cat");
14
+ var skull = emoji.get("skull");
15
+ var sparkles = emoji.get("sparkles");
16
+ var spy = emoji.get("sleuth_or_spy");
17
+ var next = emoji.get("black_right_pointing_double_triangle_with_vertical_bar");
18
+ var list = emoji.get("spiral_note_pad");
19
+ var computer = emoji.get("computer");
20
+ var finished = emoji.get("raised_hand");
21
+
22
+ (async () => {
23
+ console.log(`${spy} Let's first get a list of all the methods.`);
24
+ var methodArr = await service.returnMethods();
25
+ console.log(computer,methodArr);
26
+ console.log(
27
+ `${next} Now let's get a list of all the methods that include the word 'partition'.`
28
+ );
29
+ var methodFilterArr = await service.returnMethods("partition");
30
+ console.log(computer,methodFilterArr);
31
+
32
+ console.log(
33
+ `${cat} Great. Let's add a new route partition via 'addRoutePartition'.`
34
+ );
35
+
36
+ var method = "addRoutePartition";
37
+
38
+ console.log(
39
+ `${next} We'll need to get what params to pass to the SOAP client first.`
40
+ );
41
+ var params = await service.getMethodParams(method);
42
+ console.log(computer,params);
43
+ console.log(`${sparkles} Awesome, let's update the name and description fields.`);
44
+ params.routePartition.name = "INTERNAL-PT";
45
+ params.routePartition.description = "Internal directory numbers";
46
+ console.log(computer,params);
47
+ console.log(
48
+ `${next} Now we will attempt to add the new partition. Function should return an UUID to represent the new partition.`
49
+ );
50
+ await service
51
+ .executeMethod(method, params)
52
+ .then(async (results) => {
53
+ console.log(computer,results);
54
+ console.log(
55
+ `${cat} Great let's get a list of all the partitions on our cluster now. First we'll get the params needed for this call.`
56
+ );
57
+
58
+ method = "listRoutePartition";
59
+ params = await service.getMethodParams(method);
60
+ console.log(computer,params);
61
+
62
+ console.log(
63
+ `${spy} We want to list all partitions, so we'll be searching for a wildcard (%%) in the name and description fields.`
64
+ );
65
+ params.searchCriteria.name = "%%";
66
+ params.searchCriteria.description = "%%";
67
+ console.log(computer,params);
68
+ console.log(
69
+ `${sparkles} Great, now that we've updated our params, we'll send the AXL request via SOAP.`
70
+ );
71
+
72
+ await service
73
+ .executeMethod(method, params)
74
+ .then((results) => {
75
+ console.log(`${list} Here are a list of all the partitions on our cluster:`);
76
+ results.routePartition.map((str) => {
77
+ var outString = `${check} ${str.name}`;
78
+ console.log(outString);
79
+ });
80
+ })
81
+ .catch((error) => {
82
+ console.log(skull,error);
83
+ });
84
+ })
85
+ .catch((error) => {
86
+ console.log(skull,"Adding a new partition failed", error);
87
+ });
88
+ console.log(finished,"Test all finished. Thanks!");
89
+ })();