@itentialopensource/adapter-openstack_neutron 3.0.3 → 3.1.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/AUTH.md +9 -9
  2. package/CALLS.md +364 -328
  3. package/CHANGELOG.md +8 -0
  4. package/CONTRIBUTING.md +1 -160
  5. package/ENHANCE.md +2 -2
  6. package/README.md +32 -23
  7. package/adapter.js +174 -373
  8. package/adapterBase.js +517 -875
  9. package/changelogs/CHANGELOG.md +58 -0
  10. package/metadata.json +56 -0
  11. package/package.json +24 -26
  12. package/pronghorn.json +474 -142
  13. package/propertiesSchema.json +431 -34
  14. package/refs?service=git-upload-pack +0 -0
  15. package/report/adapter-openapi.json +14594 -0
  16. package/report/adapter-openapi.yaml +12289 -0
  17. package/report/adapterInfo.json +8 -8
  18. package/report/updateReport1691507382282.json +120 -0
  19. package/report/updateReport1692202417483.json +120 -0
  20. package/report/updateReport1694460523394.json +120 -0
  21. package/report/updateReport1698420447048.json +120 -0
  22. package/sampleProperties.json +58 -3
  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 +389 -317
  27. package/test/unit/adapterTestUnit.js +303 -114
  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 +71 -23
  35. package/utils/modify.js +13 -15
  36. package/utils/packModificationScript.js +1 -1
  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
@@ -121,10 +121,8 @@ class OpenstackNeutron extends AdapterBaseCl {
121
121
  let myIgnore = [
122
122
  'healthCheck',
123
123
  'iapGetAdapterWorkflowFunctions',
124
- 'iapHasAdapterEntity',
125
- 'iapVerifyAdapterCapability',
126
- 'iapUpdateAdapterEntityCache',
127
- 'hasEntities'
124
+ 'hasEntities',
125
+ 'getAuthorization'
128
126
  ];
129
127
  if (!inIgnore && Array.isArray(inIgnore)) {
130
128
  myIgnore = inIgnore;
@@ -150,29 +148,15 @@ class OpenstackNeutron extends AdapterBaseCl {
150
148
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
151
149
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
152
150
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
151
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
153
152
  * @param {Callback} callback - The results of the call
154
153
  */
155
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
154
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
156
155
  const meth = 'adapter-iapUpdateAdapterConfiguration';
157
156
  const origin = `${this.id}-${meth}`;
158
157
  log.trace(origin);
159
158
 
160
- super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
161
- }
162
-
163
- /**
164
- * See if the API path provided is found in this adapter
165
- *
166
- * @function iapFindAdapterPath
167
- * @param {string} apiPath - the api path to check on
168
- * @param {Callback} callback - The results of the call
169
- */
170
- iapFindAdapterPath(apiPath, callback) {
171
- const meth = 'adapter-iapFindAdapterPath';
172
- const origin = `${this.id}-${meth}`;
173
- log.trace(origin);
174
-
175
- super.iapFindAdapterPath(apiPath, callback);
159
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
176
160
  }
177
161
 
178
162
  /**
@@ -214,7 +198,7 @@ class OpenstackNeutron extends AdapterBaseCl {
214
198
  }
215
199
 
216
200
  /**
217
- * @summary Get the Adaoter Queue
201
+ * @summary Get the Adapter Queue
218
202
  *
219
203
  * @function iapGetAdapterQueue
220
204
  * @param {Callback} callback - callback function
@@ -227,6 +211,22 @@ class OpenstackNeutron extends AdapterBaseCl {
227
211
  return super.iapGetAdapterQueue(callback);
228
212
  }
229
213
 
214
+ /* SCRIPT CALLS */
215
+ /**
216
+ * See if the API path provided is found in this adapter
217
+ *
218
+ * @function iapFindAdapterPath
219
+ * @param {string} apiPath - the api path to check on
220
+ * @param {Callback} callback - The results of the call
221
+ */
222
+ iapFindAdapterPath(apiPath, callback) {
223
+ const meth = 'adapter-iapFindAdapterPath';
224
+ const origin = `${this.id}-${meth}`;
225
+ log.trace(origin);
226
+
227
+ super.iapFindAdapterPath(apiPath, callback);
228
+ }
229
+
230
230
  /**
231
231
  * @summary Runs troubleshoot scripts for adapter
232
232
  *
@@ -327,176 +327,93 @@ class OpenstackNeutron extends AdapterBaseCl {
327
327
  }
328
328
  }
329
329
 
330
- /* BROKER CALLS */
331
330
  /**
332
- * @summary Determines if this adapter supports the specific entity
331
+ * @summary Deactivate adapter tasks
333
332
  *
334
- * @function iapHasAdapterEntity
335
- * @param {String} entityType - the entity type to check for
336
- * @param {String/Array} entityId - the specific entity we are looking for
333
+ * @function iapDeactivateTasks
337
334
  *
338
- * @param {Callback} callback - An array of whether the adapter can has the
339
- * desired capability or an error
335
+ * @param {Array} tasks - List of tasks to deactivate
336
+ * @param {Callback} callback
340
337
  */
341
- iapHasAdapterEntity(entityType, entityId, callback) {
342
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
338
+ iapDeactivateTasks(tasks, callback) {
339
+ const meth = 'adapter-iapDeactivateTasks';
340
+ const origin = `${this.id}-${meth}`;
343
341
  log.trace(origin);
344
342
 
345
- // Make the call -
346
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
347
- return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
343
+ try {
344
+ return super.iapDeactivateTasks(tasks, callback);
345
+ } catch (err) {
346
+ log.error(`${origin}: ${err}`);
347
+ return callback(null, err);
348
+ }
348
349
  }
349
350
 
350
351
  /**
351
- * @summary Provides a way for the adapter to tell north bound integrations
352
- * whether the adapter supports type, action and specific entity
352
+ * @summary Activate adapter tasks that have previously been deactivated
353
353
  *
354
- * @function iapVerifyAdapterCapability
355
- * @param {String} entityType - the entity type to check for
356
- * @param {String} actionType - the action type to check for
357
- * @param {String/Array} entityId - the specific entity we are looking for
358
- *
359
- * @param {Callback} callback - An array of whether the adapter can has the
360
- * desired capability or an error
361
- */
362
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
363
- const meth = 'adapterBase-iapVerifyAdapterCapability';
364
- const origin = `${this.id}-${meth}`;
365
- log.trace(origin);
366
-
367
- // if caching
368
- if (this.caching) {
369
- // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
370
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
371
- if (error) {
372
- return callback(null, error);
373
- }
374
-
375
- // if the cache needs to be updated, update and try again
376
- if (results && results[0] === 'needupdate') {
377
- switch (entityType) {
378
- case 'template_entity': {
379
- // if the cache is invalid, update the cache
380
- return this.getEntities(null, null, null, null, (data, err) => {
381
- if (err) {
382
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
383
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
384
- return callback(null, errorObj);
385
- }
386
-
387
- // need to check the cache again since it has been updated
388
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
389
- if (verror) {
390
- return callback(null, verror);
391
- }
392
-
393
- return this.capabilityResults(vcapable, callback);
394
- });
395
- });
396
- }
397
- default: {
398
- // unsupported entity type
399
- const result = [false];
400
-
401
- // put false in array for all entities
402
- if (Array.isArray(entityId)) {
403
- for (let e = 1; e < entityId.length; e += 1) {
404
- result.push(false);
405
- }
406
- }
407
-
408
- return callback(result);
409
- }
410
- }
411
- }
412
-
413
- // return the results
414
- return this.capabilityResults(results, callback);
415
- });
416
- }
417
-
418
- // if no entity id
419
- if (!entityId) {
420
- // need to check the cache again since it has been updated
421
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
422
- if (verror) {
423
- return callback(null, verror);
424
- }
354
+ * @function iapActivateTasks
355
+ *
356
+ * @param {Array} tasks - List of tasks to activate
357
+ * @param {Callback} callback
358
+ */
359
+ iapActivateTasks(tasks, callback) {
360
+ const meth = 'adapter-iapActivateTasks';
361
+ const origin = `${this.id}-${meth}`;
362
+ log.trace(origin);
425
363
 
426
- return this.capabilityResults(vcapable, callback);
427
- });
364
+ try {
365
+ return super.iapActivateTasks(tasks, callback);
366
+ } catch (err) {
367
+ log.error(`${origin}: ${err}`);
368
+ return callback(null, err);
428
369
  }
370
+ }
429
371
 
430
- // if not caching
431
- switch (entityType) {
432
- case 'template_entity': {
433
- // need to get the entities to check
434
- return this.getEntities(null, null, null, null, (data, err) => {
435
- if (err) {
436
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
437
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
438
- return callback(null, errorObj);
439
- }
440
-
441
- // need to check the cache again since it has been updated
442
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
443
- if (verror) {
444
- return callback(null, verror);
445
- }
446
-
447
- // is the entity in the list?
448
- const isEntity = this.entityInList(entityId, data.response, callback);
449
- const res = [];
450
-
451
- // not found
452
- for (let i = 0; i < isEntity.length; i += 1) {
453
- if (vcapable) {
454
- res.push(isEntity[i]);
455
- } else {
456
- res.push(false);
457
- }
458
- }
459
-
460
- return callback(res);
461
- });
462
- });
463
- }
464
- default: {
465
- // unsupported entity type
466
- const result = [false];
467
-
468
- // put false in array for all entities
469
- if (Array.isArray(entityId)) {
470
- for (let e = 1; e < entityId.length; e += 1) {
471
- result.push(false);
472
- }
473
- }
372
+ /* CACHE CALLS */
373
+ /**
374
+ * @summary Populate the cache for the given entities
375
+ *
376
+ * @function iapPopulateEntityCache
377
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
378
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
379
+ *
380
+ * @returns status of the populate
381
+ */
382
+ iapPopulateEntityCache(entityTypes, callback) {
383
+ const meth = 'adapter-iapPopulateEntityCache';
384
+ const origin = `${this.id}-${meth}`;
385
+ log.trace(origin);
474
386
 
475
- return callback(result);
476
- }
387
+ try {
388
+ return super.iapPopulateEntityCache(entityTypes, callback);
389
+ } catch (err) {
390
+ log.error(`${origin}: ${err}`);
391
+ return callback(null, err);
477
392
  }
478
393
  }
479
394
 
480
395
  /**
481
- * @summary Updates the cache for all entities by call the get All entity method
482
- *
483
- * @function iapUpdateAdapterEntityCache
396
+ * @summary Retrieves data from cache for specified entity type
484
397
  *
398
+ * @function iapRetrieveEntitiesCache
399
+ * @param {String} entityType - entity of which to retrieve
400
+ * @param {Object} options - settings of which data to return and how to return it
401
+ * @param {Callback} callback - the data if it was retrieved
485
402
  */
486
- iapUpdateAdapterEntityCache() {
487
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
403
+ iapRetrieveEntitiesCache(entityType, options, callback) {
404
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
405
+ const origin = `${this.id}-${meth}`;
488
406
  log.trace(origin);
489
407
 
490
- if (this.caching) {
491
- // if the cache is invalid, update the cache
492
- this.getEntities(null, null, null, null, (data, err) => {
493
- if (err) {
494
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
495
- }
496
- });
408
+ try {
409
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
410
+ } catch (err) {
411
+ log.error(`${origin}: ${err}`);
412
+ return callback(null, err);
497
413
  }
498
414
  }
499
415
 
416
+ /* BROKER CALLS */
500
417
  /**
501
418
  * @summary Determines if this adapter supports any in a list of entities
502
419
  *
@@ -634,9 +551,13 @@ class OpenstackNeutron extends AdapterBaseCl {
634
551
  /**
635
552
  * Makes the requested generic call
636
553
  *
637
- * @function genericAdapterRequest
638
- * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
639
- * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
554
+ * @function iapExpandedGenericAdapterRequest
555
+ * @param {Object} metadata - metadata for the call (optional).
556
+ * Can be a stringified Object.
557
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
558
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
559
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
560
+ * Can be a stringified Object.
640
561
  * @param {Object} queryData - the parameters to be put on the url (optional).
641
562
  * Can be a stringified Object.
642
563
  * @param {Object} requestBody - the body to add to the request (optional).
@@ -646,75 +567,17 @@ class OpenstackNeutron extends AdapterBaseCl {
646
567
  * @param {getCallback} callback - a callback function to return the result (Generics)
647
568
  * or the error
648
569
  */
649
- genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
650
- const meth = 'adapter-genericAdapterRequest';
570
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
571
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
651
572
  const origin = `${this.id}-${meth}`;
652
573
  log.trace(origin);
653
574
 
654
- if (this.suspended && this.suspendMode === 'error') {
655
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
656
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
657
- return callback(null, errorObj);
658
- }
659
-
660
- /* HERE IS WHERE YOU VALIDATE DATA */
661
- if (uriPath === undefined || uriPath === null || uriPath === '') {
662
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
663
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
664
- return callback(null, errorObj);
665
- }
666
- if (restMethod === undefined || restMethod === null || restMethod === '') {
667
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
668
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
669
- return callback(null, errorObj);
670
- }
671
-
672
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
673
- // remove any leading / and split the uripath into path variables
674
- let myPath = uriPath;
675
- while (myPath.indexOf('/') === 0) {
676
- myPath = myPath.substring(1);
677
- }
678
- const pathVars = myPath.split('/');
679
- const queryParamsAvailable = queryData;
680
- const queryParams = {};
681
- const bodyVars = requestBody;
682
-
683
- // loop in template. long callback arg name to avoid identifier conflicts
684
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
685
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
686
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
687
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
688
- }
689
- });
690
-
691
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
692
- const reqObj = {
693
- payload: bodyVars,
694
- uriPathVars: pathVars,
695
- uriQuery: queryParams,
696
- uriOptions: {}
697
- };
698
- // add headers if provided
699
- if (addlHeaders) {
700
- reqObj.addlHeaders = addlHeaders;
701
- }
702
-
703
- // determine the call and return flag
704
- let action = 'getGenerics';
705
- let returnF = true;
706
- if (restMethod.toUpperCase() === 'POST') {
707
- action = 'createGeneric';
708
- } else if (restMethod.toUpperCase() === 'PUT') {
709
- action = 'updateGeneric';
710
- } else if (restMethod.toUpperCase() === 'PATCH') {
711
- action = 'patchGeneric';
712
- } else if (restMethod.toUpperCase() === 'DELETE') {
713
- action = 'deleteGeneric';
714
- returnF = false;
575
+ if (metadata === undefined || metadata === null || metadata === '') {
576
+ // eslint-disable-next-line no-param-reassign
577
+ metadata = {};
715
578
  }
716
-
717
- reqObj.authData = {
579
+ // eslint-disable-next-line no-param-reassign
580
+ metadata.authData = {
718
581
  auth: {
719
582
  identity: {
720
583
  methods: [
@@ -741,7 +604,8 @@ class OpenstackNeutron extends AdapterBaseCl {
741
604
  }
742
605
  };
743
606
 
744
- reqObj.callProperties = {
607
+ // eslint-disable-next-line no-param-reassign
608
+ metadata.callProperties = {
745
609
  ssl: {
746
610
  enabled: true,
747
611
  accept_invalid_cert: true
@@ -749,29 +613,38 @@ class OpenstackNeutron extends AdapterBaseCl {
749
613
  };
750
614
 
751
615
  try {
752
- // Make the call -
753
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
754
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
755
- // if we received an error or their is no response on the results
756
- // return an error
757
- if (irReturnError) {
758
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
759
- return callback(null, irReturnError);
760
- }
761
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
762
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
763
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
764
- return callback(null, errorObj);
765
- }
616
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
617
+ } catch (err) {
618
+ log.error(`${origin}: ${err}`);
619
+ return callback(null, err);
620
+ }
621
+ }
766
622
 
767
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
768
- // return the response
769
- return callback(irReturnData, null);
770
- });
771
- } catch (ex) {
772
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
773
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
774
- return callback(null, errorObj);
623
+ /**
624
+ * Makes the requested generic call
625
+ *
626
+ * @function genericAdapterRequest
627
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
628
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
629
+ * @param {Object} queryData - the parameters to be put on the url (optional).
630
+ * Can be a stringified Object.
631
+ * @param {Object} requestBody - the body to add to the request (optional).
632
+ * Can be a stringified Object.
633
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
634
+ * Can be a stringified Object.
635
+ * @param {getCallback} callback - a callback function to return the result (Generics)
636
+ * or the error
637
+ */
638
+ genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
639
+ const meth = 'adapter-genericAdapterRequest';
640
+ const origin = `${this.id}-${meth}`;
641
+ log.trace(origin);
642
+
643
+ try {
644
+ return this.iapExpandedGenericAdapterRequest(null, uriPath, restMethod, null, queryData, requestBody, addlHeaders, callback);
645
+ } catch (err) {
646
+ log.error(`${origin}: ${err}`);
647
+ return callback(null, err);
775
648
  }
776
649
  }
777
650
 
@@ -795,128 +668,56 @@ class OpenstackNeutron extends AdapterBaseCl {
795
668
  const origin = `${this.id}-${meth}`;
796
669
  log.trace(origin);
797
670
 
798
- if (this.suspended && this.suspendMode === 'error') {
799
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
800
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
801
- return callback(null, errorObj);
802
- }
803
-
804
- /* HERE IS WHERE YOU VALIDATE DATA */
805
- if (uriPath === undefined || uriPath === null || uriPath === '') {
806
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
807
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
808
- return callback(null, errorObj);
809
- }
810
- if (restMethod === undefined || restMethod === null || restMethod === '') {
811
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
812
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
813
- return callback(null, errorObj);
814
- }
815
-
816
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
817
- // remove any leading / and split the uripath into path variables
818
- let myPath = uriPath;
819
- while (myPath.indexOf('/') === 0) {
820
- myPath = myPath.substring(1);
671
+ try {
672
+ return this.iapExpandedGenericAdapterRequest(null, uriPath, restMethod, null, queryData, requestBody, addlHeaders, callback);
673
+ } catch (err) {
674
+ log.error(`${origin}: ${err}`);
675
+ return callback(null, err);
821
676
  }
822
- const pathVars = myPath.split('/');
823
- const queryParamsAvailable = queryData;
824
- const queryParams = {};
825
- const bodyVars = requestBody;
826
-
827
- // loop in template. long callback arg name to avoid identifier conflicts
828
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
829
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
830
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
831
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
832
- }
833
- });
677
+ }
834
678
 
835
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
836
- const reqObj = {
837
- payload: bodyVars,
838
- uriPathVars: pathVars,
839
- uriQuery: queryParams,
840
- uriOptions: {}
841
- };
842
- // add headers if provided
843
- if (addlHeaders) {
844
- reqObj.addlHeaders = addlHeaders;
845
- }
679
+ /* INVENTORY CALLS */
680
+ /**
681
+ * @summary run the adapter lint script to return the results.
682
+ *
683
+ * @function iapRunAdapterLint
684
+ * @param {Callback} callback - callback function
685
+ */
686
+ iapRunAdapterLint(callback) {
687
+ const meth = 'adapter-iapRunAdapterLint';
688
+ const origin = `${this.id}-${meth}`;
689
+ log.trace(origin);
846
690
 
847
- // determine the call and return flag
848
- let action = 'getGenericsNoBase';
849
- let returnF = true;
850
- if (restMethod.toUpperCase() === 'POST') {
851
- action = 'createGenericNoBase';
852
- } else if (restMethod.toUpperCase() === 'PUT') {
853
- action = 'updateGenericNoBase';
854
- } else if (restMethod.toUpperCase() === 'PATCH') {
855
- action = 'patchGenericNoBase';
856
- } else if (restMethod.toUpperCase() === 'DELETE') {
857
- action = 'deleteGenericNoBase';
858
- returnF = false;
859
- }
691
+ return super.iapRunAdapterLint(callback);
692
+ }
860
693
 
861
- reqObj.authData = {
862
- auth: {
863
- identity: {
864
- methods: [
865
- 'password'
866
- ],
867
- password: {
868
- user: {
869
- name: this.allProps.authentication.username,
870
- domain: {
871
- name: this.allProps.authentication.os_user_domain_name
872
- },
873
- password: this.allProps.authentication.password
874
- }
875
- }
876
- },
877
- scope: {
878
- project: {
879
- name: this.allProps.authentication.os_project_name,
880
- domain: {
881
- name: this.allProps.authentication.os_project_domain_name
882
- }
883
- }
884
- }
885
- }
886
- };
694
+ /**
695
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
696
+ * can not run integration as there can be implications with that.
697
+ *
698
+ * @function iapRunAdapterTests
699
+ * @param {Callback} callback - callback function
700
+ */
701
+ iapRunAdapterTests(callback) {
702
+ const meth = 'adapter-iapRunAdapterTests';
703
+ const origin = `${this.id}-${meth}`;
704
+ log.trace(origin);
887
705
 
888
- reqObj.callProperties = {
889
- ssl: {
890
- enabled: true,
891
- accept_invalid_cert: true
892
- }
893
- };
706
+ return super.iapRunAdapterTests(callback);
707
+ }
894
708
 
895
- try {
896
- // Make the call -
897
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
898
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
899
- // if we received an error or their is no response on the results
900
- // return an error
901
- if (irReturnError) {
902
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
903
- return callback(null, irReturnError);
904
- }
905
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
906
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
907
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
908
- return callback(null, errorObj);
909
- }
709
+ /**
710
+ * @summary provide inventory information abbout the adapter
711
+ *
712
+ * @function iapGetAdapterInventory
713
+ * @param {Callback} callback - callback function
714
+ */
715
+ iapGetAdapterInventory(callback) {
716
+ const meth = 'adapter-iapGetAdapterInventory';
717
+ const origin = `${this.id}-${meth}`;
718
+ log.trace(origin);
910
719
 
911
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
912
- // return the response
913
- return callback(irReturnData, null);
914
- });
915
- } catch (ex) {
916
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
917
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
918
- return callback(null, errorObj);
919
- }
720
+ return super.iapGetAdapterInventory(callback);
920
721
  }
921
722
 
922
723
  /**