@itentialopensource/adapter-netbrain 1.1.0 → 1.2.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.
Files changed (42) hide show
  1. package/CALLS.md +18 -0
  2. package/CHANGELOG.md +16 -0
  3. package/CONTRIBUTING.md +1 -160
  4. package/ENHANCE.md +2 -2
  5. package/README.md +32 -23
  6. package/adapter.js +242 -348
  7. package/adapterBase.js +549 -879
  8. package/changelogs/changelog.md +151 -0
  9. package/metadata.json +47 -0
  10. package/package.json +24 -27
  11. package/pronghorn.json +985 -646
  12. package/propertiesSchema.json +431 -31
  13. package/refs?service=git-upload-pack +0 -0
  14. package/report/adapter-openapi.json +8023 -0
  15. package/report/adapter-openapi.yaml +5944 -0
  16. package/report/adapterInfo.json +8 -8
  17. package/report/updateReport1691507690977.json +120 -0
  18. package/report/updateReport1692202690574.json +120 -0
  19. package/report/updateReport1694462665367.json +120 -0
  20. package/report/updateReport1698421227451.json +120 -0
  21. package/sampleProperties.json +63 -2
  22. package/test/integration/adapterTestBasicGet.js +2 -4
  23. package/test/integration/adapterTestConnectivity.js +91 -42
  24. package/test/integration/adapterTestIntegration.js +130 -2
  25. package/test/unit/adapterBaseTestUnit.js +388 -313
  26. package/test/unit/adapterTestUnit.js +338 -129
  27. package/utils/adapterInfo.js +1 -1
  28. package/utils/addAuth.js +1 -1
  29. package/utils/artifactize.js +1 -1
  30. package/utils/checkMigrate.js +1 -1
  31. package/utils/entitiesToDB.js +2 -2
  32. package/utils/findPath.js +1 -1
  33. package/utils/methodDocumentor.js +273 -0
  34. package/utils/modify.js +13 -15
  35. package/utils/packModificationScript.js +1 -1
  36. package/utils/pre-commit.sh +2 -0
  37. package/utils/taskMover.js +309 -0
  38. package/utils/tbScript.js +89 -34
  39. package/utils/tbUtils.js +41 -21
  40. package/utils/testRunner.js +1 -1
  41. package/utils/troubleshootingAdapter.js +9 -6
  42. package/workflows/README.md +0 -3
package/adapter.js CHANGED
@@ -73,12 +73,50 @@ class Netbrain extends AdapterBaseCl {
73
73
  * @param {Callback} callback - The results of the call
74
74
  */
75
75
  healthCheck(reqObj, callback) {
76
- // you can modify what is passed into the healthcheck by changing things in the newReq
77
- let newReq = null;
78
- if (reqObj) {
79
- newReq = Object.assign(...reqObj);
76
+ let myRequest = reqObj;
77
+ const origin = `${this.id}-adapter-healthCheck`;
78
+
79
+ // we are overriding the adapterBase healthcheck so that it goes through the same process as other NetBrain calls.
80
+ if (this.healthcheckQuery && Object.keys(this.healthcheckQuery).length > 0) {
81
+ if (myRequest && myRequest.uriQuery) {
82
+ myRequest.uriQuery = { ...myRequest.uriQuery, ...this.healthcheckQuery };
83
+ } else if (myRequest) {
84
+ myRequest.uriQuery = this.healthcheckQuery;
85
+ } else {
86
+ myRequest = {
87
+ uriQuery: this.healthcheckQuery
88
+ };
89
+ }
80
90
  }
81
- super.healthCheck(newReq, callback);
91
+ // super.healthCheck(newReq, callback);
92
+ return this.processRequest('.system', 'healthcheck', myRequest, false, 0, (irReturnData, irReturnError) => {
93
+ // unhealthy
94
+ if (irReturnError) {
95
+ // if we were healthy, toggle health
96
+ if (this.healthy) {
97
+ this.emit('OFFLINE', { id: this.id });
98
+ this.emit('DEGRADED', { id: this.id });
99
+ this.healthy = false;
100
+ log.error(`${origin}: HEALTH CHECK - Error ${irReturnError}`);
101
+ } else {
102
+ // still log but set the level to trace
103
+ log.trace(`${origin}: HEALTH CHECK - Still Errors ${irReturnError}`);
104
+ }
105
+
106
+ return callback(false);
107
+ }
108
+ // if we were unhealthy, toggle health
109
+ if (!this.healthy) {
110
+ this.emit('FIXED', { id: this.id });
111
+ this.emit('ONLINE', { id: this.id });
112
+ this.healthy = true;
113
+ log.info(`${origin}: HEALTH CHECK SUCCESSFUL`);
114
+ } else {
115
+ // still log but set the level to trace
116
+ log.trace(`${origin}: HEALTH CHECK STILL SUCCESSFUL`);
117
+ }
118
+ return callback(true);
119
+ });
82
120
  }
83
121
 
84
122
  /**
@@ -88,9 +126,6 @@ class Netbrain extends AdapterBaseCl {
88
126
  let myIgnore = [
89
127
  'healthCheck',
90
128
  'iapGetAdapterWorkflowFunctions',
91
- 'iapHasAdapterEntity',
92
- 'iapVerifyAdapterCapability',
93
- 'iapUpdateAdapterEntityCache',
94
129
  'hasEntities',
95
130
  'getAuthorization',
96
131
  'processRequest'
@@ -119,29 +154,15 @@ class Netbrain extends AdapterBaseCl {
119
154
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
120
155
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
121
156
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
157
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
122
158
  * @param {Callback} callback - The results of the call
123
159
  */
124
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
160
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
125
161
  const meth = 'adapter-iapUpdateAdapterConfiguration';
126
162
  const origin = `${this.id}-${meth}`;
127
163
  log.trace(origin);
128
164
 
129
- super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
130
- }
131
-
132
- /**
133
- * See if the API path provided is found in this adapter
134
- *
135
- * @function iapFindAdapterPath
136
- * @param {string} apiPath - the api path to check on
137
- * @param {Callback} callback - The results of the call
138
- */
139
- iapFindAdapterPath(apiPath, callback) {
140
- const meth = 'adapter-iapFindAdapterPath';
141
- const origin = `${this.id}-${meth}`;
142
- log.trace(origin);
143
-
144
- super.iapFindAdapterPath(apiPath, callback);
165
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
145
166
  }
146
167
 
147
168
  /**
@@ -183,7 +204,7 @@ class Netbrain extends AdapterBaseCl {
183
204
  }
184
205
 
185
206
  /**
186
- * @summary Get the Adaoter Queue
207
+ * @summary Get the Adapter Queue
187
208
  *
188
209
  * @function iapGetAdapterQueue
189
210
  * @param {Callback} callback - callback function
@@ -196,6 +217,22 @@ class Netbrain extends AdapterBaseCl {
196
217
  return super.iapGetAdapterQueue(callback);
197
218
  }
198
219
 
220
+ /* SCRIPT CALLS */
221
+ /**
222
+ * See if the API path provided is found in this adapter
223
+ *
224
+ * @function iapFindAdapterPath
225
+ * @param {string} apiPath - the api path to check on
226
+ * @param {Callback} callback - The results of the call
227
+ */
228
+ iapFindAdapterPath(apiPath, callback) {
229
+ const meth = 'adapter-iapFindAdapterPath';
230
+ const origin = `${this.id}-${meth}`;
231
+ log.trace(origin);
232
+
233
+ super.iapFindAdapterPath(apiPath, callback);
234
+ }
235
+
199
236
  /**
200
237
  * @summary Runs troubleshoot scripts for adapter
201
238
  *
@@ -296,176 +333,93 @@ class Netbrain extends AdapterBaseCl {
296
333
  }
297
334
  }
298
335
 
299
- /* BROKER CALLS */
300
336
  /**
301
- * @summary Determines if this adapter supports the specific entity
337
+ * @summary Deactivate adapter tasks
302
338
  *
303
- * @function iapHasAdapterEntity
304
- * @param {String} entityType - the entity type to check for
305
- * @param {String/Array} entityId - the specific entity we are looking for
339
+ * @function iapDeactivateTasks
306
340
  *
307
- * @param {Callback} callback - An array of whether the adapter can has the
308
- * desired capability or an error
341
+ * @param {Array} tasks - List of tasks to deactivate
342
+ * @param {Callback} callback
309
343
  */
310
- iapHasAdapterEntity(entityType, entityId, callback) {
311
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
344
+ iapDeactivateTasks(tasks, callback) {
345
+ const meth = 'adapter-iapDeactivateTasks';
346
+ const origin = `${this.id}-${meth}`;
312
347
  log.trace(origin);
313
348
 
314
- // Make the call -
315
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
316
- return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
349
+ try {
350
+ return super.iapDeactivateTasks(tasks, callback);
351
+ } catch (err) {
352
+ log.error(`${origin}: ${err}`);
353
+ return callback(null, err);
354
+ }
317
355
  }
318
356
 
319
357
  /**
320
- * @summary Provides a way for the adapter to tell north bound integrations
321
- * whether the adapter supports type, action and specific entity
358
+ * @summary Activate adapter tasks that have previously been deactivated
322
359
  *
323
- * @function iapVerifyAdapterCapability
324
- * @param {String} entityType - the entity type to check for
325
- * @param {String} actionType - the action type to check for
326
- * @param {String/Array} entityId - the specific entity we are looking for
360
+ * @function iapActivateTasks
327
361
  *
328
- * @param {Callback} callback - An array of whether the adapter can has the
329
- * desired capability or an error
362
+ * @param {Array} tasks - List of tasks to activate
363
+ * @param {Callback} callback
330
364
  */
331
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
332
- const meth = 'adapterBase-iapVerifyAdapterCapability';
365
+ iapActivateTasks(tasks, callback) {
366
+ const meth = 'adapter-iapActivateTasks';
333
367
  const origin = `${this.id}-${meth}`;
334
368
  log.trace(origin);
335
369
 
336
- // if caching
337
- if (this.caching) {
338
- // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
339
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
340
- if (error) {
341
- return callback(null, error);
342
- }
343
-
344
- // if the cache needs to be updated, update and try again
345
- if (results && results[0] === 'needupdate') {
346
- switch (entityType) {
347
- case 'template_entity': {
348
- // if the cache is invalid, update the cache
349
- return this.getEntities(null, null, null, null, (data, err) => {
350
- if (err) {
351
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
352
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
353
- return callback(null, errorObj);
354
- }
355
-
356
- // need to check the cache again since it has been updated
357
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
358
- if (verror) {
359
- return callback(null, verror);
360
- }
361
-
362
- return this.capabilityResults(vcapable, callback);
363
- });
364
- });
365
- }
366
- default: {
367
- // unsupported entity type
368
- const result = [false];
369
-
370
- // put false in array for all entities
371
- if (Array.isArray(entityId)) {
372
- for (let e = 1; e < entityId.length; e += 1) {
373
- result.push(false);
374
- }
375
- }
376
-
377
- return callback(result);
378
- }
379
- }
380
- }
381
-
382
- // return the results
383
- return this.capabilityResults(results, callback);
384
- });
385
- }
386
-
387
- // if no entity id
388
- if (!entityId) {
389
- // need to check the cache again since it has been updated
390
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
391
- if (verror) {
392
- return callback(null, verror);
393
- }
394
-
395
- return this.capabilityResults(vcapable, callback);
396
- });
370
+ try {
371
+ return super.iapActivateTasks(tasks, callback);
372
+ } catch (err) {
373
+ log.error(`${origin}: ${err}`);
374
+ return callback(null, err);
397
375
  }
376
+ }
398
377
 
399
- // if not caching
400
- switch (entityType) {
401
- case 'template_entity': {
402
- // need to get the entities to check
403
- return this.getEntities(null, null, null, null, (data, err) => {
404
- if (err) {
405
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
406
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
407
- return callback(null, errorObj);
408
- }
409
-
410
- // need to check the cache again since it has been updated
411
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
412
- if (verror) {
413
- return callback(null, verror);
414
- }
415
-
416
- // is the entity in the list?
417
- const isEntity = this.entityInList(entityId, data.response, callback);
418
- const res = [];
419
-
420
- // not found
421
- for (let i = 0; i < isEntity.length; i += 1) {
422
- if (vcapable) {
423
- res.push(isEntity[i]);
424
- } else {
425
- res.push(false);
426
- }
427
- }
428
-
429
- return callback(res);
430
- });
431
- });
432
- }
433
- default: {
434
- // unsupported entity type
435
- const result = [false];
436
-
437
- // put false in array for all entities
438
- if (Array.isArray(entityId)) {
439
- for (let e = 1; e < entityId.length; e += 1) {
440
- result.push(false);
441
- }
442
- }
378
+ /* CACHE CALLS */
379
+ /**
380
+ * @summary Populate the cache for the given entities
381
+ *
382
+ * @function iapPopulateEntityCache
383
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
384
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
385
+ *
386
+ * @returns status of the populate
387
+ */
388
+ iapPopulateEntityCache(entityTypes, callback) {
389
+ const meth = 'adapter-iapPopulateEntityCache';
390
+ const origin = `${this.id}-${meth}`;
391
+ log.trace(origin);
443
392
 
444
- return callback(result);
445
- }
393
+ try {
394
+ return super.iapPopulateEntityCache(entityTypes, callback);
395
+ } catch (err) {
396
+ log.error(`${origin}: ${err}`);
397
+ return callback(null, err);
446
398
  }
447
399
  }
448
400
 
449
401
  /**
450
- * @summary Updates the cache for all entities by call the get All entity method
451
- *
452
- * @function iapUpdateAdapterEntityCache
402
+ * @summary Retrieves data from cache for specified entity type
453
403
  *
404
+ * @function iapRetrieveEntitiesCache
405
+ * @param {String} entityType - entity of which to retrieve
406
+ * @param {Object} options - settings of which data to return and how to return it
407
+ * @param {Callback} callback - the data if it was retrieved
454
408
  */
455
- iapUpdateAdapterEntityCache() {
456
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
409
+ iapRetrieveEntitiesCache(entityType, options, callback) {
410
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
411
+ const origin = `${this.id}-${meth}`;
457
412
  log.trace(origin);
458
413
 
459
- if (this.caching) {
460
- // if the cache is invalid, update the cache
461
- this.getEntities(null, null, null, null, (data, err) => {
462
- if (err) {
463
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
464
- }
465
- });
414
+ try {
415
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
416
+ } catch (err) {
417
+ log.error(`${origin}: ${err}`);
418
+ return callback(null, err);
466
419
  }
467
420
  }
468
421
 
422
+ /* BROKER CALLS */
469
423
  /**
470
424
  * @summary Determines if this adapter supports any in a list of entities
471
425
  *
@@ -600,6 +554,38 @@ class Netbrain extends AdapterBaseCl {
600
554
  }
601
555
 
602
556
  /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
557
+ /**
558
+ * Makes the requested generic call
559
+ *
560
+ * @function iapExpandedGenericAdapterRequest
561
+ * @param {Object} metadata - metadata for the call (optional).
562
+ * Can be a stringified Object.
563
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
564
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
565
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
566
+ * Can be a stringified Object.
567
+ * @param {Object} queryData - the parameters to be put on the url (optional).
568
+ * Can be a stringified Object.
569
+ * @param {Object} requestBody - the body to add to the request (optional).
570
+ * Can be a stringified Object.
571
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
572
+ * Can be a stringified Object.
573
+ * @param {getCallback} callback - a callback function to return the result (Generics)
574
+ * or the error
575
+ */
576
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
577
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
578
+ const origin = `${this.id}-${meth}`;
579
+ log.trace(origin);
580
+
581
+ try {
582
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
583
+ } catch (err) {
584
+ log.error(`${origin}: ${err}`);
585
+ return callback(null, err);
586
+ }
587
+ }
588
+
603
589
  /**
604
590
  * Makes the requested generic call
605
591
  *
@@ -620,93 +606,11 @@ class Netbrain extends AdapterBaseCl {
620
606
  const origin = `${this.id}-${meth}`;
621
607
  log.trace(origin);
622
608
 
623
- if (this.suspended && this.suspendMode === 'error') {
624
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
625
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
626
- return callback(null, errorObj);
627
- }
628
-
629
- /* HERE IS WHERE YOU VALIDATE DATA */
630
- if (uriPath === undefined || uriPath === null || uriPath === '') {
631
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
632
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
633
- return callback(null, errorObj);
634
- }
635
- if (restMethod === undefined || restMethod === null || restMethod === '') {
636
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
637
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
638
- return callback(null, errorObj);
639
- }
640
-
641
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
642
- // remove any leading / and split the uripath into path variables
643
- let myPath = uriPath;
644
- while (myPath.indexOf('/') === 0) {
645
- myPath = myPath.substring(1);
646
- }
647
- const pathVars = myPath.split('/');
648
- const queryParamsAvailable = queryData;
649
- const queryParams = {};
650
- const bodyVars = requestBody;
651
-
652
- // loop in template. long callback arg name to avoid identifier conflicts
653
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
654
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
655
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
656
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
657
- }
658
- });
659
-
660
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
661
- const reqObj = {
662
- payload: bodyVars,
663
- uriPathVars: pathVars,
664
- uriQuery: queryParams,
665
- uriOptions: {}
666
- };
667
- // add headers if provided
668
- if (addlHeaders) {
669
- reqObj.addlHeaders = addlHeaders;
670
- }
671
-
672
- // determine the call and return flag
673
- let action = 'getGenerics';
674
- let returnF = true;
675
- if (restMethod.toUpperCase() === 'POST') {
676
- action = 'createGeneric';
677
- } else if (restMethod.toUpperCase() === 'PUT') {
678
- action = 'updateGeneric';
679
- } else if (restMethod.toUpperCase() === 'PATCH') {
680
- action = 'patchGeneric';
681
- } else if (restMethod.toUpperCase() === 'DELETE') {
682
- action = 'deleteGeneric';
683
- returnF = false;
684
- }
685
-
686
609
  try {
687
- // Make the call -
688
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
689
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
690
- // if we received an error or their is no response on the results
691
- // return an error
692
- if (irReturnError) {
693
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
694
- return callback(null, irReturnError);
695
- }
696
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
697
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
698
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
699
- return callback(null, errorObj);
700
- }
701
-
702
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
703
- // return the response
704
- return callback(irReturnData, null);
705
- });
706
- } catch (ex) {
707
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
708
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
709
- return callback(null, errorObj);
610
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
611
+ } catch (err) {
612
+ log.error(`${origin}: ${err}`);
613
+ return callback(null, err);
710
614
  }
711
615
  }
712
616
 
@@ -730,94 +634,56 @@ class Netbrain extends AdapterBaseCl {
730
634
  const origin = `${this.id}-${meth}`;
731
635
  log.trace(origin);
732
636
 
733
- if (this.suspended && this.suspendMode === 'error') {
734
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
735
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
736
- return callback(null, errorObj);
737
- }
738
-
739
- /* HERE IS WHERE YOU VALIDATE DATA */
740
- if (uriPath === undefined || uriPath === null || uriPath === '') {
741
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
742
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
743
- return callback(null, errorObj);
744
- }
745
- if (restMethod === undefined || restMethod === null || restMethod === '') {
746
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
747
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
748
- return callback(null, errorObj);
637
+ try {
638
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
639
+ } catch (err) {
640
+ log.error(`${origin}: ${err}`);
641
+ return callback(null, err);
749
642
  }
643
+ }
750
644
 
751
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
752
- // remove any leading / and split the uripath into path variables
753
- let myPath = uriPath;
754
- while (myPath.indexOf('/') === 0) {
755
- myPath = myPath.substring(1);
756
- }
757
- const pathVars = myPath.split('/');
758
- const queryParamsAvailable = queryData;
759
- const queryParams = {};
760
- const bodyVars = requestBody;
645
+ /* INVENTORY CALLS */
646
+ /**
647
+ * @summary run the adapter lint script to return the results.
648
+ *
649
+ * @function iapRunAdapterLint
650
+ * @param {Callback} callback - callback function
651
+ */
652
+ iapRunAdapterLint(callback) {
653
+ const meth = 'adapter-iapRunAdapterLint';
654
+ const origin = `${this.id}-${meth}`;
655
+ log.trace(origin);
761
656
 
762
- // loop in template. long callback arg name to avoid identifier conflicts
763
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
764
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
765
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
766
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
767
- }
768
- });
657
+ return super.iapRunAdapterLint(callback);
658
+ }
769
659
 
770
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
771
- const reqObj = {
772
- payload: bodyVars,
773
- uriPathVars: pathVars,
774
- uriQuery: queryParams,
775
- uriOptions: {}
776
- };
777
- // add headers if provided
778
- if (addlHeaders) {
779
- reqObj.addlHeaders = addlHeaders;
780
- }
660
+ /**
661
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
662
+ * can not run integration as there can be implications with that.
663
+ *
664
+ * @function iapRunAdapterTests
665
+ * @param {Callback} callback - callback function
666
+ */
667
+ iapRunAdapterTests(callback) {
668
+ const meth = 'adapter-iapRunAdapterTests';
669
+ const origin = `${this.id}-${meth}`;
670
+ log.trace(origin);
781
671
 
782
- // determine the call and return flag
783
- let action = 'getGenericsNoBase';
784
- let returnF = true;
785
- if (restMethod.toUpperCase() === 'POST') {
786
- action = 'createGenericNoBase';
787
- } else if (restMethod.toUpperCase() === 'PUT') {
788
- action = 'updateGenericNoBase';
789
- } else if (restMethod.toUpperCase() === 'PATCH') {
790
- action = 'patchGenericNoBase';
791
- } else if (restMethod.toUpperCase() === 'DELETE') {
792
- action = 'deleteGenericNoBase';
793
- returnF = false;
794
- }
672
+ return super.iapRunAdapterTests(callback);
673
+ }
795
674
 
796
- try {
797
- // Make the call -
798
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
799
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
800
- // if we received an error or their is no response on the results
801
- // return an error
802
- if (irReturnError) {
803
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
804
- return callback(null, irReturnError);
805
- }
806
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
807
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
808
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
809
- return callback(null, errorObj);
810
- }
675
+ /**
676
+ * @summary provide inventory information abbout the adapter
677
+ *
678
+ * @function iapGetAdapterInventory
679
+ * @param {Callback} callback - callback function
680
+ */
681
+ iapGetAdapterInventory(callback) {
682
+ const meth = 'adapter-iapGetAdapterInventory';
683
+ const origin = `${this.id}-${meth}`;
684
+ log.trace(origin);
811
685
 
812
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
813
- // return the response
814
- return callback(irReturnData, null);
815
- });
816
- } catch (ex) {
817
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
818
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
819
- return callback(null, errorObj);
820
- }
686
+ return super.iapGetAdapterInventory(callback);
821
687
  }
822
688
 
823
689
  /**
@@ -1219,7 +1085,7 @@ class Netbrain extends AdapterBaseCl {
1219
1085
  * @summary Query all the domains info in system.
1220
1086
  *
1221
1087
  * @function getV1CMDBDomains
1222
- * @param {string} tenantId - tenantId param
1088
+ * @param {string} tenantId - tenantId param, if passed empty it will get it from the adapter config
1223
1089
  * @param {getCallback} callback - a callback function to return the result
1224
1090
  */
1225
1091
 
@@ -1235,14 +1101,25 @@ class Netbrain extends AdapterBaseCl {
1235
1101
  return callback(null, errorObj);
1236
1102
  }
1237
1103
 
1238
- /* HERE IS WHERE YOU VALIDATE DATA */
1239
-
1240
1104
  /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1241
- const queryParamsAvailable = { tenantId };
1105
+ let configtenantId = tenantId;
1106
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
1107
+ if (this.allProps.authentication.tenantId) {
1108
+ configtenantId = this.allProps.authentication.tenantId;
1109
+ }
1110
+ }
1111
+ const queryParamsAvailable = { configtenantId };
1242
1112
  const queryParams = {};
1243
1113
  const pathVars = [];
1244
1114
  const bodyVars = {};
1245
1115
 
1116
+ /* HERE IS WHERE YOU VALIDATE DATA */
1117
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
1118
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantId'], null, null, null);
1119
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1120
+ return callback(null, errorObj);
1121
+ }
1122
+
1246
1123
  // loop in template. long callback arg name to avoid identifier conflicts
1247
1124
  Object.keys(queryParamsAvailable)
1248
1125
  .forEach((thisKeyInQueryParamsAvailable) => {
@@ -1700,19 +1577,25 @@ class Netbrain extends AdapterBaseCl {
1700
1577
  return callback(null, errorObj);
1701
1578
  }
1702
1579
 
1580
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1581
+ let configtenantId = tenantId;
1582
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
1583
+ if (this.allProps.authentication.tenantId) {
1584
+ configtenantId = this.allProps.authentication.tenantId;
1585
+ }
1586
+ }
1587
+ const queryParamsAvailable = {};
1588
+ const queryParams = {};
1589
+ const pathVars = [configtenantId];
1590
+ const bodyVars = {};
1591
+
1703
1592
  /* HERE IS WHERE YOU VALIDATE DATA */
1704
- if (tenantId === undefined || tenantId === null || tenantId === '') {
1593
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
1705
1594
  const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantId'], null, null, null);
1706
1595
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1707
1596
  return callback(null, errorObj);
1708
1597
  }
1709
1598
 
1710
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1711
- const queryParamsAvailable = {};
1712
- const queryParams = {};
1713
- const pathVars = [tenantId];
1714
- const bodyVars = {};
1715
-
1716
1599
  // loop in template. long callback arg name to avoid identifier conflicts
1717
1600
  Object.keys(queryParamsAvailable)
1718
1601
  .forEach((thisKeyInQueryParamsAvailable) => {
@@ -8652,11 +8535,15 @@ class Netbrain extends AdapterBaseCl {
8652
8535
  return callback(null, errorObj);
8653
8536
  }
8654
8537
 
8655
- /* HERE IS WHERE YOU VALIDATE DATA */
8656
-
8657
8538
  /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
8539
+ let configtenantId = tenantId;
8540
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
8541
+ if (this.allProps.authentication.tenantId) {
8542
+ configtenantId = this.allProps.authentication.tenantId;
8543
+ }
8544
+ }
8658
8545
  const queryParamsAvailable = {
8659
- tenantId,
8546
+ configtenantId,
8660
8547
  domainId,
8661
8548
  fromDate,
8662
8549
  toDate
@@ -8665,6 +8552,13 @@ class Netbrain extends AdapterBaseCl {
8665
8552
  const pathVars = [];
8666
8553
  const bodyVars = {};
8667
8554
 
8555
+ /* HERE IS WHERE YOU VALIDATE DATA */
8556
+ if (configtenantId === undefined || configtenantId === null || configtenantId === '') {
8557
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantId'], null, null, null);
8558
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
8559
+ return callback(null, errorObj);
8560
+ }
8561
+
8668
8562
  // loop in template. long callback arg name to avoid identifier conflicts
8669
8563
  Object.keys(queryParamsAvailable)
8670
8564
  .forEach((thisKeyInQueryParamsAvailable) => {