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/README.md +78 -0
- package/index.js +157 -0
- package/package.json +26 -0
- package/schema/11.0/AXLAPI.wsdl +23240 -0
- package/schema/11.0/AXLEnums.xsd +3117 -0
- package/schema/11.0/AXLSoap.xsd +53941 -0
- package/schema/11.5/AXLAPI.wsdl +23631 -0
- package/schema/11.5/AXLEnums.xsd +3260 -0
- package/schema/11.5/AXLSoap.xsd +54952 -0
- package/schema/12.0/AXLAPI.wsdl +23884 -0
- package/schema/12.0/AXLEnums.xsd +3211 -0
- package/schema/12.0/AXLSoap.xsd +55297 -0
- package/schema/12.5/AXLAPI.wsdl +24597 -0
- package/schema/12.5/AXLEnums.xsd +3447 -0
- package/schema/12.5/AXLSoap.xsd +57503 -0
- package/schema/14.0/AXLAPI.wsdl +24597 -0
- package/schema/14.0/AXLEnums.xsd +3467 -0
- package/schema/14.0/AXLSoap.xsd +57522 -0
- package/schema/current/AXLAPI.wsdl +24597 -0
- package/schema/current/AXLEnums.xsd +3467 -0
- package/schema/current/AXLSoap.xsd +57522 -0
- package/test/tests.js +89 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Cisco AXL SOAP Library
|
|
2
|
+
|
|
3
|
+
Simple library to pull AXL data Cisco CUCM via SOAP. The goal of this project is to make it easier for people to use AXL and to include all functionality of AXL!
|
|
4
|
+
|
|
5
|
+
Administrative XML (AXL) information can be found at:
|
|
6
|
+
[Administrative XML (AXL) Reference](https://developer.cisco.com/docs/axl/#!axl-developer-guide).
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Using npm:
|
|
11
|
+
|
|
12
|
+
```javascript
|
|
13
|
+
npm i -g npm
|
|
14
|
+
npm i --save cisco-axl
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
This package uses the built in Fetch API of Node. This feature was first introduced in Node v16.15.0. You may need to enable expermential vm module. Also you can disable warnings with an optional enviromental variable.
|
|
20
|
+
|
|
21
|
+
Also if you are using self signed certificates on Cisco VOS products you may need to disable TLS verification. This makes TLS, and HTTPS by extension, insecure. The use of this environment variable is strongly discouraged. Please only do this in a lab enviroment.
|
|
22
|
+
|
|
23
|
+
Suggested enviromental variables:
|
|
24
|
+
|
|
25
|
+
```env
|
|
26
|
+
NODE_OPTIONS=--experimental-vm-modules
|
|
27
|
+
NODE_NO_WARNINGS=1
|
|
28
|
+
NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
* This library uses strong-soap to parse the AXL WSDL file. As a result any AXL function for your specified version is avaliable to use!
|
|
34
|
+
* Supports the Promise API
|
|
35
|
+
* Returns all results in JSON rather than XML
|
|
36
|
+
* Automatically cleans up SQL queries to avoid injection
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
const axlService = require("cisco-axl");
|
|
42
|
+
|
|
43
|
+
let service = new axlService("10.10.20.1", "administrator", "ciscopsdt");
|
|
44
|
+
|
|
45
|
+
var method = "addRoutePartition";
|
|
46
|
+
var params = {
|
|
47
|
+
routePartition: {
|
|
48
|
+
name: 'INTERNAL-PT',
|
|
49
|
+
description: 'Internal directory numbers',
|
|
50
|
+
timeScheduleIdName: '',
|
|
51
|
+
useOriginatingDeviceTimeZone: '',
|
|
52
|
+
timeZone: '',
|
|
53
|
+
partitionUsage: ''
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
service
|
|
58
|
+
.executeMethod(method, params)
|
|
59
|
+
.then((results) => {
|
|
60
|
+
console.log(`Here are a list of all the partitions on our cluster:`);
|
|
61
|
+
results.routePartition.map((str) => {
|
|
62
|
+
console.log(str.name);
|
|
63
|
+
});
|
|
64
|
+
})
|
|
65
|
+
.catch((error) => {
|
|
66
|
+
console.log(error);
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
Check /test/tests.js for more examples.
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
npm run test
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Note: Test are using Cisco's DevNet sandbox information. Find more information here: [Cisco DevNet](https://devnetsandbox.cisco.com/)
|
package/index.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
var soap = require("strong-soap").soap;
|
|
2
|
+
var XMLHandler = soap.XMLHandler;
|
|
3
|
+
var xmlHandler = new XMLHandler();
|
|
4
|
+
var WSDL = soap.WSDL;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Cisco axlService Service
|
|
8
|
+
* This is a service class that uses fetch and promises to pull AXL data from Cisco CUCM
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @class axlService
|
|
12
|
+
*/
|
|
13
|
+
class axlService {
|
|
14
|
+
constructor(host, username, password, version) {
|
|
15
|
+
this._OPTIONS = {
|
|
16
|
+
username: username,
|
|
17
|
+
password: password,
|
|
18
|
+
url: `./schema/${version}/AXLAPI.wsdl`,
|
|
19
|
+
endpoint: `https://${host}:8443/axl/`,
|
|
20
|
+
version: version,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
returnMethods(filter) {
|
|
24
|
+
var options = this._OPTIONS;
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
soap.createClient(options.url, {}, function (err, client) {
|
|
27
|
+
client.setSecurity(
|
|
28
|
+
new soap.BasicAuthSecurity(options.username, options.password)
|
|
29
|
+
);
|
|
30
|
+
client.setEndpoint(options.endpoint);
|
|
31
|
+
|
|
32
|
+
var description = client.describe();
|
|
33
|
+
|
|
34
|
+
var outputArr = [];
|
|
35
|
+
|
|
36
|
+
for (const [key, value] of Object.entries(
|
|
37
|
+
description.AXLAPIService.AXLPort
|
|
38
|
+
)) {
|
|
39
|
+
outputArr.push(value.name);
|
|
40
|
+
}
|
|
41
|
+
const sortAlphaNum = (a, b) =>
|
|
42
|
+
a.localeCompare(b, "en", { numeric: true });
|
|
43
|
+
const matches = (substring, array) =>
|
|
44
|
+
array.filter((element) => {
|
|
45
|
+
if (element.toLowerCase().includes(substring.toLowerCase())) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (filter) {
|
|
51
|
+
resolve(matches(filter, outputArr).sort(sortAlphaNum));
|
|
52
|
+
} else {
|
|
53
|
+
resolve(outputArr.sort(sortAlphaNum));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
client.on("soapError", function (err) {
|
|
57
|
+
reject(err.root.Envelope.Body.Fault);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
getMethodParams(method) {
|
|
63
|
+
var options = this._OPTIONS;
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
WSDL.open(
|
|
66
|
+
`./schema/${options.version}/AXLAPI.wsdl`,
|
|
67
|
+
{},
|
|
68
|
+
function (err, wsdl) {
|
|
69
|
+
if (err) {
|
|
70
|
+
reject(err);
|
|
71
|
+
}
|
|
72
|
+
var operation =
|
|
73
|
+
wsdl.definitions.bindings.AXLAPIBinding.operations[method];
|
|
74
|
+
var operName = operation.$name;
|
|
75
|
+
var operationDesc = operation.describe(wsdl);
|
|
76
|
+
var envelopeBody = {};
|
|
77
|
+
operationDesc.input.body.elements.map((object) => {
|
|
78
|
+
var operMatch = new RegExp(object.qname.name, "i");
|
|
79
|
+
envelopeBody[object.qname.name] = "";
|
|
80
|
+
if (object.qname.name === "searchCriteria") {
|
|
81
|
+
let output = nestedObj(object);
|
|
82
|
+
envelopeBody.searchCriteria = output;
|
|
83
|
+
}
|
|
84
|
+
if (object.qname.name === "returnedTags") {
|
|
85
|
+
let output = nestedObj(object);
|
|
86
|
+
envelopeBody.returnedTags = output;
|
|
87
|
+
}
|
|
88
|
+
if (operName.match(operMatch)) {
|
|
89
|
+
let output = nestedObj(object);
|
|
90
|
+
envelopeBody[object.qname.name] = output;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
resolve(envelopeBody);
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
executeMethod(method, params) {
|
|
99
|
+
var options = this._OPTIONS;
|
|
100
|
+
var cleanParams = Object.fromEntries(
|
|
101
|
+
Object.entries(params).filter(([_, v]) => v != "")
|
|
102
|
+
);
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
soap.createClient(options.url, {}, function (err, client) {
|
|
105
|
+
client.setSecurity(
|
|
106
|
+
new soap.BasicAuthSecurity(options.username, options.password)
|
|
107
|
+
);
|
|
108
|
+
client.setEndpoint(options.endpoint);
|
|
109
|
+
|
|
110
|
+
client.on("soapError", function (err) {
|
|
111
|
+
reject(err.root.Envelope.Body.Fault);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
var axlFunc = client.AXLAPIService.AXLPort[method];
|
|
115
|
+
|
|
116
|
+
axlFunc(
|
|
117
|
+
cleanParams,
|
|
118
|
+
function (
|
|
119
|
+
err,
|
|
120
|
+
result,
|
|
121
|
+
envelope,
|
|
122
|
+
rawResponse,
|
|
123
|
+
soapHeader,
|
|
124
|
+
rawRequest
|
|
125
|
+
) {
|
|
126
|
+
if (err) {
|
|
127
|
+
reject(err);
|
|
128
|
+
}
|
|
129
|
+
resolve(result.return);
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const nestedObj = (object) => {
|
|
138
|
+
var operObj = {};
|
|
139
|
+
object.elements.map((object) => {
|
|
140
|
+
operObj[object.qname.name] = "";
|
|
141
|
+
if (Array.isArray(object.elements) && object.elements.length > 0) {
|
|
142
|
+
var nestName = object.qname.name;
|
|
143
|
+
operObj[nestName] = {};
|
|
144
|
+
var nestObj = nestedObj(object);
|
|
145
|
+
operObj[nestName] = nestObj;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const isEmpty = Object.keys(operObj).length === 0;
|
|
149
|
+
if (isEmpty) {
|
|
150
|
+
operObj = "";
|
|
151
|
+
return operObj;
|
|
152
|
+
} else {
|
|
153
|
+
return operObj;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
module.exports = axlService;
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cisco-axl",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Package to make Cisco AXL easier",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 NODE_TLS_REJECT_UNAUTHORIZED=0 node ./test/tests.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"cisco",
|
|
11
|
+
"node",
|
|
12
|
+
"axl",
|
|
13
|
+
"soap",
|
|
14
|
+
"xml",
|
|
15
|
+
"callmanager"
|
|
16
|
+
],
|
|
17
|
+
"author": "Jeremy Worden",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"soap": "^0.45.0",
|
|
21
|
+
"strong-soap": "^3.4.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"node-emoji": "^1.11.0"
|
|
25
|
+
}
|
|
26
|
+
}
|