@itentialopensource/adapter-sevone 2.4.0 → 2.5.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/CALLS.md +1661 -22
- package/CHANGELOG.md +16 -0
- package/CONTRIBUTING.md +1 -160
- package/ENHANCE.md +2 -2
- package/README.md +32 -23
- package/adapter.js +158 -668
- package/adapterBase.js +549 -879
- package/changelogs/CHANGELOG.md +118 -0
- package/metadata.json +49 -0
- package/package.json +24 -24
- package/pronghorn.json +980 -641
- package/propertiesSchema.json +431 -31
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +26172 -0
- package/report/adapter-openapi.yaml +11817 -0
- package/report/adapterInfo.json +8 -8
- package/report/updateReport1691508994383.json +120 -0
- package/report/updateReport1692202309339.json +120 -0
- package/report/updateReport1692203396464.json +120 -0
- package/report/updateReport1694470055393.json +120 -0
- package/report/updateReport1698423190930.json +120 -0
- package/sampleProperties.json +63 -2
- package/test/integration/adapterTestBasicGet.js +2 -4
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +130 -2
- package/test/unit/adapterBaseTestUnit.js +388 -313
- package/test/unit/adapterTestUnit.js +384 -158
- package/utils/adapterInfo.js +1 -1
- package/utils/addAuth.js +1 -1
- package/utils/artifactize.js +1 -1
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +2 -2
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +13 -15
- package/utils/packModificationScript.js +1 -1
- package/utils/pre-commit.sh +2 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +89 -34
- package/utils/tbUtils.js +41 -21
- package/utils/testRunner.js +1 -1
- package/utils/troubleshootingAdapter.js +9 -6
- package/workflows/README.md +0 -3
package/adapter.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
/* eslint object-curly-newline: warn */
|
|
9
9
|
/* eslint no-underscore-dangle: warn */
|
|
10
10
|
/* eslint camelcase: warn */
|
|
11
|
+
/* eslint default-param-last: warn */
|
|
11
12
|
|
|
12
13
|
/* Required libraries. */
|
|
13
14
|
const path = require('path');
|
|
@@ -219,9 +220,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
219
220
|
let myIgnore = [
|
|
220
221
|
'healthCheck',
|
|
221
222
|
'iapGetAdapterWorkflowFunctions',
|
|
222
|
-
'iapHasAdapterEntity',
|
|
223
|
-
'iapVerifyAdapterCapability',
|
|
224
|
-
'iapUpdateAdapterEntityCache',
|
|
225
223
|
'hasEntities',
|
|
226
224
|
'getAuthorization'
|
|
227
225
|
];
|
|
@@ -249,29 +247,15 @@ class SevOne extends AdapterBaseCl {
|
|
|
249
247
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
250
248
|
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
251
249
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
250
|
+
* @param {boolean} replace - true to replace entire mock data, false to merge/append
|
|
252
251
|
* @param {Callback} callback - The results of the call
|
|
253
252
|
*/
|
|
254
|
-
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
253
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
|
|
255
254
|
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
256
255
|
const origin = `${this.id}-${meth}`;
|
|
257
256
|
log.trace(origin);
|
|
258
257
|
|
|
259
|
-
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* See if the API path provided is found in this adapter
|
|
264
|
-
*
|
|
265
|
-
* @function iapFindAdapterPath
|
|
266
|
-
* @param {string} apiPath - the api path to check on
|
|
267
|
-
* @param {Callback} callback - The results of the call
|
|
268
|
-
*/
|
|
269
|
-
iapFindAdapterPath(apiPath, callback) {
|
|
270
|
-
const meth = 'adapter-iapFindAdapterPath';
|
|
271
|
-
const origin = `${this.id}-${meth}`;
|
|
272
|
-
log.trace(origin);
|
|
273
|
-
|
|
274
|
-
super.iapFindAdapterPath(apiPath, callback);
|
|
258
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
|
|
275
259
|
}
|
|
276
260
|
|
|
277
261
|
/**
|
|
@@ -313,7 +297,7 @@ class SevOne extends AdapterBaseCl {
|
|
|
313
297
|
}
|
|
314
298
|
|
|
315
299
|
/**
|
|
316
|
-
* @summary Get the
|
|
300
|
+
* @summary Get the Adapter Queue
|
|
317
301
|
*
|
|
318
302
|
* @function iapGetAdapterQueue
|
|
319
303
|
* @param {Callback} callback - callback function
|
|
@@ -326,6 +310,22 @@ class SevOne extends AdapterBaseCl {
|
|
|
326
310
|
return super.iapGetAdapterQueue(callback);
|
|
327
311
|
}
|
|
328
312
|
|
|
313
|
+
/* SCRIPT CALLS */
|
|
314
|
+
/**
|
|
315
|
+
* See if the API path provided is found in this adapter
|
|
316
|
+
*
|
|
317
|
+
* @function iapFindAdapterPath
|
|
318
|
+
* @param {string} apiPath - the api path to check on
|
|
319
|
+
* @param {Callback} callback - The results of the call
|
|
320
|
+
*/
|
|
321
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
322
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
323
|
+
const origin = `${this.id}-${meth}`;
|
|
324
|
+
log.trace(origin);
|
|
325
|
+
|
|
326
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
329
|
/**
|
|
330
330
|
* @summary Runs troubleshoot scripts for adapter
|
|
331
331
|
*
|
|
@@ -426,455 +426,93 @@ class SevOne extends AdapterBaseCl {
|
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
/* BROKER CALLS */
|
|
430
429
|
/**
|
|
431
|
-
* @summary
|
|
430
|
+
* @summary Deactivate adapter tasks
|
|
432
431
|
*
|
|
433
|
-
* @function
|
|
434
|
-
* @param {String} entityType - the entity type to check for
|
|
435
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
432
|
+
* @function iapDeactivateTasks
|
|
436
433
|
*
|
|
437
|
-
* @param {
|
|
438
|
-
*
|
|
434
|
+
* @param {Array} tasks - List of tasks to deactivate
|
|
435
|
+
* @param {Callback} callback
|
|
439
436
|
*/
|
|
440
|
-
|
|
441
|
-
const
|
|
437
|
+
iapDeactivateTasks(tasks, callback) {
|
|
438
|
+
const meth = 'adapter-iapDeactivateTasks';
|
|
439
|
+
const origin = `${this.id}-${meth}`;
|
|
442
440
|
log.trace(origin);
|
|
443
441
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
442
|
+
try {
|
|
443
|
+
return super.iapDeactivateTasks(tasks, callback);
|
|
444
|
+
} catch (err) {
|
|
445
|
+
log.error(`${origin}: ${err}`);
|
|
446
|
+
return callback(null, err);
|
|
447
|
+
}
|
|
447
448
|
}
|
|
448
449
|
|
|
449
450
|
/**
|
|
450
|
-
* @summary
|
|
451
|
-
* whether the adapter supports type, action and specific entity
|
|
451
|
+
* @summary Activate adapter tasks that have previously been deactivated
|
|
452
452
|
*
|
|
453
|
-
* @function
|
|
454
|
-
* @param {String} entityType - the entity type to check for
|
|
455
|
-
* @param {String} actionType - the action type to check for
|
|
456
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
453
|
+
* @function iapActivateTasks
|
|
457
454
|
*
|
|
458
|
-
* @param {
|
|
459
|
-
*
|
|
455
|
+
* @param {Array} tasks - List of tasks to activate
|
|
456
|
+
* @param {Callback} callback
|
|
460
457
|
*/
|
|
461
|
-
|
|
462
|
-
const meth = '
|
|
458
|
+
iapActivateTasks(tasks, callback) {
|
|
459
|
+
const meth = 'adapter-iapActivateTasks';
|
|
463
460
|
const origin = `${this.id}-${meth}`;
|
|
464
461
|
log.trace(origin);
|
|
465
462
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
return callback(null, error);
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// if the cache needs to be updated, update and try again
|
|
475
|
-
if (results && results[0] === 'needupdate') {
|
|
476
|
-
switch (entityType) {
|
|
477
|
-
case 'alert': {
|
|
478
|
-
// if the cache is invalid, update the cache
|
|
479
|
-
return this.getAlerts(null, null, (data, err) => {
|
|
480
|
-
if (err) {
|
|
481
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
482
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
483
|
-
return callback(null, errorObj);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// need to check the cache again since it has been updated
|
|
487
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
488
|
-
if (verror) {
|
|
489
|
-
return callback(null, verror);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
return this.capabilityResults(vcapable, callback);
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
case 'device': {
|
|
497
|
-
// if the cache is invalid, update the cache
|
|
498
|
-
return this.getDevices(null, null, (data, err) => {
|
|
499
|
-
if (err) {
|
|
500
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
501
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
502
|
-
return callback(null, errorObj);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
// need to check the cache again since it has been updated
|
|
506
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
507
|
-
if (verror) {
|
|
508
|
-
return callback(null, verror);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
return this.capabilityResults(vcapable, callback);
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
case 'device_group': {
|
|
516
|
-
// if the cache is invalid, update the cache
|
|
517
|
-
return this.getDeviceGroups(null, null, (data, err) => {
|
|
518
|
-
if (err) {
|
|
519
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
520
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
521
|
-
return callback(null, errorObj);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// need to check the cache again since it has been updated
|
|
525
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
526
|
-
if (verror) {
|
|
527
|
-
return callback(null, verror);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
return this.capabilityResults(vcapable, callback);
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
/* Can not get all components - just all components on a device
|
|
535
|
-
case 'device_component': {
|
|
536
|
-
}
|
|
537
|
-
*/
|
|
538
|
-
case 'device_component_group': {
|
|
539
|
-
// if the cache is invalid, update the cache
|
|
540
|
-
return this.getComponentGroups(null, null, (data, err) => {
|
|
541
|
-
if (err) {
|
|
542
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
543
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
544
|
-
return callback(null, errorObj);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// need to check the cache again since it has been updated
|
|
548
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
549
|
-
if (verror) {
|
|
550
|
-
return callback(null, verror);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
return this.capabilityResults(vcapable, callback);
|
|
554
|
-
});
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
case 'map': {
|
|
558
|
-
// if the cache is invalid, update the cache
|
|
559
|
-
return this.getMaps(null, null, (data, err) => {
|
|
560
|
-
if (err) {
|
|
561
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
562
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
563
|
-
return callback(null, errorObj);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// need to check the cache again since it has been updated
|
|
567
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
568
|
-
if (verror) {
|
|
569
|
-
return callback(null, verror);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
return this.capabilityResults(vcapable, callback);
|
|
573
|
-
});
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
default: {
|
|
577
|
-
// unsupported entity type
|
|
578
|
-
const result = [false];
|
|
579
|
-
|
|
580
|
-
// put false in array for all entities
|
|
581
|
-
if (Array.isArray(entityId)) {
|
|
582
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
583
|
-
result.push(false);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
return callback(result);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// return the results
|
|
593
|
-
return this.capabilityResults(results, callback);
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
// if no entity id
|
|
598
|
-
if (!entityId) {
|
|
599
|
-
// need to check the cache again since it has been updated
|
|
600
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
601
|
-
if (verror) {
|
|
602
|
-
return callback(null, verror);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
return this.capabilityResults(vcapable, callback);
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// if not caching
|
|
610
|
-
switch (entityType) {
|
|
611
|
-
case 'alert': {
|
|
612
|
-
// if the cache is invalid, update the cache
|
|
613
|
-
return this.getAlerts(null, null, (data, err) => {
|
|
614
|
-
if (err) {
|
|
615
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
616
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
617
|
-
return callback(null, errorObj);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
// need to check the cache again since it has been updated
|
|
621
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
622
|
-
if (verror) {
|
|
623
|
-
return callback(null, verror);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
const names = [];
|
|
627
|
-
|
|
628
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
629
|
-
names.push(data.list[d].name);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
// is the entity in the list?
|
|
633
|
-
const isEntity = this.entityInList(entityId, names);
|
|
634
|
-
const res = [];
|
|
635
|
-
|
|
636
|
-
// not found
|
|
637
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
638
|
-
if (vcapable[0] === 'found') {
|
|
639
|
-
res.push(isEntity[i]);
|
|
640
|
-
} else {
|
|
641
|
-
res.push(false);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
return callback(res);
|
|
646
|
-
});
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
case 'device': {
|
|
650
|
-
// if the cache is invalid, update the cache
|
|
651
|
-
return this.getDevices(null, null, (data, err) => {
|
|
652
|
-
if (err) {
|
|
653
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
654
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
655
|
-
return callback(null, errorObj);
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
// need to check the cache again since it has been updated
|
|
659
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
660
|
-
if (verror) {
|
|
661
|
-
return callback(null, verror);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
const names = [];
|
|
665
|
-
|
|
666
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
667
|
-
names.push(data.list[d].name);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
// is the entity in the list?
|
|
671
|
-
const isEntity = this.entityInList(entityId, names);
|
|
672
|
-
const res = [];
|
|
673
|
-
|
|
674
|
-
// not found
|
|
675
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
676
|
-
if (vcapable[0] === 'found') {
|
|
677
|
-
res.push(isEntity[i]);
|
|
678
|
-
} else {
|
|
679
|
-
res.push(false);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
return callback(res);
|
|
684
|
-
});
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
case 'device_group': {
|
|
688
|
-
// if the cache is invalid, update the cache
|
|
689
|
-
return this.getDeviceGroups(null, null, (data, err) => {
|
|
690
|
-
if (err) {
|
|
691
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
692
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
693
|
-
return callback(null, errorObj);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
// need to check the cache again since it has been updated
|
|
697
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
698
|
-
if (verror) {
|
|
699
|
-
return callback(null, verror);
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
const names = [];
|
|
703
|
-
|
|
704
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
705
|
-
names.push(data.list[d].name);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// is the entity in the list?
|
|
709
|
-
const isEntity = this.entityInList(entityId, names);
|
|
710
|
-
const res = [];
|
|
711
|
-
|
|
712
|
-
// not found
|
|
713
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
714
|
-
if (vcapable[0] === 'found') {
|
|
715
|
-
res.push(isEntity[i]);
|
|
716
|
-
} else {
|
|
717
|
-
res.push(false);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
return callback(res);
|
|
722
|
-
});
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
|
-
/* Can not get all components - just all components on a device
|
|
726
|
-
case 'device_component': {
|
|
727
|
-
}
|
|
728
|
-
*/
|
|
729
|
-
case 'device_component_group': {
|
|
730
|
-
// if the cache is invalid, update the cache
|
|
731
|
-
return this.getComponentGroups(null, null, (data, err) => {
|
|
732
|
-
if (err) {
|
|
733
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
734
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
735
|
-
return callback(null, errorObj);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// need to check the cache again since it has been updated
|
|
739
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
740
|
-
if (verror) {
|
|
741
|
-
return callback(null, verror);
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
const names = [];
|
|
745
|
-
|
|
746
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
747
|
-
names.push(data.list[d].name);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
// is the entity in the list?
|
|
751
|
-
const isEntity = this.entityInList(entityId, names);
|
|
752
|
-
const res = [];
|
|
753
|
-
|
|
754
|
-
// not found
|
|
755
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
756
|
-
if (vcapable[0] === 'found') {
|
|
757
|
-
res.push(isEntity[i]);
|
|
758
|
-
} else {
|
|
759
|
-
res.push(false);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
return callback(res);
|
|
764
|
-
});
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
case 'map': {
|
|
768
|
-
// if the cache is invalid, update the cache
|
|
769
|
-
return this.getMaps(null, null, (data, err) => {
|
|
770
|
-
if (err) {
|
|
771
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
772
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
773
|
-
return callback(null, errorObj);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
// need to check the cache again since it has been updated
|
|
777
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
778
|
-
if (verror) {
|
|
779
|
-
return callback(null, verror);
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
const names = [];
|
|
783
|
-
|
|
784
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
785
|
-
names.push(data.list[d].name);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
// is the entity in the list?
|
|
789
|
-
const isEntity = this.entityInList(entityId, names);
|
|
790
|
-
const res = [];
|
|
791
|
-
|
|
792
|
-
// not found
|
|
793
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
794
|
-
if (vcapable[0] === 'found') {
|
|
795
|
-
res.push(isEntity[i]);
|
|
796
|
-
} else {
|
|
797
|
-
res.push(false);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
return callback(res);
|
|
802
|
-
});
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
default: {
|
|
806
|
-
// unsupported entity type
|
|
807
|
-
const result = [false];
|
|
808
|
-
|
|
809
|
-
// put false in array for all entities
|
|
810
|
-
if (Array.isArray(entityId)) {
|
|
811
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
812
|
-
result.push(false);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
return callback(result);
|
|
817
|
-
}
|
|
463
|
+
try {
|
|
464
|
+
return super.iapActivateTasks(tasks, callback);
|
|
465
|
+
} catch (err) {
|
|
466
|
+
log.error(`${origin}: ${err}`);
|
|
467
|
+
return callback(null, err);
|
|
818
468
|
}
|
|
819
469
|
}
|
|
820
470
|
|
|
471
|
+
/* CACHE CALLS */
|
|
821
472
|
/**
|
|
822
|
-
* @summary
|
|
473
|
+
* @summary Populate the cache for the given entities
|
|
823
474
|
*
|
|
824
|
-
* @function
|
|
475
|
+
* @function iapPopulateEntityCache
|
|
476
|
+
* @param {String/Array of Strings} entityType - the entity type(s) to populate
|
|
477
|
+
* @param {Callback} callback - whether the cache was updated or not for each entity type
|
|
825
478
|
*
|
|
479
|
+
* @returns status of the populate
|
|
826
480
|
*/
|
|
827
|
-
|
|
828
|
-
const
|
|
481
|
+
iapPopulateEntityCache(entityTypes, callback) {
|
|
482
|
+
const meth = 'adapter-iapPopulateEntityCache';
|
|
483
|
+
const origin = `${this.id}-${meth}`;
|
|
829
484
|
log.trace(origin);
|
|
830
485
|
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
// if the cache is invalid, update the device cache
|
|
840
|
-
this.getDevices(null, null, null, null, (data, err) => {
|
|
841
|
-
if (err) {
|
|
842
|
-
log.trace(`Could not load devices into cache - ${err}`);
|
|
843
|
-
}
|
|
844
|
-
});
|
|
845
|
-
|
|
846
|
-
// if the cache is invalid, update the device group cache
|
|
847
|
-
this.getDeviceGroups(null, null, (data, err) => {
|
|
848
|
-
if (err) {
|
|
849
|
-
log.trace(`Could not load device groups into cache - ${err}`);
|
|
850
|
-
}
|
|
851
|
-
});
|
|
852
|
-
|
|
853
|
-
/* Can not get all components - just all components on a device
|
|
854
|
-
// if the cache is invalid, update the device component cache
|
|
855
|
-
this.getDeviceComponents(null, null, null, null, null, (data, err) => {
|
|
856
|
-
if (err) {
|
|
857
|
-
log.trace(`Could not load device groups into cache - ${err}`);
|
|
858
|
-
}
|
|
859
|
-
});
|
|
860
|
-
*/
|
|
486
|
+
try {
|
|
487
|
+
return super.iapPopulateEntityCache(entityTypes, callback);
|
|
488
|
+
} catch (err) {
|
|
489
|
+
log.error(`${origin}: ${err}`);
|
|
490
|
+
return callback(null, err);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
861
493
|
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
494
|
+
/**
|
|
495
|
+
* @summary Retrieves data from cache for specified entity type
|
|
496
|
+
*
|
|
497
|
+
* @function iapRetrieveEntitiesCache
|
|
498
|
+
* @param {String} entityType - entity of which to retrieve
|
|
499
|
+
* @param {Object} options - settings of which data to return and how to return it
|
|
500
|
+
* @param {Callback} callback - the data if it was retrieved
|
|
501
|
+
*/
|
|
502
|
+
iapRetrieveEntitiesCache(entityType, options, callback) {
|
|
503
|
+
const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
|
|
504
|
+
const origin = `${this.id}-${meth}`;
|
|
505
|
+
log.trace(origin);
|
|
868
506
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
});
|
|
507
|
+
try {
|
|
508
|
+
return super.iapRetrieveEntitiesCache(entityType, options, callback);
|
|
509
|
+
} catch (err) {
|
|
510
|
+
log.error(`${origin}: ${err}`);
|
|
511
|
+
return callback(null, err);
|
|
875
512
|
}
|
|
876
513
|
}
|
|
877
514
|
|
|
515
|
+
/* BROKER CALLS */
|
|
878
516
|
/**
|
|
879
517
|
* @summary Determines if this adapter supports any in a list of entities
|
|
880
518
|
*
|
|
@@ -1009,6 +647,38 @@ class SevOne extends AdapterBaseCl {
|
|
|
1009
647
|
}
|
|
1010
648
|
|
|
1011
649
|
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
650
|
+
/**
|
|
651
|
+
* Makes the requested generic call
|
|
652
|
+
*
|
|
653
|
+
* @function iapExpandedGenericAdapterRequest
|
|
654
|
+
* @param {Object} metadata - metadata for the call (optional).
|
|
655
|
+
* Can be a stringified Object.
|
|
656
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
|
|
657
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
|
|
658
|
+
* @param {Object} pathVars - the parameters to be put within the url path (optional).
|
|
659
|
+
* Can be a stringified Object.
|
|
660
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
661
|
+
* Can be a stringified Object.
|
|
662
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
663
|
+
* Can be a stringified Object.
|
|
664
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
665
|
+
* Can be a stringified Object.
|
|
666
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
667
|
+
* or the error
|
|
668
|
+
*/
|
|
669
|
+
iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
|
|
670
|
+
const meth = 'adapter-iapExpandedGenericAdapterRequest';
|
|
671
|
+
const origin = `${this.id}-${meth}`;
|
|
672
|
+
log.trace(origin);
|
|
673
|
+
|
|
674
|
+
try {
|
|
675
|
+
return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
|
|
676
|
+
} catch (err) {
|
|
677
|
+
log.error(`${origin}: ${err}`);
|
|
678
|
+
return callback(null, err);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
1012
682
|
/**
|
|
1013
683
|
* Makes the requested generic call
|
|
1014
684
|
*
|
|
@@ -1029,93 +699,11 @@ class SevOne extends AdapterBaseCl {
|
|
|
1029
699
|
const origin = `${this.id}-${meth}`;
|
|
1030
700
|
log.trace(origin);
|
|
1031
701
|
|
|
1032
|
-
if (this.suspended && this.suspendMode === 'error') {
|
|
1033
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1034
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1035
|
-
return callback(null, errorObj);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1039
|
-
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
1040
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
1041
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1042
|
-
return callback(null, errorObj);
|
|
1043
|
-
}
|
|
1044
|
-
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
1045
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
1046
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1047
|
-
return callback(null, errorObj);
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1051
|
-
// remove any leading / and split the uripath into path variables
|
|
1052
|
-
let myPath = uriPath;
|
|
1053
|
-
while (myPath.indexOf('/') === 0) {
|
|
1054
|
-
myPath = myPath.substring(1);
|
|
1055
|
-
}
|
|
1056
|
-
const pathVars = myPath.split('/');
|
|
1057
|
-
const queryParamsAvailable = queryData;
|
|
1058
|
-
const queryParams = {};
|
|
1059
|
-
const bodyVars = requestBody;
|
|
1060
|
-
|
|
1061
|
-
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1062
|
-
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1063
|
-
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1064
|
-
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1065
|
-
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1066
|
-
}
|
|
1067
|
-
});
|
|
1068
|
-
|
|
1069
|
-
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
1070
|
-
const reqObj = {
|
|
1071
|
-
payload: bodyVars,
|
|
1072
|
-
uriPathVars: pathVars,
|
|
1073
|
-
uriQuery: queryParams,
|
|
1074
|
-
uriOptions: {}
|
|
1075
|
-
};
|
|
1076
|
-
// add headers if provided
|
|
1077
|
-
if (addlHeaders) {
|
|
1078
|
-
reqObj.addlHeaders = addlHeaders;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
// determine the call and return flag
|
|
1082
|
-
let action = 'getGenerics';
|
|
1083
|
-
let returnF = true;
|
|
1084
|
-
if (restMethod.toUpperCase() === 'POST') {
|
|
1085
|
-
action = 'createGeneric';
|
|
1086
|
-
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
1087
|
-
action = 'updateGeneric';
|
|
1088
|
-
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
1089
|
-
action = 'patchGeneric';
|
|
1090
|
-
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
1091
|
-
action = 'deleteGeneric';
|
|
1092
|
-
returnF = false;
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
702
|
try {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
// return an error
|
|
1101
|
-
if (irReturnError) {
|
|
1102
|
-
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1103
|
-
return callback(null, irReturnError);
|
|
1104
|
-
}
|
|
1105
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1106
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
1107
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1108
|
-
return callback(null, errorObj);
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1112
|
-
// return the response
|
|
1113
|
-
return callback(irReturnData, null);
|
|
1114
|
-
});
|
|
1115
|
-
} catch (ex) {
|
|
1116
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1117
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1118
|
-
return callback(null, errorObj);
|
|
703
|
+
return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
704
|
+
} catch (err) {
|
|
705
|
+
log.error(`${origin}: ${err}`);
|
|
706
|
+
return callback(null, err);
|
|
1119
707
|
}
|
|
1120
708
|
}
|
|
1121
709
|
|
|
@@ -1139,94 +727,56 @@ class SevOne extends AdapterBaseCl {
|
|
|
1139
727
|
const origin = `${this.id}-${meth}`;
|
|
1140
728
|
log.trace(origin);
|
|
1141
729
|
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
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);
|
|
730
|
+
try {
|
|
731
|
+
return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
732
|
+
} catch (err) {
|
|
733
|
+
log.error(`${origin}: ${err}`);
|
|
734
|
+
return callback(null, err);
|
|
1158
735
|
}
|
|
736
|
+
}
|
|
1159
737
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
const
|
|
1169
|
-
const
|
|
738
|
+
/* INVENTORY CALLS */
|
|
739
|
+
/**
|
|
740
|
+
* @summary run the adapter lint script to return the results.
|
|
741
|
+
*
|
|
742
|
+
* @function iapRunAdapterLint
|
|
743
|
+
* @param {Callback} callback - callback function
|
|
744
|
+
*/
|
|
745
|
+
iapRunAdapterLint(callback) {
|
|
746
|
+
const meth = 'adapter-iapRunAdapterLint';
|
|
747
|
+
const origin = `${this.id}-${meth}`;
|
|
748
|
+
log.trace(origin);
|
|
1170
749
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1174
|
-
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1175
|
-
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1176
|
-
}
|
|
1177
|
-
});
|
|
750
|
+
return super.iapRunAdapterLint(callback);
|
|
751
|
+
}
|
|
1178
752
|
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
753
|
+
/**
|
|
754
|
+
* @summary run the adapter test scripts (baseunit and unit) to return the results.
|
|
755
|
+
* can not run integration as there can be implications with that.
|
|
756
|
+
*
|
|
757
|
+
* @function iapRunAdapterTests
|
|
758
|
+
* @param {Callback} callback - callback function
|
|
759
|
+
*/
|
|
760
|
+
iapRunAdapterTests(callback) {
|
|
761
|
+
const meth = 'adapter-iapRunAdapterTests';
|
|
762
|
+
const origin = `${this.id}-${meth}`;
|
|
763
|
+
log.trace(origin);
|
|
1190
764
|
|
|
1191
|
-
|
|
1192
|
-
|
|
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
|
-
}
|
|
765
|
+
return super.iapRunAdapterTests(callback);
|
|
766
|
+
}
|
|
1204
767
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
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
|
-
}
|
|
768
|
+
/**
|
|
769
|
+
* @summary provide inventory information abbout the adapter
|
|
770
|
+
*
|
|
771
|
+
* @function iapGetAdapterInventory
|
|
772
|
+
* @param {Callback} callback - callback function
|
|
773
|
+
*/
|
|
774
|
+
iapGetAdapterInventory(callback) {
|
|
775
|
+
const meth = 'adapter-iapGetAdapterInventory';
|
|
776
|
+
const origin = `${this.id}-${meth}`;
|
|
777
|
+
log.trace(origin);
|
|
1220
778
|
|
|
1221
|
-
|
|
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
|
-
}
|
|
779
|
+
return super.iapGetAdapterInventory(callback);
|
|
1230
780
|
}
|
|
1231
781
|
|
|
1232
782
|
/**
|
|
@@ -1302,16 +852,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
1302
852
|
return callback(null, errorObj);
|
|
1303
853
|
}
|
|
1304
854
|
|
|
1305
|
-
// if no error and a get ALL, add the entities to the cache
|
|
1306
|
-
if (!alertId && this.caching) {
|
|
1307
|
-
// add the entities to the cache - can run on its own
|
|
1308
|
-
this.addEntityCache('alert', result.response, 'id', (loaded, err) => {
|
|
1309
|
-
if (!loaded) {
|
|
1310
|
-
log.trace(`${origin}: Could not load alerts into cache - ${err}`);
|
|
1311
|
-
}
|
|
1312
|
-
});
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
855
|
// return the response
|
|
1316
856
|
return callback(addAlertTypes(result));
|
|
1317
857
|
});
|
|
@@ -3649,16 +3189,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
3649
3189
|
return callback(null, errorObj);
|
|
3650
3190
|
}
|
|
3651
3191
|
|
|
3652
|
-
// if no error and a get ALL, add the entities to the cache
|
|
3653
|
-
if (!deviceId && this.caching) {
|
|
3654
|
-
// add the entities to the cache - can run on its own
|
|
3655
|
-
this.addEntityCache('device', result.response, 'id', (loaded, err) => {
|
|
3656
|
-
if (!loaded) {
|
|
3657
|
-
log.trace(`Could not load device into cache - ${err}`);
|
|
3658
|
-
}
|
|
3659
|
-
});
|
|
3660
|
-
}
|
|
3661
|
-
|
|
3662
3192
|
// return the response
|
|
3663
3193
|
return callback(result);
|
|
3664
3194
|
});
|
|
@@ -4024,16 +3554,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
4024
3554
|
return callback(null, errorObj);
|
|
4025
3555
|
}
|
|
4026
3556
|
|
|
4027
|
-
// if no error and a get ALL, add the entities to the cache
|
|
4028
|
-
if (!groupId && this.caching) {
|
|
4029
|
-
// add the entities to the cache - can run on its own
|
|
4030
|
-
this.addEntityCache('device_group', result.response, 'id', (loaded, err) => {
|
|
4031
|
-
if (!loaded) {
|
|
4032
|
-
log.trace(`Could not load device_group into cache - ${err}`);
|
|
4033
|
-
}
|
|
4034
|
-
});
|
|
4035
|
-
}
|
|
4036
|
-
|
|
4037
3557
|
// return the response
|
|
4038
3558
|
return callback(result);
|
|
4039
3559
|
});
|
|
@@ -4429,16 +3949,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
4429
3949
|
return callback(null, errorObj);
|
|
4430
3950
|
}
|
|
4431
3951
|
|
|
4432
|
-
// if no error and a get ALL, add the entities to the cache
|
|
4433
|
-
if (!deviceId && !componentId && this.caching) {
|
|
4434
|
-
// add the entities to the cache - can run on its own
|
|
4435
|
-
this.addEntityCache('device_component', result.response, 'id', (loaded, err) => {
|
|
4436
|
-
if (!loaded) {
|
|
4437
|
-
log.trace(`Could not load device_component into cache - ${err}`);
|
|
4438
|
-
}
|
|
4439
|
-
});
|
|
4440
|
-
}
|
|
4441
|
-
|
|
4442
3952
|
// return the response
|
|
4443
3953
|
return callback(result);
|
|
4444
3954
|
});
|
|
@@ -5045,16 +4555,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
5045
4555
|
return callback(null, errorObj);
|
|
5046
4556
|
}
|
|
5047
4557
|
|
|
5048
|
-
// if no error and a get ALL, add the entities to the cache
|
|
5049
|
-
if (!groupId && this.caching) {
|
|
5050
|
-
// add the entities to the cache - can run on its own
|
|
5051
|
-
this.addEntityCache('device_component_group', result.response, 'id', (loaded, err) => {
|
|
5052
|
-
if (!loaded) {
|
|
5053
|
-
log.trace(`Could not load device_component_group into cache - ${err}`);
|
|
5054
|
-
}
|
|
5055
|
-
});
|
|
5056
|
-
}
|
|
5057
|
-
|
|
5058
4558
|
// return the response
|
|
5059
4559
|
return callback(result);
|
|
5060
4560
|
});
|
|
@@ -6014,16 +5514,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
6014
5514
|
return callback(null, errorObj);
|
|
6015
5515
|
}
|
|
6016
5516
|
|
|
6017
|
-
// if no error and a get ALL, add the entities to the cache
|
|
6018
|
-
if (!mapId && this.caching) {
|
|
6019
|
-
// add the entities to the cache - can run on its own
|
|
6020
|
-
this.addEntityCache('map', result.response, 'id', (loaded, err) => {
|
|
6021
|
-
if (!loaded) {
|
|
6022
|
-
log.trace(`Could not load map into cache - ${err}`);
|
|
6023
|
-
}
|
|
6024
|
-
});
|
|
6025
|
-
}
|
|
6026
|
-
|
|
6027
5517
|
// return the response
|
|
6028
5518
|
return callback(result);
|
|
6029
5519
|
});
|