@itentialopensource/adapter-meraki 1.0.4 → 1.2.1
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 +14 -18
- package/CALLS.md +3580 -22
- package/CHANGELOG.md +24 -0
- package/CONTRIBUTING.md +1 -160
- package/ENHANCE.md +2 -2
- package/README.md +32 -23
- package/SYSTEMINFO.md +15 -2
- package/adapter.js +164 -335
- package/adapterBase.js +494 -893
- package/changelogs/changelog.md +198 -0
- package/metadata.json +75 -0
- package/package.json +24 -24
- package/pronghorn.json +470 -138
- package/propertiesSchema.json +422 -31
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +5460 -0
- package/report/adapter-openapi.yaml +3774 -0
- package/report/adapterInfo.json +8 -8
- package/report/updateReport1690417926405.json +119 -0
- package/report/updateReport1692203092612.json +120 -0
- package/report/updateReport1694439659179.json +120 -0
- package/sampleProperties.json +86 -27
- package/test/integration/adapterTestBasicGet.js +1 -3
- package/test/integration/adapterTestConnectivity.js +90 -41
- package/test/integration/adapterTestIntegration.js +129 -1
- package/test/unit/adapterBaseTestUnit.js +387 -312
- package/test/unit/adapterTestUnit.js +336 -110
- package/utils/entitiesToDB.js +2 -2
- package/utils/methodDocumentor.js +260 -0
- package/utils/modify.js +12 -14
- package/utils/packModificationScript.js +1 -1
- package/utils/pre-commit.sh +2 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +89 -34
- package/utils/tbUtils.js +41 -21
- package/utils/troubleshootingAdapter.js +9 -6
- package/versions.json +0 -542
- package/workflows/README.md +0 -3
package/adapter.js
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
/* eslint import/no-dynamic-require: warn */
|
4
4
|
/* eslint object-curly-newline: warn */
|
5
|
+
/* eslint default-param-last: warn */
|
5
6
|
|
6
7
|
// Set globals
|
7
8
|
/* global log */
|
@@ -19,7 +20,7 @@ const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
|
|
19
20
|
/* GENERAL ADAPTER FUNCTIONS */
|
20
21
|
class Meraki extends AdapterBaseCl {
|
21
22
|
/**
|
22
|
-
*
|
23
|
+
* <%= metaInfo.adapterClass %> Adapter
|
23
24
|
* @constructor
|
24
25
|
*/
|
25
26
|
/* Working on changing the way we do Emit methods due to size and time constrainsts
|
@@ -27,7 +28,7 @@ class Meraki extends AdapterBaseCl {
|
|
27
28
|
// Instantiate the AdapterBase super class
|
28
29
|
super(prongid, properties);
|
29
30
|
|
30
|
-
const restFunctionNames = this.
|
31
|
+
const restFunctionNames = this.iapGetAdapterWorkflowFunctions();
|
31
32
|
|
32
33
|
// Dynamically bind emit functions
|
33
34
|
for (let i = 0; i < restFunctionNames.length; i += 1) {
|
@@ -86,9 +87,6 @@ class Meraki extends AdapterBaseCl {
|
|
86
87
|
let myIgnore = [
|
87
88
|
'healthCheck',
|
88
89
|
'iapGetAdapterWorkflowFunctions',
|
89
|
-
'iapHasAdapterEntity',
|
90
|
-
'iapVerifyAdapterCapability',
|
91
|
-
'iapUpdateAdapterEntityCache',
|
92
90
|
'hasEntities',
|
93
91
|
'getAuthorization'
|
94
92
|
];
|
@@ -116,29 +114,15 @@ class Meraki extends AdapterBaseCl {
|
|
116
114
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
117
115
|
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
118
116
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
117
|
+
* @param {boolean} replace - true to replace entire mock data, false to merge/append
|
119
118
|
* @param {Callback} callback - The results of the call
|
120
119
|
*/
|
121
|
-
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
120
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
|
122
121
|
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
123
122
|
const origin = `${this.id}-${meth}`;
|
124
123
|
log.trace(origin);
|
125
124
|
|
126
|
-
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
127
|
-
}
|
128
|
-
|
129
|
-
/**
|
130
|
-
* See if the API path provided is found in this adapter
|
131
|
-
*
|
132
|
-
* @function iapFindAdapterPath
|
133
|
-
* @param {string} apiPath - the api path to check on
|
134
|
-
* @param {Callback} callback - The results of the call
|
135
|
-
*/
|
136
|
-
iapFindAdapterPath(apiPath, callback) {
|
137
|
-
const meth = 'adapter-iapFindAdapterPath';
|
138
|
-
const origin = `${this.id}-${meth}`;
|
139
|
-
log.trace(origin);
|
140
|
-
|
141
|
-
super.iapFindAdapterPath(apiPath, callback);
|
125
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
|
142
126
|
}
|
143
127
|
|
144
128
|
/**
|
@@ -180,7 +164,7 @@ class Meraki extends AdapterBaseCl {
|
|
180
164
|
}
|
181
165
|
|
182
166
|
/**
|
183
|
-
* @summary Get the
|
167
|
+
* @summary Get the Adapter Queue
|
184
168
|
*
|
185
169
|
* @function iapGetAdapterQueue
|
186
170
|
* @param {Callback} callback - callback function
|
@@ -193,6 +177,22 @@ class Meraki extends AdapterBaseCl {
|
|
193
177
|
return super.iapGetAdapterQueue(callback);
|
194
178
|
}
|
195
179
|
|
180
|
+
/* SCRIPT CALLS */
|
181
|
+
/**
|
182
|
+
* See if the API path provided is found in this adapter
|
183
|
+
*
|
184
|
+
* @function iapFindAdapterPath
|
185
|
+
* @param {string} apiPath - the api path to check on
|
186
|
+
* @param {Callback} callback - The results of the call
|
187
|
+
*/
|
188
|
+
iapFindAdapterPath(apiPath, callback) {
|
189
|
+
const meth = 'adapter-iapFindAdapterPath';
|
190
|
+
const origin = `${this.id}-${meth}`;
|
191
|
+
log.trace(origin);
|
192
|
+
|
193
|
+
super.iapFindAdapterPath(apiPath, callback);
|
194
|
+
}
|
195
|
+
|
196
196
|
/**
|
197
197
|
* @summary Runs troubleshoot scripts for adapter
|
198
198
|
*
|
@@ -293,176 +293,93 @@ class Meraki extends AdapterBaseCl {
|
|
293
293
|
}
|
294
294
|
}
|
295
295
|
|
296
|
-
/* BROKER CALLS */
|
297
296
|
/**
|
298
|
-
* @summary
|
297
|
+
* @summary Deactivate adapter tasks
|
299
298
|
*
|
300
|
-
* @function
|
301
|
-
* @param {String} entityType - the entity type to check for
|
302
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
299
|
+
* @function iapDeactivateTasks
|
303
300
|
*
|
304
|
-
* @param {
|
305
|
-
*
|
301
|
+
* @param {Array} tasks - List of tasks to deactivate
|
302
|
+
* @param {Callback} callback
|
306
303
|
*/
|
307
|
-
|
308
|
-
const
|
304
|
+
iapDeactivateTasks(tasks, callback) {
|
305
|
+
const meth = 'adapter-iapDeactivateTasks';
|
306
|
+
const origin = `${this.id}-${meth}`;
|
309
307
|
log.trace(origin);
|
310
308
|
|
311
|
-
|
312
|
-
|
313
|
-
|
309
|
+
try {
|
310
|
+
return super.iapDeactivateTasks(tasks, callback);
|
311
|
+
} catch (err) {
|
312
|
+
log.error(`${origin}: ${err}`);
|
313
|
+
return callback(null, err);
|
314
|
+
}
|
314
315
|
}
|
315
316
|
|
316
317
|
/**
|
317
|
-
* @summary
|
318
|
-
* whether the adapter supports type, action and specific entity
|
318
|
+
* @summary Activate adapter tasks that have previously been deactivated
|
319
319
|
*
|
320
|
-
* @function
|
321
|
-
*
|
322
|
-
* @param {
|
323
|
-
* @param {
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
330
|
-
const origin = `${this.id}-${meth}`;
|
331
|
-
log.trace(origin);
|
332
|
-
|
333
|
-
// if caching
|
334
|
-
if (this.caching) {
|
335
|
-
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
336
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
337
|
-
if (error) {
|
338
|
-
return callback(null, error);
|
339
|
-
}
|
340
|
-
|
341
|
-
// if the cache needs to be updated, update and try again
|
342
|
-
if (results && results[0] === 'needupdate') {
|
343
|
-
switch (entityType) {
|
344
|
-
case 'template_entity': {
|
345
|
-
// if the cache is invalid, update the cache
|
346
|
-
return this.getEntities(null, null, null, null, (data, err) => {
|
347
|
-
if (err) {
|
348
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
349
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
350
|
-
return callback(null, errorObj);
|
351
|
-
}
|
352
|
-
|
353
|
-
// need to check the cache again since it has been updated
|
354
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
355
|
-
if (verror) {
|
356
|
-
return callback(null, verror);
|
357
|
-
}
|
358
|
-
|
359
|
-
return this.capabilityResults(vcapable, callback);
|
360
|
-
});
|
361
|
-
});
|
362
|
-
}
|
363
|
-
default: {
|
364
|
-
// unsupported entity type
|
365
|
-
const result = [false];
|
366
|
-
|
367
|
-
// put false in array for all entities
|
368
|
-
if (Array.isArray(entityId)) {
|
369
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
370
|
-
result.push(false);
|
371
|
-
}
|
372
|
-
}
|
373
|
-
|
374
|
-
return callback(result);
|
375
|
-
}
|
376
|
-
}
|
377
|
-
}
|
378
|
-
|
379
|
-
// return the results
|
380
|
-
return this.capabilityResults(results, callback);
|
381
|
-
});
|
382
|
-
}
|
383
|
-
|
384
|
-
// if no entity id
|
385
|
-
if (!entityId) {
|
386
|
-
// need to check the cache again since it has been updated
|
387
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
388
|
-
if (verror) {
|
389
|
-
return callback(null, verror);
|
390
|
-
}
|
320
|
+
* @function iapActivateTasks
|
321
|
+
*
|
322
|
+
* @param {Array} tasks - List of tasks to activate
|
323
|
+
* @param {Callback} callback
|
324
|
+
*/
|
325
|
+
iapActivateTasks(tasks, callback) {
|
326
|
+
const meth = 'adapter-iapActivateTasks';
|
327
|
+
const origin = `${this.id}-${meth}`;
|
328
|
+
log.trace(origin);
|
391
329
|
|
392
|
-
|
393
|
-
|
330
|
+
try {
|
331
|
+
return super.iapActivateTasks(tasks, callback);
|
332
|
+
} catch (err) {
|
333
|
+
log.error(`${origin}: ${err}`);
|
334
|
+
return callback(null, err);
|
394
335
|
}
|
336
|
+
}
|
395
337
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
return callback(null, verror);
|
411
|
-
}
|
412
|
-
|
413
|
-
// is the entity in the list?
|
414
|
-
const isEntity = this.entityInList(entityId, data.response, callback);
|
415
|
-
const res = [];
|
416
|
-
|
417
|
-
// not found
|
418
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
419
|
-
if (vcapable) {
|
420
|
-
res.push(isEntity[i]);
|
421
|
-
} else {
|
422
|
-
res.push(false);
|
423
|
-
}
|
424
|
-
}
|
425
|
-
|
426
|
-
return callback(res);
|
427
|
-
});
|
428
|
-
});
|
429
|
-
}
|
430
|
-
default: {
|
431
|
-
// unsupported entity type
|
432
|
-
const result = [false];
|
433
|
-
|
434
|
-
// put false in array for all entities
|
435
|
-
if (Array.isArray(entityId)) {
|
436
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
437
|
-
result.push(false);
|
438
|
-
}
|
439
|
-
}
|
338
|
+
/* CACHE CALLS */
|
339
|
+
/**
|
340
|
+
* @summary Populate the cache for the given entities
|
341
|
+
*
|
342
|
+
* @function iapPopulateEntityCache
|
343
|
+
* @param {String/Array of Strings} entityType - the entity type(s) to populate
|
344
|
+
* @param {Callback} callback - whether the cache was updated or not for each entity type
|
345
|
+
*
|
346
|
+
* @returns status of the populate
|
347
|
+
*/
|
348
|
+
iapPopulateEntityCache(entityTypes, callback) {
|
349
|
+
const meth = 'adapter-iapPopulateEntityCache';
|
350
|
+
const origin = `${this.id}-${meth}`;
|
351
|
+
log.trace(origin);
|
440
352
|
|
441
|
-
|
442
|
-
|
353
|
+
try {
|
354
|
+
return super.iapPopulateEntityCache(entityTypes, callback);
|
355
|
+
} catch (err) {
|
356
|
+
log.error(`${origin}: ${err}`);
|
357
|
+
return callback(null, err);
|
443
358
|
}
|
444
359
|
}
|
445
360
|
|
446
361
|
/**
|
447
|
-
* @summary
|
448
|
-
*
|
449
|
-
* @function iapUpdateAdapterEntityCache
|
362
|
+
* @summary Retrieves data from cache for specified entity type
|
450
363
|
*
|
364
|
+
* @function iapRetrieveEntitiesCache
|
365
|
+
* @param {String} entityType - entity of which to retrieve
|
366
|
+
* @param {Object} options - settings of which data to return and how to return it
|
367
|
+
* @param {Callback} callback - the data if it was retrieved
|
451
368
|
*/
|
452
|
-
|
453
|
-
const
|
369
|
+
iapRetrieveEntitiesCache(entityType, options, callback) {
|
370
|
+
const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
|
371
|
+
const origin = `${this.id}-${meth}`;
|
454
372
|
log.trace(origin);
|
455
373
|
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
}
|
462
|
-
});
|
374
|
+
try {
|
375
|
+
return super.iapRetrieveEntitiesCache(entityType, options, callback);
|
376
|
+
} catch (err) {
|
377
|
+
log.error(`${origin}: ${err}`);
|
378
|
+
return callback(null, err);
|
463
379
|
}
|
464
380
|
}
|
465
381
|
|
382
|
+
/* BROKER CALLS */
|
466
383
|
/**
|
467
384
|
* @summary Determines if this adapter supports any in a list of entities
|
468
385
|
*
|
@@ -597,6 +514,38 @@ class Meraki extends AdapterBaseCl {
|
|
597
514
|
}
|
598
515
|
|
599
516
|
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
517
|
+
/**
|
518
|
+
* Makes the requested generic call
|
519
|
+
*
|
520
|
+
* @function iapExpandedGenericAdapterRequest
|
521
|
+
* @param {Object} metadata - metadata for the call (optional).
|
522
|
+
* Can be a stringified Object.
|
523
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
|
524
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
|
525
|
+
* @param {Object} pathVars - the parameters to be put within the url path (optional).
|
526
|
+
* Can be a stringified Object.
|
527
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
528
|
+
* Can be a stringified Object.
|
529
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
530
|
+
* Can be a stringified Object.
|
531
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
532
|
+
* Can be a stringified Object.
|
533
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
534
|
+
* or the error
|
535
|
+
*/
|
536
|
+
iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
|
537
|
+
const meth = 'adapter-iapExpandedGenericAdapterRequest';
|
538
|
+
const origin = `${this.id}-${meth}`;
|
539
|
+
log.trace(origin);
|
540
|
+
|
541
|
+
try {
|
542
|
+
return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
|
543
|
+
} catch (err) {
|
544
|
+
log.error(`${origin}: ${err}`);
|
545
|
+
return callback(null, err);
|
546
|
+
}
|
547
|
+
}
|
548
|
+
|
600
549
|
/**
|
601
550
|
* Makes the requested generic call
|
602
551
|
*
|
@@ -617,93 +566,11 @@ class Meraki extends AdapterBaseCl {
|
|
617
566
|
const origin = `${this.id}-${meth}`;
|
618
567
|
log.trace(origin);
|
619
568
|
|
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);
|
634
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
635
|
-
return callback(null, errorObj);
|
636
|
-
}
|
637
|
-
|
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;
|
648
|
-
|
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];
|
654
|
-
}
|
655
|
-
});
|
656
|
-
|
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
569
|
try {
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
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);
|
697
|
-
}
|
698
|
-
|
699
|
-
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
700
|
-
// return the response
|
701
|
-
return callback(irReturnData, null);
|
702
|
-
});
|
703
|
-
} catch (ex) {
|
704
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
705
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
706
|
-
return callback(null, errorObj);
|
570
|
+
return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
571
|
+
} catch (err) {
|
572
|
+
log.error(`${origin}: ${err}`);
|
573
|
+
return callback(null, err);
|
707
574
|
}
|
708
575
|
}
|
709
576
|
|
@@ -727,94 +594,56 @@ class Meraki extends AdapterBaseCl {
|
|
727
594
|
const origin = `${this.id}-${meth}`;
|
728
595
|
log.trace(origin);
|
729
596
|
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
737
|
-
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
738
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
739
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
740
|
-
return callback(null, errorObj);
|
741
|
-
}
|
742
|
-
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
743
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
744
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
745
|
-
return callback(null, errorObj);
|
597
|
+
try {
|
598
|
+
return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
599
|
+
} catch (err) {
|
600
|
+
log.error(`${origin}: ${err}`);
|
601
|
+
return callback(null, err);
|
746
602
|
}
|
603
|
+
}
|
747
604
|
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
const
|
757
|
-
const
|
605
|
+
/* INVENTORY CALLS */
|
606
|
+
/**
|
607
|
+
* @summary run the adapter lint script to return the results.
|
608
|
+
*
|
609
|
+
* @function iapRunAdapterLint
|
610
|
+
* @param {Callback} callback - callback function
|
611
|
+
*/
|
612
|
+
iapRunAdapterLint(callback) {
|
613
|
+
const meth = 'adapter-iapRunAdapterLint';
|
614
|
+
const origin = `${this.id}-${meth}`;
|
615
|
+
log.trace(origin);
|
758
616
|
|
759
|
-
|
760
|
-
|
761
|
-
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
762
|
-
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
763
|
-
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
764
|
-
}
|
765
|
-
});
|
617
|
+
return super.iapRunAdapterLint(callback);
|
618
|
+
}
|
766
619
|
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
620
|
+
/**
|
621
|
+
* @summary run the adapter test scripts (baseunit and unit) to return the results.
|
622
|
+
* can not run integration as there can be implications with that.
|
623
|
+
*
|
624
|
+
* @function iapRunAdapterTests
|
625
|
+
* @param {Callback} callback - callback function
|
626
|
+
*/
|
627
|
+
iapRunAdapterTests(callback) {
|
628
|
+
const meth = 'adapter-iapRunAdapterTests';
|
629
|
+
const origin = `${this.id}-${meth}`;
|
630
|
+
log.trace(origin);
|
778
631
|
|
779
|
-
|
780
|
-
|
781
|
-
let returnF = true;
|
782
|
-
if (restMethod.toUpperCase() === 'POST') {
|
783
|
-
action = 'createGenericNoBase';
|
784
|
-
} else if (restMethod.toUpperCase() === 'PUT') {
|
785
|
-
action = 'updateGenericNoBase';
|
786
|
-
} else if (restMethod.toUpperCase() === 'PATCH') {
|
787
|
-
action = 'patchGenericNoBase';
|
788
|
-
} else if (restMethod.toUpperCase() === 'DELETE') {
|
789
|
-
action = 'deleteGenericNoBase';
|
790
|
-
returnF = false;
|
791
|
-
}
|
632
|
+
return super.iapRunAdapterTests(callback);
|
633
|
+
}
|
792
634
|
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
804
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
805
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
806
|
-
return callback(null, errorObj);
|
807
|
-
}
|
635
|
+
/**
|
636
|
+
* @summary provide inventory information abbout the adapter
|
637
|
+
*
|
638
|
+
* @function iapGetAdapterInventory
|
639
|
+
* @param {Callback} callback - callback function
|
640
|
+
*/
|
641
|
+
iapGetAdapterInventory(callback) {
|
642
|
+
const meth = 'adapter-iapGetAdapterInventory';
|
643
|
+
const origin = `${this.id}-${meth}`;
|
644
|
+
log.trace(origin);
|
808
645
|
|
809
|
-
|
810
|
-
// return the response
|
811
|
-
return callback(irReturnData, null);
|
812
|
-
});
|
813
|
-
} catch (ex) {
|
814
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
815
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
816
|
-
return callback(null, errorObj);
|
817
|
-
}
|
646
|
+
return super.iapGetAdapterInventory(callback);
|
818
647
|
}
|
819
648
|
|
820
649
|
/**
|