@itentialopensource/adapter-netbrain 1.1.1 → 1.2.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.
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 +157 -329
  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 +981 -642
  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 -130
  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
@@ -126,9 +126,6 @@ class Netbrain extends AdapterBaseCl {
126
126
  let myIgnore = [
127
127
  'healthCheck',
128
128
  'iapGetAdapterWorkflowFunctions',
129
- 'iapHasAdapterEntity',
130
- 'iapVerifyAdapterCapability',
131
- 'iapUpdateAdapterEntityCache',
132
129
  'hasEntities',
133
130
  'getAuthorization',
134
131
  'processRequest'
@@ -157,29 +154,15 @@ class Netbrain extends AdapterBaseCl {
157
154
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
158
155
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
159
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
160
158
  * @param {Callback} callback - The results of the call
161
159
  */
162
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
160
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
163
161
  const meth = 'adapter-iapUpdateAdapterConfiguration';
164
162
  const origin = `${this.id}-${meth}`;
165
163
  log.trace(origin);
166
164
 
167
- super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
168
- }
169
-
170
- /**
171
- * See if the API path provided is found in this adapter
172
- *
173
- * @function iapFindAdapterPath
174
- * @param {string} apiPath - the api path to check on
175
- * @param {Callback} callback - The results of the call
176
- */
177
- iapFindAdapterPath(apiPath, callback) {
178
- const meth = 'adapter-iapFindAdapterPath';
179
- const origin = `${this.id}-${meth}`;
180
- log.trace(origin);
181
-
182
- super.iapFindAdapterPath(apiPath, callback);
165
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
183
166
  }
184
167
 
185
168
  /**
@@ -221,7 +204,7 @@ class Netbrain extends AdapterBaseCl {
221
204
  }
222
205
 
223
206
  /**
224
- * @summary Get the Adaoter Queue
207
+ * @summary Get the Adapter Queue
225
208
  *
226
209
  * @function iapGetAdapterQueue
227
210
  * @param {Callback} callback - callback function
@@ -234,6 +217,22 @@ class Netbrain extends AdapterBaseCl {
234
217
  return super.iapGetAdapterQueue(callback);
235
218
  }
236
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
+
237
236
  /**
238
237
  * @summary Runs troubleshoot scripts for adapter
239
238
  *
@@ -334,176 +333,93 @@ class Netbrain extends AdapterBaseCl {
334
333
  }
335
334
  }
336
335
 
337
- /* BROKER CALLS */
338
336
  /**
339
- * @summary Determines if this adapter supports the specific entity
337
+ * @summary Deactivate adapter tasks
340
338
  *
341
- * @function iapHasAdapterEntity
342
- * @param {String} entityType - the entity type to check for
343
- * @param {String/Array} entityId - the specific entity we are looking for
339
+ * @function iapDeactivateTasks
344
340
  *
345
- * @param {Callback} callback - An array of whether the adapter can has the
346
- * desired capability or an error
341
+ * @param {Array} tasks - List of tasks to deactivate
342
+ * @param {Callback} callback
347
343
  */
348
- iapHasAdapterEntity(entityType, entityId, callback) {
349
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
344
+ iapDeactivateTasks(tasks, callback) {
345
+ const meth = 'adapter-iapDeactivateTasks';
346
+ const origin = `${this.id}-${meth}`;
350
347
  log.trace(origin);
351
348
 
352
- // Make the call -
353
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
354
- 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
+ }
355
355
  }
356
356
 
357
357
  /**
358
- * @summary Provides a way for the adapter to tell north bound integrations
359
- * whether the adapter supports type, action and specific entity
358
+ * @summary Activate adapter tasks that have previously been deactivated
360
359
  *
361
- * @function iapVerifyAdapterCapability
362
- * @param {String} entityType - the entity type to check for
363
- * @param {String} actionType - the action type to check for
364
- * @param {String/Array} entityId - the specific entity we are looking for
360
+ * @function iapActivateTasks
365
361
  *
366
- * @param {Callback} callback - An array of whether the adapter can has the
367
- * desired capability or an error
362
+ * @param {Array} tasks - List of tasks to activate
363
+ * @param {Callback} callback
368
364
  */
369
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
370
- const meth = 'adapterBase-iapVerifyAdapterCapability';
365
+ iapActivateTasks(tasks, callback) {
366
+ const meth = 'adapter-iapActivateTasks';
371
367
  const origin = `${this.id}-${meth}`;
372
368
  log.trace(origin);
373
369
 
374
- // if caching
375
- if (this.caching) {
376
- // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
377
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
378
- if (error) {
379
- return callback(null, error);
380
- }
381
-
382
- // if the cache needs to be updated, update and try again
383
- if (results && results[0] === 'needupdate') {
384
- switch (entityType) {
385
- case 'template_entity': {
386
- // if the cache is invalid, update the cache
387
- return this.getEntities(null, null, null, null, (data, err) => {
388
- if (err) {
389
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
390
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
391
- return callback(null, errorObj);
392
- }
393
-
394
- // need to check the cache again since it has been updated
395
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
396
- if (verror) {
397
- return callback(null, verror);
398
- }
399
-
400
- return this.capabilityResults(vcapable, callback);
401
- });
402
- });
403
- }
404
- default: {
405
- // unsupported entity type
406
- const result = [false];
407
-
408
- // put false in array for all entities
409
- if (Array.isArray(entityId)) {
410
- for (let e = 1; e < entityId.length; e += 1) {
411
- result.push(false);
412
- }
413
- }
414
-
415
- return callback(result);
416
- }
417
- }
418
- }
419
-
420
- // return the results
421
- return this.capabilityResults(results, callback);
422
- });
423
- }
424
-
425
- // if no entity id
426
- if (!entityId) {
427
- // need to check the cache again since it has been updated
428
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
429
- if (verror) {
430
- return callback(null, verror);
431
- }
432
-
433
- return this.capabilityResults(vcapable, callback);
434
- });
370
+ try {
371
+ return super.iapActivateTasks(tasks, callback);
372
+ } catch (err) {
373
+ log.error(`${origin}: ${err}`);
374
+ return callback(null, err);
435
375
  }
376
+ }
436
377
 
437
- // if not caching
438
- switch (entityType) {
439
- case 'template_entity': {
440
- // need to get the entities to check
441
- return this.getEntities(null, null, null, null, (data, err) => {
442
- if (err) {
443
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
444
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
445
- return callback(null, errorObj);
446
- }
447
-
448
- // need to check the cache again since it has been updated
449
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
450
- if (verror) {
451
- return callback(null, verror);
452
- }
453
-
454
- // is the entity in the list?
455
- const isEntity = this.entityInList(entityId, data.response, callback);
456
- const res = [];
457
-
458
- // not found
459
- for (let i = 0; i < isEntity.length; i += 1) {
460
- if (vcapable) {
461
- res.push(isEntity[i]);
462
- } else {
463
- res.push(false);
464
- }
465
- }
466
-
467
- return callback(res);
468
- });
469
- });
470
- }
471
- default: {
472
- // unsupported entity type
473
- const result = [false];
474
-
475
- // put false in array for all entities
476
- if (Array.isArray(entityId)) {
477
- for (let e = 1; e < entityId.length; e += 1) {
478
- result.push(false);
479
- }
480
- }
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);
481
392
 
482
- return callback(result);
483
- }
393
+ try {
394
+ return super.iapPopulateEntityCache(entityTypes, callback);
395
+ } catch (err) {
396
+ log.error(`${origin}: ${err}`);
397
+ return callback(null, err);
484
398
  }
485
399
  }
486
400
 
487
401
  /**
488
- * @summary Updates the cache for all entities by call the get All entity method
489
- *
490
- * @function iapUpdateAdapterEntityCache
402
+ * @summary Retrieves data from cache for specified entity type
491
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
492
408
  */
493
- iapUpdateAdapterEntityCache() {
494
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
409
+ iapRetrieveEntitiesCache(entityType, options, callback) {
410
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
411
+ const origin = `${this.id}-${meth}`;
495
412
  log.trace(origin);
496
413
 
497
- if (this.caching) {
498
- // if the cache is invalid, update the cache
499
- this.getEntities(null, null, null, null, (data, err) => {
500
- if (err) {
501
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
502
- }
503
- });
414
+ try {
415
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
416
+ } catch (err) {
417
+ log.error(`${origin}: ${err}`);
418
+ return callback(null, err);
504
419
  }
505
420
  }
506
421
 
422
+ /* BROKER CALLS */
507
423
  /**
508
424
  * @summary Determines if this adapter supports any in a list of entities
509
425
  *
@@ -638,6 +554,38 @@ class Netbrain extends AdapterBaseCl {
638
554
  }
639
555
 
640
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
+
641
589
  /**
642
590
  * Makes the requested generic call
643
591
  *
@@ -658,93 +606,11 @@ class Netbrain extends AdapterBaseCl {
658
606
  const origin = `${this.id}-${meth}`;
659
607
  log.trace(origin);
660
608
 
661
- if (this.suspended && this.suspendMode === 'error') {
662
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
663
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
664
- return callback(null, errorObj);
665
- }
666
-
667
- /* HERE IS WHERE YOU VALIDATE DATA */
668
- if (uriPath === undefined || uriPath === null || uriPath === '') {
669
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
670
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
671
- return callback(null, errorObj);
672
- }
673
- if (restMethod === undefined || restMethod === null || restMethod === '') {
674
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
675
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
676
- return callback(null, errorObj);
677
- }
678
-
679
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
680
- // remove any leading / and split the uripath into path variables
681
- let myPath = uriPath;
682
- while (myPath.indexOf('/') === 0) {
683
- myPath = myPath.substring(1);
684
- }
685
- const pathVars = myPath.split('/');
686
- const queryParamsAvailable = queryData;
687
- const queryParams = {};
688
- const bodyVars = requestBody;
689
-
690
- // loop in template. long callback arg name to avoid identifier conflicts
691
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
692
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
693
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
694
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
695
- }
696
- });
697
-
698
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
699
- const reqObj = {
700
- payload: bodyVars,
701
- uriPathVars: pathVars,
702
- uriQuery: queryParams,
703
- uriOptions: {}
704
- };
705
- // add headers if provided
706
- if (addlHeaders) {
707
- reqObj.addlHeaders = addlHeaders;
708
- }
709
-
710
- // determine the call and return flag
711
- let action = 'getGenerics';
712
- let returnF = true;
713
- if (restMethod.toUpperCase() === 'POST') {
714
- action = 'createGeneric';
715
- } else if (restMethod.toUpperCase() === 'PUT') {
716
- action = 'updateGeneric';
717
- } else if (restMethod.toUpperCase() === 'PATCH') {
718
- action = 'patchGeneric';
719
- } else if (restMethod.toUpperCase() === 'DELETE') {
720
- action = 'deleteGeneric';
721
- returnF = false;
722
- }
723
-
724
609
  try {
725
- // Make the call -
726
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
727
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
728
- // if we received an error or their is no response on the results
729
- // return an error
730
- if (irReturnError) {
731
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
732
- return callback(null, irReturnError);
733
- }
734
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
735
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
736
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
737
- return callback(null, errorObj);
738
- }
739
-
740
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
741
- // return the response
742
- return callback(irReturnData, null);
743
- });
744
- } catch (ex) {
745
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
746
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
747
- 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);
748
614
  }
749
615
  }
750
616
 
@@ -768,94 +634,56 @@ class Netbrain extends AdapterBaseCl {
768
634
  const origin = `${this.id}-${meth}`;
769
635
  log.trace(origin);
770
636
 
771
- if (this.suspended && this.suspendMode === 'error') {
772
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
773
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
774
- return callback(null, errorObj);
775
- }
776
-
777
- /* HERE IS WHERE YOU VALIDATE DATA */
778
- if (uriPath === undefined || uriPath === null || uriPath === '') {
779
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
780
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
781
- return callback(null, errorObj);
782
- }
783
- if (restMethod === undefined || restMethod === null || restMethod === '') {
784
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
785
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
786
- 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);
787
642
  }
643
+ }
788
644
 
789
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
790
- // remove any leading / and split the uripath into path variables
791
- let myPath = uriPath;
792
- while (myPath.indexOf('/') === 0) {
793
- myPath = myPath.substring(1);
794
- }
795
- const pathVars = myPath.split('/');
796
- const queryParamsAvailable = queryData;
797
- const queryParams = {};
798
- 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);
799
656
 
800
- // loop in template. long callback arg name to avoid identifier conflicts
801
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
802
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
803
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
804
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
805
- }
806
- });
657
+ return super.iapRunAdapterLint(callback);
658
+ }
807
659
 
808
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
809
- const reqObj = {
810
- payload: bodyVars,
811
- uriPathVars: pathVars,
812
- uriQuery: queryParams,
813
- uriOptions: {}
814
- };
815
- // add headers if provided
816
- if (addlHeaders) {
817
- reqObj.addlHeaders = addlHeaders;
818
- }
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);
819
671
 
820
- // determine the call and return flag
821
- let action = 'getGenericsNoBase';
822
- let returnF = true;
823
- if (restMethod.toUpperCase() === 'POST') {
824
- action = 'createGenericNoBase';
825
- } else if (restMethod.toUpperCase() === 'PUT') {
826
- action = 'updateGenericNoBase';
827
- } else if (restMethod.toUpperCase() === 'PATCH') {
828
- action = 'patchGenericNoBase';
829
- } else if (restMethod.toUpperCase() === 'DELETE') {
830
- action = 'deleteGenericNoBase';
831
- returnF = false;
832
- }
672
+ return super.iapRunAdapterTests(callback);
673
+ }
833
674
 
834
- try {
835
- // Make the call -
836
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
837
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
838
- // if we received an error or their is no response on the results
839
- // return an error
840
- if (irReturnError) {
841
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
842
- return callback(null, irReturnError);
843
- }
844
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
845
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
846
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
847
- return callback(null, errorObj);
848
- }
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);
849
685
 
850
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
851
- // return the response
852
- return callback(irReturnData, null);
853
- });
854
- } catch (ex) {
855
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
856
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
857
- return callback(null, errorObj);
858
- }
686
+ return super.iapGetAdapterInventory(callback);
859
687
  }
860
688
 
861
689
  /**