@itentialopensource/adapter-meraki 0.8.0 → 0.8.3
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/AUTH.md +39 -0
- package/BROKER.md +195 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +24 -0
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +221 -571
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +291 -471
- package/adapterBase.js +973 -252
- package/entities/.generic/action.json +105 -0
- package/entities/.generic/schema.json +6 -1
- package/error.json +6 -0
- package/package.json +4 -3
- package/pronghorn.json +170 -98
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +380 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/updateReport1651511176919.json +115 -0
- package/sampleProperties.json +82 -0
- package/test/integration/adapterTestIntegration.js +1 -0
- package/test/unit/adapterBaseTestUnit.js +30 -25
- package/test/unit/adapterTestUnit.js +61 -65
- package/utils/adapterInfo.js +206 -0
- package/utils/pre-commit.sh +3 -0
- package/utils/tbUtils.js +20 -7
package/adapter.js
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
/* eslint import/no-dynamic-require: warn */
|
4
4
|
/* eslint object-curly-newline: warn */
|
5
|
-
/* eslint no-underscore-dangle: warn */
|
6
|
-
/* eslint camelcase: warn */
|
7
5
|
|
8
6
|
// Set globals
|
9
7
|
/* global log */
|
@@ -82,10 +80,17 @@ class Meraki extends AdapterBaseCl {
|
|
82
80
|
}
|
83
81
|
|
84
82
|
/**
|
85
|
-
* @
|
83
|
+
* @iapGetAdapterWorkflowFunctions
|
86
84
|
*/
|
87
|
-
|
88
|
-
let myIgnore = [
|
85
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
86
|
+
let myIgnore = [
|
87
|
+
'healthCheck',
|
88
|
+
'iapGetAdapterWorkflowFunctions',
|
89
|
+
'iapHasAdapterEntity',
|
90
|
+
'iapVerifyAdapterCapability',
|
91
|
+
'iapUpdateAdapterEntityCache',
|
92
|
+
'hasEntities'
|
93
|
+
];
|
89
94
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
90
95
|
myIgnore = inIgnore;
|
91
96
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
@@ -96,15 +101,15 @@ class Meraki extends AdapterBaseCl {
|
|
96
101
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
97
102
|
// myIgnore.push('myMethodNotInWorkflow');
|
98
103
|
|
99
|
-
return super.
|
104
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
100
105
|
}
|
101
106
|
|
102
107
|
/**
|
103
|
-
*
|
108
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
104
109
|
* allows customers to make changes to adapter configuration without having to be on the
|
105
110
|
* file system.
|
106
111
|
*
|
107
|
-
* @function
|
112
|
+
* @function iapUpdateAdapterConfiguration
|
108
113
|
* @param {string} configFile - the name of the file being updated (required)
|
109
114
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
110
115
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
@@ -112,36 +117,42 @@ class Meraki extends AdapterBaseCl {
|
|
112
117
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
113
118
|
* @param {Callback} callback - The results of the call
|
114
119
|
*/
|
115
|
-
|
116
|
-
const
|
120
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
121
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
122
|
+
const origin = `${this.id}-${meth}`;
|
117
123
|
log.trace(origin);
|
118
|
-
|
124
|
+
|
125
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
119
126
|
}
|
120
127
|
|
121
128
|
/**
|
122
129
|
* See if the API path provided is found in this adapter
|
123
130
|
*
|
124
|
-
* @function
|
131
|
+
* @function iapFindAdapterPath
|
125
132
|
* @param {string} apiPath - the api path to check on
|
126
133
|
* @param {Callback} callback - The results of the call
|
127
134
|
*/
|
128
|
-
|
129
|
-
const
|
135
|
+
iapFindAdapterPath(apiPath, callback) {
|
136
|
+
const meth = 'adapter-iapFindAdapterPath';
|
137
|
+
const origin = `${this.id}-${meth}`;
|
130
138
|
log.trace(origin);
|
131
|
-
|
139
|
+
|
140
|
+
super.iapFindAdapterPath(apiPath, callback);
|
132
141
|
}
|
133
142
|
|
134
143
|
/**
|
135
144
|
* @summary Suspends adapter
|
136
145
|
*
|
137
|
-
* @function
|
146
|
+
* @function iapSuspendAdapter
|
138
147
|
* @param {Callback} callback - callback function
|
139
148
|
*/
|
140
|
-
|
141
|
-
const
|
149
|
+
iapSuspendAdapter(mode, callback) {
|
150
|
+
const meth = 'adapter-iapSuspendAdapter';
|
151
|
+
const origin = `${this.id}-${meth}`;
|
142
152
|
log.trace(origin);
|
153
|
+
|
143
154
|
try {
|
144
|
-
return super.
|
155
|
+
return super.iapSuspendAdapter(mode, callback);
|
145
156
|
} catch (error) {
|
146
157
|
log.error(`${origin}: ${error}`);
|
147
158
|
return callback(null, error);
|
@@ -151,14 +162,16 @@ class Meraki extends AdapterBaseCl {
|
|
151
162
|
/**
|
152
163
|
* @summary Unsuspends adapter
|
153
164
|
*
|
154
|
-
* @function
|
165
|
+
* @function iapUnsuspendAdapter
|
155
166
|
* @param {Callback} callback - callback function
|
156
167
|
*/
|
157
|
-
|
158
|
-
const
|
168
|
+
iapUnsuspendAdapter(callback) {
|
169
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
170
|
+
const origin = `${this.id}-${meth}`;
|
159
171
|
log.trace(origin);
|
172
|
+
|
160
173
|
try {
|
161
|
-
return super.
|
174
|
+
return super.iapUnsuspendAdapter(callback);
|
162
175
|
} catch (error) {
|
163
176
|
log.error(`${origin}: ${error}`);
|
164
177
|
return callback(null, error);
|
@@ -168,29 +181,33 @@ class Meraki extends AdapterBaseCl {
|
|
168
181
|
/**
|
169
182
|
* @summary Get the Adaoter Queue
|
170
183
|
*
|
171
|
-
* @function
|
184
|
+
* @function iapGetAdapterQueue
|
172
185
|
* @param {Callback} callback - callback function
|
173
186
|
*/
|
174
|
-
|
175
|
-
const
|
187
|
+
iapGetAdapterQueue(callback) {
|
188
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
189
|
+
const origin = `${this.id}-${meth}`;
|
176
190
|
log.trace(origin);
|
177
|
-
|
191
|
+
|
192
|
+
return super.iapGetAdapterQueue(callback);
|
178
193
|
}
|
179
194
|
|
180
195
|
/**
|
181
196
|
* @summary Runs troubleshoot scripts for adapter
|
182
197
|
*
|
183
|
-
* @function
|
198
|
+
* @function iapTroubleshootAdapter
|
184
199
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
185
200
|
*
|
186
201
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
187
202
|
* @param {Callback} callback - The results of the call
|
188
203
|
*/
|
189
|
-
|
190
|
-
const
|
204
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
205
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
206
|
+
const origin = `${this.id}-${meth}`;
|
191
207
|
log.trace(origin);
|
208
|
+
|
192
209
|
try {
|
193
|
-
return super.
|
210
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
194
211
|
} catch (error) {
|
195
212
|
log.error(`${origin}: ${error}`);
|
196
213
|
return callback(null, error);
|
@@ -200,15 +217,17 @@ class Meraki extends AdapterBaseCl {
|
|
200
217
|
/**
|
201
218
|
* @summary runs healthcheck script for adapter
|
202
219
|
*
|
203
|
-
* @function
|
220
|
+
* @function iapRunAdapterHealthcheck
|
204
221
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
205
222
|
* @param {Callback} callback - callback function
|
206
223
|
*/
|
207
|
-
|
208
|
-
const
|
224
|
+
iapRunAdapterHealthcheck(callback) {
|
225
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
226
|
+
const origin = `${this.id}-${meth}`;
|
209
227
|
log.trace(origin);
|
228
|
+
|
210
229
|
try {
|
211
|
-
return super.
|
230
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
212
231
|
} catch (error) {
|
213
232
|
log.error(`${origin}: ${error}`);
|
214
233
|
return callback(null, error);
|
@@ -218,14 +237,16 @@ class Meraki extends AdapterBaseCl {
|
|
218
237
|
/**
|
219
238
|
* @summary runs connectivity check script for adapter
|
220
239
|
*
|
221
|
-
* @function
|
240
|
+
* @function iapRunAdapterConnectivity
|
222
241
|
* @param {Callback} callback - callback function
|
223
242
|
*/
|
224
|
-
|
225
|
-
const
|
243
|
+
iapRunAdapterConnectivity(callback) {
|
244
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
245
|
+
const origin = `${this.id}-${meth}`;
|
226
246
|
log.trace(origin);
|
247
|
+
|
227
248
|
try {
|
228
|
-
return super.
|
249
|
+
return super.iapRunAdapterConnectivity(callback);
|
229
250
|
} catch (error) {
|
230
251
|
log.error(`${origin}: ${error}`);
|
231
252
|
return callback(null, error);
|
@@ -235,14 +256,16 @@ class Meraki extends AdapterBaseCl {
|
|
235
256
|
/**
|
236
257
|
* @summary runs basicGet script for adapter
|
237
258
|
*
|
238
|
-
* @function
|
259
|
+
* @function iapRunAdapterBasicGet
|
239
260
|
* @param {Callback} callback - callback function
|
240
261
|
*/
|
241
|
-
|
242
|
-
const
|
262
|
+
iapRunAdapterBasicGet(callback) {
|
263
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
264
|
+
const origin = `${this.id}-${meth}`;
|
243
265
|
log.trace(origin);
|
266
|
+
|
244
267
|
try {
|
245
|
-
return super.
|
268
|
+
return super.iapRunAdapterBasicGet(callback);
|
246
269
|
} catch (error) {
|
247
270
|
log.error(`${origin}: ${error}`);
|
248
271
|
return callback(null, error);
|
@@ -252,45 +275,48 @@ class Meraki extends AdapterBaseCl {
|
|
252
275
|
/**
|
253
276
|
* @summary moves entites into Mongo DB
|
254
277
|
*
|
255
|
-
* @function
|
278
|
+
* @function iapMoveAdapterEntitiesToDB
|
256
279
|
* @param {getCallback} callback - a callback function to return the result (Generics)
|
257
280
|
* or the error
|
258
281
|
*/
|
259
|
-
|
260
|
-
const
|
282
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
283
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
284
|
+
const origin = `${this.id}-${meth}`;
|
261
285
|
log.trace(origin);
|
286
|
+
|
262
287
|
try {
|
263
|
-
return super.
|
288
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
264
289
|
} catch (err) {
|
265
290
|
log.error(`${origin}: ${err}`);
|
266
291
|
return callback(null, err);
|
267
292
|
}
|
268
293
|
}
|
269
294
|
|
295
|
+
/* BROKER CALLS */
|
270
296
|
/**
|
271
297
|
* @summary Determines if this adapter supports the specific entity
|
272
298
|
*
|
273
|
-
* @function
|
299
|
+
* @function iapHasAdapterEntity
|
274
300
|
* @param {String} entityType - the entity type to check for
|
275
301
|
* @param {String/Array} entityId - the specific entity we are looking for
|
276
302
|
*
|
277
303
|
* @param {Callback} callback - An array of whether the adapter can has the
|
278
304
|
* desired capability or an error
|
279
305
|
*/
|
280
|
-
|
281
|
-
const origin = `${this.id}-adapter-
|
306
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
307
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
282
308
|
log.trace(origin);
|
283
309
|
|
284
310
|
// Make the call -
|
285
|
-
//
|
286
|
-
return this.
|
311
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
312
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
287
313
|
}
|
288
314
|
|
289
315
|
/**
|
290
316
|
* @summary Provides a way for the adapter to tell north bound integrations
|
291
317
|
* whether the adapter supports type, action and specific entity
|
292
318
|
*
|
293
|
-
* @function
|
319
|
+
* @function iapVerifyAdapterCapability
|
294
320
|
* @param {String} entityType - the entity type to check for
|
295
321
|
* @param {String} actionType - the action type to check for
|
296
322
|
* @param {String/Array} entityId - the specific entity we are looking for
|
@@ -298,15 +324,15 @@ class Meraki extends AdapterBaseCl {
|
|
298
324
|
* @param {Callback} callback - An array of whether the adapter can has the
|
299
325
|
* desired capability or an error
|
300
326
|
*/
|
301
|
-
|
302
|
-
const meth = 'adapterBase-
|
327
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
328
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
303
329
|
const origin = `${this.id}-${meth}`;
|
304
330
|
log.trace(origin);
|
305
331
|
|
306
332
|
// if caching
|
307
333
|
if (this.caching) {
|
308
|
-
// Make the call -
|
309
|
-
return this.requestHandlerInst.
|
334
|
+
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
335
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
310
336
|
if (error) {
|
311
337
|
return callback(null, error);
|
312
338
|
}
|
@@ -324,7 +350,7 @@ class Meraki extends AdapterBaseCl {
|
|
324
350
|
}
|
325
351
|
|
326
352
|
// need to check the cache again since it has been updated
|
327
|
-
return this.requestHandlerInst.
|
353
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
328
354
|
if (verror) {
|
329
355
|
return callback(null, verror);
|
330
356
|
}
|
@@ -357,7 +383,7 @@ class Meraki extends AdapterBaseCl {
|
|
357
383
|
// if no entity id
|
358
384
|
if (!entityId) {
|
359
385
|
// need to check the cache again since it has been updated
|
360
|
-
return this.requestHandlerInst.
|
386
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
361
387
|
if (verror) {
|
362
388
|
return callback(null, verror);
|
363
389
|
}
|
@@ -378,7 +404,7 @@ class Meraki extends AdapterBaseCl {
|
|
378
404
|
}
|
379
405
|
|
380
406
|
// need to check the cache again since it has been updated
|
381
|
-
return this.requestHandlerInst.
|
407
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
382
408
|
if (verror) {
|
383
409
|
return callback(null, verror);
|
384
410
|
}
|
@@ -419,11 +445,11 @@ class Meraki extends AdapterBaseCl {
|
|
419
445
|
/**
|
420
446
|
* @summary Updates the cache for all entities by call the get All entity method
|
421
447
|
*
|
422
|
-
* @function
|
448
|
+
* @function iapUpdateAdapterEntityCache
|
423
449
|
*
|
424
450
|
*/
|
425
|
-
|
426
|
-
const origin = `${this.id}-adapter-
|
451
|
+
iapUpdateAdapterEntityCache() {
|
452
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
427
453
|
log.trace(origin);
|
428
454
|
|
429
455
|
if (this.caching) {
|
@@ -436,6 +462,140 @@ class Meraki extends AdapterBaseCl {
|
|
436
462
|
}
|
437
463
|
}
|
438
464
|
|
465
|
+
/**
|
466
|
+
* @summary Determines if this adapter supports any in a list of entities
|
467
|
+
*
|
468
|
+
* @function hasEntities
|
469
|
+
* @param {String} entityType - the entity type to check for
|
470
|
+
* @param {Array} entityList - the list of entities we are looking for
|
471
|
+
*
|
472
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
473
|
+
* value is true or false
|
474
|
+
*/
|
475
|
+
hasEntities(entityType, entityList, callback) {
|
476
|
+
const meth = 'adapter-hasEntities';
|
477
|
+
const origin = `${this.id}-${meth}`;
|
478
|
+
log.trace(origin);
|
479
|
+
|
480
|
+
try {
|
481
|
+
return super.hasEntities(entityType, entityList, callback);
|
482
|
+
} catch (err) {
|
483
|
+
log.error(`${origin}: ${err}`);
|
484
|
+
return callback(null, err);
|
485
|
+
}
|
486
|
+
}
|
487
|
+
|
488
|
+
/**
|
489
|
+
* @summary Get Appliance that match the deviceName
|
490
|
+
*
|
491
|
+
* @function getDevice
|
492
|
+
* @param {String} deviceName - the deviceName to find (required)
|
493
|
+
*
|
494
|
+
* @param {getCallback} callback - a callback function to return the result
|
495
|
+
* (appliance) or the error
|
496
|
+
*/
|
497
|
+
getDevice(deviceName, callback) {
|
498
|
+
const meth = 'adapter-getDevice';
|
499
|
+
const origin = `${this.id}-${meth}`;
|
500
|
+
log.trace(origin);
|
501
|
+
|
502
|
+
try {
|
503
|
+
return super.getDevice(deviceName, callback);
|
504
|
+
} catch (err) {
|
505
|
+
log.error(`${origin}: ${err}`);
|
506
|
+
return callback(null, err);
|
507
|
+
}
|
508
|
+
}
|
509
|
+
|
510
|
+
/**
|
511
|
+
* @summary Get Appliances that match the filter
|
512
|
+
*
|
513
|
+
* @function getDevicesFiltered
|
514
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
515
|
+
*
|
516
|
+
* @param {getCallback} callback - a callback function to return the result
|
517
|
+
* (appliances) or the error
|
518
|
+
*/
|
519
|
+
getDevicesFiltered(options, callback) {
|
520
|
+
const meth = 'adapter-getDevicesFiltered';
|
521
|
+
const origin = `${this.id}-${meth}`;
|
522
|
+
log.trace(origin);
|
523
|
+
|
524
|
+
try {
|
525
|
+
return super.getDevicesFiltered(options, callback);
|
526
|
+
} catch (err) {
|
527
|
+
log.error(`${origin}: ${err}`);
|
528
|
+
return callback(null, err);
|
529
|
+
}
|
530
|
+
}
|
531
|
+
|
532
|
+
/**
|
533
|
+
* @summary Gets the status for the provided appliance
|
534
|
+
*
|
535
|
+
* @function isAlive
|
536
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
537
|
+
*
|
538
|
+
* @param {configCallback} callback - callback function to return the result
|
539
|
+
* (appliance isAlive) or the error
|
540
|
+
*/
|
541
|
+
isAlive(deviceName, callback) {
|
542
|
+
const meth = 'adapter-isAlive';
|
543
|
+
const origin = `${this.id}-${meth}`;
|
544
|
+
log.trace(origin);
|
545
|
+
|
546
|
+
try {
|
547
|
+
return super.isAlive(deviceName, callback);
|
548
|
+
} catch (err) {
|
549
|
+
log.error(`${origin}: ${err}`);
|
550
|
+
return callback(null, err);
|
551
|
+
}
|
552
|
+
}
|
553
|
+
|
554
|
+
/**
|
555
|
+
* @summary Gets a config for the provided Appliance
|
556
|
+
*
|
557
|
+
* @function getConfig
|
558
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
559
|
+
* @param {String} format - the desired format of the config. (optional)
|
560
|
+
*
|
561
|
+
* @param {configCallback} callback - callback function to return the result
|
562
|
+
* (appliance config) or the error
|
563
|
+
*/
|
564
|
+
getConfig(deviceName, format, callback) {
|
565
|
+
const meth = 'adapter-getConfig';
|
566
|
+
const origin = `${this.id}-${meth}`;
|
567
|
+
log.trace(origin);
|
568
|
+
|
569
|
+
try {
|
570
|
+
return super.getConfig(deviceName, format, callback);
|
571
|
+
} catch (err) {
|
572
|
+
log.error(`${origin}: ${err}`);
|
573
|
+
return callback(null, err);
|
574
|
+
}
|
575
|
+
}
|
576
|
+
|
577
|
+
/**
|
578
|
+
* @summary Gets the device count from the system
|
579
|
+
*
|
580
|
+
* @function iapGetDeviceCount
|
581
|
+
*
|
582
|
+
* @param {getCallback} callback - callback function to return the result
|
583
|
+
* (count) or the error
|
584
|
+
*/
|
585
|
+
iapGetDeviceCount(callback) {
|
586
|
+
const meth = 'adapter-iapGetDeviceCount';
|
587
|
+
const origin = `${this.id}-${meth}`;
|
588
|
+
log.trace(origin);
|
589
|
+
|
590
|
+
try {
|
591
|
+
return super.iapGetDeviceCount(callback);
|
592
|
+
} catch (err) {
|
593
|
+
log.error(`${origin}: ${err}`);
|
594
|
+
return callback(null, err);
|
595
|
+
}
|
596
|
+
}
|
597
|
+
|
598
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
439
599
|
/**
|
440
600
|
* Makes the requested generic call
|
441
601
|
*
|
@@ -546,79 +706,23 @@ class Meraki extends AdapterBaseCl {
|
|
546
706
|
}
|
547
707
|
}
|
548
708
|
|
549
|
-
/* BROKER CALLS */
|
550
|
-
/**
|
551
|
-
* @summary Determines if this adapter supports any in a list of entities
|
552
|
-
*
|
553
|
-
* @function hasEntities
|
554
|
-
* @param {String} entityType - the entity type to check for
|
555
|
-
* @param {Array} entityList - the list of entities we are looking for
|
556
|
-
*
|
557
|
-
* @param {Callback} callback - A map where the entity is the key and the
|
558
|
-
* value is true or false
|
559
|
-
*/
|
560
|
-
hasEntities(entityType, entityList, callback) {
|
561
|
-
const origin = `${this.id}-adapter-hasEntities`;
|
562
|
-
log.trace(origin);
|
563
|
-
|
564
|
-
switch (entityType) {
|
565
|
-
case 'Device':
|
566
|
-
return this.hasDevices(entityList, callback);
|
567
|
-
default:
|
568
|
-
return callback(null, `${this.id} does not support entity ${entityType}`);
|
569
|
-
}
|
570
|
-
}
|
571
|
-
|
572
709
|
/**
|
573
|
-
*
|
710
|
+
* Makes the requested generic call with no base path or version
|
574
711
|
*
|
575
|
-
* @
|
576
|
-
* @param {
|
577
|
-
*
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
log.debug(`In reduce: ${JSON.stringify(map)}`);
|
587
|
-
return map;
|
588
|
-
}, {});
|
589
|
-
const apiCalls = deviceList.map((device) => new Promise((resolve) => {
|
590
|
-
this.getDevice(device, (result, error) => {
|
591
|
-
if (error) {
|
592
|
-
log.debug(`In map error: ${JSON.stringify(device)}`);
|
593
|
-
return resolve({ name: device, found: false });
|
594
|
-
}
|
595
|
-
log.debug(`In map: ${JSON.stringify(device)}`);
|
596
|
-
return resolve({ name: device, found: true });
|
597
|
-
});
|
598
|
-
}));
|
599
|
-
Promise.all(apiCalls).then((results) => {
|
600
|
-
results.forEach((device) => {
|
601
|
-
findings[device.name] = device.found;
|
602
|
-
});
|
603
|
-
log.debug(`FINDINGS: ${JSON.stringify(findings)}`);
|
604
|
-
return callback(findings);
|
605
|
-
}).catch((errors) => {
|
606
|
-
log.error('Unable to do device lookup.');
|
607
|
-
return callback(null, { code: 503, message: 'Unable to do device lookup.', error: errors });
|
608
|
-
});
|
609
|
-
}
|
610
|
-
|
611
|
-
/**
|
612
|
-
* @summary Get Appliance that match the deviceName
|
613
|
-
*
|
614
|
-
* @function getDevice
|
615
|
-
* @param {String} deviceName - the deviceName to find (required)
|
616
|
-
*
|
617
|
-
* @param {getCallback} callback - a callback function to return the result
|
618
|
-
* (appliance) or the error
|
712
|
+
* @function genericAdapterRequestNoBasePath
|
713
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
714
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
715
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
716
|
+
* Can be a stringified Object.
|
717
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
718
|
+
* Can be a stringified Object.
|
719
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
720
|
+
* Can be a stringified Object.
|
721
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
722
|
+
* or the error
|
619
723
|
*/
|
620
|
-
|
621
|
-
const meth = 'adapter-
|
724
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
725
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
622
726
|
const origin = `${this.id}-${meth}`;
|
623
727
|
log.trace(origin);
|
624
728
|
|
@@ -629,365 +733,81 @@ class Meraki extends AdapterBaseCl {
|
|
629
733
|
}
|
630
734
|
|
631
735
|
/* HERE IS WHERE YOU VALIDATE DATA */
|
632
|
-
if (
|
633
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['
|
736
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
737
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
634
738
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
635
739
|
return callback(null, errorObj);
|
636
740
|
}
|
637
|
-
|
638
|
-
|
639
|
-
// need to get the device so we can convert the deviceName to an id
|
640
|
-
// !! if we can do a lookup by name the getDevicesFiltered may not be necessary
|
641
|
-
const opts = {
|
642
|
-
filter: {
|
643
|
-
name: deviceName
|
644
|
-
}
|
645
|
-
};
|
646
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
647
|
-
// if we received an error or their is no response on the results return an error
|
648
|
-
if (ferr) {
|
649
|
-
return callback(null, ferr);
|
650
|
-
}
|
651
|
-
if (devs.list.length < 1) {
|
652
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
653
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
654
|
-
return callback(null, errorObj);
|
655
|
-
}
|
656
|
-
// get the uuid from the device
|
657
|
-
const { uuid } = devs.list[0];
|
658
|
-
|
659
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
660
|
-
// !! you can also replace with a specific call if that is easier
|
661
|
-
const uriPath = `/call/toget/device/${uuid}`;
|
662
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
663
|
-
// if we received an error or their is no response on the results return an error
|
664
|
-
if (error) {
|
665
|
-
return callback(null, error);
|
666
|
-
}
|
667
|
-
if (!result.response || !result.response.applianceMo) {
|
668
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevice'], null, null, null);
|
669
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
670
|
-
return callback(null, errorObj);
|
671
|
-
}
|
672
|
-
|
673
|
-
// return the response
|
674
|
-
// !! format the data we send back
|
675
|
-
// !! these fields are config manager fields you need to map to the data we receive
|
676
|
-
const thisDevice = result.response;
|
677
|
-
thisDevice.name = thisDevice.systemName;
|
678
|
-
thisDevice.ostype = `System-${thisDevice.systemType}`;
|
679
|
-
thisDevice.port = thisDevice.systemPort;
|
680
|
-
thisDevice.ipaddress = thisDevice.systemIP;
|
681
|
-
return callback(thisDevice);
|
682
|
-
});
|
683
|
-
});
|
684
|
-
} catch (ex) {
|
685
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
741
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
742
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
686
743
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
687
744
|
return callback(null, errorObj);
|
688
745
|
}
|
689
|
-
}
|
690
746
|
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
*
|
697
|
-
* @param {getCallback} callback - a callback function to return the result
|
698
|
-
* (appliances) or the error
|
699
|
-
*/
|
700
|
-
getDevicesFiltered(options, callback) {
|
701
|
-
const meth = 'adapter-getDevicesFiltered';
|
702
|
-
const origin = `${this.id}-${meth}`;
|
703
|
-
log.trace(origin);
|
704
|
-
|
705
|
-
// verify the required fields have been provided
|
706
|
-
if (options === undefined || options === null || options === '' || options.length === 0) {
|
707
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['options'], null, null, null);
|
708
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
709
|
-
return callback(null, errorObj);
|
747
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
748
|
+
// remove any leading / and split the uripath into path variables
|
749
|
+
let myPath = uriPath;
|
750
|
+
while (myPath.indexOf('/') === 0) {
|
751
|
+
myPath = myPath.substring(1);
|
710
752
|
}
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
// const maxResults = options.limit;
|
753
|
+
const pathVars = myPath.split('/');
|
754
|
+
const queryParamsAvailable = queryData;
|
755
|
+
const queryParams = {};
|
756
|
+
const bodyVars = requestBody;
|
716
757
|
|
717
|
-
//
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
// eslint-disable-next-line prefer-destructuring
|
723
|
-
filterName = options.filter.name;
|
724
|
-
} else {
|
725
|
-
filterName = [options.filter.name];
|
758
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
759
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
760
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
761
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
762
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
726
763
|
}
|
727
|
-
}
|
728
|
-
|
729
|
-
// TODO - get sort and order working
|
730
|
-
/*
|
731
|
-
if (options && options.sort) {
|
732
|
-
reqObj.uriOptions.sort = JSON.stringify(options.sort);
|
733
|
-
}
|
734
|
-
if (options && options.order) {
|
735
|
-
reqObj.uriOptions.order = options.order;
|
736
|
-
}
|
737
|
-
*/
|
738
|
-
try {
|
739
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
740
|
-
// !! you can also replace with a specific call if that is easier
|
741
|
-
const uriPath = '/call/toget/devices';
|
742
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
743
|
-
// if we received an error or their is no response on the results return an error
|
744
|
-
if (error) {
|
745
|
-
return callback(null, error);
|
746
|
-
}
|
747
|
-
if (!result.response) {
|
748
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
|
749
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
750
|
-
return callback(null, errorObj);
|
751
|
-
}
|
752
|
-
|
753
|
-
// !! go through the response - may have to look for sub object
|
754
|
-
// handle an array of devices
|
755
|
-
if (Array.isArray(result.response)) {
|
756
|
-
const myDevices = [];
|
757
|
-
|
758
|
-
for (let d = 0; d < result.response.length; d += 1) {
|
759
|
-
// !! format the data we send back
|
760
|
-
// !! these fields are config manager fields you need to map to the data we receive
|
761
|
-
const thisDevice = result.response;
|
762
|
-
thisDevice.name = thisDevice.systemName;
|
763
|
-
thisDevice.ostype = `System-${thisDevice.systemType}`;
|
764
|
-
thisDevice.port = thisDevice.systemPort;
|
765
|
-
thisDevice.ipaddress = thisDevice.systemIP;
|
766
|
-
|
767
|
-
// if there is no filter - return the device
|
768
|
-
if (filterName.length === 0) {
|
769
|
-
myDevices.push(thisDevice);
|
770
|
-
} else {
|
771
|
-
// if we have to match a filter
|
772
|
-
let found = false;
|
773
|
-
for (let f = 0; f < filterName.length; f += 1) {
|
774
|
-
if (thisDevice.name.indexOf(filterName[f]) >= 0) {
|
775
|
-
found = true;
|
776
|
-
break;
|
777
|
-
}
|
778
|
-
}
|
779
|
-
// matching device
|
780
|
-
if (found) {
|
781
|
-
myDevices.push(thisDevice);
|
782
|
-
}
|
783
|
-
}
|
784
|
-
}
|
785
|
-
log.debug(`${origin}: Found #${myDevices.length} devices.`);
|
786
|
-
log.debug(`Devices: ${JSON.stringify(myDevices)}`);
|
787
|
-
return callback({ total: myDevices.length, list: myDevices });
|
788
|
-
}
|
789
|
-
// handle a single device response
|
790
|
-
// !! format the data we send back
|
791
|
-
// !! these fields are config manager fields you need to map to the data we receive
|
792
|
-
const thisDevice = result.response;
|
793
|
-
thisDevice.name = thisDevice.systemName;
|
794
|
-
thisDevice.ostype = `System-${thisDevice.systemType}`;
|
795
|
-
thisDevice.port = thisDevice.systemPort;
|
796
|
-
thisDevice.ipaddress = thisDevice.systemIP;
|
797
|
-
|
798
|
-
// if there is no filter - return the device
|
799
|
-
if (filterName.length === 0) {
|
800
|
-
log.debug(`${origin}: Found #1 device.`);
|
801
|
-
log.debug(`Device: ${JSON.stringify(thisDevice)}`);
|
802
|
-
return callback({ total: 1, list: [thisDevice] });
|
803
|
-
}
|
804
|
-
|
805
|
-
// if there is a filter need to check for matching device
|
806
|
-
let found = false;
|
807
|
-
for (let f = 0; f < filterName.length; f += 1) {
|
808
|
-
if (thisDevice.name.indexOf(filterName[f]) >= 0) {
|
809
|
-
found = true;
|
810
|
-
break;
|
811
|
-
}
|
812
|
-
}
|
813
|
-
// matching device
|
814
|
-
if (found) {
|
815
|
-
log.debug(`${origin}: Found #1 device.`);
|
816
|
-
log.debug(`Device Found: ${JSON.stringify(thisDevice)}`);
|
817
|
-
return callback({ total: 1, list: [thisDevice] });
|
818
|
-
}
|
819
|
-
// not a matching device
|
820
|
-
log.debug(`${origin}: No matching device found.`);
|
821
|
-
return callback({ total: 0, list: [] });
|
822
|
-
});
|
823
|
-
} catch (ex) {
|
824
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
825
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
826
|
-
return callback(null, errorObj);
|
827
|
-
}
|
828
|
-
}
|
829
|
-
|
830
|
-
/**
|
831
|
-
* @summary Gets the status for the provided appliance
|
832
|
-
*
|
833
|
-
* @function isAlive
|
834
|
-
* @param {String} deviceName - the deviceName of the appliance. (required)
|
835
|
-
*
|
836
|
-
* @param {configCallback} callback - callback function to return the result
|
837
|
-
* (appliance isAlive) or the error
|
838
|
-
*/
|
839
|
-
isAlive(deviceName, callback) {
|
840
|
-
const meth = 'adapter-isAlive';
|
841
|
-
const origin = `${this.id}-${meth}`;
|
842
|
-
log.trace(origin);
|
843
|
-
|
844
|
-
// verify the required fields have been provided
|
845
|
-
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
846
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
847
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
848
|
-
return callback(null, errorObj);
|
849
|
-
}
|
850
|
-
|
851
|
-
try {
|
852
|
-
// need to get the device so we can convert the deviceName to an id
|
853
|
-
// !! if we can do a lookup by name the getDevicesFiltered may not be necessary
|
854
|
-
const opts = {
|
855
|
-
filter: {
|
856
|
-
name: deviceName
|
857
|
-
}
|
858
|
-
};
|
859
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
860
|
-
// if we received an error or their is no response on the results return an error
|
861
|
-
if (ferr) {
|
862
|
-
return callback(null, ferr);
|
863
|
-
}
|
864
|
-
if (devs.list.length < 1) {
|
865
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
866
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
867
|
-
return callback(null, errorObj);
|
868
|
-
}
|
869
|
-
// get the uuid from the device
|
870
|
-
const { uuid } = devs.list[0];
|
871
|
-
|
872
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
873
|
-
// !! you can also replace with a specific call if that is easier
|
874
|
-
const uriPath = `/call/toget/status/${uuid}`;
|
875
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
876
|
-
// if we received an error or their is no response on the results return an error
|
877
|
-
if (error) {
|
878
|
-
return callback(null, error);
|
879
|
-
}
|
880
|
-
// !! should update this to make sure we are checking for the appropriate object/field
|
881
|
-
if (!result.response || !result.response.returnObj || !Object.hasOwnProperty.call(result.response.returnObj, 'statusField')) {
|
882
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['isAlive'], null, null, null);
|
883
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
884
|
-
return callback(null, errorObj);
|
885
|
-
}
|
764
|
+
});
|
886
765
|
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
766
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
767
|
+
const reqObj = {
|
768
|
+
payload: bodyVars,
|
769
|
+
uriPathVars: pathVars,
|
770
|
+
uriQuery: queryParams,
|
771
|
+
uriOptions: {}
|
772
|
+
};
|
773
|
+
// add headers if provided
|
774
|
+
if (addlHeaders) {
|
775
|
+
reqObj.addlHeaders = addlHeaders;
|
895
776
|
}
|
896
|
-
}
|
897
|
-
|
898
|
-
/**
|
899
|
-
* @summary Gets a config for the provided Appliance
|
900
|
-
*
|
901
|
-
* @function getConfig
|
902
|
-
* @param {String} deviceName - the deviceName of the appliance. (required)
|
903
|
-
* @param {String} format - the desired format of the config. (optional)
|
904
|
-
*
|
905
|
-
* @param {configCallback} callback - callback function to return the result
|
906
|
-
* (appliance config) or the error
|
907
|
-
*/
|
908
|
-
getConfig(deviceName, format, callback) {
|
909
|
-
const meth = 'adapter-getConfig';
|
910
|
-
const origin = `${this.id}-${meth}`;
|
911
|
-
log.trace(origin);
|
912
777
|
|
913
|
-
//
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
778
|
+
// determine the call and return flag
|
779
|
+
let action = 'getGenericsNoBase';
|
780
|
+
let returnF = true;
|
781
|
+
if (restMethod.toUpperCase() === 'POST') {
|
782
|
+
action = 'createGenericNoBase';
|
783
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
784
|
+
action = 'updateGenericNoBase';
|
785
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
786
|
+
action = 'patchGenericNoBase';
|
787
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
788
|
+
action = 'deleteGenericNoBase';
|
789
|
+
returnF = false;
|
918
790
|
}
|
919
791
|
|
920
792
|
try {
|
921
|
-
//
|
922
|
-
//
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
// if we received an error or their is no response on the results return an error
|
930
|
-
if (ferr) {
|
931
|
-
return callback(null, ferr);
|
793
|
+
// Make the call -
|
794
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
795
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
796
|
+
// if we received an error or their is no response on the results
|
797
|
+
// return an error
|
798
|
+
if (irReturnError) {
|
799
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
800
|
+
return callback(null, irReturnError);
|
932
801
|
}
|
933
|
-
if (
|
934
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth,
|
802
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
803
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
935
804
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
936
805
|
return callback(null, errorObj);
|
937
806
|
}
|
938
|
-
// get the uuid from the device
|
939
|
-
const { uuid } = devs.list[0];
|
940
|
-
|
941
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
942
|
-
// !! you can also replace with a specific call if that is easier
|
943
|
-
const uriPath = `/call/toget/config/${uuid}`;
|
944
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
945
|
-
// if we received an error or their is no response on the results return an error
|
946
|
-
if (error) {
|
947
|
-
return callback(null, error);
|
948
|
-
}
|
949
|
-
|
950
|
-
// return the result
|
951
|
-
const newResponse = {
|
952
|
-
response: JSON.stringify(result.response, null, 2)
|
953
|
-
};
|
954
|
-
return callback(newResponse);
|
955
|
-
});
|
956
|
-
});
|
957
|
-
} catch (ex) {
|
958
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
959
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
960
|
-
return callback(null, errorObj);
|
961
|
-
}
|
962
|
-
}
|
963
|
-
|
964
|
-
/**
|
965
|
-
* @summary Gets the device count from the system
|
966
|
-
*
|
967
|
-
* @function getCount
|
968
|
-
*
|
969
|
-
* @param {getCallback} callback - callback function to return the result
|
970
|
-
* (count) or the error
|
971
|
-
*/
|
972
|
-
getCount(callback) {
|
973
|
-
const meth = 'adapter-getCount';
|
974
|
-
const origin = `${this.id}-${meth}`;
|
975
|
-
log.trace(origin);
|
976
|
-
|
977
|
-
// verify the required fields have been provided
|
978
|
-
|
979
|
-
try {
|
980
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
981
|
-
// !! you can also replace with a specific call if that is easier
|
982
|
-
const uriPath = '/call/toget/count';
|
983
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
984
|
-
// if we received an error or their is no response on the results return an error
|
985
|
-
if (error) {
|
986
|
-
return callback(null, error);
|
987
|
-
}
|
988
807
|
|
989
|
-
|
990
|
-
return
|
808
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
809
|
+
// return the response
|
810
|
+
return callback(irReturnData, null);
|
991
811
|
});
|
992
812
|
} catch (ex) {
|
993
813
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|