@itentialopensource/adapter-sevone 2.3.1 → 2.4.0
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 +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +45 -91
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +223 -573
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +347 -56
- package/adapterBase.js +1021 -245
- package/entities/.generic/action.json +110 -5
- package/entities/.generic/schema.json +6 -1
- package/entities/device/mockdatafiles/getdeviceerror.json +1 -58
- package/error.json +6 -0
- package/package.json +13 -7
- package/pronghorn.json +644 -380
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +421 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653680202971.json +120 -0
- package/sampleProperties.json +90 -1
- package/test/integration/adapterTestBasicGet.js +1 -1
- package/test/integration/adapterTestIntegration.js +28 -104
- package/test/unit/adapterBaseTestUnit.js +30 -25
- package/test/unit/adapterTestUnit.js +193 -181
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/basicGet.js +1 -14
- package/utils/entitiesToDB.js +179 -0
- package/utils/modify.js +1 -1
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +3 -0
- package/utils/removeHooks.js +20 -0
- package/utils/tbScript.js +43 -22
- package/utils/tbUtils.js +126 -29
- package/utils/testRunner.js +16 -16
- package/utils/troubleshootingAdapter.js +2 -26
package/SUMMARY.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
This adapter is used to integrate the Itential Automation Platform (IAP) with the SevOne System. The API that was used to build the adapter for SevOne is usually available in the report directory of this adapter. The adapter utilizes the SevOne API to provide the integrations that are deemed pertinent to IAP. The ReadMe file is intended to provide information on this adapter it is generated from various other Markdown files.
|
|
4
|
+
|
|
5
|
+
>**Note**: It is possible that some integrations will be supported through the SevOne adapter while other integrations will not. If you need additional API calls, you can use the Update capabilities provided by the Adapter Builder or request Itential to add them if the Adapter is an Itential opensourced adapter.
|
|
6
|
+
|
|
7
|
+
Itential provides information on all of its product adapters in the Customer Knowledge Base. Information in the <a href="https://itential.atlassian.net/servicedesk/customer/portals" target="_blank">Customer Knowledge Base</a> is consistently maintained and goes through documentation reviews. As a result, it should be the first place to go for information.
|
|
8
|
+
|
|
9
|
+
For opensourced and custom built adapters, the ReadMe is a starting point to understand what you have built, provide the information for you to be able to update the adapter, and assist you with deploying the adapter into IAP.
|
package/SYSTEMINFO.md
ADDED
package/TROUBLESHOOT.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
## Troubleshoot
|
|
2
|
+
|
|
3
|
+
Run `npm run troubleshoot` to start the interactive troubleshooting process. The command allows you to verify and update connection, authentication as well as healthcheck configuration. After that it will test these properties by sending HTTP request to the endpoint. If the tests pass, it will persist these changes into IAP.
|
|
4
|
+
|
|
5
|
+
You also have the option to run individual commands to perform specific test:
|
|
6
|
+
|
|
7
|
+
- `npm run healthcheck` will perform a healthcheck request of with current setting.
|
|
8
|
+
- `npm run basicget` will perform some non-parameter GET request with current setting.
|
|
9
|
+
- `npm run connectivity` will perform networking diagnostics of the adatper endpoint.
|
|
10
|
+
|
|
11
|
+
### Connectivity Issues
|
|
12
|
+
|
|
13
|
+
1. You can run the adapter troubleshooting script which will check connectivity, run the healthcheck and run basic get calls.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run troubleshoot
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Verify the adapter properties are set up correctly.
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
3. Verify there is connectivity between the Itential Platform Server and SevOne Server.
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
ping the ip address of SevOne server
|
|
29
|
+
try telnet to the ip address port of SevOne
|
|
30
|
+
execute a curl command to the other system
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
4. Verify the credentials provided for SevOne.
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
login to SevOne using the provided credentials
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
5. Verify the API of the call utilized for SevOne Healthcheck.
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Functional Issues
|
|
46
|
+
|
|
47
|
+
Adapter logs are located in `/var/log/pronghorn`. In older releases of the Itential Platform, there is a `pronghorn.log` file which contains logs for all of the Itential Platform. In newer versions, adapters can be configured to log into their own files.
|
package/adapter.js
CHANGED
|
@@ -213,10 +213,18 @@ class SevOne extends AdapterBaseCl {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
/**
|
|
216
|
-
* @
|
|
217
|
-
*/
|
|
218
|
-
|
|
219
|
-
let myIgnore = [
|
|
216
|
+
* @iapGetAdapterWorkflowFunctions
|
|
217
|
+
*/
|
|
218
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
219
|
+
let myIgnore = [
|
|
220
|
+
'healthCheck',
|
|
221
|
+
'iapGetAdapterWorkflowFunctions',
|
|
222
|
+
'iapHasAdapterEntity',
|
|
223
|
+
'iapVerifyAdapterCapability',
|
|
224
|
+
'iapUpdateAdapterEntityCache',
|
|
225
|
+
'hasEntities',
|
|
226
|
+
'getAuthorization'
|
|
227
|
+
];
|
|
220
228
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
221
229
|
myIgnore = inIgnore;
|
|
222
230
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -227,15 +235,15 @@ class SevOne extends AdapterBaseCl {
|
|
|
227
235
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
228
236
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
229
237
|
|
|
230
|
-
return super.
|
|
238
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
231
239
|
}
|
|
232
240
|
|
|
233
241
|
/**
|
|
234
|
-
*
|
|
242
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
235
243
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
236
244
|
* file system.
|
|
237
245
|
*
|
|
238
|
-
* @function
|
|
246
|
+
* @function iapUpdateAdapterConfiguration
|
|
239
247
|
* @param {string} configFile - the name of the file being updated (required)
|
|
240
248
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
241
249
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
@@ -243,36 +251,42 @@ class SevOne extends AdapterBaseCl {
|
|
|
243
251
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
244
252
|
* @param {Callback} callback - The results of the call
|
|
245
253
|
*/
|
|
246
|
-
|
|
247
|
-
const
|
|
254
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
255
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
256
|
+
const origin = `${this.id}-${meth}`;
|
|
248
257
|
log.trace(origin);
|
|
249
|
-
|
|
258
|
+
|
|
259
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
250
260
|
}
|
|
251
261
|
|
|
252
262
|
/**
|
|
253
263
|
* See if the API path provided is found in this adapter
|
|
254
264
|
*
|
|
255
|
-
* @function
|
|
265
|
+
* @function iapFindAdapterPath
|
|
256
266
|
* @param {string} apiPath - the api path to check on
|
|
257
267
|
* @param {Callback} callback - The results of the call
|
|
258
268
|
*/
|
|
259
|
-
|
|
260
|
-
const
|
|
269
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
270
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
271
|
+
const origin = `${this.id}-${meth}`;
|
|
261
272
|
log.trace(origin);
|
|
262
|
-
|
|
273
|
+
|
|
274
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
263
275
|
}
|
|
264
276
|
|
|
265
277
|
/**
|
|
266
278
|
* @summary Suspends adapter
|
|
267
279
|
*
|
|
268
|
-
* @function
|
|
280
|
+
* @function iapSuspendAdapter
|
|
269
281
|
* @param {Callback} callback - callback function
|
|
270
282
|
*/
|
|
271
|
-
|
|
272
|
-
const
|
|
283
|
+
iapSuspendAdapter(mode, callback) {
|
|
284
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
285
|
+
const origin = `${this.id}-${meth}`;
|
|
273
286
|
log.trace(origin);
|
|
287
|
+
|
|
274
288
|
try {
|
|
275
|
-
return super.
|
|
289
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
276
290
|
} catch (error) {
|
|
277
291
|
log.error(`${origin}: ${error}`);
|
|
278
292
|
return callback(null, error);
|
|
@@ -282,14 +296,16 @@ class SevOne extends AdapterBaseCl {
|
|
|
282
296
|
/**
|
|
283
297
|
* @summary Unsuspends adapter
|
|
284
298
|
*
|
|
285
|
-
* @function
|
|
299
|
+
* @function iapUnsuspendAdapter
|
|
286
300
|
* @param {Callback} callback - callback function
|
|
287
301
|
*/
|
|
288
|
-
|
|
289
|
-
const
|
|
302
|
+
iapUnsuspendAdapter(callback) {
|
|
303
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
304
|
+
const origin = `${this.id}-${meth}`;
|
|
290
305
|
log.trace(origin);
|
|
306
|
+
|
|
291
307
|
try {
|
|
292
|
-
return super.
|
|
308
|
+
return super.iapUnsuspendAdapter(callback);
|
|
293
309
|
} catch (error) {
|
|
294
310
|
log.error(`${origin}: ${error}`);
|
|
295
311
|
return callback(null, error);
|
|
@@ -299,29 +315,33 @@ class SevOne extends AdapterBaseCl {
|
|
|
299
315
|
/**
|
|
300
316
|
* @summary Get the Adaoter Queue
|
|
301
317
|
*
|
|
302
|
-
* @function
|
|
318
|
+
* @function iapGetAdapterQueue
|
|
303
319
|
* @param {Callback} callback - callback function
|
|
304
320
|
*/
|
|
305
|
-
|
|
306
|
-
const
|
|
321
|
+
iapGetAdapterQueue(callback) {
|
|
322
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
323
|
+
const origin = `${this.id}-${meth}`;
|
|
307
324
|
log.trace(origin);
|
|
308
|
-
|
|
325
|
+
|
|
326
|
+
return super.iapGetAdapterQueue(callback);
|
|
309
327
|
}
|
|
310
328
|
|
|
311
329
|
/**
|
|
312
330
|
* @summary Runs troubleshoot scripts for adapter
|
|
313
331
|
*
|
|
314
|
-
* @function
|
|
332
|
+
* @function iapTroubleshootAdapter
|
|
315
333
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
316
334
|
*
|
|
317
335
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
318
336
|
* @param {Callback} callback - The results of the call
|
|
319
337
|
*/
|
|
320
|
-
|
|
321
|
-
const
|
|
338
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
339
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
340
|
+
const origin = `${this.id}-${meth}`;
|
|
322
341
|
log.trace(origin);
|
|
342
|
+
|
|
323
343
|
try {
|
|
324
|
-
return super.
|
|
344
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
325
345
|
} catch (error) {
|
|
326
346
|
log.error(`${origin}: ${error}`);
|
|
327
347
|
return callback(null, error);
|
|
@@ -331,15 +351,17 @@ class SevOne extends AdapterBaseCl {
|
|
|
331
351
|
/**
|
|
332
352
|
* @summary runs healthcheck script for adapter
|
|
333
353
|
*
|
|
334
|
-
* @function
|
|
354
|
+
* @function iapRunAdapterHealthcheck
|
|
335
355
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
336
356
|
* @param {Callback} callback - callback function
|
|
337
357
|
*/
|
|
338
|
-
|
|
339
|
-
const
|
|
358
|
+
iapRunAdapterHealthcheck(callback) {
|
|
359
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
360
|
+
const origin = `${this.id}-${meth}`;
|
|
340
361
|
log.trace(origin);
|
|
362
|
+
|
|
341
363
|
try {
|
|
342
|
-
return super.
|
|
364
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
343
365
|
} catch (error) {
|
|
344
366
|
log.error(`${origin}: ${error}`);
|
|
345
367
|
return callback(null, error);
|
|
@@ -349,14 +371,16 @@ class SevOne extends AdapterBaseCl {
|
|
|
349
371
|
/**
|
|
350
372
|
* @summary runs connectivity check script for adapter
|
|
351
373
|
*
|
|
352
|
-
* @function
|
|
374
|
+
* @function iapRunAdapterConnectivity
|
|
353
375
|
* @param {Callback} callback - callback function
|
|
354
376
|
*/
|
|
355
|
-
|
|
356
|
-
const
|
|
377
|
+
iapRunAdapterConnectivity(callback) {
|
|
378
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
379
|
+
const origin = `${this.id}-${meth}`;
|
|
357
380
|
log.trace(origin);
|
|
381
|
+
|
|
358
382
|
try {
|
|
359
|
-
return super.
|
|
383
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
360
384
|
} catch (error) {
|
|
361
385
|
log.error(`${origin}: ${error}`);
|
|
362
386
|
return callback(null, error);
|
|
@@ -366,44 +390,67 @@ class SevOne extends AdapterBaseCl {
|
|
|
366
390
|
/**
|
|
367
391
|
* @summary runs basicGet script for adapter
|
|
368
392
|
*
|
|
369
|
-
* @function
|
|
393
|
+
* @function iapRunAdapterBasicGet
|
|
370
394
|
* @param {Callback} callback - callback function
|
|
371
395
|
*/
|
|
372
|
-
|
|
373
|
-
const
|
|
396
|
+
iapRunAdapterBasicGet(callback) {
|
|
397
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
398
|
+
const origin = `${this.id}-${meth}`;
|
|
374
399
|
log.trace(origin);
|
|
400
|
+
|
|
375
401
|
try {
|
|
376
|
-
return super.
|
|
402
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
377
403
|
} catch (error) {
|
|
378
404
|
log.error(`${origin}: ${error}`);
|
|
379
405
|
return callback(null, error);
|
|
380
406
|
}
|
|
381
407
|
}
|
|
382
408
|
|
|
409
|
+
/**
|
|
410
|
+
* @summary moves entites into Mongo DB
|
|
411
|
+
*
|
|
412
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
413
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
414
|
+
* or the error
|
|
415
|
+
*/
|
|
416
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
417
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
418
|
+
const origin = `${this.id}-${meth}`;
|
|
419
|
+
log.trace(origin);
|
|
420
|
+
|
|
421
|
+
try {
|
|
422
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
423
|
+
} catch (err) {
|
|
424
|
+
log.error(`${origin}: ${err}`);
|
|
425
|
+
return callback(null, err);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/* BROKER CALLS */
|
|
383
430
|
/**
|
|
384
431
|
* @summary Determines if this adapter supports the specific entity
|
|
385
432
|
*
|
|
386
|
-
* @function
|
|
433
|
+
* @function iapHasAdapterEntity
|
|
387
434
|
* @param {String} entityType - the entity type to check for
|
|
388
435
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
389
436
|
*
|
|
390
437
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
391
438
|
* desired capability or an error
|
|
392
439
|
*/
|
|
393
|
-
|
|
394
|
-
const origin = `${this.id}-adapter-
|
|
440
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
441
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
395
442
|
log.trace(origin);
|
|
396
443
|
|
|
397
444
|
// Make the call -
|
|
398
|
-
//
|
|
399
|
-
return this.
|
|
445
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
446
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
400
447
|
}
|
|
401
448
|
|
|
402
449
|
/**
|
|
403
450
|
* @summary Provides a way for the adapter to tell north bound integrations
|
|
404
451
|
* whether the adapter supports type, action and specific entity
|
|
405
452
|
*
|
|
406
|
-
* @function
|
|
453
|
+
* @function iapVerifyAdapterCapability
|
|
407
454
|
* @param {String} entityType - the entity type to check for
|
|
408
455
|
* @param {String} actionType - the action type to check for
|
|
409
456
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
@@ -411,7 +458,7 @@ class SevOne extends AdapterBaseCl {
|
|
|
411
458
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
412
459
|
* desired capability or an error
|
|
413
460
|
*/
|
|
414
|
-
|
|
461
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
415
462
|
const meth = 'adapterBase-verifyCapability';
|
|
416
463
|
const origin = `${this.id}-${meth}`;
|
|
417
464
|
log.trace(origin);
|
|
@@ -774,10 +821,10 @@ class SevOne extends AdapterBaseCl {
|
|
|
774
821
|
/**
|
|
775
822
|
* @summary Updates the cache for all entities by call the get All entity method
|
|
776
823
|
*
|
|
777
|
-
* @function
|
|
824
|
+
* @function iapUpdateAdapterEntityCache
|
|
778
825
|
*
|
|
779
826
|
*/
|
|
780
|
-
|
|
827
|
+
iapUpdateAdapterEntityCache() {
|
|
781
828
|
const origin = `${this.id}-adapter-updateEntityCache`;
|
|
782
829
|
log.trace(origin);
|
|
783
830
|
|
|
@@ -828,6 +875,140 @@ class SevOne extends AdapterBaseCl {
|
|
|
828
875
|
}
|
|
829
876
|
}
|
|
830
877
|
|
|
878
|
+
/**
|
|
879
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
880
|
+
*
|
|
881
|
+
* @function hasEntities
|
|
882
|
+
* @param {String} entityType - the entity type to check for
|
|
883
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
884
|
+
*
|
|
885
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
886
|
+
* value is true or false
|
|
887
|
+
*/
|
|
888
|
+
hasEntities(entityType, entityList, callback) {
|
|
889
|
+
const meth = 'adapter-hasEntities';
|
|
890
|
+
const origin = `${this.id}-${meth}`;
|
|
891
|
+
log.trace(origin);
|
|
892
|
+
|
|
893
|
+
try {
|
|
894
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
895
|
+
} catch (err) {
|
|
896
|
+
log.error(`${origin}: ${err}`);
|
|
897
|
+
return callback(null, err);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* @summary Get Appliance that match the deviceName
|
|
903
|
+
*
|
|
904
|
+
* @function getDevice
|
|
905
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
906
|
+
*
|
|
907
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
908
|
+
* (appliance) or the error
|
|
909
|
+
*/
|
|
910
|
+
getDevice(deviceName, callback) {
|
|
911
|
+
const meth = 'adapter-getDevice';
|
|
912
|
+
const origin = `${this.id}-${meth}`;
|
|
913
|
+
log.trace(origin);
|
|
914
|
+
|
|
915
|
+
try {
|
|
916
|
+
return super.getDevice(deviceName, callback);
|
|
917
|
+
} catch (err) {
|
|
918
|
+
log.error(`${origin}: ${err}`);
|
|
919
|
+
return callback(null, err);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* @summary Get Appliances that match the filter
|
|
925
|
+
*
|
|
926
|
+
* @function getDevicesFiltered
|
|
927
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
928
|
+
*
|
|
929
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
930
|
+
* (appliances) or the error
|
|
931
|
+
*/
|
|
932
|
+
getDevicesFiltered(options, callback) {
|
|
933
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
934
|
+
const origin = `${this.id}-${meth}`;
|
|
935
|
+
log.trace(origin);
|
|
936
|
+
|
|
937
|
+
try {
|
|
938
|
+
return super.getDevicesFiltered(options, callback);
|
|
939
|
+
} catch (err) {
|
|
940
|
+
log.error(`${origin}: ${err}`);
|
|
941
|
+
return callback(null, err);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* @summary Gets the status for the provided appliance
|
|
947
|
+
*
|
|
948
|
+
* @function isAlive
|
|
949
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
950
|
+
*
|
|
951
|
+
* @param {configCallback} callback - callback function to return the result
|
|
952
|
+
* (appliance isAlive) or the error
|
|
953
|
+
*/
|
|
954
|
+
isAlive(deviceName, callback) {
|
|
955
|
+
const meth = 'adapter-isAlive';
|
|
956
|
+
const origin = `${this.id}-${meth}`;
|
|
957
|
+
log.trace(origin);
|
|
958
|
+
|
|
959
|
+
try {
|
|
960
|
+
return super.isAlive(deviceName, callback);
|
|
961
|
+
} catch (err) {
|
|
962
|
+
log.error(`${origin}: ${err}`);
|
|
963
|
+
return callback(null, err);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* @summary Gets a config for the provided Appliance
|
|
969
|
+
*
|
|
970
|
+
* @function getConfig
|
|
971
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
972
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
973
|
+
*
|
|
974
|
+
* @param {configCallback} callback - callback function to return the result
|
|
975
|
+
* (appliance config) or the error
|
|
976
|
+
*/
|
|
977
|
+
getConfig(deviceName, format, callback) {
|
|
978
|
+
const meth = 'adapter-getConfig';
|
|
979
|
+
const origin = `${this.id}-${meth}`;
|
|
980
|
+
log.trace(origin);
|
|
981
|
+
|
|
982
|
+
try {
|
|
983
|
+
return super.getConfig(deviceName, format, callback);
|
|
984
|
+
} catch (err) {
|
|
985
|
+
log.error(`${origin}: ${err}`);
|
|
986
|
+
return callback(null, err);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* @summary Gets the device count from the system
|
|
992
|
+
*
|
|
993
|
+
* @function iapGetDeviceCount
|
|
994
|
+
*
|
|
995
|
+
* @param {getCallback} callback - callback function to return the result
|
|
996
|
+
* (count) or the error
|
|
997
|
+
*/
|
|
998
|
+
iapGetDeviceCount(callback) {
|
|
999
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
1000
|
+
const origin = `${this.id}-${meth}`;
|
|
1001
|
+
log.trace(origin);
|
|
1002
|
+
|
|
1003
|
+
try {
|
|
1004
|
+
return super.iapGetDeviceCount(callback);
|
|
1005
|
+
} catch (err) {
|
|
1006
|
+
log.error(`${origin}: ${err}`);
|
|
1007
|
+
return callback(null, err);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
831
1012
|
/**
|
|
832
1013
|
* Makes the requested generic call
|
|
833
1014
|
*
|
|
@@ -938,6 +1119,116 @@ class SevOne extends AdapterBaseCl {
|
|
|
938
1119
|
}
|
|
939
1120
|
}
|
|
940
1121
|
|
|
1122
|
+
/**
|
|
1123
|
+
* Makes the requested generic call with no base path or version
|
|
1124
|
+
*
|
|
1125
|
+
* @function genericAdapterRequestNoBasePath
|
|
1126
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
1127
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
1128
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
1129
|
+
* Can be a stringified Object.
|
|
1130
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
1131
|
+
* Can be a stringified Object.
|
|
1132
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
1133
|
+
* Can be a stringified Object.
|
|
1134
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
1135
|
+
* or the error
|
|
1136
|
+
*/
|
|
1137
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
1138
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
1139
|
+
const origin = `${this.id}-${meth}`;
|
|
1140
|
+
log.trace(origin);
|
|
1141
|
+
|
|
1142
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1143
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1144
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1145
|
+
return callback(null, errorObj);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1149
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
1150
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
1151
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1152
|
+
return callback(null, errorObj);
|
|
1153
|
+
}
|
|
1154
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
1155
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
1156
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1157
|
+
return callback(null, errorObj);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1161
|
+
// remove any leading / and split the uripath into path variables
|
|
1162
|
+
let myPath = uriPath;
|
|
1163
|
+
while (myPath.indexOf('/') === 0) {
|
|
1164
|
+
myPath = myPath.substring(1);
|
|
1165
|
+
}
|
|
1166
|
+
const pathVars = myPath.split('/');
|
|
1167
|
+
const queryParamsAvailable = queryData;
|
|
1168
|
+
const queryParams = {};
|
|
1169
|
+
const bodyVars = requestBody;
|
|
1170
|
+
|
|
1171
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1172
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1173
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1174
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1175
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
|
|
1179
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
1180
|
+
const reqObj = {
|
|
1181
|
+
payload: bodyVars,
|
|
1182
|
+
uriPathVars: pathVars,
|
|
1183
|
+
uriQuery: queryParams,
|
|
1184
|
+
uriOptions: {}
|
|
1185
|
+
};
|
|
1186
|
+
// add headers if provided
|
|
1187
|
+
if (addlHeaders) {
|
|
1188
|
+
reqObj.addlHeaders = addlHeaders;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
// determine the call and return flag
|
|
1192
|
+
let action = 'getGenericsNoBase';
|
|
1193
|
+
let returnF = true;
|
|
1194
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
1195
|
+
action = 'createGenericNoBase';
|
|
1196
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
1197
|
+
action = 'updateGenericNoBase';
|
|
1198
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
1199
|
+
action = 'patchGenericNoBase';
|
|
1200
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
1201
|
+
action = 'deleteGenericNoBase';
|
|
1202
|
+
returnF = false;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
try {
|
|
1206
|
+
// Make the call -
|
|
1207
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1208
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
1209
|
+
// if we received an error or their is no response on the results
|
|
1210
|
+
// return an error
|
|
1211
|
+
if (irReturnError) {
|
|
1212
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1213
|
+
return callback(null, irReturnError);
|
|
1214
|
+
}
|
|
1215
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1216
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
|
1217
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1218
|
+
return callback(null, errorObj);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1222
|
+
// return the response
|
|
1223
|
+
return callback(irReturnData, null);
|
|
1224
|
+
});
|
|
1225
|
+
} catch (ex) {
|
|
1226
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1227
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1228
|
+
return callback(null, errorObj);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
|
|
941
1232
|
/**
|
|
942
1233
|
* @callback healthCallback
|
|
943
1234
|
* @param {Object} result - the result of the get request (contains an id and a status)
|
|
@@ -3429,7 +3720,7 @@ class SevOne extends AdapterBaseCl {
|
|
|
3429
3720
|
/**
|
|
3430
3721
|
* @summary This function will retrieve the Devices from SevOne and pass them up to Pronghorn
|
|
3431
3722
|
*
|
|
3432
|
-
* @function
|
|
3723
|
+
* @function getSevDevicesFiltered
|
|
3433
3724
|
* @param {Object} filterObj - the filter to be used (optional).
|
|
3434
3725
|
* Can be a stringified Object.
|
|
3435
3726
|
* @param {uriOptions} uriOptions - optional paramters to pass on uri of the request (optional).
|
|
@@ -3439,8 +3730,8 @@ class SevOne extends AdapterBaseCl {
|
|
|
3439
3730
|
* @param {createCallback} callback - a callback function to return a result
|
|
3440
3731
|
* (Entity) or the error
|
|
3441
3732
|
*/
|
|
3442
|
-
|
|
3443
|
-
const meth = 'adapter-
|
|
3733
|
+
getSevDevicesFiltered(filterObj, uriOptions, callback) {
|
|
3734
|
+
const meth = 'adapter-getSevDevicesFiltered';
|
|
3444
3735
|
const origin = `${this.id}-${meth}`;
|
|
3445
3736
|
log.trace(origin);
|
|
3446
3737
|
|
|
@@ -3469,7 +3760,7 @@ class SevOne extends AdapterBaseCl {
|
|
|
3469
3760
|
return callback(null, error);
|
|
3470
3761
|
}
|
|
3471
3762
|
if (!Object.hasOwnProperty.call(result, 'response')) {
|
|
3472
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['
|
|
3763
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSevDevicesFiltered'], null, null, null);
|
|
3473
3764
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3474
3765
|
return callback(null, errorObj);
|
|
3475
3766
|
}
|
|
@@ -3513,7 +3804,7 @@ class SevOne extends AdapterBaseCl {
|
|
|
3513
3804
|
}
|
|
3514
3805
|
|
|
3515
3806
|
// real call to get devices
|
|
3516
|
-
return this.
|
|
3807
|
+
return this.getSevDevicesFiltered(deviceObj, uriOptions, callback);
|
|
3517
3808
|
}
|
|
3518
3809
|
|
|
3519
3810
|
/**
|