@itentialopensource/adapter-alkira 0.1.1 → 0.1.3
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/AUTH.md +30 -4
- package/CHANGELOG.md +16 -1
- package/adapterBase.js +48 -47
- package/entities/.system/schemaTokenReq.json +1 -1
- package/entities/.system/schemaTokenResp.json +14 -2
- package/package.json +3 -3
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +5 -5
package/AUTH.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
## Authenticating Alkira Adapter
|
|
1
|
+
## Authenticating Alkira Adapter
|
|
2
2
|
|
|
3
|
-
This document will go through the steps for authenticating the Alkira adapter with Basic Authentication. Properly configuring the properties for an adapter in IAP is critical for getting the adapter online. You can read more about adapter authentication <a href="https://www.itential.com/automation-platform/integrations/adapters-resources/authentication/" target="_blank">HERE</a>.
|
|
3
|
+
This document will go through the steps for authenticating the Alkira adapter with Basic Authentication. Properly configuring the properties for an adapter in IAP is critical for getting the adapter online. You can read more about adapter authentication <a href="https://www.itential.com/automation-platform/integrations/adapters-resources/authentication/" target="_blank">HERE</a>.
|
|
4
4
|
|
|
5
5
|
### Basic Authentication
|
|
6
6
|
The Alkira adapter requires Basic Authentication. If you change authentication methods, you should change this section accordingly and merge it back into the adapter repository.
|
|
7
7
|
|
|
8
|
-
STEPS
|
|
8
|
+
STEPS
|
|
9
9
|
1. Ensure you have access to a Alkira server and that it is running
|
|
10
10
|
2. Follow the steps in the README.md to import the adapter into IAP if you have not already done so
|
|
11
11
|
3. Use the properties below for the ```properties.authentication``` field
|
|
@@ -26,7 +26,33 @@ STEPS
|
|
|
26
26
|
"grant_type": ""
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
|
-
4. Restart the adapter. If your properties were set correctly, the adapter should go online.
|
|
29
|
+
4. Restart the adapter. If your properties were set correctly, the adapter should go online.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Token Authentication
|
|
33
|
+
|
|
34
|
+
STEPS
|
|
35
|
+
1. Ensure you have access to a Alkira server and that it is running
|
|
36
|
+
2. Follow the steps in the README.md to import the adapter into IAP if you have not already done so
|
|
37
|
+
3. Use the properties below for the ```properties.authentication``` field
|
|
38
|
+
```json
|
|
39
|
+
"authentication": {
|
|
40
|
+
"auth_method": "request_token",
|
|
41
|
+
"username": "<username>",
|
|
42
|
+
"password": "<password>",
|
|
43
|
+
"token": "",
|
|
44
|
+
"token_timeout": 1800000,
|
|
45
|
+
"token_cache": "local",
|
|
46
|
+
"invalid_token_error": 401,
|
|
47
|
+
"auth_field": "header.headers.Cookie",
|
|
48
|
+
"auth_field_format": "JSESSIONID={token};SESSION={tokenp2}",
|
|
49
|
+
"auth_logging": false,
|
|
50
|
+
"client_id": "",
|
|
51
|
+
"client_secret": "",
|
|
52
|
+
"grant_type": ""
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
4. Restart the adapter. If your properties were set correctly, the adapter should go online.
|
|
30
56
|
|
|
31
57
|
### Troubleshooting
|
|
32
58
|
- Make sure you copied over the correct username and password.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
## 0.1.3 [04-06-2023]
|
|
3
|
+
|
|
4
|
+
* bug fix for getConfig and iapGetDeviceCount in adapterBase.js
|
|
5
|
+
|
|
6
|
+
See merge request itentialopensource/adapters/cloud/adapter-alkira!2
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 0.1.2 [12-21-2022]
|
|
11
|
+
|
|
12
|
+
* Updates to authentication schemas
|
|
13
|
+
|
|
14
|
+
See merge request itentialopensource/adapters/cloud/adapter-alkira!1
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
2
18
|
## 0.1.1 [11-28-2022]
|
|
3
19
|
|
|
4
20
|
* Bug fixes and performance improvements
|
|
@@ -6,4 +22,3 @@
|
|
|
6
22
|
See commit c896979
|
|
7
23
|
|
|
8
24
|
---
|
|
9
|
-
|
package/adapterBase.js
CHANGED
|
@@ -1160,72 +1160,65 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1160
1160
|
uriMethod = callProps.method;
|
|
1161
1161
|
}
|
|
1162
1162
|
if (callProps.query) {
|
|
1163
|
-
callQuery = callProps.query;
|
|
1163
|
+
callQuery = { ...callProps.query };
|
|
1164
1164
|
|
|
1165
1165
|
// go through the query params to check for variable values
|
|
1166
1166
|
const cpKeys = Object.keys(callQuery);
|
|
1167
1167
|
for (let cp = 0; cp < cpKeys.length; cp += 1) {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
// put the value into the query - if it has been specified in the query
|
|
1179
|
-
callQuery[cpKeys[cp]] = fieldValue;
|
|
1180
|
-
}
|
|
1168
|
+
// make any necessary changes to the query params
|
|
1169
|
+
if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
|
|
1170
|
+
const rqKeys = Object.keys(callProps.requestFields);
|
|
1171
|
+
|
|
1172
|
+
// get the field from the provided device
|
|
1173
|
+
for (let rq = 0; rq < rqKeys.length; rq += 1) {
|
|
1174
|
+
if (callQuery[cpKeys[cp]] === rqKeys[rq]) {
|
|
1175
|
+
const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
|
|
1176
|
+
// put the value into the query - if it has been specified in the query
|
|
1177
|
+
callQuery[cpKeys[cp]] = fieldValue;
|
|
1181
1178
|
}
|
|
1182
1179
|
}
|
|
1183
1180
|
}
|
|
1184
1181
|
}
|
|
1185
1182
|
}
|
|
1186
1183
|
if (callProps.body) {
|
|
1187
|
-
callBody = callProps.body;
|
|
1184
|
+
callBody = { ...callProps.body };
|
|
1188
1185
|
|
|
1189
1186
|
// go through the body fields to check for variable values
|
|
1190
1187
|
const cbKeys = Object.keys(callBody);
|
|
1191
1188
|
for (let cb = 0; cb < cbKeys.length; cb += 1) {
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
callBody[cbKeys[cb]] = fieldValue;
|
|
1204
|
-
}
|
|
1189
|
+
// make any necessary changes to the query params
|
|
1190
|
+
if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
|
|
1191
|
+
const rqKeys = Object.keys(callProps.requestFields);
|
|
1192
|
+
|
|
1193
|
+
// get the field from the provided device
|
|
1194
|
+
for (let rq = 0; rq < rqKeys.length; rq += 1) {
|
|
1195
|
+
if (callBody[cbKeys[cb]] === rqKeys[rq]) {
|
|
1196
|
+
const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
|
|
1197
|
+
|
|
1198
|
+
// put the value into the query - if it has been specified in the query
|
|
1199
|
+
callBody[cbKeys[cb]] = fieldValue;
|
|
1205
1200
|
}
|
|
1206
1201
|
}
|
|
1207
1202
|
}
|
|
1208
1203
|
}
|
|
1209
1204
|
}
|
|
1210
1205
|
if (callProps.headers) {
|
|
1211
|
-
callHeaders = callProps.headers;
|
|
1206
|
+
callHeaders = { ...callProps.headers };
|
|
1212
1207
|
|
|
1213
1208
|
// go through the body fields to check for variable values
|
|
1214
1209
|
const chKeys = Object.keys(callHeaders);
|
|
1215
1210
|
for (let ch = 0; ch < chKeys.length; ch += 1) {
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
callHeaders[chKeys[ch]] = fieldValue;
|
|
1228
|
-
}
|
|
1211
|
+
// make any necessary changes to the query params
|
|
1212
|
+
if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
|
|
1213
|
+
const rqKeys = Object.keys(callProps.requestFields);
|
|
1214
|
+
|
|
1215
|
+
// get the field from the provided device
|
|
1216
|
+
for (let rq = 0; rq < rqKeys.length; rq += 1) {
|
|
1217
|
+
if (callHeaders[chKeys[ch]] === rqKeys[rq]) {
|
|
1218
|
+
const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
|
|
1219
|
+
|
|
1220
|
+
// put the value into the query - if it has been specified in the query
|
|
1221
|
+
callHeaders[chKeys[ch]] = fieldValue;
|
|
1229
1222
|
}
|
|
1230
1223
|
}
|
|
1231
1224
|
}
|
|
@@ -1247,6 +1240,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1247
1240
|
// if we received an error or their is no response on the results return an error
|
|
1248
1241
|
if (error) {
|
|
1249
1242
|
if (handleFail === 'fail') {
|
|
1243
|
+
// IT IS CRASHING RIGHT BELOW HERE
|
|
1250
1244
|
return callback(null, error);
|
|
1251
1245
|
}
|
|
1252
1246
|
return callback({}, null);
|
|
@@ -1427,7 +1421,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1427
1421
|
// Perform component calls here.
|
|
1428
1422
|
callPromises.push(
|
|
1429
1423
|
new Promise((resolve, reject) => {
|
|
1430
|
-
this.iapMakeBrokerCall('getDevice', this.allProps.devicebroker.getDevice[i], [devs.list[0]],
|
|
1424
|
+
this.iapMakeBrokerCall('getDevice', this.allProps.devicebroker.getDevice[i], [devs.list[0]], [deviceName], (callRet, callErr) => {
|
|
1431
1425
|
// return an error
|
|
1432
1426
|
if (callErr) {
|
|
1433
1427
|
reject(callErr);
|
|
@@ -1535,6 +1529,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1535
1529
|
let myResult = [];
|
|
1536
1530
|
results.forEach((result) => {
|
|
1537
1531
|
if (Array.isArray(result)) {
|
|
1532
|
+
// myResult = myResult.concat(result);
|
|
1538
1533
|
myResult = [...myResult, ...result];
|
|
1539
1534
|
} else if (Object.keys(result).length > 0) {
|
|
1540
1535
|
myResult.push(result);
|
|
@@ -1691,7 +1686,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1691
1686
|
// Perform component calls here.
|
|
1692
1687
|
callPromises.push(
|
|
1693
1688
|
new Promise((resolve, reject) => {
|
|
1694
|
-
this.iapMakeBrokerCall('getConfig', this.allProps.devicebroker.getConfig[i], [devs.list[0]],
|
|
1689
|
+
this.iapMakeBrokerCall('getConfig', this.allProps.devicebroker.getConfig[i], [devs.list[0]], [deviceName], (callRet, callErr) => {
|
|
1695
1690
|
// return an error
|
|
1696
1691
|
if (callErr) {
|
|
1697
1692
|
reject(callErr);
|
|
@@ -1708,7 +1703,13 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1708
1703
|
return Promise.all(callPromises).then((results) => {
|
|
1709
1704
|
let myResult = {};
|
|
1710
1705
|
results.forEach((result) => {
|
|
1711
|
-
|
|
1706
|
+
if (typeof result === 'string') {
|
|
1707
|
+
myResult = { ...myResult, result };
|
|
1708
|
+
} else if (Array.isArray(result)) {
|
|
1709
|
+
myResult = result[0];
|
|
1710
|
+
} else {
|
|
1711
|
+
myResult = { ...myResult, ...result };
|
|
1712
|
+
}
|
|
1712
1713
|
});
|
|
1713
1714
|
|
|
1714
1715
|
// return the result
|
|
@@ -1753,7 +1754,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1753
1754
|
// Perform component calls here.
|
|
1754
1755
|
callPromises.push(
|
|
1755
1756
|
new Promise((resolve, reject) => {
|
|
1756
|
-
this.iapMakeBrokerCall('getCount', this.allProps.devicebroker.getCount[i],
|
|
1757
|
+
this.iapMakeBrokerCall('getCount', this.allProps.devicebroker.getCount[i], [{ fake: 'fakedata' }], null, (callRet, callErr) => {
|
|
1757
1758
|
// return an error
|
|
1758
1759
|
if (callErr) {
|
|
1759
1760
|
reject(callErr);
|
|
@@ -1774,7 +1775,7 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1774
1775
|
});
|
|
1775
1776
|
|
|
1776
1777
|
// return the result
|
|
1777
|
-
return callback({ count: myResult.length });
|
|
1778
|
+
return callback({ count: Object.keys(myResult).length });
|
|
1778
1779
|
});
|
|
1779
1780
|
} catch (ex) {
|
|
1780
1781
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
@@ -41,12 +41,24 @@
|
|
|
41
41
|
"description": "token returned by system",
|
|
42
42
|
"parse": false,
|
|
43
43
|
"encode": false,
|
|
44
|
-
"placement": "
|
|
44
|
+
"placement": "HEADER",
|
|
45
45
|
"encrypt": {
|
|
46
46
|
"type": "AES",
|
|
47
47
|
"key": ""
|
|
48
48
|
},
|
|
49
|
-
"external_name": "
|
|
49
|
+
"external_name": "set-cookie.JSESSIONID"
|
|
50
|
+
},
|
|
51
|
+
"tokenp2": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"description": "token returned by system",
|
|
54
|
+
"parse": false,
|
|
55
|
+
"encode": false,
|
|
56
|
+
"placement": "HEADER",
|
|
57
|
+
"encrypt": {
|
|
58
|
+
"type": "AES",
|
|
59
|
+
"key": ""
|
|
60
|
+
},
|
|
61
|
+
"external_name": "set-cookie.SESSION"
|
|
50
62
|
}
|
|
51
63
|
},
|
|
52
64
|
"definitions": {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itentialopensource/adapter-alkira",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "This adapter integrates with system described as: alkiraApi.",
|
|
5
5
|
"main": "adapter.js",
|
|
6
6
|
"wizardVersion": "2.44.15",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"mongodb": "^4.1.0",
|
|
66
66
|
"network-diagnostics": "^0.5.3",
|
|
67
67
|
"nyc": "^15.1.0",
|
|
68
|
+
"prompts": "^2.4.2",
|
|
68
69
|
"readline-sync": "^1.4.10",
|
|
69
70
|
"semver": "^7.3.2",
|
|
70
|
-
"winston": "^3.3.3"
|
|
71
|
-
"prompts": "^2.4.2"
|
|
71
|
+
"winston": "^3.3.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"chai": "^4.3.4",
|
|
Binary file
|
package/report/adapterInfo.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
3
|
-
"configLines":
|
|
2
|
+
"version": "0.1.2",
|
|
3
|
+
"configLines": 46212,
|
|
4
4
|
"scriptLines": 1795,
|
|
5
|
-
"codeLines":
|
|
6
|
-
"testLines":
|
|
5
|
+
"codeLines": 40907,
|
|
6
|
+
"testLines": 32660,
|
|
7
7
|
"testCases": 1735,
|
|
8
|
-
"totalCodeLines":
|
|
8
|
+
"totalCodeLines": 75362,
|
|
9
9
|
"wfTasks": 457
|
|
10
10
|
}
|