@itentialopensource/adapter-netbox 0.9.0 → 0.11.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 (43) hide show
  1. package/AUTH.md +9 -15
  2. package/CALLS.md +2447 -22
  3. package/CHANGELOG.md +16 -0
  4. package/CONTRIBUTING.md +1 -160
  5. package/ENHANCE.md +2 -2
  6. package/README.md +32 -23
  7. package/SYSTEMINFO.md +12 -3
  8. package/adapter.js +162 -333
  9. package/adapterBase.js +549 -879
  10. package/changelogs/changelog.md +181 -0
  11. package/metadata.json +69 -0
  12. package/package.json +24 -24
  13. package/pronghorn.json +470 -138
  14. package/propertiesSchema.json +422 -31
  15. package/refs?service=git-upload-pack +0 -0
  16. package/report/adapter-openapi.json +52536 -0
  17. package/report/adapter-openapi.yaml +37346 -0
  18. package/report/adapterInfo.json +8 -8
  19. package/report/updateReport1691508495299.json +120 -0
  20. package/report/updateReport1692202980865.json +120 -0
  21. package/report/updateReport1694466470665.json +120 -0
  22. package/sampleProperties.json +65 -4
  23. package/test/integration/adapterTestBasicGet.js +2 -4
  24. package/test/integration/adapterTestConnectivity.js +91 -42
  25. package/test/integration/adapterTestIntegration.js +130 -2
  26. package/test/unit/adapterBaseTestUnit.js +388 -313
  27. package/test/unit/adapterTestUnit.js +338 -112
  28. package/utils/adapterInfo.js +1 -1
  29. package/utils/addAuth.js +1 -1
  30. package/utils/artifactize.js +1 -1
  31. package/utils/checkMigrate.js +1 -1
  32. package/utils/entitiesToDB.js +2 -2
  33. package/utils/findPath.js +1 -1
  34. package/utils/methodDocumentor.js +260 -0
  35. package/utils/modify.js +13 -15
  36. package/utils/packModificationScript.js +1 -1
  37. package/utils/pre-commit.sh +2 -0
  38. package/utils/taskMover.js +309 -0
  39. package/utils/tbScript.js +89 -34
  40. package/utils/tbUtils.js +41 -21
  41. package/utils/testRunner.js +1 -1
  42. package/utils/troubleshootingAdapter.js +9 -6
  43. package/workflows/README.md +0 -3
package/adapter.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  /* eslint import/no-dynamic-require: warn */
4
4
  /* eslint object-curly-newline: warn */
5
+ /* eslint default-param-last: warn */
5
6
 
6
7
  // Set globals
7
8
  /* global log */
@@ -101,9 +102,6 @@ class Netbox extends AdapterBaseCl {
101
102
  let myIgnore = [
102
103
  'healthCheck',
103
104
  'iapGetAdapterWorkflowFunctions',
104
- 'iapHasAdapterEntity',
105
- 'iapVerifyAdapterCapability',
106
- 'iapUpdateAdapterEntityCache',
107
105
  'hasEntities',
108
106
  'getAuthorization'
109
107
  ];
@@ -131,29 +129,15 @@ class Netbox extends AdapterBaseCl {
131
129
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
132
130
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
133
131
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
132
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
134
133
  * @param {Callback} callback - The results of the call
135
134
  */
136
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
135
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
137
136
  const meth = 'adapter-iapUpdateAdapterConfiguration';
138
137
  const origin = `${this.id}-${meth}`;
139
138
  log.trace(origin);
140
139
 
141
- super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
142
- }
143
-
144
- /**
145
- * See if the API path provided is found in this adapter
146
- *
147
- * @function iapFindAdapterPath
148
- * @param {string} apiPath - the api path to check on
149
- * @param {Callback} callback - The results of the call
150
- */
151
- iapFindAdapterPath(apiPath, callback) {
152
- const meth = 'adapter-iapFindAdapterPath';
153
- const origin = `${this.id}-${meth}`;
154
- log.trace(origin);
155
-
156
- super.iapFindAdapterPath(apiPath, callback);
140
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
157
141
  }
158
142
 
159
143
  /**
@@ -195,7 +179,7 @@ class Netbox extends AdapterBaseCl {
195
179
  }
196
180
 
197
181
  /**
198
- * @summary Get the Adaoter Queue
182
+ * @summary Get the Adapter Queue
199
183
  *
200
184
  * @function iapGetAdapterQueue
201
185
  * @param {Callback} callback - callback function
@@ -208,6 +192,22 @@ class Netbox extends AdapterBaseCl {
208
192
  return super.iapGetAdapterQueue(callback);
209
193
  }
210
194
 
195
+ /* SCRIPT CALLS */
196
+ /**
197
+ * See if the API path provided is found in this adapter
198
+ *
199
+ * @function iapFindAdapterPath
200
+ * @param {string} apiPath - the api path to check on
201
+ * @param {Callback} callback - The results of the call
202
+ */
203
+ iapFindAdapterPath(apiPath, callback) {
204
+ const meth = 'adapter-iapFindAdapterPath';
205
+ const origin = `${this.id}-${meth}`;
206
+ log.trace(origin);
207
+
208
+ super.iapFindAdapterPath(apiPath, callback);
209
+ }
210
+
211
211
  /**
212
212
  * @summary Runs troubleshoot scripts for adapter
213
213
  *
@@ -308,176 +308,93 @@ class Netbox extends AdapterBaseCl {
308
308
  }
309
309
  }
310
310
 
311
- /* BROKER CALLS */
312
311
  /**
313
- * @summary Determines if this adapter supports the specific entity
312
+ * @summary Deactivate adapter tasks
314
313
  *
315
- * @function iapHasAdapterEntity
316
- * @param {String} entityType - the entity type to check for
317
- * @param {String/Array} entityId - the specific entity we are looking for
314
+ * @function iapDeactivateTasks
318
315
  *
319
- * @param {Callback} callback - An array of whether the adapter can has the
320
- * desired capability or an error
316
+ * @param {Array} tasks - List of tasks to deactivate
317
+ * @param {Callback} callback
321
318
  */
322
- iapHasAdapterEntity(entityType, entityId, callback) {
323
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
319
+ iapDeactivateTasks(tasks, callback) {
320
+ const meth = 'adapter-iapDeactivateTasks';
321
+ const origin = `${this.id}-${meth}`;
324
322
  log.trace(origin);
325
323
 
326
- // Make the call -
327
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
328
- return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
324
+ try {
325
+ return super.iapDeactivateTasks(tasks, callback);
326
+ } catch (err) {
327
+ log.error(`${origin}: ${err}`);
328
+ return callback(null, err);
329
+ }
329
330
  }
330
331
 
331
332
  /**
332
- * @summary Provides a way for the adapter to tell north bound integrations
333
- * whether the adapter supports type, action and specific entity
333
+ * @summary Activate adapter tasks that have previously been deactivated
334
334
  *
335
- * @function iapVerifyAdapterCapability
336
- * @param {String} entityType - the entity type to check for
337
- * @param {String} actionType - the action type to check for
338
- * @param {String/Array} entityId - the specific entity we are looking for
339
- *
340
- * @param {Callback} callback - An array of whether the adapter can has the
341
- * desired capability or an error
342
- */
343
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
344
- const meth = 'adapterBase-iapVerifyAdapterCapability';
345
- const origin = `${this.id}-${meth}`;
346
- log.trace(origin);
347
-
348
- // if caching
349
- if (this.caching) {
350
- // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
351
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
352
- if (error) {
353
- return callback(null, error);
354
- }
355
-
356
- // if the cache needs to be updated, update and try again
357
- if (results && results[0] === 'needupdate') {
358
- switch (entityType) {
359
- case 'template_entity': {
360
- // if the cache is invalid, update the cache
361
- return this.getEntities(null, null, null, null, (data, err) => {
362
- if (err) {
363
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
364
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
365
- return callback(null, errorObj);
366
- }
367
-
368
- // need to check the cache again since it has been updated
369
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
370
- if (verror) {
371
- return callback(null, verror);
372
- }
373
-
374
- return this.capabilityResults(vcapable, callback);
375
- });
376
- });
377
- }
378
- default: {
379
- // unsupported entity type
380
- const result = [false];
381
-
382
- // put false in array for all entities
383
- if (Array.isArray(entityId)) {
384
- for (let e = 1; e < entityId.length; e += 1) {
385
- result.push(false);
386
- }
387
- }
388
-
389
- return callback(result);
390
- }
391
- }
392
- }
393
-
394
- // return the results
395
- return this.capabilityResults(results, callback);
396
- });
397
- }
398
-
399
- // if no entity id
400
- if (!entityId) {
401
- // need to check the cache again since it has been updated
402
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
403
- if (verror) {
404
- return callback(null, verror);
405
- }
335
+ * @function iapActivateTasks
336
+ *
337
+ * @param {Array} tasks - List of tasks to activate
338
+ * @param {Callback} callback
339
+ */
340
+ iapActivateTasks(tasks, callback) {
341
+ const meth = 'adapter-iapActivateTasks';
342
+ const origin = `${this.id}-${meth}`;
343
+ log.trace(origin);
406
344
 
407
- return this.capabilityResults(vcapable, callback);
408
- });
345
+ try {
346
+ return super.iapActivateTasks(tasks, callback);
347
+ } catch (err) {
348
+ log.error(`${origin}: ${err}`);
349
+ return callback(null, err);
409
350
  }
351
+ }
410
352
 
411
- // if not caching
412
- switch (entityType) {
413
- case 'template_entity': {
414
- // need to get the entities to check
415
- return this.getEntities(null, null, null, null, (data, err) => {
416
- if (err) {
417
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
418
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
419
- return callback(null, errorObj);
420
- }
421
-
422
- // need to check the cache again since it has been updated
423
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
424
- if (verror) {
425
- return callback(null, verror);
426
- }
427
-
428
- // is the entity in the list?
429
- const isEntity = this.entityInList(entityId, data.response, callback);
430
- const res = [];
431
-
432
- // not found
433
- for (let i = 0; i < isEntity.length; i += 1) {
434
- if (vcapable) {
435
- res.push(isEntity[i]);
436
- } else {
437
- res.push(false);
438
- }
439
- }
440
-
441
- return callback(res);
442
- });
443
- });
444
- }
445
- default: {
446
- // unsupported entity type
447
- const result = [false];
448
-
449
- // put false in array for all entities
450
- if (Array.isArray(entityId)) {
451
- for (let e = 1; e < entityId.length; e += 1) {
452
- result.push(false);
453
- }
454
- }
353
+ /* CACHE CALLS */
354
+ /**
355
+ * @summary Populate the cache for the given entities
356
+ *
357
+ * @function iapPopulateEntityCache
358
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
359
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
360
+ *
361
+ * @returns status of the populate
362
+ */
363
+ iapPopulateEntityCache(entityTypes, callback) {
364
+ const meth = 'adapter-iapPopulateEntityCache';
365
+ const origin = `${this.id}-${meth}`;
366
+ log.trace(origin);
455
367
 
456
- return callback(result);
457
- }
368
+ try {
369
+ return super.iapPopulateEntityCache(entityTypes, callback);
370
+ } catch (err) {
371
+ log.error(`${origin}: ${err}`);
372
+ return callback(null, err);
458
373
  }
459
374
  }
460
375
 
461
376
  /**
462
- * @summary Updates the cache for all entities by call the get All entity method
463
- *
464
- * @function iapUpdateAdapterEntityCache
377
+ * @summary Retrieves data from cache for specified entity type
465
378
  *
379
+ * @function iapRetrieveEntitiesCache
380
+ * @param {String} entityType - entity of which to retrieve
381
+ * @param {Object} options - settings of which data to return and how to return it
382
+ * @param {Callback} callback - the data if it was retrieved
466
383
  */
467
- iapUpdateAdapterEntityCache() {
468
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
384
+ iapRetrieveEntitiesCache(entityType, options, callback) {
385
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
386
+ const origin = `${this.id}-${meth}`;
469
387
  log.trace(origin);
470
388
 
471
- if (this.caching) {
472
- // if the cache is invalid, update the cache
473
- this.getEntities(null, null, null, null, (data, err) => {
474
- if (err) {
475
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
476
- }
477
- });
389
+ try {
390
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
391
+ } catch (err) {
392
+ log.error(`${origin}: ${err}`);
393
+ return callback(null, err);
478
394
  }
479
395
  }
480
396
 
397
+ /* BROKER CALLS */
481
398
  /**
482
399
  * @summary Determines if this adapter supports any in a list of entities
483
400
  *
@@ -612,6 +529,38 @@ class Netbox extends AdapterBaseCl {
612
529
  }
613
530
 
614
531
  /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
532
+ /**
533
+ * Makes the requested generic call
534
+ *
535
+ * @function iapExpandedGenericAdapterRequest
536
+ * @param {Object} metadata - metadata for the call (optional).
537
+ * Can be a stringified Object.
538
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
539
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
540
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
541
+ * Can be a stringified Object.
542
+ * @param {Object} queryData - the parameters to be put on the url (optional).
543
+ * Can be a stringified Object.
544
+ * @param {Object} requestBody - the body to add to the request (optional).
545
+ * Can be a stringified Object.
546
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
547
+ * Can be a stringified Object.
548
+ * @param {getCallback} callback - a callback function to return the result (Generics)
549
+ * or the error
550
+ */
551
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
552
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
553
+ const origin = `${this.id}-${meth}`;
554
+ log.trace(origin);
555
+
556
+ try {
557
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
558
+ } catch (err) {
559
+ log.error(`${origin}: ${err}`);
560
+ return callback(null, err);
561
+ }
562
+ }
563
+
615
564
  /**
616
565
  * Makes the requested generic call
617
566
  *
@@ -632,93 +581,11 @@ class Netbox extends AdapterBaseCl {
632
581
  const origin = `${this.id}-${meth}`;
633
582
  log.trace(origin);
634
583
 
635
- if (this.suspended && this.suspendMode === 'error') {
636
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
637
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
638
- return callback(null, errorObj);
639
- }
640
-
641
- /* HERE IS WHERE YOU VALIDATE DATA */
642
- if (uriPath === undefined || uriPath === null || uriPath === '') {
643
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
644
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
645
- return callback(null, errorObj);
646
- }
647
- if (restMethod === undefined || restMethod === null || restMethod === '') {
648
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
649
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
650
- return callback(null, errorObj);
651
- }
652
-
653
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
654
- // remove any leading / and split the uripath into path variables
655
- let myPath = uriPath;
656
- while (myPath.indexOf('/') === 0) {
657
- myPath = myPath.substring(1);
658
- }
659
- const pathVars = myPath.split('/');
660
- const queryParamsAvailable = queryData;
661
- const queryParams = {};
662
- const bodyVars = requestBody;
663
-
664
- // loop in template. long callback arg name to avoid identifier conflicts
665
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
666
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
667
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
668
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
669
- }
670
- });
671
-
672
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
673
- const reqObj = {
674
- payload: bodyVars,
675
- uriPathVars: pathVars,
676
- uriQuery: queryParams,
677
- uriOptions: {}
678
- };
679
- // add headers if provided
680
- if (addlHeaders) {
681
- reqObj.addlHeaders = addlHeaders;
682
- }
683
-
684
- // determine the call and return flag
685
- let action = 'getGenerics';
686
- let returnF = true;
687
- if (restMethod.toUpperCase() === 'POST') {
688
- action = 'createGeneric';
689
- } else if (restMethod.toUpperCase() === 'PUT') {
690
- action = 'updateGeneric';
691
- } else if (restMethod.toUpperCase() === 'PATCH') {
692
- action = 'patchGeneric';
693
- } else if (restMethod.toUpperCase() === 'DELETE') {
694
- action = 'deleteGeneric';
695
- returnF = false;
696
- }
697
-
698
584
  try {
699
- // Make the call -
700
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
701
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
702
- // if we received an error or their is no response on the results
703
- // return an error
704
- if (irReturnError) {
705
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
706
- return callback(null, irReturnError);
707
- }
708
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
709
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
710
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
711
- return callback(null, errorObj);
712
- }
713
-
714
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
715
- // return the response
716
- return callback(irReturnData, null);
717
- });
718
- } catch (ex) {
719
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
720
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
721
- return callback(null, errorObj);
585
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
586
+ } catch (err) {
587
+ log.error(`${origin}: ${err}`);
588
+ return callback(null, err);
722
589
  }
723
590
  }
724
591
 
@@ -742,94 +609,56 @@ class Netbox extends AdapterBaseCl {
742
609
  const origin = `${this.id}-${meth}`;
743
610
  log.trace(origin);
744
611
 
745
- if (this.suspended && this.suspendMode === 'error') {
746
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
747
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
748
- return callback(null, errorObj);
749
- }
750
-
751
- /* HERE IS WHERE YOU VALIDATE DATA */
752
- if (uriPath === undefined || uriPath === null || uriPath === '') {
753
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
754
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
755
- return callback(null, errorObj);
756
- }
757
- if (restMethod === undefined || restMethod === null || restMethod === '') {
758
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
759
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
760
- return callback(null, errorObj);
612
+ try {
613
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
614
+ } catch (err) {
615
+ log.error(`${origin}: ${err}`);
616
+ return callback(null, err);
761
617
  }
618
+ }
762
619
 
763
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
764
- // remove any leading / and split the uripath into path variables
765
- let myPath = uriPath;
766
- while (myPath.indexOf('/') === 0) {
767
- myPath = myPath.substring(1);
768
- }
769
- const pathVars = myPath.split('/');
770
- const queryParamsAvailable = queryData;
771
- const queryParams = {};
772
- const bodyVars = requestBody;
620
+ /* INVENTORY CALLS */
621
+ /**
622
+ * @summary run the adapter lint script to return the results.
623
+ *
624
+ * @function iapRunAdapterLint
625
+ * @param {Callback} callback - callback function
626
+ */
627
+ iapRunAdapterLint(callback) {
628
+ const meth = 'adapter-iapRunAdapterLint';
629
+ const origin = `${this.id}-${meth}`;
630
+ log.trace(origin);
773
631
 
774
- // loop in template. long callback arg name to avoid identifier conflicts
775
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
776
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
777
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
778
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
779
- }
780
- });
632
+ return super.iapRunAdapterLint(callback);
633
+ }
781
634
 
782
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
783
- const reqObj = {
784
- payload: bodyVars,
785
- uriPathVars: pathVars,
786
- uriQuery: queryParams,
787
- uriOptions: {}
788
- };
789
- // add headers if provided
790
- if (addlHeaders) {
791
- reqObj.addlHeaders = addlHeaders;
792
- }
635
+ /**
636
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
637
+ * can not run integration as there can be implications with that.
638
+ *
639
+ * @function iapRunAdapterTests
640
+ * @param {Callback} callback - callback function
641
+ */
642
+ iapRunAdapterTests(callback) {
643
+ const meth = 'adapter-iapRunAdapterTests';
644
+ const origin = `${this.id}-${meth}`;
645
+ log.trace(origin);
793
646
 
794
- // determine the call and return flag
795
- let action = 'getGenericsNoBase';
796
- let returnF = true;
797
- if (restMethod.toUpperCase() === 'POST') {
798
- action = 'createGenericNoBase';
799
- } else if (restMethod.toUpperCase() === 'PUT') {
800
- action = 'updateGenericNoBase';
801
- } else if (restMethod.toUpperCase() === 'PATCH') {
802
- action = 'patchGenericNoBase';
803
- } else if (restMethod.toUpperCase() === 'DELETE') {
804
- action = 'deleteGenericNoBase';
805
- returnF = false;
806
- }
647
+ return super.iapRunAdapterTests(callback);
648
+ }
807
649
 
808
- try {
809
- // Make the call -
810
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
811
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
812
- // if we received an error or their is no response on the results
813
- // return an error
814
- if (irReturnError) {
815
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
816
- return callback(null, irReturnError);
817
- }
818
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
819
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
820
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
821
- return callback(null, errorObj);
822
- }
650
+ /**
651
+ * @summary provide inventory information abbout the adapter
652
+ *
653
+ * @function iapGetAdapterInventory
654
+ * @param {Callback} callback - callback function
655
+ */
656
+ iapGetAdapterInventory(callback) {
657
+ const meth = 'adapter-iapGetAdapterInventory';
658
+ const origin = `${this.id}-${meth}`;
659
+ log.trace(origin);
823
660
 
824
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
825
- // return the response
826
- return callback(irReturnData, null);
827
- });
828
- } catch (ex) {
829
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
830
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
831
- return callback(null, errorObj);
832
- }
661
+ return super.iapGetAdapterInventory(callback);
833
662
  }
834
663
 
835
664
  /**