@itentialopensource/adapter-infoblox 1.12.3 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/AUTH.md +4 -9
  2. package/CALLS.md +2033 -22
  3. package/CHANGELOG.md +16 -0
  4. package/CONTRIBUTING.md +1 -160
  5. package/ENHANCE.md +2 -2
  6. package/README.md +32 -23
  7. package/SYSTEMINFO.md +13 -3
  8. package/adapter.js +237 -333
  9. package/adapterBase.js +549 -879
  10. package/changelogs/changelog.md +212 -0
  11. package/entities/Networks/action.json +21 -0
  12. package/entities/Networks/mockdatafiles/listNetworkContainers.json +6 -0
  13. package/entities/Networks/requestSchema.json +2 -1
  14. package/entities/Networks/responseSchema.json +2 -1
  15. package/entities/Networks/schema.json +1 -0
  16. package/metadata.json +68 -0
  17. package/package.json +24 -24
  18. package/pronghorn.json +535 -169
  19. package/propertiesSchema.json +422 -31
  20. package/refs?service=git-upload-pack +0 -0
  21. package/report/adapter-openapi.json +11283 -0
  22. package/report/adapter-openapi.yaml +8812 -0
  23. package/report/adapterInfo.json +8 -8
  24. package/report/updateReport1691508491036.json +120 -0
  25. package/report/updateReport1692202976507.json +120 -0
  26. package/report/updateReport1694466431390.json +120 -0
  27. package/sampleProperties.json +63 -2
  28. package/test/integration/adapterTestBasicGet.js +2 -4
  29. package/test/integration/adapterTestConnectivity.js +91 -42
  30. package/test/integration/adapterTestIntegration.js +153 -2
  31. package/test/unit/adapterBaseTestUnit.js +388 -313
  32. package/test/unit/adapterTestUnit.js +355 -117
  33. package/utils/adapterInfo.js +1 -1
  34. package/utils/addAuth.js +1 -1
  35. package/utils/artifactize.js +1 -1
  36. package/utils/checkMigrate.js +1 -1
  37. package/utils/entitiesToDB.js +2 -2
  38. package/utils/findPath.js +1 -1
  39. package/utils/methodDocumentor.js +260 -0
  40. package/utils/modify.js +13 -15
  41. package/utils/packModificationScript.js +1 -1
  42. package/utils/pre-commit.sh +2 -0
  43. package/utils/taskMover.js +309 -0
  44. package/utils/tbScript.js +89 -34
  45. package/utils/tbUtils.js +41 -21
  46. package/utils/testRunner.js +1 -1
  47. package/utils/troubleshootingAdapter.js +9 -6
  48. package/workflows/Object entity.json +0 -1
  49. package/workflows/README.md +0 -3
package/adapter.js CHANGED
@@ -91,9 +91,6 @@ class Infoblox extends AdapterBaseCl {
91
91
  let myIgnore = [
92
92
  'healthCheck',
93
93
  'iapGetAdapterWorkflowFunctions',
94
- 'iapHasAdapterEntity',
95
- 'iapVerifyAdapterCapability',
96
- 'iapUpdateAdapterEntityCache',
97
94
  'hasEntities',
98
95
  'getAuthorization'
99
96
  ];
@@ -121,29 +118,15 @@ class Infoblox extends AdapterBaseCl {
121
118
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
122
119
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
123
120
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
121
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
124
122
  * @param {Callback} callback - The results of the call
125
123
  */
126
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
124
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
127
125
  const meth = 'adapter-iapUpdateAdapterConfiguration';
128
126
  const origin = `${this.id}-${meth}`;
129
127
  log.trace(origin);
130
128
 
131
- super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
132
- }
133
-
134
- /**
135
- * See if the API path provided is found in this adapter
136
- *
137
- * @function iapFindAdapterPath
138
- * @param {string} apiPath - the api path to check on
139
- * @param {Callback} callback - The results of the call
140
- */
141
- iapFindAdapterPath(apiPath, callback) {
142
- const meth = 'adapter-iapFindAdapterPath';
143
- const origin = `${this.id}-${meth}`;
144
- log.trace(origin);
145
-
146
- super.iapFindAdapterPath(apiPath, callback);
129
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
147
130
  }
148
131
 
149
132
  /**
@@ -185,7 +168,7 @@ class Infoblox extends AdapterBaseCl {
185
168
  }
186
169
 
187
170
  /**
188
- * @summary Get the Adaoter Queue
171
+ * @summary Get the Adapter Queue
189
172
  *
190
173
  * @function iapGetAdapterQueue
191
174
  * @param {Callback} callback - callback function
@@ -198,6 +181,22 @@ class Infoblox extends AdapterBaseCl {
198
181
  return super.iapGetAdapterQueue(callback);
199
182
  }
200
183
 
184
+ /* SCRIPT CALLS */
185
+ /**
186
+ * See if the API path provided is found in this adapter
187
+ *
188
+ * @function iapFindAdapterPath
189
+ * @param {string} apiPath - the api path to check on
190
+ * @param {Callback} callback - The results of the call
191
+ */
192
+ iapFindAdapterPath(apiPath, callback) {
193
+ const meth = 'adapter-iapFindAdapterPath';
194
+ const origin = `${this.id}-${meth}`;
195
+ log.trace(origin);
196
+
197
+ super.iapFindAdapterPath(apiPath, callback);
198
+ }
199
+
201
200
  /**
202
201
  * @summary Runs troubleshoot scripts for adapter
203
202
  *
@@ -298,176 +297,93 @@ class Infoblox extends AdapterBaseCl {
298
297
  }
299
298
  }
300
299
 
301
- /* BROKER CALLS */
302
300
  /**
303
- * @summary Determines if this adapter supports the specific entity
301
+ * @summary Deactivate adapter tasks
304
302
  *
305
- * @function iapHasAdapterEntity
306
- * @param {String} entityType - the entity type to check for
307
- * @param {String/Array} entityId - the specific entity we are looking for
303
+ * @function iapDeactivateTasks
308
304
  *
309
- * @param {Callback} callback - An array of whether the adapter can has the
310
- * desired capability or an error
305
+ * @param {Array} tasks - List of tasks to deactivate
306
+ * @param {Callback} callback
311
307
  */
312
- iapHasAdapterEntity(entityType, entityId, callback) {
313
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
308
+ iapDeactivateTasks(tasks, callback) {
309
+ const meth = 'adapter-iapDeactivateTasks';
310
+ const origin = `${this.id}-${meth}`;
314
311
  log.trace(origin);
315
312
 
316
- // Make the call -
317
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
318
- return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
313
+ try {
314
+ return super.iapDeactivateTasks(tasks, callback);
315
+ } catch (err) {
316
+ log.error(`${origin}: ${err}`);
317
+ return callback(null, err);
318
+ }
319
319
  }
320
320
 
321
321
  /**
322
- * @summary Provides a way for the adapter to tell north bound integrations
323
- * whether the adapter supports type, action and specific entity
322
+ * @summary Activate adapter tasks that have previously been deactivated
324
323
  *
325
- * @function iapVerifyAdapterCapability
326
- * @param {String} entityType - the entity type to check for
327
- * @param {String} actionType - the action type to check for
328
- * @param {String/Array} entityId - the specific entity we are looking for
329
- *
330
- * @param {Callback} callback - An array of whether the adapter can has the
331
- * desired capability or an error
332
- */
333
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
334
- const meth = 'adapterBase-iapVerifyAdapterCapability';
335
- const origin = `${this.id}-${meth}`;
336
- log.trace(origin);
337
-
338
- // if caching
339
- if (this.caching) {
340
- // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
341
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
342
- if (error) {
343
- return callback(null, error);
344
- }
345
-
346
- // if the cache needs to be updated, update and try again
347
- if (results && results[0] === 'needupdate') {
348
- switch (entityType) {
349
- case 'template_entity': {
350
- // if the cache is invalid, update the cache
351
- return this.getEntities(null, null, null, null, (data, err) => {
352
- if (err) {
353
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
354
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
355
- return callback(null, errorObj);
356
- }
357
-
358
- // need to check the cache again since it has been updated
359
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
360
- if (verror) {
361
- return callback(null, verror);
362
- }
363
-
364
- return this.capabilityResults(vcapable, callback);
365
- });
366
- });
367
- }
368
- default: {
369
- // unsupported entity type
370
- const result = [false];
371
-
372
- // put false in array for all entities
373
- if (Array.isArray(entityId)) {
374
- for (let e = 1; e < entityId.length; e += 1) {
375
- result.push(false);
376
- }
377
- }
378
-
379
- return callback(result);
380
- }
381
- }
382
- }
383
-
384
- // return the results
385
- return this.capabilityResults(results, callback);
386
- });
387
- }
388
-
389
- // if no entity id
390
- if (!entityId) {
391
- // need to check the cache again since it has been updated
392
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
393
- if (verror) {
394
- return callback(null, verror);
395
- }
324
+ * @function iapActivateTasks
325
+ *
326
+ * @param {Array} tasks - List of tasks to activate
327
+ * @param {Callback} callback
328
+ */
329
+ iapActivateTasks(tasks, callback) {
330
+ const meth = 'adapter-iapActivateTasks';
331
+ const origin = `${this.id}-${meth}`;
332
+ log.trace(origin);
396
333
 
397
- return this.capabilityResults(vcapable, callback);
398
- });
334
+ try {
335
+ return super.iapActivateTasks(tasks, callback);
336
+ } catch (err) {
337
+ log.error(`${origin}: ${err}`);
338
+ return callback(null, err);
399
339
  }
340
+ }
400
341
 
401
- // if not caching
402
- switch (entityType) {
403
- case 'template_entity': {
404
- // need to get the entities to check
405
- return this.getEntities(null, null, null, null, (data, err) => {
406
- if (err) {
407
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
408
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
409
- return callback(null, errorObj);
410
- }
411
-
412
- // need to check the cache again since it has been updated
413
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
414
- if (verror) {
415
- return callback(null, verror);
416
- }
417
-
418
- // is the entity in the list?
419
- const isEntity = this.entityInList(entityId, data.response, callback);
420
- const res = [];
421
-
422
- // not found
423
- for (let i = 0; i < isEntity.length; i += 1) {
424
- if (vcapable) {
425
- res.push(isEntity[i]);
426
- } else {
427
- res.push(false);
428
- }
429
- }
430
-
431
- return callback(res);
432
- });
433
- });
434
- }
435
- default: {
436
- // unsupported entity type
437
- const result = [false];
438
-
439
- // put false in array for all entities
440
- if (Array.isArray(entityId)) {
441
- for (let e = 1; e < entityId.length; e += 1) {
442
- result.push(false);
443
- }
444
- }
342
+ /* CACHE CALLS */
343
+ /**
344
+ * @summary Populate the cache for the given entities
345
+ *
346
+ * @function iapPopulateEntityCache
347
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
348
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
349
+ *
350
+ * @returns status of the populate
351
+ */
352
+ iapPopulateEntityCache(entityTypes, callback) {
353
+ const meth = 'adapter-iapPopulateEntityCache';
354
+ const origin = `${this.id}-${meth}`;
355
+ log.trace(origin);
445
356
 
446
- return callback(result);
447
- }
357
+ try {
358
+ return super.iapPopulateEntityCache(entityTypes, callback);
359
+ } catch (err) {
360
+ log.error(`${origin}: ${err}`);
361
+ return callback(null, err);
448
362
  }
449
363
  }
450
364
 
451
365
  /**
452
- * @summary Updates the cache for all entities by call the get All entity method
453
- *
454
- * @function iapUpdateAdapterEntityCache
366
+ * @summary Retrieves data from cache for specified entity type
455
367
  *
368
+ * @function iapRetrieveEntitiesCache
369
+ * @param {String} entityType - entity of which to retrieve
370
+ * @param {Object} options - settings of which data to return and how to return it
371
+ * @param {Callback} callback - the data if it was retrieved
456
372
  */
457
- iapUpdateAdapterEntityCache() {
458
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
373
+ iapRetrieveEntitiesCache(entityType, options, callback) {
374
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
375
+ const origin = `${this.id}-${meth}`;
459
376
  log.trace(origin);
460
377
 
461
- if (this.caching) {
462
- // if the cache is invalid, update the cache
463
- this.getEntities(null, null, null, null, (data, err) => {
464
- if (err) {
465
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
466
- }
467
- });
378
+ try {
379
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
380
+ } catch (err) {
381
+ log.error(`${origin}: ${err}`);
382
+ return callback(null, err);
468
383
  }
469
384
  }
470
385
 
386
+ /* BROKER CALLS */
471
387
  /**
472
388
  * @summary Determines if this adapter supports any in a list of entities
473
389
  *
@@ -602,6 +518,38 @@ class Infoblox extends AdapterBaseCl {
602
518
  }
603
519
 
604
520
  /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
521
+ /**
522
+ * Makes the requested generic call
523
+ *
524
+ * @function iapExpandedGenericAdapterRequest
525
+ * @param {Object} metadata - metadata for the call (optional).
526
+ * Can be a stringified Object.
527
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
528
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
529
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
530
+ * Can be a stringified Object.
531
+ * @param {Object} queryData - the parameters to be put on the url (optional).
532
+ * Can be a stringified Object.
533
+ * @param {Object} requestBody - the body to add to the request (optional).
534
+ * Can be a stringified Object.
535
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
536
+ * Can be a stringified Object.
537
+ * @param {getCallback} callback - a callback function to return the result (Generics)
538
+ * or the error
539
+ */
540
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
541
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
542
+ const origin = `${this.id}-${meth}`;
543
+ log.trace(origin);
544
+
545
+ try {
546
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
547
+ } catch (err) {
548
+ log.error(`${origin}: ${err}`);
549
+ return callback(null, err);
550
+ }
551
+ }
552
+
605
553
  /**
606
554
  * Makes the requested generic call
607
555
  *
@@ -622,93 +570,11 @@ class Infoblox extends AdapterBaseCl {
622
570
  const origin = `${this.id}-${meth}`;
623
571
  log.trace(origin);
624
572
 
625
- if (this.suspended && this.suspendMode === 'error') {
626
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
627
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
628
- return callback(null, errorObj);
629
- }
630
-
631
- /* HERE IS WHERE YOU VALIDATE DATA */
632
- if (uriPath === undefined || uriPath === null || uriPath === '') {
633
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
634
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
635
- return callback(null, errorObj);
636
- }
637
- if (restMethod === undefined || restMethod === null || restMethod === '') {
638
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
639
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
640
- return callback(null, errorObj);
641
- }
642
-
643
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
644
- // remove any leading / and split the uripath into path variables
645
- let myPath = uriPath;
646
- while (myPath.indexOf('/') === 0) {
647
- myPath = myPath.substring(1);
648
- }
649
- const pathVars = myPath.split('/');
650
- const queryParamsAvailable = queryData;
651
- const queryParams = {};
652
- const bodyVars = requestBody;
653
-
654
- // loop in template. long callback arg name to avoid identifier conflicts
655
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
656
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
657
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
658
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
659
- }
660
- });
661
-
662
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
663
- const reqObj = {
664
- payload: bodyVars,
665
- uriPathVars: pathVars,
666
- uriQuery: queryParams,
667
- uriOptions: {}
668
- };
669
- // add headers if provided
670
- if (addlHeaders) {
671
- reqObj.addlHeaders = addlHeaders;
672
- }
673
-
674
- // determine the call and return flag
675
- let action = 'getGenerics';
676
- let returnF = true;
677
- if (restMethod.toUpperCase() === 'POST') {
678
- action = 'createGeneric';
679
- } else if (restMethod.toUpperCase() === 'PUT') {
680
- action = 'updateGeneric';
681
- } else if (restMethod.toUpperCase() === 'PATCH') {
682
- action = 'patchGeneric';
683
- } else if (restMethod.toUpperCase() === 'DELETE') {
684
- action = 'deleteGeneric';
685
- returnF = false;
686
- }
687
-
688
573
  try {
689
- // Make the call -
690
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
691
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
692
- // if we received an error or their is no response on the results
693
- // return an error
694
- if (irReturnError) {
695
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
696
- return callback(null, irReturnError);
697
- }
698
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
699
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
700
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
701
- return callback(null, errorObj);
702
- }
703
-
704
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
705
- // return the response
706
- return callback(irReturnData, null);
707
- });
708
- } catch (ex) {
709
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
710
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
711
- return callback(null, errorObj);
574
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
575
+ } catch (err) {
576
+ log.error(`${origin}: ${err}`);
577
+ return callback(null, err);
712
578
  }
713
579
  }
714
580
 
@@ -732,94 +598,56 @@ class Infoblox extends AdapterBaseCl {
732
598
  const origin = `${this.id}-${meth}`;
733
599
  log.trace(origin);
734
600
 
735
- if (this.suspended && this.suspendMode === 'error') {
736
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
737
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
738
- return callback(null, errorObj);
739
- }
740
-
741
- /* HERE IS WHERE YOU VALIDATE DATA */
742
- if (uriPath === undefined || uriPath === null || uriPath === '') {
743
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
744
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
745
- return callback(null, errorObj);
746
- }
747
- if (restMethod === undefined || restMethod === null || restMethod === '') {
748
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
749
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
750
- return callback(null, errorObj);
601
+ try {
602
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
603
+ } catch (err) {
604
+ log.error(`${origin}: ${err}`);
605
+ return callback(null, err);
751
606
  }
607
+ }
752
608
 
753
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
754
- // remove any leading / and split the uripath into path variables
755
- let myPath = uriPath;
756
- while (myPath.indexOf('/') === 0) {
757
- myPath = myPath.substring(1);
758
- }
759
- const pathVars = myPath.split('/');
760
- const queryParamsAvailable = queryData;
761
- const queryParams = {};
762
- const bodyVars = requestBody;
609
+ /* INVENTORY CALLS */
610
+ /**
611
+ * @summary run the adapter lint script to return the results.
612
+ *
613
+ * @function iapRunAdapterLint
614
+ * @param {Callback} callback - callback function
615
+ */
616
+ iapRunAdapterLint(callback) {
617
+ const meth = 'adapter-iapRunAdapterLint';
618
+ const origin = `${this.id}-${meth}`;
619
+ log.trace(origin);
763
620
 
764
- // loop in template. long callback arg name to avoid identifier conflicts
765
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
766
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
767
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
768
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
769
- }
770
- });
621
+ return super.iapRunAdapterLint(callback);
622
+ }
771
623
 
772
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
773
- const reqObj = {
774
- payload: bodyVars,
775
- uriPathVars: pathVars,
776
- uriQuery: queryParams,
777
- uriOptions: {}
778
- };
779
- // add headers if provided
780
- if (addlHeaders) {
781
- reqObj.addlHeaders = addlHeaders;
782
- }
624
+ /**
625
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
626
+ * can not run integration as there can be implications with that.
627
+ *
628
+ * @function iapRunAdapterTests
629
+ * @param {Callback} callback - callback function
630
+ */
631
+ iapRunAdapterTests(callback) {
632
+ const meth = 'adapter-iapRunAdapterTests';
633
+ const origin = `${this.id}-${meth}`;
634
+ log.trace(origin);
783
635
 
784
- // determine the call and return flag
785
- let action = 'getGenericsNoBase';
786
- let returnF = true;
787
- if (restMethod.toUpperCase() === 'POST') {
788
- action = 'createGenericNoBase';
789
- } else if (restMethod.toUpperCase() === 'PUT') {
790
- action = 'updateGenericNoBase';
791
- } else if (restMethod.toUpperCase() === 'PATCH') {
792
- action = 'patchGenericNoBase';
793
- } else if (restMethod.toUpperCase() === 'DELETE') {
794
- action = 'deleteGenericNoBase';
795
- returnF = false;
796
- }
636
+ return super.iapRunAdapterTests(callback);
637
+ }
797
638
 
798
- try {
799
- // Make the call -
800
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
801
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
802
- // if we received an error or their is no response on the results
803
- // return an error
804
- if (irReturnError) {
805
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
806
- return callback(null, irReturnError);
807
- }
808
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
809
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
810
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
811
- return callback(null, errorObj);
812
- }
639
+ /**
640
+ * @summary provide inventory information abbout the adapter
641
+ *
642
+ * @function iapGetAdapterInventory
643
+ * @param {Callback} callback - callback function
644
+ */
645
+ iapGetAdapterInventory(callback) {
646
+ const meth = 'adapter-iapGetAdapterInventory';
647
+ const origin = `${this.id}-${meth}`;
648
+ log.trace(origin);
813
649
 
814
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
815
- // return the response
816
- return callback(irReturnData, null);
817
- });
818
- } catch (ex) {
819
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
820
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
821
- return callback(null, errorObj);
822
- }
650
+ return super.iapGetAdapterInventory(callback);
823
651
  }
824
652
 
825
653
  /**
@@ -1495,6 +1323,72 @@ class Infoblox extends AdapterBaseCl {
1495
1323
  }
1496
1324
  }
1497
1325
 
1326
+ /**
1327
+ * @summary This function will get the list of network containers
1328
+ *
1329
+ * @function listNetworkContainers
1330
+ * @param {object} query - optional query params for request
1331
+ * @param {getCallback} callback - a callback function to return the result
1332
+ * (entities) or the error
1333
+ */
1334
+ listNetworkContainers(query, callback) {
1335
+ const meth = 'adapter-listNetworkContainers';
1336
+ const origin = `${this.id}-${meth}`;
1337
+ log.trace(origin);
1338
+
1339
+ if (this.suspended && this.suspendMode === 'error') {
1340
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1341
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1342
+ return callback(null, errorObj);
1343
+ }
1344
+
1345
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1346
+ const queryParamsAvailable = {};
1347
+ const queryParams = {};
1348
+ const pathVars = [];
1349
+ const bodyVars = {};
1350
+ if (query) {
1351
+ Object.assign(queryParamsAvailable, query);
1352
+ }
1353
+
1354
+ // loop in template. long callback arg name to avoid identifier conflicts
1355
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1356
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1357
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1358
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1359
+ }
1360
+ });
1361
+
1362
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1363
+ // see adapter code documentation for more information on the request object's fields
1364
+ const reqObj = {
1365
+ payload: bodyVars,
1366
+ uriPathVars: pathVars,
1367
+ uriQuery: queryParams
1368
+ };
1369
+
1370
+ try {
1371
+ // Make the call -
1372
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1373
+ return this.requestHandlerInst.identifyRequest('Networks', 'listNetworkContainers', reqObj, true, (irReturnData, irReturnError) => {
1374
+ // if we received an error or their is no response on the results
1375
+ // return an error
1376
+ if (irReturnError) {
1377
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1378
+ return callback(null, irReturnError);
1379
+ }
1380
+
1381
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1382
+ // return the response
1383
+ return callback(irReturnData);
1384
+ });
1385
+ } catch (ex) {
1386
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1387
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1388
+ return callback(null, errorObj);
1389
+ }
1390
+ }
1391
+
1498
1392
  /**
1499
1393
  * @summary This function will get the auth zone details
1500
1394
  *
@@ -3629,6 +3523,16 @@ class Infoblox extends AdapterBaseCl {
3629
3523
  }
3630
3524
 
3631
3525
  /* HERE IS WHERE YOU VALIDATE DATA */
3526
+ if (networkIP === undefined || networkIP === null || networkIP === '') {
3527
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['networkIP'], null, null, null);
3528
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3529
+ return callback(null, errorObj);
3530
+ }
3531
+ if (comment === undefined || comment === null || comment === '') {
3532
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['comment'], null, null, null);
3533
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3534
+ return callback(null, errorObj);
3535
+ }
3632
3536
 
3633
3537
  /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3634
3538
  const queryParamsAvailable = {};