@itentialopensource/adapter-sevone 2.3.1 → 2.5.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 +1808 -0
- package/CHANGELOG.md +53 -91
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +3 -148
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +237 -578
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +377 -596
- package/adapterBase.js +854 -408
- package/changelogs/CHANGELOG.md +118 -0
- 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/metadata.json +49 -0
- package/package.json +28 -22
- package/pronghorn.json +673 -70
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +827 -6
- 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 +10 -0
- package/report/updateReport1653680202971.json +120 -0
- 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 +153 -3
- package/test/integration/adapterTestBasicGet.js +3 -5
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +157 -105
- package/test/unit/adapterBaseTestUnit.js +388 -308
- package/test/unit/adapterTestUnit.js +548 -310
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +1 -1
- package/utils/basicGet.js +1 -14
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +179 -0
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +14 -16
- package/utils/packModificationScript.js +1 -1
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +5 -0
- package/utils/removeHooks.js +20 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +129 -53
- package/utils/tbUtils.js +152 -35
- package/utils/testRunner.js +17 -17
- package/utils/troubleshootingAdapter.js +10 -31
- 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');
|
|
@@ -213,10 +214,15 @@ class SevOne extends AdapterBaseCl {
|
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
/**
|
|
216
|
-
* @
|
|
217
|
+
* @iapGetAdapterWorkflowFunctions
|
|
217
218
|
*/
|
|
218
|
-
|
|
219
|
-
let myIgnore = [
|
|
219
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
220
|
+
let myIgnore = [
|
|
221
|
+
'healthCheck',
|
|
222
|
+
'iapGetAdapterWorkflowFunctions',
|
|
223
|
+
'hasEntities',
|
|
224
|
+
'getAuthorization'
|
|
225
|
+
];
|
|
220
226
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
221
227
|
myIgnore = inIgnore;
|
|
222
228
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -227,52 +233,44 @@ class SevOne extends AdapterBaseCl {
|
|
|
227
233
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
228
234
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
229
235
|
|
|
230
|
-
return super.
|
|
236
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
231
237
|
}
|
|
232
238
|
|
|
233
239
|
/**
|
|
234
|
-
*
|
|
240
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
235
241
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
236
242
|
* file system.
|
|
237
243
|
*
|
|
238
|
-
* @function
|
|
244
|
+
* @function iapUpdateAdapterConfiguration
|
|
239
245
|
* @param {string} configFile - the name of the file being updated (required)
|
|
240
246
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
241
247
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
242
248
|
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
243
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
|
|
244
251
|
* @param {Callback} callback - The results of the call
|
|
245
252
|
*/
|
|
246
|
-
|
|
247
|
-
const
|
|
253
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
|
|
254
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
255
|
+
const origin = `${this.id}-${meth}`;
|
|
248
256
|
log.trace(origin);
|
|
249
|
-
super.updateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
250
|
-
}
|
|
251
257
|
|
|
252
|
-
|
|
253
|
-
* See if the API path provided is found in this adapter
|
|
254
|
-
*
|
|
255
|
-
* @function findPath
|
|
256
|
-
* @param {string} apiPath - the api path to check on
|
|
257
|
-
* @param {Callback} callback - The results of the call
|
|
258
|
-
*/
|
|
259
|
-
findPath(apiPath, callback) {
|
|
260
|
-
const origin = `${this.id}-adapter-findPath`;
|
|
261
|
-
log.trace(origin);
|
|
262
|
-
super.findPath(apiPath, callback);
|
|
258
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
|
|
263
259
|
}
|
|
264
260
|
|
|
265
261
|
/**
|
|
266
262
|
* @summary Suspends adapter
|
|
267
263
|
*
|
|
268
|
-
* @function
|
|
264
|
+
* @function iapSuspendAdapter
|
|
269
265
|
* @param {Callback} callback - callback function
|
|
270
266
|
*/
|
|
271
|
-
|
|
272
|
-
const
|
|
267
|
+
iapSuspendAdapter(mode, callback) {
|
|
268
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
269
|
+
const origin = `${this.id}-${meth}`;
|
|
273
270
|
log.trace(origin);
|
|
271
|
+
|
|
274
272
|
try {
|
|
275
|
-
return super.
|
|
273
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
276
274
|
} catch (error) {
|
|
277
275
|
log.error(`${origin}: ${error}`);
|
|
278
276
|
return callback(null, error);
|
|
@@ -282,14 +280,16 @@ class SevOne extends AdapterBaseCl {
|
|
|
282
280
|
/**
|
|
283
281
|
* @summary Unsuspends adapter
|
|
284
282
|
*
|
|
285
|
-
* @function
|
|
283
|
+
* @function iapUnsuspendAdapter
|
|
286
284
|
* @param {Callback} callback - callback function
|
|
287
285
|
*/
|
|
288
|
-
|
|
289
|
-
const
|
|
286
|
+
iapUnsuspendAdapter(callback) {
|
|
287
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
288
|
+
const origin = `${this.id}-${meth}`;
|
|
290
289
|
log.trace(origin);
|
|
290
|
+
|
|
291
291
|
try {
|
|
292
|
-
return super.
|
|
292
|
+
return super.iapUnsuspendAdapter(callback);
|
|
293
293
|
} catch (error) {
|
|
294
294
|
log.error(`${origin}: ${error}`);
|
|
295
295
|
return callback(null, error);
|
|
@@ -297,31 +297,51 @@ class SevOne extends AdapterBaseCl {
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
/**
|
|
300
|
-
* @summary Get the
|
|
300
|
+
* @summary Get the Adapter Queue
|
|
301
301
|
*
|
|
302
|
-
* @function
|
|
302
|
+
* @function iapGetAdapterQueue
|
|
303
303
|
* @param {Callback} callback - callback function
|
|
304
304
|
*/
|
|
305
|
-
|
|
306
|
-
const
|
|
305
|
+
iapGetAdapterQueue(callback) {
|
|
306
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
307
|
+
const origin = `${this.id}-${meth}`;
|
|
307
308
|
log.trace(origin);
|
|
308
|
-
|
|
309
|
+
|
|
310
|
+
return super.iapGetAdapterQueue(callback);
|
|
311
|
+
}
|
|
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);
|
|
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,14 +390,16 @@ 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);
|
|
@@ -381,450 +407,275 @@ class SevOne extends AdapterBaseCl {
|
|
|
381
407
|
}
|
|
382
408
|
|
|
383
409
|
/**
|
|
384
|
-
* @summary
|
|
410
|
+
* @summary moves entites into Mongo DB
|
|
385
411
|
*
|
|
386
|
-
* @function
|
|
387
|
-
* @param {
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
* @param {Callback} callback - An array of whether the adapter can has the
|
|
391
|
-
* desired capability or an error
|
|
412
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
413
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
414
|
+
* or the error
|
|
392
415
|
*/
|
|
393
|
-
|
|
394
|
-
const
|
|
416
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
417
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
418
|
+
const origin = `${this.id}-${meth}`;
|
|
395
419
|
log.trace(origin);
|
|
396
420
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
421
|
+
try {
|
|
422
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
423
|
+
} catch (err) {
|
|
424
|
+
log.error(`${origin}: ${err}`);
|
|
425
|
+
return callback(null, err);
|
|
426
|
+
}
|
|
400
427
|
}
|
|
401
428
|
|
|
402
429
|
/**
|
|
403
|
-
* @summary
|
|
404
|
-
* whether the adapter supports type, action and specific entity
|
|
430
|
+
* @summary Deactivate adapter tasks
|
|
405
431
|
*
|
|
406
|
-
* @function
|
|
407
|
-
* @param {String} entityType - the entity type to check for
|
|
408
|
-
* @param {String} actionType - the action type to check for
|
|
409
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
432
|
+
* @function iapDeactivateTasks
|
|
410
433
|
*
|
|
411
|
-
* @param {
|
|
412
|
-
*
|
|
434
|
+
* @param {Array} tasks - List of tasks to deactivate
|
|
435
|
+
* @param {Callback} callback
|
|
413
436
|
*/
|
|
414
|
-
|
|
415
|
-
const meth = '
|
|
437
|
+
iapDeactivateTasks(tasks, callback) {
|
|
438
|
+
const meth = 'adapter-iapDeactivateTasks';
|
|
416
439
|
const origin = `${this.id}-${meth}`;
|
|
417
440
|
log.trace(origin);
|
|
418
441
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
return callback(null, error);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// if the cache needs to be updated, update and try again
|
|
428
|
-
if (results && results[0] === 'needupdate') {
|
|
429
|
-
switch (entityType) {
|
|
430
|
-
case 'alert': {
|
|
431
|
-
// if the cache is invalid, update the cache
|
|
432
|
-
return this.getAlerts(null, null, (data, err) => {
|
|
433
|
-
if (err) {
|
|
434
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
435
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
436
|
-
return callback(null, errorObj);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// need to check the cache again since it has been updated
|
|
440
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
441
|
-
if (verror) {
|
|
442
|
-
return callback(null, verror);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return this.capabilityResults(vcapable, callback);
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
case 'device': {
|
|
450
|
-
// if the cache is invalid, update the cache
|
|
451
|
-
return this.getDevices(null, null, (data, err) => {
|
|
452
|
-
if (err) {
|
|
453
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
454
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
455
|
-
return callback(null, errorObj);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// need to check the cache again since it has been updated
|
|
459
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
460
|
-
if (verror) {
|
|
461
|
-
return callback(null, verror);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
return this.capabilityResults(vcapable, callback);
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
case 'device_group': {
|
|
469
|
-
// if the cache is invalid, update the cache
|
|
470
|
-
return this.getDeviceGroups(null, null, (data, err) => {
|
|
471
|
-
if (err) {
|
|
472
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
473
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
474
|
-
return callback(null, errorObj);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// need to check the cache again since it has been updated
|
|
478
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
479
|
-
if (verror) {
|
|
480
|
-
return callback(null, verror);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
return this.capabilityResults(vcapable, callback);
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
/* Can not get all components - just all components on a device
|
|
488
|
-
case 'device_component': {
|
|
489
|
-
}
|
|
490
|
-
*/
|
|
491
|
-
case 'device_component_group': {
|
|
492
|
-
// if the cache is invalid, update the cache
|
|
493
|
-
return this.getComponentGroups(null, null, (data, err) => {
|
|
494
|
-
if (err) {
|
|
495
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
496
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
497
|
-
return callback(null, errorObj);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// need to check the cache again since it has been updated
|
|
501
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
502
|
-
if (verror) {
|
|
503
|
-
return callback(null, verror);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
return this.capabilityResults(vcapable, callback);
|
|
507
|
-
});
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
case 'map': {
|
|
511
|
-
// if the cache is invalid, update the cache
|
|
512
|
-
return this.getMaps(null, null, (data, err) => {
|
|
513
|
-
if (err) {
|
|
514
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
515
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
516
|
-
return callback(null, errorObj);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// need to check the cache again since it has been updated
|
|
520
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
521
|
-
if (verror) {
|
|
522
|
-
return callback(null, verror);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
return this.capabilityResults(vcapable, callback);
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
default: {
|
|
530
|
-
// unsupported entity type
|
|
531
|
-
const result = [false];
|
|
532
|
-
|
|
533
|
-
// put false in array for all entities
|
|
534
|
-
if (Array.isArray(entityId)) {
|
|
535
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
536
|
-
result.push(false);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
return callback(result);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// return the results
|
|
546
|
-
return this.capabilityResults(results, callback);
|
|
547
|
-
});
|
|
442
|
+
try {
|
|
443
|
+
return super.iapDeactivateTasks(tasks, callback);
|
|
444
|
+
} catch (err) {
|
|
445
|
+
log.error(`${origin}: ${err}`);
|
|
446
|
+
return callback(null, err);
|
|
548
447
|
}
|
|
448
|
+
}
|
|
549
449
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
450
|
+
/**
|
|
451
|
+
* @summary Activate adapter tasks that have previously been deactivated
|
|
452
|
+
*
|
|
453
|
+
* @function iapActivateTasks
|
|
454
|
+
*
|
|
455
|
+
* @param {Array} tasks - List of tasks to activate
|
|
456
|
+
* @param {Callback} callback
|
|
457
|
+
*/
|
|
458
|
+
iapActivateTasks(tasks, callback) {
|
|
459
|
+
const meth = 'adapter-iapActivateTasks';
|
|
460
|
+
const origin = `${this.id}-${meth}`;
|
|
461
|
+
log.trace(origin);
|
|
557
462
|
|
|
558
|
-
|
|
559
|
-
|
|
463
|
+
try {
|
|
464
|
+
return super.iapActivateTasks(tasks, callback);
|
|
465
|
+
} catch (err) {
|
|
466
|
+
log.error(`${origin}: ${err}`);
|
|
467
|
+
return callback(null, err);
|
|
560
468
|
}
|
|
469
|
+
}
|
|
561
470
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
return callback(null, verror);
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
const names = [];
|
|
580
|
-
|
|
581
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
582
|
-
names.push(data.list[d].name);
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
// is the entity in the list?
|
|
586
|
-
const isEntity = this.entityInList(entityId, names);
|
|
587
|
-
const res = [];
|
|
588
|
-
|
|
589
|
-
// not found
|
|
590
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
591
|
-
if (vcapable[0] === 'found') {
|
|
592
|
-
res.push(isEntity[i]);
|
|
593
|
-
} else {
|
|
594
|
-
res.push(false);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
return callback(res);
|
|
599
|
-
});
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
case 'device': {
|
|
603
|
-
// if the cache is invalid, update the cache
|
|
604
|
-
return this.getDevices(null, null, (data, err) => {
|
|
605
|
-
if (err) {
|
|
606
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
607
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
608
|
-
return callback(null, errorObj);
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// need to check the cache again since it has been updated
|
|
612
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
613
|
-
if (verror) {
|
|
614
|
-
return callback(null, verror);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
const names = [];
|
|
618
|
-
|
|
619
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
620
|
-
names.push(data.list[d].name);
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
// is the entity in the list?
|
|
624
|
-
const isEntity = this.entityInList(entityId, names);
|
|
625
|
-
const res = [];
|
|
626
|
-
|
|
627
|
-
// not found
|
|
628
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
629
|
-
if (vcapable[0] === 'found') {
|
|
630
|
-
res.push(isEntity[i]);
|
|
631
|
-
} else {
|
|
632
|
-
res.push(false);
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
return callback(res);
|
|
637
|
-
});
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
case 'device_group': {
|
|
641
|
-
// if the cache is invalid, update the cache
|
|
642
|
-
return this.getDeviceGroups(null, null, (data, err) => {
|
|
643
|
-
if (err) {
|
|
644
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
645
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
646
|
-
return callback(null, errorObj);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
// need to check the cache again since it has been updated
|
|
650
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
651
|
-
if (verror) {
|
|
652
|
-
return callback(null, verror);
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
const names = [];
|
|
656
|
-
|
|
657
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
658
|
-
names.push(data.list[d].name);
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
// is the entity in the list?
|
|
662
|
-
const isEntity = this.entityInList(entityId, names);
|
|
663
|
-
const res = [];
|
|
664
|
-
|
|
665
|
-
// not found
|
|
666
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
667
|
-
if (vcapable[0] === 'found') {
|
|
668
|
-
res.push(isEntity[i]);
|
|
669
|
-
} else {
|
|
670
|
-
res.push(false);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
return callback(res);
|
|
675
|
-
});
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
/* Can not get all components - just all components on a device
|
|
679
|
-
case 'device_component': {
|
|
680
|
-
}
|
|
681
|
-
*/
|
|
682
|
-
case 'device_component_group': {
|
|
683
|
-
// if the cache is invalid, update the cache
|
|
684
|
-
return this.getComponentGroups(null, null, (data, err) => {
|
|
685
|
-
if (err) {
|
|
686
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
687
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
688
|
-
return callback(null, errorObj);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
// need to check the cache again since it has been updated
|
|
692
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
693
|
-
if (verror) {
|
|
694
|
-
return callback(null, verror);
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
const names = [];
|
|
698
|
-
|
|
699
|
-
for (let d = 0; d < data.list.length; d += 1) {
|
|
700
|
-
names.push(data.list[d].name);
|
|
701
|
-
}
|
|
471
|
+
/* CACHE CALLS */
|
|
472
|
+
/**
|
|
473
|
+
* @summary Populate the cache for the given entities
|
|
474
|
+
*
|
|
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
|
|
478
|
+
*
|
|
479
|
+
* @returns status of the populate
|
|
480
|
+
*/
|
|
481
|
+
iapPopulateEntityCache(entityTypes, callback) {
|
|
482
|
+
const meth = 'adapter-iapPopulateEntityCache';
|
|
483
|
+
const origin = `${this.id}-${meth}`;
|
|
484
|
+
log.trace(origin);
|
|
702
485
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
486
|
+
try {
|
|
487
|
+
return super.iapPopulateEntityCache(entityTypes, callback);
|
|
488
|
+
} catch (err) {
|
|
489
|
+
log.error(`${origin}: ${err}`);
|
|
490
|
+
return callback(null, err);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
706
493
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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);
|
|
715
506
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
if (err) {
|
|
724
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
725
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
726
|
-
return callback(null, errorObj);
|
|
727
|
-
}
|
|
507
|
+
try {
|
|
508
|
+
return super.iapRetrieveEntitiesCache(entityType, options, callback);
|
|
509
|
+
} catch (err) {
|
|
510
|
+
log.error(`${origin}: ${err}`);
|
|
511
|
+
return callback(null, err);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
728
514
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
515
|
+
/* BROKER CALLS */
|
|
516
|
+
/**
|
|
517
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
518
|
+
*
|
|
519
|
+
* @function hasEntities
|
|
520
|
+
* @param {String} entityType - the entity type to check for
|
|
521
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
522
|
+
*
|
|
523
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
524
|
+
* value is true or false
|
|
525
|
+
*/
|
|
526
|
+
hasEntities(entityType, entityList, callback) {
|
|
527
|
+
const meth = 'adapter-hasEntities';
|
|
528
|
+
const origin = `${this.id}-${meth}`;
|
|
529
|
+
log.trace(origin);
|
|
734
530
|
|
|
735
|
-
|
|
531
|
+
try {
|
|
532
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
533
|
+
} catch (err) {
|
|
534
|
+
log.error(`${origin}: ${err}`);
|
|
535
|
+
return callback(null, err);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
736
538
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
539
|
+
/**
|
|
540
|
+
* @summary Get Appliance that match the deviceName
|
|
541
|
+
*
|
|
542
|
+
* @function getDevice
|
|
543
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
544
|
+
*
|
|
545
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
546
|
+
* (appliance) or the error
|
|
547
|
+
*/
|
|
548
|
+
getDevice(deviceName, callback) {
|
|
549
|
+
const meth = 'adapter-getDevice';
|
|
550
|
+
const origin = `${this.id}-${meth}`;
|
|
551
|
+
log.trace(origin);
|
|
740
552
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
553
|
+
try {
|
|
554
|
+
return super.getDevice(deviceName, callback);
|
|
555
|
+
} catch (err) {
|
|
556
|
+
log.error(`${origin}: ${err}`);
|
|
557
|
+
return callback(null, err);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
744
560
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
561
|
+
/**
|
|
562
|
+
* @summary Get Appliances that match the filter
|
|
563
|
+
*
|
|
564
|
+
* @function getDevicesFiltered
|
|
565
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
566
|
+
*
|
|
567
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
568
|
+
* (appliances) or the error
|
|
569
|
+
*/
|
|
570
|
+
getDevicesFiltered(options, callback) {
|
|
571
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
572
|
+
const origin = `${this.id}-${meth}`;
|
|
573
|
+
log.trace(origin);
|
|
753
574
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
575
|
+
try {
|
|
576
|
+
return super.getDevicesFiltered(options, callback);
|
|
577
|
+
} catch (err) {
|
|
578
|
+
log.error(`${origin}: ${err}`);
|
|
579
|
+
return callback(null, err);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
761
582
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
583
|
+
/**
|
|
584
|
+
* @summary Gets the status for the provided appliance
|
|
585
|
+
*
|
|
586
|
+
* @function isAlive
|
|
587
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
588
|
+
*
|
|
589
|
+
* @param {configCallback} callback - callback function to return the result
|
|
590
|
+
* (appliance isAlive) or the error
|
|
591
|
+
*/
|
|
592
|
+
isAlive(deviceName, callback) {
|
|
593
|
+
const meth = 'adapter-isAlive';
|
|
594
|
+
const origin = `${this.id}-${meth}`;
|
|
595
|
+
log.trace(origin);
|
|
768
596
|
|
|
769
|
-
|
|
770
|
-
|
|
597
|
+
try {
|
|
598
|
+
return super.isAlive(deviceName, callback);
|
|
599
|
+
} catch (err) {
|
|
600
|
+
log.error(`${origin}: ${err}`);
|
|
601
|
+
return callback(null, err);
|
|
771
602
|
}
|
|
772
603
|
}
|
|
773
604
|
|
|
774
605
|
/**
|
|
775
|
-
* @summary
|
|
606
|
+
* @summary Gets a config for the provided Appliance
|
|
776
607
|
*
|
|
777
|
-
* @function
|
|
608
|
+
* @function getConfig
|
|
609
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
610
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
778
611
|
*
|
|
612
|
+
* @param {configCallback} callback - callback function to return the result
|
|
613
|
+
* (appliance config) or the error
|
|
779
614
|
*/
|
|
780
|
-
|
|
781
|
-
const
|
|
615
|
+
getConfig(deviceName, format, callback) {
|
|
616
|
+
const meth = 'adapter-getConfig';
|
|
617
|
+
const origin = `${this.id}-${meth}`;
|
|
782
618
|
log.trace(origin);
|
|
783
619
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
// if the cache is invalid, update the device cache
|
|
793
|
-
this.getDevices(null, null, null, null, (data, err) => {
|
|
794
|
-
if (err) {
|
|
795
|
-
log.trace(`Could not load devices into cache - ${err}`);
|
|
796
|
-
}
|
|
797
|
-
});
|
|
620
|
+
try {
|
|
621
|
+
return super.getConfig(deviceName, format, callback);
|
|
622
|
+
} catch (err) {
|
|
623
|
+
log.error(`${origin}: ${err}`);
|
|
624
|
+
return callback(null, err);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
798
627
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
628
|
+
/**
|
|
629
|
+
* @summary Gets the device count from the system
|
|
630
|
+
*
|
|
631
|
+
* @function iapGetDeviceCount
|
|
632
|
+
*
|
|
633
|
+
* @param {getCallback} callback - callback function to return the result
|
|
634
|
+
* (count) or the error
|
|
635
|
+
*/
|
|
636
|
+
iapGetDeviceCount(callback) {
|
|
637
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
638
|
+
const origin = `${this.id}-${meth}`;
|
|
639
|
+
log.trace(origin);
|
|
805
640
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
*/
|
|
641
|
+
try {
|
|
642
|
+
return super.iapGetDeviceCount(callback);
|
|
643
|
+
} catch (err) {
|
|
644
|
+
log.error(`${origin}: ${err}`);
|
|
645
|
+
return callback(null, err);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
814
648
|
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
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);
|
|
821
673
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
});
|
|
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);
|
|
828
679
|
}
|
|
829
680
|
}
|
|
830
681
|
|
|
@@ -848,94 +699,84 @@ class SevOne extends AdapterBaseCl {
|
|
|
848
699
|
const origin = `${this.id}-${meth}`;
|
|
849
700
|
log.trace(origin);
|
|
850
701
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
702
|
+
try {
|
|
703
|
+
return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
704
|
+
} catch (err) {
|
|
705
|
+
log.error(`${origin}: ${err}`);
|
|
706
|
+
return callback(null, err);
|
|
855
707
|
}
|
|
708
|
+
}
|
|
856
709
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
710
|
+
/**
|
|
711
|
+
* Makes the requested generic call with no base path or version
|
|
712
|
+
*
|
|
713
|
+
* @function genericAdapterRequestNoBasePath
|
|
714
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
715
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
716
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
717
|
+
* Can be a stringified Object.
|
|
718
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
719
|
+
* Can be a stringified Object.
|
|
720
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
721
|
+
* Can be a stringified Object.
|
|
722
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
723
|
+
* or the error
|
|
724
|
+
*/
|
|
725
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
726
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
727
|
+
const origin = `${this.id}-${meth}`;
|
|
728
|
+
log.trace(origin);
|
|
868
729
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
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);
|
|
874
735
|
}
|
|
875
|
-
|
|
876
|
-
const queryParamsAvailable = queryData;
|
|
877
|
-
const queryParams = {};
|
|
878
|
-
const bodyVars = requestBody;
|
|
736
|
+
}
|
|
879
737
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
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);
|
|
887
749
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
payload: bodyVars,
|
|
891
|
-
uriPathVars: pathVars,
|
|
892
|
-
uriQuery: queryParams,
|
|
893
|
-
uriOptions: {}
|
|
894
|
-
};
|
|
895
|
-
// add headers if provided
|
|
896
|
-
if (addlHeaders) {
|
|
897
|
-
reqObj.addlHeaders = addlHeaders;
|
|
898
|
-
}
|
|
750
|
+
return super.iapRunAdapterLint(callback);
|
|
751
|
+
}
|
|
899
752
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
returnF = false;
|
|
912
|
-
}
|
|
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);
|
|
913
764
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
917
|
-
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
918
|
-
// if we received an error or their is no response on the results
|
|
919
|
-
// return an error
|
|
920
|
-
if (irReturnError) {
|
|
921
|
-
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
922
|
-
return callback(null, irReturnError);
|
|
923
|
-
}
|
|
924
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
925
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
926
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
927
|
-
return callback(null, errorObj);
|
|
928
|
-
}
|
|
765
|
+
return super.iapRunAdapterTests(callback);
|
|
766
|
+
}
|
|
929
767
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
}
|
|
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);
|
|
778
|
+
|
|
779
|
+
return super.iapGetAdapterInventory(callback);
|
|
939
780
|
}
|
|
940
781
|
|
|
941
782
|
/**
|
|
@@ -1011,16 +852,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
1011
852
|
return callback(null, errorObj);
|
|
1012
853
|
}
|
|
1013
854
|
|
|
1014
|
-
// if no error and a get ALL, add the entities to the cache
|
|
1015
|
-
if (!alertId && this.caching) {
|
|
1016
|
-
// add the entities to the cache - can run on its own
|
|
1017
|
-
this.addEntityCache('alert', result.response, 'id', (loaded, err) => {
|
|
1018
|
-
if (!loaded) {
|
|
1019
|
-
log.trace(`${origin}: Could not load alerts into cache - ${err}`);
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
855
|
// return the response
|
|
1025
856
|
return callback(addAlertTypes(result));
|
|
1026
857
|
});
|
|
@@ -3358,16 +3189,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
3358
3189
|
return callback(null, errorObj);
|
|
3359
3190
|
}
|
|
3360
3191
|
|
|
3361
|
-
// if no error and a get ALL, add the entities to the cache
|
|
3362
|
-
if (!deviceId && this.caching) {
|
|
3363
|
-
// add the entities to the cache - can run on its own
|
|
3364
|
-
this.addEntityCache('device', result.response, 'id', (loaded, err) => {
|
|
3365
|
-
if (!loaded) {
|
|
3366
|
-
log.trace(`Could not load device into cache - ${err}`);
|
|
3367
|
-
}
|
|
3368
|
-
});
|
|
3369
|
-
}
|
|
3370
|
-
|
|
3371
3192
|
// return the response
|
|
3372
3193
|
return callback(result);
|
|
3373
3194
|
});
|
|
@@ -3429,7 +3250,7 @@ class SevOne extends AdapterBaseCl {
|
|
|
3429
3250
|
/**
|
|
3430
3251
|
* @summary This function will retrieve the Devices from SevOne and pass them up to Pronghorn
|
|
3431
3252
|
*
|
|
3432
|
-
* @function
|
|
3253
|
+
* @function getSevDevicesFiltered
|
|
3433
3254
|
* @param {Object} filterObj - the filter to be used (optional).
|
|
3434
3255
|
* Can be a stringified Object.
|
|
3435
3256
|
* @param {uriOptions} uriOptions - optional paramters to pass on uri of the request (optional).
|
|
@@ -3439,8 +3260,8 @@ class SevOne extends AdapterBaseCl {
|
|
|
3439
3260
|
* @param {createCallback} callback - a callback function to return a result
|
|
3440
3261
|
* (Entity) or the error
|
|
3441
3262
|
*/
|
|
3442
|
-
|
|
3443
|
-
const meth = 'adapter-
|
|
3263
|
+
getSevDevicesFiltered(filterObj, uriOptions, callback) {
|
|
3264
|
+
const meth = 'adapter-getSevDevicesFiltered';
|
|
3444
3265
|
const origin = `${this.id}-${meth}`;
|
|
3445
3266
|
log.trace(origin);
|
|
3446
3267
|
|
|
@@ -3469,7 +3290,7 @@ class SevOne extends AdapterBaseCl {
|
|
|
3469
3290
|
return callback(null, error);
|
|
3470
3291
|
}
|
|
3471
3292
|
if (!Object.hasOwnProperty.call(result, 'response')) {
|
|
3472
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['
|
|
3293
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSevDevicesFiltered'], null, null, null);
|
|
3473
3294
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3474
3295
|
return callback(null, errorObj);
|
|
3475
3296
|
}
|
|
@@ -3513,7 +3334,7 @@ class SevOne extends AdapterBaseCl {
|
|
|
3513
3334
|
}
|
|
3514
3335
|
|
|
3515
3336
|
// real call to get devices
|
|
3516
|
-
return this.
|
|
3337
|
+
return this.getSevDevicesFiltered(deviceObj, uriOptions, callback);
|
|
3517
3338
|
}
|
|
3518
3339
|
|
|
3519
3340
|
/**
|
|
@@ -3733,16 +3554,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
3733
3554
|
return callback(null, errorObj);
|
|
3734
3555
|
}
|
|
3735
3556
|
|
|
3736
|
-
// if no error and a get ALL, add the entities to the cache
|
|
3737
|
-
if (!groupId && this.caching) {
|
|
3738
|
-
// add the entities to the cache - can run on its own
|
|
3739
|
-
this.addEntityCache('device_group', result.response, 'id', (loaded, err) => {
|
|
3740
|
-
if (!loaded) {
|
|
3741
|
-
log.trace(`Could not load device_group into cache - ${err}`);
|
|
3742
|
-
}
|
|
3743
|
-
});
|
|
3744
|
-
}
|
|
3745
|
-
|
|
3746
3557
|
// return the response
|
|
3747
3558
|
return callback(result);
|
|
3748
3559
|
});
|
|
@@ -4138,16 +3949,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
4138
3949
|
return callback(null, errorObj);
|
|
4139
3950
|
}
|
|
4140
3951
|
|
|
4141
|
-
// if no error and a get ALL, add the entities to the cache
|
|
4142
|
-
if (!deviceId && !componentId && this.caching) {
|
|
4143
|
-
// add the entities to the cache - can run on its own
|
|
4144
|
-
this.addEntityCache('device_component', result.response, 'id', (loaded, err) => {
|
|
4145
|
-
if (!loaded) {
|
|
4146
|
-
log.trace(`Could not load device_component into cache - ${err}`);
|
|
4147
|
-
}
|
|
4148
|
-
});
|
|
4149
|
-
}
|
|
4150
|
-
|
|
4151
3952
|
// return the response
|
|
4152
3953
|
return callback(result);
|
|
4153
3954
|
});
|
|
@@ -4754,16 +4555,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
4754
4555
|
return callback(null, errorObj);
|
|
4755
4556
|
}
|
|
4756
4557
|
|
|
4757
|
-
// if no error and a get ALL, add the entities to the cache
|
|
4758
|
-
if (!groupId && this.caching) {
|
|
4759
|
-
// add the entities to the cache - can run on its own
|
|
4760
|
-
this.addEntityCache('device_component_group', result.response, 'id', (loaded, err) => {
|
|
4761
|
-
if (!loaded) {
|
|
4762
|
-
log.trace(`Could not load device_component_group into cache - ${err}`);
|
|
4763
|
-
}
|
|
4764
|
-
});
|
|
4765
|
-
}
|
|
4766
|
-
|
|
4767
4558
|
// return the response
|
|
4768
4559
|
return callback(result);
|
|
4769
4560
|
});
|
|
@@ -5723,16 +5514,6 @@ class SevOne extends AdapterBaseCl {
|
|
|
5723
5514
|
return callback(null, errorObj);
|
|
5724
5515
|
}
|
|
5725
5516
|
|
|
5726
|
-
// if no error and a get ALL, add the entities to the cache
|
|
5727
|
-
if (!mapId && this.caching) {
|
|
5728
|
-
// add the entities to the cache - can run on its own
|
|
5729
|
-
this.addEntityCache('map', result.response, 'id', (loaded, err) => {
|
|
5730
|
-
if (!loaded) {
|
|
5731
|
-
log.trace(`Could not load map into cache - ${err}`);
|
|
5732
|
-
}
|
|
5733
|
-
});
|
|
5734
|
-
}
|
|
5735
|
-
|
|
5736
5517
|
// return the response
|
|
5737
5518
|
return callback(result);
|
|
5738
5519
|
});
|