@itentialopensource/adapter-meraki 0.8.1 → 0.8.4

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.
package/adapter.js CHANGED
@@ -83,7 +83,15 @@ class Meraki extends AdapterBaseCl {
83
83
  * @iapGetAdapterWorkflowFunctions
84
84
  */
85
85
  iapGetAdapterWorkflowFunctions(inIgnore) {
86
- let myIgnore = ['hasEntities', 'hasDevices'];
86
+ let myIgnore = [
87
+ 'healthCheck',
88
+ 'iapGetAdapterWorkflowFunctions',
89
+ 'iapHasAdapterEntity',
90
+ 'iapVerifyAdapterCapability',
91
+ 'iapUpdateAdapterEntityCache',
92
+ 'hasEntities',
93
+ 'getAuthorization'
94
+ ];
87
95
  if (!inIgnore && Array.isArray(inIgnore)) {
88
96
  myIgnore = inIgnore;
89
97
  } else if (!inIgnore && typeof inIgnore === 'string') {
@@ -111,8 +119,10 @@ class Meraki extends AdapterBaseCl {
111
119
  * @param {Callback} callback - The results of the call
112
120
  */
113
121
  iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
114
- const origin = `${this.id}-adapter-iapUpdateAdapterConfiguration`;
122
+ const meth = 'adapter-iapUpdateAdapterConfiguration';
123
+ const origin = `${this.id}-${meth}`;
115
124
  log.trace(origin);
125
+
116
126
  super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
117
127
  }
118
128
 
@@ -124,8 +134,10 @@ class Meraki extends AdapterBaseCl {
124
134
  * @param {Callback} callback - The results of the call
125
135
  */
126
136
  iapFindAdapterPath(apiPath, callback) {
127
- const origin = `${this.id}-adapter-iapFindAdapterPath`;
137
+ const meth = 'adapter-iapFindAdapterPath';
138
+ const origin = `${this.id}-${meth}`;
128
139
  log.trace(origin);
140
+
129
141
  super.iapFindAdapterPath(apiPath, callback);
130
142
  }
131
143
 
@@ -136,8 +148,10 @@ class Meraki extends AdapterBaseCl {
136
148
  * @param {Callback} callback - callback function
137
149
  */
138
150
  iapSuspendAdapter(mode, callback) {
139
- const origin = `${this.id}-adapter-iapSuspendAdapter`;
151
+ const meth = 'adapter-iapSuspendAdapter';
152
+ const origin = `${this.id}-${meth}`;
140
153
  log.trace(origin);
154
+
141
155
  try {
142
156
  return super.iapSuspendAdapter(mode, callback);
143
157
  } catch (error) {
@@ -153,8 +167,10 @@ class Meraki extends AdapterBaseCl {
153
167
  * @param {Callback} callback - callback function
154
168
  */
155
169
  iapUnsuspendAdapter(callback) {
156
- const origin = `${this.id}-adapter-iapUnsuspendAdapter`;
170
+ const meth = 'adapter-iapUnsuspendAdapter';
171
+ const origin = `${this.id}-${meth}`;
157
172
  log.trace(origin);
173
+
158
174
  try {
159
175
  return super.iapUnsuspendAdapter(callback);
160
176
  } catch (error) {
@@ -170,8 +186,10 @@ class Meraki extends AdapterBaseCl {
170
186
  * @param {Callback} callback - callback function
171
187
  */
172
188
  iapGetAdapterQueue(callback) {
173
- const origin = `${this.id}-adapter-iapGetAdapterQueue`;
189
+ const meth = 'adapter-iapGetAdapterQueue';
190
+ const origin = `${this.id}-${meth}`;
174
191
  log.trace(origin);
192
+
175
193
  return super.iapGetAdapterQueue(callback);
176
194
  }
177
195
 
@@ -185,8 +203,10 @@ class Meraki extends AdapterBaseCl {
185
203
  * @param {Callback} callback - The results of the call
186
204
  */
187
205
  iapTroubleshootAdapter(props, persistFlag, callback) {
188
- const origin = `${this.id}-adapter-iapTroubleshootAdapter`;
206
+ const meth = 'adapter-iapTroubleshootAdapter';
207
+ const origin = `${this.id}-${meth}`;
189
208
  log.trace(origin);
209
+
190
210
  try {
191
211
  return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
192
212
  } catch (error) {
@@ -203,8 +223,10 @@ class Meraki extends AdapterBaseCl {
203
223
  * @param {Callback} callback - callback function
204
224
  */
205
225
  iapRunAdapterHealthcheck(callback) {
206
- const origin = `${this.id}-adapter-iapRunAdapterHealthcheck`;
226
+ const meth = 'adapter-iapRunAdapterHealthcheck';
227
+ const origin = `${this.id}-${meth}`;
207
228
  log.trace(origin);
229
+
208
230
  try {
209
231
  return super.iapRunAdapterHealthcheck(this, callback);
210
232
  } catch (error) {
@@ -220,8 +242,10 @@ class Meraki extends AdapterBaseCl {
220
242
  * @param {Callback} callback - callback function
221
243
  */
222
244
  iapRunAdapterConnectivity(callback) {
223
- const origin = `${this.id}-adapter-iapRunAdapterConnectivity`;
245
+ const meth = 'adapter-iapRunAdapterConnectivity';
246
+ const origin = `${this.id}-${meth}`;
224
247
  log.trace(origin);
248
+
225
249
  try {
226
250
  return super.iapRunAdapterConnectivity(callback);
227
251
  } catch (error) {
@@ -237,8 +261,10 @@ class Meraki extends AdapterBaseCl {
237
261
  * @param {Callback} callback - callback function
238
262
  */
239
263
  iapRunAdapterBasicGet(callback) {
240
- const origin = `${this.id}-adapter-iapRunAdapterBasicGet`;
264
+ const meth = 'adapter-iapRunAdapterBasicGet';
265
+ const origin = `${this.id}-${meth}`;
241
266
  log.trace(origin);
267
+
242
268
  try {
243
269
  return super.iapRunAdapterBasicGet(callback);
244
270
  } catch (error) {
@@ -255,8 +281,10 @@ class Meraki extends AdapterBaseCl {
255
281
  * or the error
256
282
  */
257
283
  iapMoveAdapterEntitiesToDB(callback) {
258
- const origin = `${this.id}-adapter-iapMoveAdapterEntitiesToDB`;
284
+ const meth = 'adapter-iapMoveAdapterEntitiesToDB';
285
+ const origin = `${this.id}-${meth}`;
259
286
  log.trace(origin);
287
+
260
288
  try {
261
289
  return super.iapMoveAdapterEntitiesToDB(callback);
262
290
  } catch (err) {
@@ -446,56 +474,18 @@ class Meraki extends AdapterBaseCl {
446
474
  * value is true or false
447
475
  */
448
476
  hasEntities(entityType, entityList, callback) {
449
- const origin = `${this.id}-adapter-hasEntities`;
477
+ const meth = 'adapter-hasEntities';
478
+ const origin = `${this.id}-${meth}`;
450
479
  log.trace(origin);
451
480
 
452
- switch (entityType) {
453
- case 'Device':
454
- return this.hasDevices(entityList, callback);
455
- default:
456
- return callback(null, `${this.id} does not support entity ${entityType}`);
481
+ try {
482
+ return super.hasEntities(entityType, entityList, callback);
483
+ } catch (err) {
484
+ log.error(`${origin}: ${err}`);
485
+ return callback(null, err);
457
486
  }
458
487
  }
459
488
 
460
- /**
461
- * @summary Helper method for hasEntities for the specific device case
462
- *
463
- * @param {Array} deviceList - array of unique device identifiers
464
- * @param {Callback} callback - A map where the device is the key and the
465
- * value is true or false
466
- */
467
- hasDevices(deviceList, callback) {
468
- const origin = `${this.id}-adapter-hasDevices`;
469
- log.trace(origin);
470
-
471
- const findings = deviceList.reduce((map, device) => {
472
- // eslint-disable-next-line no-param-reassign
473
- map[device] = false;
474
- log.debug(`In reduce: ${JSON.stringify(map)}`);
475
- return map;
476
- }, {});
477
- const apiCalls = deviceList.map((device) => new Promise((resolve) => {
478
- this.getDevice(device, (result, error) => {
479
- if (error) {
480
- log.debug(`In map error: ${JSON.stringify(device)}`);
481
- return resolve({ name: device, found: false });
482
- }
483
- log.debug(`In map: ${JSON.stringify(device)}`);
484
- return resolve({ name: device, found: true });
485
- });
486
- }));
487
- Promise.all(apiCalls).then((results) => {
488
- results.forEach((device) => {
489
- findings[device.name] = device.found;
490
- });
491
- log.debug(`FINDINGS: ${JSON.stringify(findings)}`);
492
- return callback(findings);
493
- }).catch((errors) => {
494
- log.error('Unable to do device lookup.');
495
- return callback(null, { code: 503, message: 'Unable to do device lookup.', error: errors });
496
- });
497
- }
498
-
499
489
  /**
500
490
  * @summary Get Appliance that match the deviceName
501
491
  *
@@ -510,167 +500,11 @@ class Meraki extends AdapterBaseCl {
510
500
  const origin = `${this.id}-${meth}`;
511
501
  log.trace(origin);
512
502
 
513
- // make sure we are set up for device broker getDevice
514
- if (!this.props.devicebroker || !this.props.devicebroker.getDevice || !this.props.devicebroker.getDevice.path) {
515
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevice.path'], null, null, null);
516
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
517
- return callback(null, errorObj);
518
- }
519
-
520
- /* HERE IS WHERE YOU VALIDATE DATA */
521
- if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
522
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
523
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
524
- return callback(null, errorObj);
525
- }
526
-
527
503
  try {
528
- // need to get the device so we can convert the deviceName to an id
529
- // !! if we can do a lookup by name the getDevicesFiltered may not be necessary
530
- const opts = {
531
- filter: {
532
- name: deviceName
533
- }
534
- };
535
- return this.getDevicesFiltered(opts, (devs, ferr) => {
536
- // if we received an error or their is no response on the results return an error
537
- if (ferr) {
538
- return callback(null, ferr);
539
- }
540
- if (devs.list.length < 1) {
541
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
542
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
543
- return callback(null, errorObj);
544
- }
545
- // get the uuid from the device
546
- const { uuid } = devs.list[0];
547
-
548
- // !! using Generic makes it easier on the Adapter Builder (just need to change the path)
549
- // !! you can also replace with a specific call if that is easier
550
- let uriPath = '';
551
- let uriMethod = 'GET';
552
- let callQuery = {};
553
- let callBody = {};
554
- let callHeaders = {};
555
- let nameField = 'name';
556
- let nameArray = ['name'];
557
- let ostypeField = 'ostype';
558
- let ostypeArray = ['ostype'];
559
- let ostypePrefix = '';
560
- let portField = 'port';
561
- let portArray = ['port'];
562
- let ipField = 'ipaddress';
563
- let ipArray = ['ipaddress'];
564
- if (this.props.devicebroker.getDevice.path) {
565
- uriPath = `${this.props.devicebroker.getDevice.path}`;
566
- uriPath = uriPath.replace('{deviceid}', uuid);
567
- }
568
- if (this.props.devicebroker.getDevice.method) {
569
- uriMethod = this.props.devicebroker.getDevice.method;
570
- }
571
- if (this.props.devicebroker.getDevice.query) {
572
- try {
573
- callQuery = JSON.parse(this.props.devicebroker.getDevice.query);
574
- } catch (e) {
575
- log.warn('Could not parse query parameter for getDevice call');
576
- }
577
- }
578
- if (this.props.devicebroker.getDevice.body) {
579
- try {
580
- callBody = this.props.devicebroker.getDevice.body;
581
- } catch (e) {
582
- log.warn('Could not parse body for getDevice call');
583
- }
584
- }
585
- if (this.props.devicebroker.getDevice.headers) {
586
- try {
587
- callHeaders = this.props.devicebroker.getDevice.headers;
588
- } catch (e) {
589
- log.warn('Could not parse headers for getDevice call');
590
- }
591
- }
592
- if (this.props.devicebroker.getDevice.name_field) {
593
- nameField = this.props.devicebroker.getDevice.name_field;
594
- nameArray = nameField.split('.');
595
- }
596
- if (this.props.devicebroker.getDevice.ostype_field) {
597
- ostypeField = this.props.devicebroker.getDevice.ostype_field;
598
- ostypeArray = ostypeField.split('.');
599
- }
600
- if (this.props.devicebroker.getDevice.ostype_prefix) {
601
- ostypePrefix = this.props.devicebroker.getDevice.ostype_prefix;
602
- }
603
- if (this.props.devicebroker.getDevice.port_field) {
604
- portField = this.props.devicebroker.getDevice.port_field;
605
- portArray = portField.split('.');
606
- }
607
- if (this.props.devicebroker.getDevice.ip_field) {
608
- ipField = this.props.devicebroker.getDevice.ip_field;
609
- ipArray = ipField.split('.');
610
- }
611
-
612
- return this.genericAdapterRequest(uriPath, uriMethod, callQuery, callBody, callHeaders, (result, error) => {
613
- // if we received an error or their is no response on the results return an error
614
- if (error) {
615
- return callback(null, error);
616
- }
617
- if (!result.response) {
618
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevice'], null, null, null);
619
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
620
- return callback(null, errorObj);
621
- }
622
-
623
- // return the response
624
- // !! format the data we send back
625
- // !! these fields are config manager fields you need to map to the data we receive
626
- const thisDevice = result.response;
627
- let thisName = thisDevice;
628
- for (let i = 0; i < nameArray.length; i += 1) {
629
- if (!Object.hasOwnProperty.call(thisName, nameArray[i])) {
630
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
631
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
632
- return callback(null, errorObj);
633
- }
634
- thisName = thisName[nameArray[i]];
635
- }
636
- thisDevice.name = thisName;
637
- let thisOstype = thisDevice;
638
- for (let i = 0; i < ostypeArray.length; i += 1) {
639
- if (!Object.hasOwnProperty.call(thisOstype, ostypeArray[i])) {
640
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
641
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
642
- return callback(null, errorObj);
643
- }
644
- thisOstype = thisOstype[ostypeArray[i]];
645
- }
646
- thisDevice.ostype = ostypePrefix + thisOstype;
647
- let thisPort = thisDevice;
648
- for (let i = 0; i < portArray.length; i += 1) {
649
- if (!Object.hasOwnProperty.call(thisPort, portArray[i])) {
650
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
651
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
652
- return callback(null, errorObj);
653
- }
654
- thisPort = thisPort[portArray[i]];
655
- }
656
- thisDevice.port = thisPort;
657
- let thisIp = thisDevice;
658
- for (let i = 0; i < ipArray.length; i += 1) {
659
- if (!Object.hasOwnProperty.call(thisIp, ipArray[i])) {
660
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
661
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
662
- return callback(null, errorObj);
663
- }
664
- thisIp = thisIp[ipArray[i]];
665
- }
666
- thisDevice.ipaddress = thisIp;
667
- return callback(thisDevice);
668
- });
669
- });
670
- } catch (ex) {
671
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
672
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
673
- return callback(null, errorObj);
504
+ return super.getDevice(deviceName, callback);
505
+ } catch (err) {
506
+ log.error(`${origin}: ${err}`);
507
+ return callback(null, err);
674
508
  }
675
509
  }
676
510
 
@@ -688,267 +522,11 @@ class Meraki extends AdapterBaseCl {
688
522
  const origin = `${this.id}-${meth}`;
689
523
  log.trace(origin);
690
524
 
691
- // make sure we are set up for device broker getDevicesFiltered
692
- if (!this.props.devicebroker || !this.props.devicebroker.getDevicesFiltered || !this.props.devicebroker.getDevicesFiltered.path) {
693
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevicesFiltered.path'], null, null, null);
694
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
695
- return callback(null, errorObj);
696
- }
697
-
698
- // verify the required fields have been provided
699
- if (options === undefined || options === null || options === '' || options.length === 0) {
700
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['options'], null, null, null);
701
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
702
- return callback(null, errorObj);
703
- }
704
- log.debug(`Device Filter Options: ${JSON.stringify(options)}`);
705
-
706
- // TODO - get pagination working
707
- // const nextToken = options.start;
708
- // const maxResults = options.limit;
709
-
710
- // set up the filter of Device Names
711
- let filterName = [];
712
- if (options && options.filter && options.filter.name) {
713
- // when this hack is removed, remove the lint ignore above
714
- if (Array.isArray(options.filter.name)) {
715
- // eslint-disable-next-line prefer-destructuring
716
- filterName = options.filter.name;
717
- } else {
718
- filterName = [options.filter.name];
719
- }
720
- }
721
-
722
- // TODO - get sort and order working
723
- /*
724
- if (options && options.sort) {
725
- reqObj.uriOptions.sort = JSON.stringify(options.sort);
726
- }
727
- if (options && options.order) {
728
- reqObj.uriOptions.order = options.order;
729
- }
730
- */
731
525
  try {
732
- // !! using Generic makes it easier on the Adapter Builder (just need to change the path)
733
- // !! you can also replace with a specific call if that is easier
734
- let uriPath = '';
735
- let uriMethod = 'GET';
736
- let callQuery = {};
737
- let callBody = {};
738
- let callHeaders = {};
739
- let nameField = 'name';
740
- let nameArray = ['name'];
741
- let ostypeField = 'ostype';
742
- let ostypeArray = ['ostype'];
743
- let ostypePrefix = '';
744
- let portField = 'port';
745
- let portArray = ['port'];
746
- let ipField = 'ipaddress';
747
- let ipArray = ['ipaddress'];
748
- if (this.props.devicebroker.getDevicesFiltered.path) {
749
- uriPath = this.props.devicebroker.getDevicesFiltered.path;
750
- }
751
- if (this.props.devicebroker.getDevicesFiltered.method) {
752
- uriMethod = this.props.devicebroker.getDevicesFiltered.method;
753
- }
754
- if (this.props.devicebroker.getDevicesFiltered.query) {
755
- try {
756
- callQuery = this.props.devicebroker.getDevicesFiltered.query;
757
- } catch (e) {
758
- log.warn('Could not parse query parameter for getDevicesFiltered call');
759
- }
760
- }
761
- if (this.props.devicebroker.getDevicesFiltered.body) {
762
- try {
763
- callBody = this.props.devicebroker.getDevicesFiltered.body;
764
- } catch (e) {
765
- log.warn('Could not parse body for getDevicesFiltered call');
766
- }
767
- }
768
- if (this.props.devicebroker.getDevicesFiltered.headers) {
769
- try {
770
- callHeaders = this.props.devicebroker.getDevicesFiltered.headers;
771
- } catch (e) {
772
- log.warn('Could not parse headers for getDevicesFiltered call');
773
- }
774
- }
775
- if (this.props.devicebroker.getDevicesFiltered.name_field) {
776
- nameField = this.props.devicebroker.getDevicesFiltered.name_field;
777
- nameArray = nameField.split('.');
778
- }
779
- if (this.props.devicebroker.getDevicesFiltered.ostype_field) {
780
- ostypeField = this.props.devicebroker.getDevicesFiltered.ostype_field;
781
- ostypeArray = ostypeField.split('.');
782
- }
783
- if (this.props.devicebroker.getDevicesFiltered.ostype_prefix) {
784
- ostypePrefix = this.props.devicebroker.getDevicesFiltered.ostype_prefix;
785
- }
786
- if (this.props.devicebroker.getDevicesFiltered.port_field) {
787
- portField = this.props.devicebroker.getDevicesFiltered.port_field;
788
- portArray = portField.split('.');
789
- }
790
- if (this.props.devicebroker.getDevicesFiltered.ip_field) {
791
- ipField = this.props.devicebroker.getDevicesFiltered.ip_field;
792
- ipArray = ipField.split('.');
793
- }
794
-
795
- return this.genericAdapterRequest(uriPath, uriMethod, callQuery, callBody, callHeaders, (result, error) => {
796
- // if we received an error or their is no response on the results return an error
797
- if (error) {
798
- return callback(null, error);
799
- }
800
- if (!result.response) {
801
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
802
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
803
- return callback(null, errorObj);
804
- }
805
-
806
- // !! go through the response - may have to look for sub object
807
- // handle an array of devices
808
- if (Array.isArray(result.response)) {
809
- const myDevices = [];
810
-
811
- for (let d = 0; d < result.response.length; d += 1) {
812
- // !! format the data we send back
813
- // !! these fields are config manager fields you need to map to the data we receive
814
- const thisDevice = result.response;
815
- let thisName = thisDevice;
816
- for (let i = 0; i < nameArray.length; i += 1) {
817
- if (!Object.hasOwnProperty.call(thisName, nameArray[i])) {
818
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
819
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
820
- return callback(null, errorObj);
821
- }
822
- thisName = thisName[nameArray[i]];
823
- }
824
- thisDevice.name = thisName;
825
- let thisOstype = thisDevice;
826
- for (let i = 0; i < ostypeArray.length; i += 1) {
827
- if (!Object.hasOwnProperty.call(thisOstype, ostypeArray[i])) {
828
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
829
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
830
- return callback(null, errorObj);
831
- }
832
- thisOstype = thisOstype[ostypeArray[i]];
833
- }
834
- thisDevice.ostype = ostypePrefix + thisOstype;
835
- let thisPort = thisDevice;
836
- for (let i = 0; i < portArray.length; i += 1) {
837
- if (!Object.hasOwnProperty.call(thisPort, portArray[i])) {
838
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
839
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
840
- return callback(null, errorObj);
841
- }
842
- thisPort = thisPort[portArray[i]];
843
- }
844
- thisDevice.port = thisPort;
845
- let thisIp = thisDevice;
846
- for (let i = 0; i < ipArray.length; i += 1) {
847
- if (!Object.hasOwnProperty.call(thisIp, ipArray[i])) {
848
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
849
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
850
- return callback(null, errorObj);
851
- }
852
- thisIp = thisIp[ipArray[i]];
853
- }
854
- thisDevice.ipaddress = thisIp;
855
-
856
- // if there is no filter - return the device
857
- if (filterName.length === 0) {
858
- myDevices.push(thisDevice);
859
- } else {
860
- // if we have to match a filter
861
- let found = false;
862
- for (let f = 0; f < filterName.length; f += 1) {
863
- if (thisDevice.name.indexOf(filterName[f]) >= 0) {
864
- found = true;
865
- break;
866
- }
867
- }
868
- // matching device
869
- if (found) {
870
- myDevices.push(thisDevice);
871
- }
872
- }
873
- }
874
- log.debug(`${origin}: Found #${myDevices.length} devices.`);
875
- log.debug(`Devices: ${JSON.stringify(myDevices)}`);
876
- return callback({ total: myDevices.length, list: myDevices });
877
- }
878
- // handle a single device response
879
- // !! format the data we send back
880
- // !! these fields are config manager fields you need to map to the data we receive
881
- const thisDevice = result.response;
882
- let thisName = thisDevice;
883
- for (let i = 0; i < nameArray.length; i += 1) {
884
- if (!Object.hasOwnProperty.call(thisName, nameArray[i])) {
885
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
886
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
887
- return callback(null, errorObj);
888
- }
889
- thisName = thisName[nameArray[i]];
890
- }
891
- thisDevice.name = thisName;
892
- let thisOstype = thisDevice;
893
- for (let i = 0; i < ostypeArray.length; i += 1) {
894
- if (!Object.hasOwnProperty.call(thisOstype, ostypeArray[i])) {
895
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
896
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
897
- return callback(null, errorObj);
898
- }
899
- thisOstype = thisOstype[ostypeArray[i]];
900
- }
901
- thisDevice.ostype = ostypePrefix + thisOstype;
902
- let thisPort = thisDevice;
903
- for (let i = 0; i < portArray.length; i += 1) {
904
- if (!Object.hasOwnProperty.call(thisPort, portArray[i])) {
905
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
906
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
907
- return callback(null, errorObj);
908
- }
909
- thisPort = thisPort[portArray[i]];
910
- }
911
- thisDevice.port = thisPort;
912
- let thisIp = thisDevice;
913
- for (let i = 0; i < ipArray.length; i += 1) {
914
- if (!Object.hasOwnProperty.call(thisIp, ipArray[i])) {
915
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
916
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
917
- return callback(null, errorObj);
918
- }
919
- thisIp = thisIp[ipArray[i]];
920
- }
921
- thisDevice.ipaddress = thisIp;
922
-
923
- // if there is no filter - return the device
924
- if (filterName.length === 0) {
925
- log.debug(`${origin}: Found #1 device.`);
926
- log.debug(`Device: ${JSON.stringify(thisDevice)}`);
927
- return callback({ total: 1, list: [thisDevice] });
928
- }
929
-
930
- // if there is a filter need to check for matching device
931
- let found = false;
932
- for (let f = 0; f < filterName.length; f += 1) {
933
- if (thisDevice.name.indexOf(filterName[f]) >= 0) {
934
- found = true;
935
- break;
936
- }
937
- }
938
- // matching device
939
- if (found) {
940
- log.debug(`${origin}: Found #1 device.`);
941
- log.debug(`Device Found: ${JSON.stringify(thisDevice)}`);
942
- return callback({ total: 1, list: [thisDevice] });
943
- }
944
- // not a matching device
945
- log.debug(`${origin}: No matching device found.`);
946
- return callback({ total: 0, list: [] });
947
- });
948
- } catch (ex) {
949
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
950
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
951
- return callback(null, errorObj);
526
+ return super.getDevicesFiltered(options, callback);
527
+ } catch (err) {
528
+ log.error(`${origin}: ${err}`);
529
+ return callback(null, err);
952
530
  }
953
531
  }
954
532
 
@@ -966,121 +544,11 @@ class Meraki extends AdapterBaseCl {
966
544
  const origin = `${this.id}-${meth}`;
967
545
  log.trace(origin);
968
546
 
969
- // make sure we are set up for device broker isAlive
970
- if (!this.props.devicebroker || !this.props.devicebroker.isAlive || !this.props.devicebroker.isAlive.path) {
971
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.isAlive.path'], null, null, null);
972
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
973
- return callback(null, errorObj);
974
- }
975
-
976
- // verify the required fields have been provided
977
- if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
978
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
979
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
980
- return callback(null, errorObj);
981
- }
982
-
983
547
  try {
984
- // need to get the device so we can convert the deviceName to an id
985
- // !! if we can do a lookup by name the getDevicesFiltered may not be necessary
986
- const opts = {
987
- filter: {
988
- name: deviceName
989
- }
990
- };
991
- return this.getDevicesFiltered(opts, (devs, ferr) => {
992
- // if we received an error or their is no response on the results return an error
993
- if (ferr) {
994
- return callback(null, ferr);
995
- }
996
- if (devs.list.length < 1) {
997
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
998
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
999
- return callback(null, errorObj);
1000
- }
1001
- // get the uuid from the device
1002
- const { uuid } = devs.list[0];
1003
-
1004
- // !! using Generic makes it easier on the Adapter Builder (just need to change the path)
1005
- // !! you can also replace with a specific call if that is easier
1006
- let uriPath = '';
1007
- let uriMethod = 'GET';
1008
- let callQuery = {};
1009
- let callBody = {};
1010
- let callHeaders = {};
1011
- let statusField = 'status';
1012
- let statusArray = ['status'];
1013
- let statusValue = 'true';
1014
- if (this.props.devicebroker.isAlive.path) {
1015
- uriPath = `${this.props.devicebroker.isAlive.path}`;
1016
- uriPath = uriPath.replace('{deviceid}', uuid);
1017
- }
1018
- if (this.props.devicebroker.isAlive.method) {
1019
- uriMethod = this.props.devicebroker.isAlive.method;
1020
- }
1021
- if (this.props.devicebroker.isAlive.query) {
1022
- try {
1023
- callQuery = this.props.devicebroker.isAlive.query;
1024
- } catch (e) {
1025
- log.warn('Could not parse query parameter for isAlive call');
1026
- }
1027
- }
1028
- if (this.props.devicebroker.isAlive.body) {
1029
- try {
1030
- callBody = this.props.devicebroker.isAlive.body;
1031
- } catch (e) {
1032
- log.warn('Could not parse body for isAlive call');
1033
- }
1034
- }
1035
- if (this.props.devicebroker.isAlive.headers) {
1036
- try {
1037
- callHeaders = this.props.devicebroker.isAlive.headers;
1038
- } catch (e) {
1039
- log.warn('Could not parse headers for isAlive call');
1040
- }
1041
- }
1042
- if (this.props.devicebroker.isAlive.response && this.props.devicebroker.isAlive.status_field) {
1043
- statusField = this.props.devicebroker.isAlive.status_field;
1044
- statusArray = statusField.split('.');
1045
- }
1046
- if (this.props.devicebroker.isAlive.response && this.props.devicebroker.isAlive.status_value) {
1047
- statusValue = this.props.devicebroker.isAlive.response.status_value;
1048
- }
1049
-
1050
- return this.genericAdapterRequest(uriPath, uriMethod, callQuery, callBody, callHeaders, (result, error) => {
1051
- // if we received an error or their is no response on the results return an error
1052
- if (error) {
1053
- return callback(null, error);
1054
- }
1055
-
1056
- // !! should update this to make sure we are checking for the appropriate object/field
1057
- if (!result.response || !result.response.returnObj) {
1058
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['isAlive'], null, null, null);
1059
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1060
- return callback(null, errorObj);
1061
- }
1062
- let thisObj = result.response.returnObj;
1063
- for (let i = 0; i < statusArray.length; i += 1) {
1064
- if (!Object.hasOwnProperty.call(thisObj, statusArray[i])) {
1065
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['isAlive'], null, null, null);
1066
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1067
- return callback(null, errorObj);
1068
- }
1069
- thisObj = thisObj[statusArray[i]];
1070
- }
1071
-
1072
- // !! return the response - Update to the appropriate object/field
1073
- let response = true;
1074
- if (thisObj.toString() !== statusValue) {
1075
- response = false;
1076
- }
1077
- return callback(response);
1078
- });
1079
- });
1080
- } catch (ex) {
1081
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1082
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1083
- return callback(null, errorObj);
548
+ return super.isAlive(deviceName, callback);
549
+ } catch (err) {
550
+ log.error(`${origin}: ${err}`);
551
+ return callback(null, err);
1084
552
  }
1085
553
  }
1086
554
 
@@ -1099,94 +567,11 @@ class Meraki extends AdapterBaseCl {
1099
567
  const origin = `${this.id}-${meth}`;
1100
568
  log.trace(origin);
1101
569
 
1102
- // make sure we are set up for device broker getConfig
1103
- if (!this.props.devicebroker || !this.props.devicebroker.getConfig || !this.props.devicebroker.getConfig.path) {
1104
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getConfig.path'], null, null, null);
1105
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1106
- return callback(null, errorObj);
1107
- }
1108
-
1109
- // verify the required fields have been provided
1110
- if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
1111
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
1112
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1113
- return callback(null, errorObj);
1114
- }
1115
-
1116
570
  try {
1117
- // need to get the device so we can convert the deviceName to an id
1118
- // !! if we can do a lookup by name the getDevicesFiltered may not be necessary
1119
- const opts = {
1120
- filter: {
1121
- name: deviceName
1122
- }
1123
- };
1124
- return this.getDevicesFiltered(opts, (devs, ferr) => {
1125
- // if we received an error or their is no response on the results return an error
1126
- if (ferr) {
1127
- return callback(null, ferr);
1128
- }
1129
- if (devs.list.length < 1) {
1130
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
1131
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1132
- return callback(null, errorObj);
1133
- }
1134
- // get the uuid from the device
1135
- const { uuid } = devs.list[0];
1136
-
1137
- // !! using Generic makes it easier on the Adapter Builder (just need to change the path)
1138
- // !! you can also replace with a specific call if that is easier
1139
- let uriPath = '';
1140
- let uriMethod = 'GET';
1141
- let callQuery = {};
1142
- let callBody = {};
1143
- let callHeaders = {};
1144
- if (this.props.devicebroker.getConfig.path) {
1145
- uriPath = `${this.props.devicebroker.getConfig.path}`;
1146
- uriPath = uriPath.replace('{deviceid}', uuid);
1147
- }
1148
- if (this.props.devicebroker.getConfig.method) {
1149
- uriMethod = this.props.devicebroker.getConfig.method;
1150
- }
1151
- if (this.props.devicebroker.getConfig.query) {
1152
- try {
1153
- callQuery = this.props.devicebroker.getConfig.query;
1154
- } catch (e) {
1155
- log.warn('Could not parse query parameter for getConfig call');
1156
- }
1157
- }
1158
- if (this.props.devicebroker.getConfig.body) {
1159
- try {
1160
- callBody = this.props.devicebroker.getConfig.body;
1161
- } catch (e) {
1162
- log.warn('Could not parse body for getConfig call');
1163
- }
1164
- }
1165
- if (this.props.devicebroker.getConfig.headers) {
1166
- try {
1167
- callHeaders = this.props.devicebroker.getConfig.headers;
1168
- } catch (e) {
1169
- log.warn('Could not parse headers for getConfig call');
1170
- }
1171
- }
1172
-
1173
- return this.genericAdapterRequest(uriPath, uriMethod, callQuery, callBody, callHeaders, (result, error) => {
1174
- // if we received an error or their is no response on the results return an error
1175
- if (error) {
1176
- return callback(null, error);
1177
- }
1178
-
1179
- // return the result
1180
- const newResponse = {
1181
- response: JSON.stringify(result.response, null, 2)
1182
- };
1183
- return callback(newResponse);
1184
- });
1185
- });
1186
- } catch (ex) {
1187
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1188
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1189
- return callback(null, errorObj);
571
+ return super.getConfig(deviceName, format, callback);
572
+ } catch (err) {
573
+ log.error(`${origin}: ${err}`);
574
+ return callback(null, err);
1190
575
  }
1191
576
  }
1192
577
 
@@ -1203,59 +588,117 @@ class Meraki extends AdapterBaseCl {
1203
588
  const origin = `${this.id}-${meth}`;
1204
589
  log.trace(origin);
1205
590
 
1206
- // make sure we are set up for device broker getCount
1207
- if (!this.props.devicebroker || !this.props.devicebroker.getCount || !this.props.devicebroker.getCount.path) {
1208
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getCount.path'], null, null, null);
591
+ try {
592
+ return super.iapGetDeviceCount(callback);
593
+ } catch (err) {
594
+ log.error(`${origin}: ${err}`);
595
+ return callback(null, err);
596
+ }
597
+ }
598
+
599
+ /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
600
+ /**
601
+ * Makes the requested generic call
602
+ *
603
+ * @function genericAdapterRequest
604
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
605
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
606
+ * @param {Object} queryData - the parameters to be put on the url (optional).
607
+ * Can be a stringified Object.
608
+ * @param {Object} requestBody - the body to add to the request (optional).
609
+ * Can be a stringified Object.
610
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
611
+ * Can be a stringified Object.
612
+ * @param {getCallback} callback - a callback function to return the result (Generics)
613
+ * or the error
614
+ */
615
+ genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
616
+ const meth = 'adapter-genericAdapterRequest';
617
+ const origin = `${this.id}-${meth}`;
618
+ log.trace(origin);
619
+
620
+ if (this.suspended && this.suspendMode === 'error') {
621
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
622
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
623
+ return callback(null, errorObj);
624
+ }
625
+
626
+ /* HERE IS WHERE YOU VALIDATE DATA */
627
+ if (uriPath === undefined || uriPath === null || uriPath === '') {
628
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
629
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
630
+ return callback(null, errorObj);
631
+ }
632
+ if (restMethod === undefined || restMethod === null || restMethod === '') {
633
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
1209
634
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1210
635
  return callback(null, errorObj);
1211
636
  }
1212
637
 
1213
- // verify the required fields have been provided
638
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
639
+ // remove any leading / and split the uripath into path variables
640
+ let myPath = uriPath;
641
+ while (myPath.indexOf('/') === 0) {
642
+ myPath = myPath.substring(1);
643
+ }
644
+ const pathVars = myPath.split('/');
645
+ const queryParamsAvailable = queryData;
646
+ const queryParams = {};
647
+ const bodyVars = requestBody;
1214
648
 
1215
- try {
1216
- // !! using Generic makes it easier on the Adapter Builder (just need to set the path or call in properties)
1217
- // !! you can also replace with a specific call if that is easier
1218
- let uriPath = '';
1219
- let uriMethod = 'GET';
1220
- let callQuery = {};
1221
- let callBody = {};
1222
- let callHeaders = {};
1223
- if (this.props.devicebroker.getCount.path) {
1224
- uriPath = this.props.devicebroker.getCount.path;
1225
- }
1226
- if (this.props.devicebroker.getCount.method) {
1227
- uriMethod = this.props.devicebroker.getCount.method;
1228
- }
1229
- if (this.props.devicebroker.getCount.query) {
1230
- try {
1231
- callQuery = this.props.devicebroker.getCount.query;
1232
- } catch (e) {
1233
- log.warn('Could not parse query parameter for getCount call');
1234
- }
1235
- }
1236
- if (this.props.devicebroker.getCount.body) {
1237
- try {
1238
- callBody = this.props.devicebroker.getCount.body;
1239
- } catch (e) {
1240
- log.warn('Could not parse body for getCount call');
1241
- }
1242
- }
1243
- if (this.props.devicebroker.getCount.headers) {
1244
- try {
1245
- callHeaders = this.props.devicebroker.getCount.headers;
1246
- } catch (e) {
1247
- log.warn('Could not parse headers for getCount call');
1248
- }
649
+ // loop in template. long callback arg name to avoid identifier conflicts
650
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
651
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
652
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
653
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1249
654
  }
655
+ });
1250
656
 
1251
- return this.genericAdapterRequest(uriPath, uriMethod, callQuery, callBody, callHeaders, (result, error) => {
1252
- // if we received an error or their is no response on the results return an error
1253
- if (error) {
1254
- return callback(null, error);
657
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
658
+ const reqObj = {
659
+ payload: bodyVars,
660
+ uriPathVars: pathVars,
661
+ uriQuery: queryParams,
662
+ uriOptions: {}
663
+ };
664
+ // add headers if provided
665
+ if (addlHeaders) {
666
+ reqObj.addlHeaders = addlHeaders;
667
+ }
668
+
669
+ // determine the call and return flag
670
+ let action = 'getGenerics';
671
+ let returnF = true;
672
+ if (restMethod.toUpperCase() === 'POST') {
673
+ action = 'createGeneric';
674
+ } else if (restMethod.toUpperCase() === 'PUT') {
675
+ action = 'updateGeneric';
676
+ } else if (restMethod.toUpperCase() === 'PATCH') {
677
+ action = 'patchGeneric';
678
+ } else if (restMethod.toUpperCase() === 'DELETE') {
679
+ action = 'deleteGeneric';
680
+ returnF = false;
681
+ }
682
+
683
+ try {
684
+ // Make the call -
685
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
686
+ return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
687
+ // if we received an error or their is no response on the results
688
+ // return an error
689
+ if (irReturnError) {
690
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
691
+ return callback(null, irReturnError);
692
+ }
693
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
694
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
695
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
696
+ return callback(null, errorObj);
1255
697
  }
1256
698
 
1257
- // return the result
1258
- return callback({ count: result.response });
699
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
700
+ // return the response
701
+ return callback(irReturnData, null);
1259
702
  });
1260
703
  } catch (ex) {
1261
704
  const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
@@ -1264,11 +707,10 @@ class Meraki extends AdapterBaseCl {
1264
707
  }
1265
708
  }
1266
709
 
1267
- /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
1268
710
  /**
1269
- * Makes the requested generic call
711
+ * Makes the requested generic call with no base path or version
1270
712
  *
1271
- * @function genericAdapterRequest
713
+ * @function genericAdapterRequestNoBasePath
1272
714
  * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
1273
715
  * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
1274
716
  * @param {Object} queryData - the parameters to be put on the url (optional).
@@ -1280,8 +722,8 @@ class Meraki extends AdapterBaseCl {
1280
722
  * @param {getCallback} callback - a callback function to return the result (Generics)
1281
723
  * or the error
1282
724
  */
1283
- genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
1284
- const meth = 'adapter-genericAdapterRequest';
725
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
726
+ const meth = 'adapter-genericAdapterRequestNoBasePath';
1285
727
  const origin = `${this.id}-${meth}`;
1286
728
  log.trace(origin);
1287
729
 
@@ -1335,16 +777,16 @@ class Meraki extends AdapterBaseCl {
1335
777
  }
1336
778
 
1337
779
  // determine the call and return flag
1338
- let action = 'getGenerics';
780
+ let action = 'getGenericsNoBase';
1339
781
  let returnF = true;
1340
782
  if (restMethod.toUpperCase() === 'POST') {
1341
- action = 'createGeneric';
783
+ action = 'createGenericNoBase';
1342
784
  } else if (restMethod.toUpperCase() === 'PUT') {
1343
- action = 'updateGeneric';
785
+ action = 'updateGenericNoBase';
1344
786
  } else if (restMethod.toUpperCase() === 'PATCH') {
1345
- action = 'patchGeneric';
787
+ action = 'patchGenericNoBase';
1346
788
  } else if (restMethod.toUpperCase() === 'DELETE') {
1347
- action = 'deleteGeneric';
789
+ action = 'deleteGenericNoBase';
1348
790
  returnF = false;
1349
791
  }
1350
792
 
@@ -1359,7 +801,7 @@ class Meraki extends AdapterBaseCl {
1359
801
  return callback(null, irReturnError);
1360
802
  }
1361
803
  if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1362
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
804
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
1363
805
  log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1364
806
  return callback(null, errorObj);
1365
807
  }