@itentialopensource/adapter-utils 4.48.16 → 5.0.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.
@@ -1,7 +1,8 @@
1
+ /* eslint-disable no-param-reassign */
1
2
  /* @copyright Itential, LLC 2018 */
2
3
 
3
4
  // Set globals
4
- /* global log g_redis */
5
+ /* global log */
5
6
  /* eslint consistent-return: warn */
6
7
  /* eslint global-require: warn */
7
8
  /* eslint import/no-dynamic-require: warn */
@@ -9,15 +10,19 @@
9
10
  /* NodeJS internal utilities */
10
11
  const fs = require('fs');
11
12
  const path = require('path');
12
- const AsyncLockCl = require('async-lock');
13
+ const jsonQuery = require('json-query');
13
14
 
14
15
  // The schema validator
15
16
  const AjvCl = require('ajv');
17
+ const { request } = require('http');
16
18
 
17
19
  /* Fetch in the other needed components for the this Class */
18
20
  const RestHandlerCl = require(path.join(__dirname, '/restHandler.js'));
19
- const PropUtilCl = require(path.join(__dirname, '/propertyUtil.js'));
21
+ const CacheHandlerCl = require(path.join(__dirname, '/cacheHandler.js'));
22
+ const BrokerHandlerCl = require(path.join(__dirname, '/brokerHandler.js'));
23
+ const GenericHandlerCl = require(path.join(__dirname, '/genericHandler.js'));
20
24
  const ConnectorCl = require(path.join(__dirname, '/connectorRest.js'));
25
+ const PropUtilCl = require(path.join(__dirname, '/propertyUtil.js'));
21
26
  const TransUtilCl = require(path.join(__dirname, '/translatorUtil.js'));
22
27
  const DBUtilCl = require(path.join(__dirname, '/dbUtil.js'));
23
28
 
@@ -29,11 +34,7 @@ let propUtilInst = null;
29
34
  let transUtilInst = null;
30
35
  const NS_PER_SEC = 1e9;
31
36
  let username = null;
32
-
33
- // used for local cache or a temp if using redis
34
- let cache = {};
35
- const cachelock = 0;
36
- let clock = null;
37
+ let healthcheckpath = null;
37
38
 
38
39
  // INTERNAL FUNCTIONS
39
40
  /**
@@ -60,10 +61,12 @@ function validateProperties(properties) {
60
61
  const combinedProps = propUtilInst.mergeProperties(properties, propUtilInst.setDefaults(propertySchema));
61
62
 
62
63
  // validate the entity against the schema
63
- const ajvInst = new AjvCl();
64
+ const ajvInst = new AjvCl({ strictSchema: false, allowUnionTypes: true });
64
65
  const validate = ajvInst.compile(propertySchema);
65
66
  const result = validate(combinedProps);
66
67
 
68
+ log.info(`request is ${request}`); // for lint
69
+
67
70
  // if invalid properties throw an error
68
71
  if (!result) {
69
72
  // create the generic part of an error object
@@ -141,7 +144,7 @@ function walkThroughActionFiles(directory) {
141
144
  const allActions = propUtilInst.mergeProperties(actions, defActions);
142
145
 
143
146
  // validate the entity against the schema
144
- const ajvInst = new AjvCl();
147
+ const ajvInst = new AjvCl({ strictSchema: false, allowUnionTypes: true });
145
148
  const validate = ajvInst.compile(actionSchema);
146
149
  const result = validate(allActions);
147
150
 
@@ -261,58 +264,6 @@ function walkThroughActionFiles(directory) {
261
264
  }
262
265
  }
263
266
 
264
- /**
265
- * @summary Method to check if the entity is in the cache
266
- *
267
- * @function isEntityCached
268
- * @param {String} entityType - the entity type to check for
269
- * @param {String/Array} entityId - the specific entity we are looking for
270
- *
271
- * @return {Array of Enumeration} - whether the entity was
272
- * 'found' - entity was found
273
- * 'notfound' - entity was not found
274
- * 'needupdate' - update cache and try again
275
- */
276
- function isEntityCached(entityType, entityId) {
277
- const origin = `${id}-requestHandler-isEntityCached`;
278
- log.trace(origin);
279
- let entityIds = entityId;
280
- const results = [];
281
-
282
- // go through the cache
283
- if (cache[entityType]) {
284
- const now = new Date().getTime();
285
-
286
- // see if the cache is valid
287
- if ((cache[entityType].updated) && (cache[entityType].updated >= now - 300000)) {
288
- // entityId is not an Array, make it one
289
- if (!Array.isArray(entityIds)) {
290
- entityIds = [entityId];
291
- }
292
-
293
- for (let e = 0; e < entityIds.length; e += 1) {
294
- // see if the device is in the cache
295
- if (cache[entityType].list.includes(entityIds[e])) {
296
- log.trace(`${origin}: Entity ${entityIds[e]} found in cache`);
297
- results.push('found');
298
- } else {
299
- log.trace(`${origin}: Entity ${entityIds[e]} not found in cache`);
300
- results.push('notfound');
301
- }
302
- }
303
-
304
- return results;
305
- }
306
-
307
- log.warn(`${origin}: Entity Cache out of date`);
308
- return ['needupdate'];
309
- }
310
-
311
- // Entity not found in cache
312
- log.warn(`${origin}: Entity not in cache`);
313
- return ['needupdate'];
314
- }
315
-
316
267
  /**
317
268
  * @summary Method for metric db calls and tests
318
269
  *
@@ -374,6 +325,27 @@ function dbCalls(collectionName, entity, action, data, callback) {
374
325
  }
375
326
  }
376
327
 
328
+ /*
329
+ * INTERNAL FUNCTION: get data from source(s) - nested
330
+ */
331
+ function getDataFromSources(loopField, sources) {
332
+ let fieldValue = loopField;
333
+
334
+ // go through the sources to find the field
335
+ for (let s = 0; s < sources.length; s += 1) {
336
+ // find the field value using jsonquery
337
+ const nestedValue = jsonQuery(loopField, { data: sources[s] }).value;
338
+
339
+ // if we found in source - set and no need to check other sources
340
+ if (nestedValue) {
341
+ fieldValue = nestedValue;
342
+ break;
343
+ }
344
+ }
345
+
346
+ return fieldValue;
347
+ }
348
+
377
349
  class RequestHandler {
378
350
  /**
379
351
  * Request Handler
@@ -406,8 +378,6 @@ class RequestHandler {
406
378
 
407
379
  // save the adapter base directory
408
380
  this.adapterBaseDir = directory;
409
- this.clockInst = new AsyncLockCl();
410
- clock = this.clockInst;
411
381
 
412
382
  // set up the properties I care about
413
383
  this.refreshProperties(properties);
@@ -415,10 +385,13 @@ class RequestHandler {
415
385
  // instantiate other runtime components
416
386
  this.connector = new ConnectorCl(this.myid, this.props, this.transUtil, this.propUtil, this.dbUtil);
417
387
  this.restHandler = new RestHandlerCl(this.myid, this.props, this.connector, this.transUtil);
388
+ this.brokerHandler = new BrokerHandlerCl(this.myid, this.props, this.directory, this);
389
+ this.genericHandler = new GenericHandlerCl(this.myid, this.props, this);
390
+ this.cacheHandler = new CacheHandlerCl(this.myid, this.props, this.directory, this);
418
391
  } catch (e) {
419
392
  // handle any exception
420
393
  const origin = `${this.myid}-requestHandler-constructor`;
421
- return this.transUtil.checkAndThrow(e, origin, 'Could not start Adapter Runtime Library');
394
+ this.transUtil.checkAndThrow(e, origin, 'Could not start Adapter Runtime Library');
422
395
  }
423
396
  }
424
397
 
@@ -443,7 +416,6 @@ class RequestHandler {
443
416
  try {
444
417
  // validate the properties that came in against library property schema
445
418
  this.props = validateProperties(properties);
446
-
447
419
  // get the list of failover codes
448
420
  this.failoverCodes = [];
449
421
 
@@ -452,13 +424,6 @@ class RequestHandler {
452
424
  this.failoverCodes = this.props.request.failover_codes;
453
425
  }
454
426
 
455
- // get the cache location
456
- this.cacheLocation = 'local';
457
-
458
- if (this.props.cache_location) {
459
- this.cacheLocation = this.props.cache_location;
460
- }
461
-
462
427
  this.saveMetric = this.props.save_metric || false;
463
428
 
464
429
  // set the username (required - default is null)
@@ -466,6 +431,13 @@ class RequestHandler {
466
431
  username = this.props.authentication.username;
467
432
  }
468
433
 
434
+ // set the healthcheck path (required - default is null)
435
+ if (this.props.healthcheck) {
436
+ if (typeof this.props.healthcheck.URI_Path === 'string') {
437
+ healthcheckpath = this.props.healthcheck.URI_Path;
438
+ }
439
+ }
440
+
469
441
  // if this is truly a refresh and we have a connector or rest handler, refresh them
470
442
  if (this.connector) {
471
443
  this.connector.refreshProperties(properties);
@@ -473,6 +445,15 @@ class RequestHandler {
473
445
  if (this.restHandler) {
474
446
  this.restHandler.refreshProperties(properties);
475
447
  }
448
+ if (this.cacheHandler) {
449
+ this.cacheHandler.refreshProperties(properties);
450
+ }
451
+ if (this.brokerHandler) {
452
+ this.brokerHandler.refreshProperties(properties);
453
+ }
454
+ if (this.genericHandler) {
455
+ this.genericHandler.refreshProperties(properties);
456
+ }
476
457
  } catch (e) {
477
458
  // handle any exception
478
459
  return this.transUtil.checkAndThrow(e, origin, 'Properties may not have been updated properly');
@@ -544,6 +525,264 @@ class RequestHandler {
544
525
  }
545
526
  }
546
527
 
528
+ /**
529
+ * @summary Make the provided call(s) - could be one of many
530
+ *
531
+ * @function iapMakeGenericCall
532
+ * @param {string} callName - the name of the call (required)
533
+ * @param {object} callProps - the proeprties for the broker call (required)
534
+ * @param {object} devResp - the device details to extract needed inputs (required)
535
+ * @param {string} filterName - any filter to search on (required)
536
+ *
537
+ * @param {getCallback} callback - a callback function to return the result of the call
538
+ */
539
+ iapMakeGenericCall(callName, callProps, devResp, filterName, callback) {
540
+ const meth = 'requestHandler-iapMakeGenericCall';
541
+ const origin = `${this.myid}-${meth}`;
542
+ log.trace(`${origin}: ${callName}`);
543
+
544
+ try {
545
+ let uriPath = '';
546
+ let uriMethod = 'GET';
547
+ let callQuery = {};
548
+ let callBody = {};
549
+ let callHeaders = {};
550
+ let handleFail = 'fail';
551
+ let ostypePrefix = '';
552
+ let statusValue = 'true';
553
+ if (callProps.path) {
554
+ uriPath = `${callProps.path}`;
555
+
556
+ // make any necessary changes to the path
557
+ if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
558
+ const rqKeys = Object.keys(callProps.requestFields);
559
+
560
+ // get the field from the provided device
561
+ for (let rq = 0; rq < rqKeys.length; rq += 1) {
562
+ const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
563
+
564
+ // put the value into the path - if it has been specified in the path
565
+ uriPath = uriPath.replace(`{${rqKeys[rq]}}`, fieldValue);
566
+ }
567
+ }
568
+ }
569
+ if (callProps.method) {
570
+ uriMethod = callProps.method;
571
+ }
572
+ if (callProps.query) {
573
+ callQuery = { ...callProps.query };
574
+ // go through the query params to check for variable values
575
+ const cpKeys = Object.keys(callQuery);
576
+ for (let cp = 0; cp < cpKeys.length; cp += 1) {
577
+ // if (callQuery[cpKeys[cp]].startsWith('{') && callQuery[cpKeys[cp]].endsWith('}')) {
578
+ // make any necessary changes to the query params
579
+ if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
580
+ const rqKeys = Object.keys(callProps.requestFields);
581
+
582
+ // get the field from the provided device
583
+ for (let rq = 0; rq < rqKeys.length; rq += 1) {
584
+ if (callQuery[cpKeys[cp]] === rqKeys[rq]) {
585
+ const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
586
+ // put the value into the query - if it has been specified in the query
587
+ callQuery[cpKeys[cp]] = fieldValue;
588
+ }
589
+ }
590
+ }
591
+ // }
592
+ }
593
+ }
594
+ if (callProps.body) {
595
+ callBody = { ...callProps.body };
596
+
597
+ // go through the body fields to check for variable values
598
+ const cbKeys = Object.keys(callBody);
599
+ for (let cb = 0; cb < cbKeys.length; cb += 1) {
600
+ // if (callBody[cbKeys[cb]].startsWith('{') && callBody[cbKeys[cb]].endsWith('}')) {
601
+ // make any necessary changes to the query params
602
+ if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
603
+ const rqKeys = Object.keys(callProps.requestFields);
604
+
605
+ // get the field from the provided device
606
+ for (let rq = 0; rq < rqKeys.length; rq += 1) {
607
+ if (callBody[cbKeys[cb]] === rqKeys[rq]) {
608
+ const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
609
+
610
+ // put the value into the query - if it has been specified in the query
611
+ callBody[cbKeys[cb]] = fieldValue;
612
+ }
613
+ }
614
+ }
615
+ // }
616
+ }
617
+ }
618
+ if (callProps.headers) {
619
+ callHeaders = { ...callProps.headers };
620
+
621
+ // go through the body fields to check for variable values
622
+ const chKeys = Object.keys(callHeaders);
623
+ for (let ch = 0; ch < chKeys.length; ch += 1) {
624
+ // if (callHeaders[chKeys[ch]].startsWith('{') && callHeaders[chKeys[ch]].endsWith('}')) {
625
+ // make any necessary changes to the query params
626
+ if (devResp !== null && callProps.requestFields && Object.keys(callProps.requestFields).length > 0) {
627
+ const rqKeys = Object.keys(callProps.requestFields);
628
+
629
+ // get the field from the provided device
630
+ for (let rq = 0; rq < rqKeys.length; rq += 1) {
631
+ if (callHeaders[chKeys[ch]] === rqKeys[rq]) {
632
+ const fieldValue = getDataFromSources(callProps.requestFields[rqKeys[rq]], devResp);
633
+
634
+ // put the value into the query - if it has been specified in the query
635
+ callHeaders[chKeys[ch]] = fieldValue;
636
+ }
637
+ }
638
+ }
639
+ // }
640
+ }
641
+ }
642
+ if (callProps.handleFailure) {
643
+ handleFail = callProps.handleFailure;
644
+ }
645
+ if (callProps.responseFields && callProps.responseFields.ostypePrefix) {
646
+ ostypePrefix = callProps.responseFields.ostypePrefix;
647
+ }
648
+ if (callProps.responseFields && callProps.responseFields.statusValue) {
649
+ statusValue = callProps.responseFields.statusValue;
650
+ }
651
+
652
+ // !! using Generic makes it easier on the Adapter Builder (just need to change the path)
653
+ // !! you can also replace with a specific call if that is easier
654
+ return this.genericAdapterRequest(uriPath, uriMethod, callQuery, callBody, callHeaders, (result, error) => {
655
+ // if we received an error or their is no response on the results return an error
656
+ if (error) {
657
+ if (handleFail === 'fail') {
658
+ return callback(null, error);
659
+ }
660
+ return callback({}, null);
661
+ }
662
+ if (!result.response) {
663
+ if (handleFail === 'fail') {
664
+ const errorObj = this.formatErrorObject(this.myid, meth, 'Invalid Response', [callName], null, null, null);
665
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
666
+ return callback(null, errorObj);
667
+ }
668
+ return callback({}, null);
669
+ }
670
+
671
+ // get the response piece we care about from the response
672
+ const myResult = result;
673
+ if (callProps.responseDatakey) {
674
+ myResult.response = jsonQuery(callProps.responseDatakey, { data: myResult.response }).value;
675
+ }
676
+
677
+ // get the keys for the response fields
678
+ let rfKeys = [];
679
+ if (callProps.responseFields && Object.keys(callProps.responseFields).length > 0) {
680
+ rfKeys = Object.keys(callProps.responseFields);
681
+ }
682
+
683
+ // if we got an array returned (e.g. getDevicesFitered)
684
+ if (Array.isArray(myResult.response)) {
685
+ const listDevices = [];
686
+ for (let a = 0; a < myResult.response.length; a += 1) {
687
+ const thisDevice = myResult.response[a];
688
+ for (let rf = 0; rf < rfKeys.length; rf += 1) {
689
+ if (rfKeys[rf] !== 'ostypePrefix') {
690
+ let fieldValue = getDataFromSources(callProps.responseFields[rfKeys[rf]], [thisDevice, devResp, callProps.requestFields]);
691
+
692
+ // if the field is ostype - need to add prefix
693
+ if (rfKeys[rf] === 'ostype' && typeof fieldValue === 'string') {
694
+ fieldValue = ostypePrefix + fieldValue;
695
+ }
696
+ // if there is a status to set, set it
697
+ if (rfKeys[rf] === 'status') {
698
+ // if really looking for just a good response
699
+ if (callProps.responseFields[rfKeys[rf]] === 'return2xx' && myResult.icode === statusValue.toString()) {
700
+ thisDevice.isAlive = true;
701
+ } else if (fieldValue.toString() === statusValue.toString()) {
702
+ thisDevice.isAlive = true;
703
+ } else {
704
+ thisDevice.isAlive = false;
705
+ }
706
+ }
707
+ // if we found a good value
708
+ thisDevice[rfKeys[rf]] = fieldValue;
709
+ }
710
+ }
711
+
712
+ // if there is no filter - add the device to the list
713
+ if (!filterName || filterName.length === 0) {
714
+ listDevices.push(thisDevice);
715
+ } else {
716
+ // if we have to match a filter
717
+ let found = false;
718
+ for (let f = 0; f < filterName.length; f += 1) {
719
+ if (thisDevice.name.indexOf(filterName[f]) >= 0) {
720
+ found = true;
721
+ break;
722
+ }
723
+ }
724
+ // matching device
725
+ if (found) {
726
+ listDevices.push(thisDevice);
727
+ }
728
+ }
729
+ }
730
+
731
+ // return the array of devices
732
+ return callback(listDevices, null);
733
+ }
734
+
735
+ // if this is not an array - just about everything else, just handle as a single object
736
+ let thisDevice = myResult.response;
737
+ for (let rf = 0; rf < rfKeys.length; rf += 1) {
738
+ // skip ostypePrefix since it is not a field
739
+ if (rfKeys[rf] !== 'ostypePrefix') {
740
+ let fieldValue = getDataFromSources(callProps.responseFields[rfKeys[rf]], [thisDevice, devResp, callProps.requestFields]);
741
+
742
+ // if the field is ostype - need to add prefix
743
+ if (rfKeys[rf] === 'ostype' && typeof fieldValue === 'string') {
744
+ fieldValue = ostypePrefix + fieldValue;
745
+ }
746
+ // if there is a status to set, set it
747
+ if (rfKeys[rf] === 'status') {
748
+ // if really looking for just a good response
749
+ if (callProps.responseFields[rfKeys[rf]] === 'return2xx' && myResult.icode === statusValue.toString()) {
750
+ thisDevice.isAlive = true;
751
+ } else if (fieldValue.toString() === statusValue.toString()) {
752
+ thisDevice.isAlive = true;
753
+ } else {
754
+ thisDevice.isAlive = false;
755
+ }
756
+ }
757
+ // if we found a good value
758
+ thisDevice[rfKeys[rf]] = fieldValue;
759
+ }
760
+ }
761
+
762
+ // if there is a filter - check the device is in the list
763
+ if (filterName && filterName.length > 0) {
764
+ let found = false;
765
+ for (let f = 0; f < filterName.length; f += 1) {
766
+ if (thisDevice.name.indexOf(filterName[f]) >= 0) {
767
+ found = true;
768
+ break;
769
+ }
770
+ }
771
+ // no matching device - clear the device
772
+ if (!found) {
773
+ thisDevice = {};
774
+ }
775
+ }
776
+
777
+ return callback(thisDevice, null);
778
+ });
779
+ } catch (e) {
780
+ const errorObj = this.formatErrorObject(this.myid, meth, 'Caught Exception', null, null, null, e);
781
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
782
+ return callback(null, errorObj);
783
+ }
784
+ }
785
+
547
786
  /**
548
787
  * @summary Method that identifies the actual request to be made and then
549
788
  * makes the call through the appropriate Handler
@@ -567,7 +806,6 @@ class RequestHandler {
567
806
  const origin = `${this.myid}-${meth}`;
568
807
  log.trace(`${origin}: ${entity}-${action}`);
569
808
  const overallTime = process.hrtime();
570
-
571
809
  try {
572
810
  // verify parameters passed are valid
573
811
  if (entity === null || entity === '') {
@@ -581,6 +819,18 @@ class RequestHandler {
581
819
  return callback(null, errorObj);
582
820
  }
583
821
 
822
+ if (this.props.cache.enabled && action !== 'getGenerics' && this.cacheHandler.isTaskCached(entity, action)) {
823
+ return this.retrieveEntitiesCache(entity, {}, (result, error) => {
824
+ if (error) {
825
+ return callback(null, error);
826
+ }
827
+ if (translate) {
828
+ return callback(result);
829
+ }
830
+ return callback('success');
831
+ });
832
+ }
833
+
584
834
  // Get the entity schema from the file system
585
835
  return this.propUtil.getEntitySchema(entity, action, this.props.choosepath, this.dbUtil, (entitySchema, entityError) => {
586
836
  // verify protocol for call
@@ -608,7 +858,6 @@ class RequestHandler {
608
858
  }
609
859
 
610
860
  newError.metrics.capabilityTime = overallEnd;
611
- // console.log(newError); //can't test b/c no errors built into tests rn.
612
861
  // will call from adapterFunction.ejs only eventually since it will have all metrics here + the 2 missing ones.
613
862
  if (this.saveMetric) {
614
863
  dbCalls('metrics', entity, action, newError.metrics, (saved) => {
@@ -683,6 +932,13 @@ class RequestHandler {
683
932
  log.debug(`${origin}: Using adapter properties for healthcheck information`);
684
933
  } else {
685
934
  log.debug(`${origin}: Using action and schema for healthcheck information`);
935
+ if (healthcheckpath) {
936
+ log.debug('Reading healthcheck URI from Service Instance Configuration.');
937
+ healthSchema.entitypath = healthcheckpath;
938
+ if (healthSchema.mockresponses && healthSchema.mockresponses[0] && healthSchema.mockresponses[0].name) {
939
+ healthSchema.mockresponses[0].name = healthcheckpath;
940
+ }
941
+ }
686
942
  }
687
943
 
688
944
  if (healthSchema && healthSchema.protocol) {
@@ -701,7 +957,6 @@ class RequestHandler {
701
957
  }
702
958
 
703
959
  newError.metrics.capabilityTime = overallEnd;
704
- // console.log(newError); //can't test b/c no errors built into tests rn.
705
960
  // will call from adapterFunction.ejs only eventually since it will have all metrics here + the 2 missing ones.
706
961
  if (this.saveMetric) {
707
962
  dbCalls('metrics', '.system', 'healthcheck', newError.metrics, (saved) => {
@@ -871,131 +1126,6 @@ class RequestHandler {
871
1126
  }
872
1127
  }
873
1128
 
874
- /**
875
- * @summary Check the current cache to see if we know about a specific entity
876
- *
877
- * @function isEntityCached
878
- * @param {String} entityType - the entity type to check for
879
- * @param {String/Array} entityId - the specific entity we are looking for
880
- *
881
- * @return {Array of Enumeration} - whether the entity was
882
- * 'found' - entity was found
883
- * 'notfound' - entity was not found
884
- * 'error' - there was an error - check logs
885
- * 'needupdate' - update cache and try again
886
- */
887
- checkEntityCached(entityType, entityId, callback) {
888
- const origin = `${this.myid}-requestHandler-checkEntityCached`;
889
- log.trace(origin);
890
-
891
- try {
892
- if (this.cacheLocation === 'redis') {
893
- const ckey = `${this.myid}__%%__cache`;
894
-
895
- // get the cache from redis
896
- return g_redis.get(ckey, (err, res) => {
897
- if (err) {
898
- log.error(`${origin}: Error on retrieve cache for ${ckey}`);
899
- return callback(['error']);
900
- }
901
-
902
- // if there was no cache returned
903
- if (!res) {
904
- log.error(`${origin}: No cache for ${ckey}`);
905
- return callback(['needupdate']);
906
- }
907
-
908
- // set the local cache to what we got from redis (temp storage)
909
- cache = res;
910
- return callback(isEntityCached(entityType, entityId));
911
- });
912
- }
913
-
914
- return callback(isEntityCached(entityType, entityId));
915
- } catch (e) {
916
- log.error(`${origin}: Caught Exception ${e}`);
917
- return callback(['error']);
918
- }
919
- }
920
-
921
- /**
922
- * @summary Adds the provided entity list to the cache
923
- *
924
- * @function addEntityCache
925
- * @param {String} entityType - the entity type for the list
926
- * @param {Array} entities - the list of entities to be added
927
- *
928
- * @param {Callback} callback - whether the cache was updated
929
- */
930
- addEntityCache(entityType, entities, callback) {
931
- const meth = 'requestHandler-addEntityCache';
932
- const origin = `${this.myid}-${meth}`;
933
- log.trace(origin);
934
- let storeEnt = entities;
935
-
936
- if (!Array.isArray(entities)) {
937
- storeEnt = [entities];
938
- }
939
-
940
- const entityEntry = {
941
- list: storeEnt,
942
- updated: new Date().getTime()
943
- };
944
-
945
- try {
946
- // Lock the cache while adding items to it
947
- return clock.acquire(cachelock, (done) => {
948
- // if only storing locally, done
949
- if (this.cacheLocation === 'local') {
950
- // add the entities to the cache
951
- cache[entityType] = entityEntry;
952
- done(true, null);
953
- } else {
954
- // set the redis key
955
- const ckey = `${this.myid}__%%__cache`;
956
-
957
- // get the cache from redis
958
- g_redis.get(ckey, (err, res) => {
959
- if (err) {
960
- log.error(`${origin}: Error on retrieve cache for ${ckey}`);
961
- done(false, null);
962
- } else {
963
- cache = res;
964
-
965
- // if no cache was found
966
- if (!cache) {
967
- cache = {};
968
- }
969
-
970
- // add the entities to the cache
971
- cache[entityType] = entityEntry;
972
-
973
- // store the cache in redis
974
- g_redis.set(ckey, JSON.stringify(cache), (error) => {
975
- if (error) {
976
- log.error(`${origin}: Cache: ${ckey} not stored in redis`);
977
- done(false, null);
978
- } else {
979
- done(true, null);
980
- }
981
- });
982
- }
983
- });
984
- }
985
- }, (ret, error) => {
986
- if (error) {
987
- log.error(`${origin}: Error from retrieving entity cache: ${error}`);
988
- }
989
-
990
- return callback(ret, error);
991
- });
992
- } catch (e) {
993
- // handle any exception
994
- const errorObj = this.transUtil.checkAndReturn(e, origin, 'Issue adding entity to cache');
995
- return callback(null, errorObj);
996
- }
997
- }
998
-
999
1129
  /**
1000
1130
  * @summary Provides a way for the adapter to tell north bound integrations
1001
1131
  * whether the adapter supports type and specific entity
@@ -1003,18 +1133,18 @@ class RequestHandler {
1003
1133
  * @function verifyCapability
1004
1134
  * @param {String} entityType - the entity type to check for
1005
1135
  * @param {String} actionType - the action type to check for
1006
- * @param {String/Array} entityId - the specific entity we are looking for
1136
+ * @param {String/Array} entityId - the specific entity we are looking for only works
1137
+ * if caching for that entityType is enabled. does not make API call!
1007
1138
  *
1008
1139
  * @return {Array of Enumeration} - whether the entity was
1009
1140
  * 'found' - entity was found
1010
1141
  * 'notfound' - entity was not found
1011
1142
  * 'error' - there was an error - check logs
1012
- * 'needupdate' - update cache and try again
1013
1143
  */
1014
1144
  verifyCapability(entityType, actionType, entityId, callback) {
1015
1145
  const origin = `${this.myid}-requestHandler-verifyCapability`;
1016
1146
  log.trace(origin);
1017
- const entitiesD = `${this.adapterBaseDir}/entities`;
1147
+ const entitiesD = `${this.adapterBaseDir}/entities`; // causes verifyCapability errors
1018
1148
 
1019
1149
  try {
1020
1150
  // verify the entities directory exists
@@ -1025,7 +1155,6 @@ class RequestHandler {
1025
1155
 
1026
1156
  // get the entities this adapter supports
1027
1157
  const entities = fs.readdirSync(entitiesD);
1028
-
1029
1158
  // go through the entities
1030
1159
  for (let e = 0; e < entities.length; e += 1) {
1031
1160
  // did we find the entity type?
@@ -1033,16 +1162,23 @@ class RequestHandler {
1033
1162
  // if we are only interested in the entity
1034
1163
  if (!actionType && !entityId) {
1035
1164
  return callback(['found']);
1165
+ // return callback([true]);
1036
1166
  }
1037
1167
  // if we do not have an action, check for the specific entity
1038
1168
  if (!actionType) {
1039
- return this.checkEntityCached(entityType, entityId, callback);
1169
+ return this.checkEntityCached(entityType, entityId, (data, error) => {
1170
+ if (error) {
1171
+ log.error(`${origin}: Failed check entity cached with error ${error}`);
1172
+ return callback(null, error);
1173
+ }
1174
+ return callback(data);
1175
+ });
1040
1176
  }
1041
1177
 
1042
1178
  // get the entity actions from the action file
1043
1179
  const actionFile = `${entitiesD}/${entities[e]}/action.json`;
1044
1180
  if (fs.existsSync(actionFile)) {
1045
- const actionJson = require(actionFile);
1181
+ const actionJson = require(actionFile); // fails verify unit test, exists but can't require
1046
1182
  const { actions } = actionJson;
1047
1183
 
1048
1184
  // go through the actions for a match
@@ -1052,7 +1188,16 @@ class RequestHandler {
1052
1188
  if (!entityId) {
1053
1189
  return callback(['found']);
1054
1190
  }
1055
- return this.checkEntityCached(entityType, entityId, callback);
1191
+ return this.checkEntityCached(entityType, entityId, (data, error) => {
1192
+ if (error) {
1193
+ log.error(`${origin}: Failed check entity cached with error ${error}`);
1194
+ return callback(null, error);
1195
+ }
1196
+ if (data) {
1197
+ return callback(['found']);
1198
+ }
1199
+ return callback(['notfound']);
1200
+ });
1056
1201
  }
1057
1202
  }
1058
1203
 
@@ -1168,13 +1313,439 @@ class RequestHandler {
1168
1313
  }
1169
1314
 
1170
1315
  // validate the action files for the adapter
1171
- return this.connector.makeTokenRequest('/none/token/path', useUser, reqBody, null, callProperties, callback);
1316
+ return callback(this.connector.makeTokenRequest('/none/token/path', useUser, reqBody, null, callProperties, callback));
1172
1317
  } catch (e) {
1173
1318
  // handle any exception
1174
1319
  const errorObj = this.transUtil.checkAndReturn(e, origin, 'Issue getting token');
1175
1320
  return callback(null, errorObj);
1176
1321
  }
1177
1322
  }
1323
+
1324
+ /**
1325
+ * @summary provide inventory information abbout the adapter
1326
+ *
1327
+ * @function getAdapterInventory
1328
+ *
1329
+ * @return {Object} - containing the adapter inventory information
1330
+ */
1331
+ getAdapterInventory(callback) {
1332
+ const origin = `${this.myid}-requestHandler-getAdapterInventory`;
1333
+ log.trace(origin);
1334
+
1335
+ try {
1336
+ const adapterInv = {
1337
+ issues: {}
1338
+ };
1339
+
1340
+ // are the utils within the adapter
1341
+ if (__dirname.indexOf(this.directory) === 0) {
1342
+ adapterInv.issues.embedUtils = true;
1343
+ } else {
1344
+ adapterInv.issues.embedUtils = false;
1345
+ }
1346
+
1347
+ // get the adapter package.json
1348
+ if (fs.existsSync(path.join(this.directory, 'package.json'))) {
1349
+ const adaptPackage = require(path.join(this.directory, 'package.json'));
1350
+
1351
+ // Namespace - package & directory
1352
+ const [tempNS, tempName] = adaptPackage.name.split('/');
1353
+ adapterInv.namespace = tempNS;
1354
+ if (this.directory.indexOf(adapterInv.namespace) > 0) {
1355
+ adapterInv.issues.inNamespace = true;
1356
+ } else {
1357
+ adapterInv.issues.inNamespace = false;
1358
+ }
1359
+
1360
+ // Name - package & directory
1361
+ adapterInv.name = tempName;
1362
+ if (this.directory.indexOf(adapterInv.name) > 0) {
1363
+ adapterInv.issues.inName = true;
1364
+ } else {
1365
+ adapterInv.issues.inName = false;
1366
+ }
1367
+
1368
+ // Version - package
1369
+ adapterInv.version = adaptPackage.version;
1370
+ } else {
1371
+ adapterInv.namespace = 'TBD';
1372
+ adapterInv.issues.inNamespace = false;
1373
+ adapterInv.name = 'TBD';
1374
+ adapterInv.issues.inName = false;
1375
+ adapterInv.version = 'TBD';
1376
+ }
1377
+
1378
+ // get the adapter pronghorn.json
1379
+ adapterInv.brokerDefined = false;
1380
+ adapterInv.cacheDefined = false;
1381
+ if (fs.existsSync(path.join(this.directory, 'pronghorn.json'))) {
1382
+ const adaptPronghorn = require(path.join(this.directory, 'pronghorn.json'));
1383
+
1384
+ // Active WF Tasks - pronghorn.json
1385
+ let wfCount = 0;
1386
+ for (let i = 0; i < adaptPronghorn.methods.length; i += 1) {
1387
+ if (adaptPronghorn.methods[i].task === true) {
1388
+ wfCount += 1;
1389
+ }
1390
+ if (adaptPronghorn.methods[i].name === 'getDevicesFiltered') {
1391
+ adapterInv.brokerDefined = true;
1392
+ }
1393
+ if (adaptPronghorn.methods[i].name === 'iapUpdateAdapterCache') {
1394
+ adapterInv.cacheDefined = true;
1395
+ }
1396
+ }
1397
+ adapterInv.activeWFTasks = wfCount;
1398
+ } else {
1399
+ adapterInv.activeWFTasks = -1;
1400
+ }
1401
+
1402
+ // get the utils package.json
1403
+ if (fs.existsSync('../package.json')) {
1404
+ const utilsPackage = require('../package.json');
1405
+
1406
+ // Version of adapter-utils - utils package
1407
+ adapterInv.utilVersion = utilsPackage.version;
1408
+ } else {
1409
+ adapterInv.utilVersion = 'TBD';
1410
+ }
1411
+
1412
+ // return the results
1413
+ return callback(adapterInv);
1414
+ } catch (e) {
1415
+ // handle any exception
1416
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Issue getting Inventory information');
1417
+ return callback(null, errorObj);
1418
+ }
1419
+ }
1420
+
1421
+ /* ********************************************** */
1422
+ /* */
1423
+ /* EXPOSES CACHE HANDLER */
1424
+ /* */
1425
+ /* ********************************************** */
1426
+ /**
1427
+ * @summary Check the current cache to see if we know about a specific entity
1428
+ *
1429
+ * @function checkEntityCached
1430
+ * @param {String} entityType - the entity type to check for
1431
+ * @param {String/Array} entityNames - the specific entity we are looking for
1432
+ *
1433
+ * @return {Array of Boolean} - for each entity name, whether found
1434
+ */
1435
+ checkEntityCached(entityType, entityNames, callback) {
1436
+ const origin = `${this.myid}-requestHandler-checkEntityCached`;
1437
+ log.trace(origin);
1438
+
1439
+ try {
1440
+ return this.cacheHandler.isEntityCached(entityType, entityNames, callback);
1441
+ } catch (e) {
1442
+ // handle any exception
1443
+ log.error('Check Entity Cached failed with error.');
1444
+ return callback(false); // pretend no error and that it is not cached
1445
+ }
1446
+ }
1447
+
1448
+ /**
1449
+ * @function checkEntityTypeCached
1450
+ * @summary checks whether an entity type is currently cached
1451
+ * @param {String} entityType - entity type to check
1452
+ * @return {Boolean} - whether or not the entity type is in cache
1453
+ */
1454
+ checkEntityTypeCached(entityType, callback) {
1455
+ const origin = `${this.myid}-requestHandler-checkEntityTypeCached`;
1456
+ log.trace(origin);
1457
+
1458
+ try {
1459
+ return this.cacheHandler.isEntityTypeToBeCached(entityType, callback);
1460
+ } catch (e) {
1461
+ // handle any exception
1462
+ log.error('Check Entity Type Cached failed with error.');
1463
+ return callback(false); // pretend no error and that it is not cached
1464
+ }
1465
+ }
1466
+
1467
+ /**
1468
+ * @summary Adds the provided entity list to the cache
1469
+ *
1470
+ * @function addEntityCache
1471
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
1472
+ * @param {Integer} cacheLimit - limit of items to store in cache
1473
+ * @param {Double} newFrequency - how often to update (in hours)
1474
+ * @param {Callback} callback - whether the cache was updated or not
1475
+ * @returns return of the callback
1476
+ */
1477
+ addEntityCache(entityType, entities, callback) {
1478
+ const origin = `${this.myid}-requestHandler-addEntityCache`;
1479
+ return callback(null, `${origin} ${entityType}:${entities} call has been deprecated with new cache handling!`);
1480
+ }
1481
+
1482
+ /**
1483
+ * @summary Populate the cache for the given entities
1484
+ *
1485
+ * @function populateEntityCache
1486
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
1487
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
1488
+ * @returns return of the callback
1489
+ */
1490
+ populateEntityCache(entityTypes, callback) {
1491
+ const origin = `${this.myid}-requestHandler-populateEntityCache`;
1492
+ log.trace(origin);
1493
+
1494
+ return this.cacheHandler.populateCache(entityTypes).then((result) => callback(result, null)).catch((error) => callback(null, error));
1495
+ }
1496
+
1497
+ /**
1498
+ * @summary Retrieves data from cache for specified entity type
1499
+ *
1500
+ * @function retrieveEntitiesCache
1501
+ * @param {String} entityType - entity of which to retrieve
1502
+ * @param {Object} options - settings of which data to return and how to return it
1503
+ * @param {Callback} callback - the data if it was retrieved
1504
+ */
1505
+ retrieveEntitiesCache(entityType, options, callback) {
1506
+ const origin = `${this.myid}-requestHandler-retrieveEntitiesCache`;
1507
+ log.trace(origin);
1508
+
1509
+ if (!options) {
1510
+ return callback(null, 'Options cannot be null!');
1511
+ }
1512
+ try {
1513
+ return this.cacheHandler.retrieveCacheEntries(entityType, options, callback);
1514
+ } catch (e) {
1515
+ // handle any exception
1516
+ return callback(null, 'Retrieve Cache Failed');
1517
+ }
1518
+ }
1519
+
1520
+ /* ********************************************** */
1521
+ /* */
1522
+ /* EXPOSES BROKER HANDLER */
1523
+ /* */
1524
+ /* ********************************************** */
1525
+ /**
1526
+ * @summary Determines if this adapter supports any in a list of entities
1527
+ *
1528
+ * @function hasEntities
1529
+ * @param {String} entityType - the entity type to check for
1530
+ * @param {Array} entityList - the list of entities we are looking for
1531
+ *
1532
+ * @param {Callback} callback - A map where the entity is the key and the
1533
+ * value is true or false
1534
+ */
1535
+ hasEntities(entityType, entityList, callback) {
1536
+ const origin = `${this.myid}-requestHandler-hasEntities`;
1537
+ log.trace(origin);
1538
+
1539
+ try {
1540
+ return this.brokerHandler.hasEntities(entityType, entityList, callback);
1541
+ } catch (e) {
1542
+ // handle any exception
1543
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Broker hasEntities Failed');
1544
+ return callback(null, errorObj);
1545
+ }
1546
+ }
1547
+
1548
+ /**
1549
+ * @summary Get Appliance that match the deviceName
1550
+ *
1551
+ * @function getDevice
1552
+ * @param {String} deviceName - the deviceName to find (required)
1553
+ *
1554
+ * @param {getCallback} callback - a callback function to return the result
1555
+ * (appliance) or the error
1556
+ */
1557
+ getDevice(deviceName, callback) {
1558
+ const origin = `${this.myid}-requestHandler-getDevice`;
1559
+ log.trace(origin);
1560
+
1561
+ try {
1562
+ return this.brokerHandler.getDevice(deviceName, callback);
1563
+ } catch (e) {
1564
+ // handle any exception
1565
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Broker getDevice Failed');
1566
+ return callback(null, errorObj);
1567
+ }
1568
+ }
1569
+
1570
+ /**
1571
+ * @summary Get Appliances that match the filter
1572
+ *
1573
+ * @function getDevicesFiltered
1574
+ * @param {Object} options - the data to use to filter the appliances (optional)
1575
+ *
1576
+ * @param {getCallback} callback - a callback function to return the result
1577
+ * (appliances) or the error
1578
+ */
1579
+ getDevicesFiltered(options, callback) {
1580
+ const origin = `${this.myid}-requestHandler-getDevicesFiltered`;
1581
+ log.trace(origin);
1582
+ try {
1583
+ return this.brokerHandler.getDevicesFiltered(options, callback);
1584
+ } catch (e) {
1585
+ // handle any exception
1586
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Broker getDevicesFiltered Failed');
1587
+ return callback(null, errorObj);
1588
+ }
1589
+ }
1590
+
1591
+ /**
1592
+ * @summary Gets the status for the provided appliance
1593
+ *
1594
+ * @function isAlive
1595
+ * @param {String} deviceName - the deviceName of the appliance. (required)
1596
+ *
1597
+ * @param {configCallback} callback - callback function to return the result
1598
+ * (appliance isAlive) or the error
1599
+ */
1600
+ isAlive(deviceName, callback) {
1601
+ const origin = `${this.myid}-requestHandler-isAlive`;
1602
+ log.trace(origin);
1603
+
1604
+ try {
1605
+ return this.brokerHandler.isAlive(deviceName, callback);
1606
+ } catch (e) {
1607
+ // handle any exception
1608
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Broker isAlive Failed');
1609
+ return callback(null, errorObj);
1610
+ }
1611
+ }
1612
+
1613
+ /**
1614
+ * @summary Gets a config for the provided Appliance
1615
+ *
1616
+ * @function getConfig
1617
+ * @param {String} deviceName - the deviceName of the appliance. (required)
1618
+ * @param {String} format - the desired format of the config. (optional)
1619
+ *
1620
+ * @param {configCallback} callback - callback function to return the result
1621
+ * (appliance config) or the error
1622
+ */
1623
+ getConfig(deviceName, format, callback) {
1624
+ const origin = `${this.myid}-requestHandler-getConfig`;
1625
+ log.trace(origin);
1626
+
1627
+ try {
1628
+ return this.brokerHandler.getConfig(deviceName, format, callback);
1629
+ } catch (e) {
1630
+ // handle any exception
1631
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Broker getConfig Failed');
1632
+ return callback(null, errorObj);
1633
+ }
1634
+ }
1635
+
1636
+ /**
1637
+ * @summary Gets the device count from the system
1638
+ *
1639
+ * @function iapGetDeviceCount
1640
+ *
1641
+ * @param {getCallback} callback - callback function to return the result
1642
+ * (count) or the error
1643
+ */
1644
+ iapGetDeviceCount(callback) {
1645
+ const origin = `${this.myid}-requestHandler-iapGetDeviceCount`;
1646
+ log.trace(origin);
1647
+
1648
+ try {
1649
+ return this.brokerHandler.iapGetDeviceCount(callback);
1650
+ } catch (e) {
1651
+ // handle any exception
1652
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Broker iapGetDeviceCount Failed');
1653
+ return callback(null, errorObj);
1654
+ }
1655
+ }
1656
+
1657
+ /* ********************************************** */
1658
+ /* */
1659
+ /* EXPOSES GENERIC HANDLER */
1660
+ /* */
1661
+ /* ********************************************** */
1662
+ /**
1663
+ * Makes the requested generic call
1664
+ *
1665
+ * @function expandedGenericAdapterRequest
1666
+ * @param {Object} metadata - metadata for the call (optional).
1667
+ * Can be a stringified Object.
1668
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
1669
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
1670
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
1671
+ * Can be a stringified Object.
1672
+ * @param {Object} queryData - the parameters to be put on the url (optional).
1673
+ * Can be a stringified Object.
1674
+ * @param {Object} requestBody - the body to add to the request (optional).
1675
+ * Can be a stringified Object.
1676
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
1677
+ * Can be a stringified Object.
1678
+ * @param {getCallback} callback - a callback function to return the result (Generics)
1679
+ * or the error
1680
+ */
1681
+ expandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
1682
+ const origin = `${this.myid}-requestHandler-expandedGenericAdapterRequest`;
1683
+ log.trace(origin);
1684
+
1685
+ try {
1686
+ return this.genericHandler.expandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
1687
+ } catch (e) {
1688
+ // handle any exception
1689
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Expanded Generic Adapter Request Failed');
1690
+ return callback(null, errorObj);
1691
+ }
1692
+ }
1693
+
1694
+ /**
1695
+ * Makes the requested generic call
1696
+ *
1697
+ * @function genericAdapterRequest
1698
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
1699
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
1700
+ * @param {Object} queryData - the parameters to be put on the url (optional).
1701
+ * Can be a stringified Object.
1702
+ * @param {Object} requestBody - the body to add to the request (optional).
1703
+ * Can be a stringified Object.
1704
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
1705
+ * Can be a stringified Object.
1706
+ * @param {getCallback} callback - a callback function to return the result (Generics)
1707
+ * or the error
1708
+ */
1709
+ genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
1710
+ const origin = `${this.myid}-requestHandler-genericAdapterRequest`;
1711
+ log.trace(origin);
1712
+
1713
+ try {
1714
+ return this.genericHandler.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
1715
+ } catch (e) {
1716
+ // handle any exception
1717
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Generic Adapter Request Failed');
1718
+ return callback(null, errorObj);
1719
+ }
1720
+ }
1721
+
1722
+ /**
1723
+ * Makes the requested generic call with no base path or version
1724
+ *
1725
+ * @function genericAdapterRequestNoBasePath
1726
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
1727
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
1728
+ * @param {Object} queryData - the parameters to be put on the url (optional).
1729
+ * Can be a stringified Object.
1730
+ * @param {Object} requestBody - the body to add to the request (optional).
1731
+ * Can be a stringified Object.
1732
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
1733
+ * Can be a stringified Object.
1734
+ * @param {getCallback} callback - a callback function to return the result (Generics)
1735
+ * or the error
1736
+ */
1737
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
1738
+ const origin = `${this.myid}-requestHandler-genericAdapterRequestNoBasePath`;
1739
+ log.trace(origin);
1740
+
1741
+ try {
1742
+ return this.genericHandler.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
1743
+ } catch (e) {
1744
+ // handle any exception
1745
+ const errorObj = this.transUtil.checkAndReturn(e, origin, 'Generic Adapter Request No Base Path Failed');
1746
+ return callback(null, errorObj);
1747
+ }
1748
+ }
1178
1749
  }
1179
1750
 
1180
1751
  module.exports = RequestHandler;