@itentialopensource/adapter-zscaler 0.7.0 → 0.8.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 +342 -0
  2. package/CHANGELOG.md +3 -112
  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 +118 -0
  9. package/metadata.json +49 -0
  10. package/package.json +24 -25
  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 +1828 -0
  15. package/report/adapter-openapi.yaml +1462 -0
  16. package/report/adapterInfo.json +8 -8
  17. package/report/updateReport1691508819418.json +120 -0
  18. package/report/updateReport1692203278243.json +120 -0
  19. package/report/updateReport1694468959859.json +120 -0
  20. package/report/updateReport1698422816279.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 -112
  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
@@ -88,9 +88,6 @@ class Zscaler extends AdapterBaseCl {
88
88
  let myIgnore = [
89
89
  'healthCheck',
90
90
  'iapGetAdapterWorkflowFunctions',
91
- 'iapHasAdapterEntity',
92
- 'iapVerifyAdapterCapability',
93
- 'iapUpdateAdapterEntityCache',
94
91
  'hasEntities',
95
92
  'getAuthorization',
96
93
  'getObfuscatedKey'
@@ -119,29 +116,15 @@ class Zscaler extends AdapterBaseCl {
119
116
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
120
117
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
121
118
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
119
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
122
120
  * @param {Callback} callback - The results of the call
123
121
  */
124
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
122
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
125
123
  const meth = 'adapter-iapUpdateAdapterConfiguration';
126
124
  const origin = `${this.id}-${meth}`;
127
125
  log.trace(origin);
128
126
 
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);
127
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
145
128
  }
146
129
 
147
130
  /**
@@ -183,7 +166,7 @@ class Zscaler extends AdapterBaseCl {
183
166
  }
184
167
 
185
168
  /**
186
- * @summary Get the Adaoter Queue
169
+ * @summary Get the Adapter Queue
187
170
  *
188
171
  * @function iapGetAdapterQueue
189
172
  * @param {Callback} callback - callback function
@@ -196,6 +179,22 @@ class Zscaler extends AdapterBaseCl {
196
179
  return super.iapGetAdapterQueue(callback);
197
180
  }
198
181
 
182
+ /* SCRIPT CALLS */
183
+ /**
184
+ * See if the API path provided is found in this adapter
185
+ *
186
+ * @function iapFindAdapterPath
187
+ * @param {string} apiPath - the api path to check on
188
+ * @param {Callback} callback - The results of the call
189
+ */
190
+ iapFindAdapterPath(apiPath, callback) {
191
+ const meth = 'adapter-iapFindAdapterPath';
192
+ const origin = `${this.id}-${meth}`;
193
+ log.trace(origin);
194
+
195
+ super.iapFindAdapterPath(apiPath, callback);
196
+ }
197
+
199
198
  /**
200
199
  * @summary Runs troubleshoot scripts for adapter
201
200
  *
@@ -296,176 +295,93 @@ class Zscaler extends AdapterBaseCl {
296
295
  }
297
296
  }
298
297
 
299
- /* BROKER CALLS */
300
298
  /**
301
- * @summary Determines if this adapter supports the specific entity
299
+ * @summary Deactivate adapter tasks
302
300
  *
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
301
+ * @function iapDeactivateTasks
306
302
  *
307
- * @param {Callback} callback - An array of whether the adapter can has the
308
- * desired capability or an error
303
+ * @param {Array} tasks - List of tasks to deactivate
304
+ * @param {Callback} callback
309
305
  */
310
- iapHasAdapterEntity(entityType, entityId, callback) {
311
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
306
+ iapDeactivateTasks(tasks, callback) {
307
+ const meth = 'adapter-iapDeactivateTasks';
308
+ const origin = `${this.id}-${meth}`;
312
309
  log.trace(origin);
313
310
 
314
- // Make the call -
315
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
316
- return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
311
+ try {
312
+ return super.iapDeactivateTasks(tasks, callback);
313
+ } catch (err) {
314
+ log.error(`${origin}: ${err}`);
315
+ return callback(null, err);
316
+ }
317
317
  }
318
318
 
319
319
  /**
320
- * @summary Provides a way for the adapter to tell north bound integrations
321
- * whether the adapter supports type, action and specific entity
320
+ * @summary Activate adapter tasks that have previously been deactivated
322
321
  *
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
322
+ * @function iapActivateTasks
327
323
  *
328
- * @param {Callback} callback - An array of whether the adapter can has the
329
- * desired capability or an error
324
+ * @param {Array} tasks - List of tasks to activate
325
+ * @param {Callback} callback
330
326
  */
331
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
332
- const meth = 'adapterBase-iapVerifyAdapterCapability';
327
+ iapActivateTasks(tasks, callback) {
328
+ const meth = 'adapter-iapActivateTasks';
333
329
  const origin = `${this.id}-${meth}`;
334
330
  log.trace(origin);
335
331
 
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
- });
332
+ try {
333
+ return super.iapActivateTasks(tasks, callback);
334
+ } catch (err) {
335
+ log.error(`${origin}: ${err}`);
336
+ return callback(null, err);
397
337
  }
338
+ }
398
339
 
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
- }
340
+ /* CACHE CALLS */
341
+ /**
342
+ * @summary Populate the cache for the given entities
343
+ *
344
+ * @function iapPopulateEntityCache
345
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
346
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
347
+ *
348
+ * @returns status of the populate
349
+ */
350
+ iapPopulateEntityCache(entityTypes, callback) {
351
+ const meth = 'adapter-iapPopulateEntityCache';
352
+ const origin = `${this.id}-${meth}`;
353
+ log.trace(origin);
443
354
 
444
- return callback(result);
445
- }
355
+ try {
356
+ return super.iapPopulateEntityCache(entityTypes, callback);
357
+ } catch (err) {
358
+ log.error(`${origin}: ${err}`);
359
+ return callback(null, err);
446
360
  }
447
361
  }
448
362
 
449
363
  /**
450
- * @summary Updates the cache for all entities by call the get All entity method
451
- *
452
- * @function iapUpdateAdapterEntityCache
364
+ * @summary Retrieves data from cache for specified entity type
453
365
  *
366
+ * @function iapRetrieveEntitiesCache
367
+ * @param {String} entityType - entity of which to retrieve
368
+ * @param {Object} options - settings of which data to return and how to return it
369
+ * @param {Callback} callback - the data if it was retrieved
454
370
  */
455
- iapUpdateAdapterEntityCache() {
456
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
371
+ iapRetrieveEntitiesCache(entityType, options, callback) {
372
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
373
+ const origin = `${this.id}-${meth}`;
457
374
  log.trace(origin);
458
375
 
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
- });
376
+ try {
377
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
378
+ } catch (err) {
379
+ log.error(`${origin}: ${err}`);
380
+ return callback(null, err);
466
381
  }
467
382
  }
468
383
 
384
+ /* BROKER CALLS */
469
385
  /**
470
386
  * @summary Determines if this adapter supports any in a list of entities
471
387
  *
@@ -600,6 +516,38 @@ class Zscaler extends AdapterBaseCl {
600
516
  }
601
517
 
602
518
  /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
519
+ /**
520
+ * Makes the requested generic call
521
+ *
522
+ * @function iapExpandedGenericAdapterRequest
523
+ * @param {Object} metadata - metadata for the call (optional).
524
+ * Can be a stringified Object.
525
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
526
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
527
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
528
+ * Can be a stringified Object.
529
+ * @param {Object} queryData - the parameters to be put on the url (optional).
530
+ * Can be a stringified Object.
531
+ * @param {Object} requestBody - the body to add to the request (optional).
532
+ * Can be a stringified Object.
533
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
534
+ * Can be a stringified Object.
535
+ * @param {getCallback} callback - a callback function to return the result (Generics)
536
+ * or the error
537
+ */
538
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
539
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
540
+ const origin = `${this.id}-${meth}`;
541
+ log.trace(origin);
542
+
543
+ try {
544
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
545
+ } catch (err) {
546
+ log.error(`${origin}: ${err}`);
547
+ return callback(null, err);
548
+ }
549
+ }
550
+
603
551
  /**
604
552
  * Makes the requested generic call
605
553
  *
@@ -620,93 +568,11 @@ class Zscaler extends AdapterBaseCl {
620
568
  const origin = `${this.id}-${meth}`;
621
569
  log.trace(origin);
622
570
 
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
571
  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);
572
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
573
+ } catch (err) {
574
+ log.error(`${origin}: ${err}`);
575
+ return callback(null, err);
710
576
  }
711
577
  }
712
578
 
@@ -730,94 +596,56 @@ class Zscaler extends AdapterBaseCl {
730
596
  const origin = `${this.id}-${meth}`;
731
597
  log.trace(origin);
732
598
 
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);
599
+ try {
600
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
601
+ } catch (err) {
602
+ log.error(`${origin}: ${err}`);
603
+ return callback(null, err);
749
604
  }
605
+ }
750
606
 
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;
607
+ /* INVENTORY CALLS */
608
+ /**
609
+ * @summary run the adapter lint script to return the results.
610
+ *
611
+ * @function iapRunAdapterLint
612
+ * @param {Callback} callback - callback function
613
+ */
614
+ iapRunAdapterLint(callback) {
615
+ const meth = 'adapter-iapRunAdapterLint';
616
+ const origin = `${this.id}-${meth}`;
617
+ log.trace(origin);
761
618
 
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
- });
619
+ return super.iapRunAdapterLint(callback);
620
+ }
769
621
 
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
- }
622
+ /**
623
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
624
+ * can not run integration as there can be implications with that.
625
+ *
626
+ * @function iapRunAdapterTests
627
+ * @param {Callback} callback - callback function
628
+ */
629
+ iapRunAdapterTests(callback) {
630
+ const meth = 'adapter-iapRunAdapterTests';
631
+ const origin = `${this.id}-${meth}`;
632
+ log.trace(origin);
781
633
 
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
- }
634
+ return super.iapRunAdapterTests(callback);
635
+ }
795
636
 
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
- }
637
+ /**
638
+ * @summary provide inventory information abbout the adapter
639
+ *
640
+ * @function iapGetAdapterInventory
641
+ * @param {Callback} callback - callback function
642
+ */
643
+ iapGetAdapterInventory(callback) {
644
+ const meth = 'adapter-iapGetAdapterInventory';
645
+ const origin = `${this.id}-${meth}`;
646
+ log.trace(origin);
811
647
 
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
- }
648
+ return super.iapGetAdapterInventory(callback);
821
649
  }
822
650
 
823
651
  /**