@itentialopensource/adapter-microsoft_graph 1.0.2 → 1.1.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.
Files changed (48) hide show
  1. package/.eslintignore +0 -1
  2. package/.jshintrc +3 -0
  3. package/AUTH.md +20 -16
  4. package/CALLS.md +69 -28
  5. package/CHANGELOG.md +16 -0
  6. package/CONTRIBUTING.md +1 -160
  7. package/ENHANCE.md +2 -2
  8. package/README.md +31 -22
  9. package/SUMMARY.md +2 -2
  10. package/SYSTEMINFO.md +15 -5
  11. package/adapter.js +248 -330
  12. package/adapterBase.js +538 -873
  13. package/changelogs/changelog.md +6 -0
  14. package/entities/Mail/action.json +20 -0
  15. package/entities/Mail/schema.json +1 -0
  16. package/metadata.json +52 -0
  17. package/package.json +22 -25
  18. package/pronghorn.json +550 -144
  19. package/propertiesSchema.json +444 -40
  20. package/refs?service=git-upload-pack +0 -0
  21. package/report/adapter-openapi.json +14709 -0
  22. package/report/adapter-openapi.yaml +9744 -0
  23. package/report/adapterInfo.json +8 -8
  24. package/report/updateReport1691507370664.json +120 -0
  25. package/report/updateReport1692202407231.json +120 -0
  26. package/report/updateReport1694460353234.json +120 -0
  27. package/report/updateReport1695667793473.json +120 -0
  28. package/sampleProperties.json +63 -2
  29. package/test/integration/adapterTestBasicGet.js +1 -1
  30. package/test/integration/adapterTestConnectivity.js +91 -42
  31. package/test/integration/adapterTestIntegration.js +130 -2
  32. package/test/unit/adapterBaseTestUnit.js +395 -292
  33. package/test/unit/adapterTestUnit.js +306 -109
  34. package/utils/adapterInfo.js +1 -1
  35. package/utils/addAuth.js +1 -1
  36. package/utils/artifactize.js +1 -1
  37. package/utils/checkMigrate.js +1 -1
  38. package/utils/entitiesToDB.js +1 -0
  39. package/utils/findPath.js +1 -1
  40. package/utils/methodDocumentor.js +57 -22
  41. package/utils/modify.js +13 -15
  42. package/utils/packModificationScript.js +1 -1
  43. package/utils/taskMover.js +309 -0
  44. package/utils/tbScript.js +3 -10
  45. package/utils/tbUtils.js +2 -3
  46. package/utils/testRunner.js +1 -1
  47. package/utils/troubleshootingAdapter.js +1 -3
  48. package/workflows/README.md +0 -3
package/adapter.js CHANGED
@@ -86,10 +86,8 @@ class MicrosoftGraph extends AdapterBaseCl {
86
86
  let myIgnore = [
87
87
  'healthCheck',
88
88
  'iapGetAdapterWorkflowFunctions',
89
- 'iapHasAdapterEntity',
90
- 'iapVerifyAdapterCapability',
91
- 'iapUpdateAdapterEntityCache',
92
- 'hasEntities'
89
+ 'hasEntities',
90
+ 'getAuthorization'
93
91
  ];
94
92
  if (!inIgnore && Array.isArray(inIgnore)) {
95
93
  myIgnore = inIgnore;
@@ -115,29 +113,15 @@ class MicrosoftGraph extends AdapterBaseCl {
115
113
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
116
114
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
117
115
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
116
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
118
117
  * @param {Callback} callback - The results of the call
119
118
  */
120
- iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
119
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
121
120
  const meth = 'adapter-iapUpdateAdapterConfiguration';
122
121
  const origin = `${this.id}-${meth}`;
123
122
  log.trace(origin);
124
123
 
125
- super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
126
- }
127
-
128
- /**
129
- * See if the API path provided is found in this adapter
130
- *
131
- * @function iapFindAdapterPath
132
- * @param {string} apiPath - the api path to check on
133
- * @param {Callback} callback - The results of the call
134
- */
135
- iapFindAdapterPath(apiPath, callback) {
136
- const meth = 'adapter-iapFindAdapterPath';
137
- const origin = `${this.id}-${meth}`;
138
- log.trace(origin);
139
-
140
- super.iapFindAdapterPath(apiPath, callback);
124
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
141
125
  }
142
126
 
143
127
  /**
@@ -179,7 +163,7 @@ class MicrosoftGraph extends AdapterBaseCl {
179
163
  }
180
164
 
181
165
  /**
182
- * @summary Get the Adaoter Queue
166
+ * @summary Get the Adapter Queue
183
167
  *
184
168
  * @function iapGetAdapterQueue
185
169
  * @param {Callback} callback - callback function
@@ -192,6 +176,22 @@ class MicrosoftGraph extends AdapterBaseCl {
192
176
  return super.iapGetAdapterQueue(callback);
193
177
  }
194
178
 
179
+ /* SCRIPT CALLS */
180
+ /**
181
+ * See if the API path provided is found in this adapter
182
+ *
183
+ * @function iapFindAdapterPath
184
+ * @param {string} apiPath - the api path to check on
185
+ * @param {Callback} callback - The results of the call
186
+ */
187
+ iapFindAdapterPath(apiPath, callback) {
188
+ const meth = 'adapter-iapFindAdapterPath';
189
+ const origin = `${this.id}-${meth}`;
190
+ log.trace(origin);
191
+
192
+ super.iapFindAdapterPath(apiPath, callback);
193
+ }
194
+
195
195
  /**
196
196
  * @summary Runs troubleshoot scripts for adapter
197
197
  *
@@ -292,176 +292,93 @@ class MicrosoftGraph extends AdapterBaseCl {
292
292
  }
293
293
  }
294
294
 
295
- /* BROKER CALLS */
296
295
  /**
297
- * @summary Determines if this adapter supports the specific entity
296
+ * @summary Deactivate adapter tasks
298
297
  *
299
- * @function iapHasAdapterEntity
300
- * @param {String} entityType - the entity type to check for
301
- * @param {String/Array} entityId - the specific entity we are looking for
298
+ * @function iapDeactivateTasks
302
299
  *
303
- * @param {Callback} callback - An array of whether the adapter can has the
304
- * desired capability or an error
300
+ * @param {Array} tasks - List of tasks to deactivate
301
+ * @param {Callback} callback
305
302
  */
306
- iapHasAdapterEntity(entityType, entityId, callback) {
307
- const origin = `${this.id}-adapter-iapHasAdapterEntity`;
303
+ iapDeactivateTasks(tasks, callback) {
304
+ const meth = 'adapter-iapDeactivateTasks';
305
+ const origin = `${this.id}-${meth}`;
308
306
  log.trace(origin);
309
307
 
310
- // Make the call -
311
- // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
312
- return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
308
+ try {
309
+ return super.iapDeactivateTasks(tasks, callback);
310
+ } catch (err) {
311
+ log.error(`${origin}: ${err}`);
312
+ return callback(null, err);
313
+ }
313
314
  }
314
315
 
315
316
  /**
316
- * @summary Provides a way for the adapter to tell north bound integrations
317
- * whether the adapter supports type, action and specific entity
317
+ * @summary Activate adapter tasks that have previously been deactivated
318
318
  *
319
- * @function iapVerifyAdapterCapability
320
- * @param {String} entityType - the entity type to check for
321
- * @param {String} actionType - the action type to check for
322
- * @param {String/Array} entityId - the specific entity we are looking for
319
+ * @function iapActivateTasks
323
320
  *
324
- * @param {Callback} callback - An array of whether the adapter can has the
325
- * desired capability or an error
321
+ * @param {Array} tasks - List of tasks to activate
322
+ * @param {Callback} callback
326
323
  */
327
- iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
328
- const meth = 'adapterBase-iapVerifyAdapterCapability';
324
+ iapActivateTasks(tasks, callback) {
325
+ const meth = 'adapter-iapActivateTasks';
329
326
  const origin = `${this.id}-${meth}`;
330
327
  log.trace(origin);
331
328
 
332
- // if caching
333
- if (this.caching) {
334
- // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
335
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
336
- if (error) {
337
- return callback(null, error);
338
- }
339
-
340
- // if the cache needs to be updated, update and try again
341
- if (results && results[0] === 'needupdate') {
342
- switch (entityType) {
343
- case 'template_entity': {
344
- // if the cache is invalid, update the cache
345
- return this.getEntities(null, null, null, null, (data, err) => {
346
- if (err) {
347
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
348
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
349
- return callback(null, errorObj);
350
- }
351
-
352
- // need to check the cache again since it has been updated
353
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
354
- if (verror) {
355
- return callback(null, verror);
356
- }
357
-
358
- return this.capabilityResults(vcapable, callback);
359
- });
360
- });
361
- }
362
- default: {
363
- // unsupported entity type
364
- const result = [false];
365
-
366
- // put false in array for all entities
367
- if (Array.isArray(entityId)) {
368
- for (let e = 1; e < entityId.length; e += 1) {
369
- result.push(false);
370
- }
371
- }
372
-
373
- return callback(result);
374
- }
375
- }
376
- }
377
-
378
- // return the results
379
- return this.capabilityResults(results, callback);
380
- });
381
- }
382
-
383
- // if no entity id
384
- if (!entityId) {
385
- // need to check the cache again since it has been updated
386
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
387
- if (verror) {
388
- return callback(null, verror);
389
- }
390
-
391
- return this.capabilityResults(vcapable, callback);
392
- });
329
+ try {
330
+ return super.iapActivateTasks(tasks, callback);
331
+ } catch (err) {
332
+ log.error(`${origin}: ${err}`);
333
+ return callback(null, err);
393
334
  }
335
+ }
394
336
 
395
- // if not caching
396
- switch (entityType) {
397
- case 'template_entity': {
398
- // need to get the entities to check
399
- return this.getEntities(null, null, null, null, (data, err) => {
400
- if (err) {
401
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
402
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
403
- return callback(null, errorObj);
404
- }
405
-
406
- // need to check the cache again since it has been updated
407
- return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
408
- if (verror) {
409
- return callback(null, verror);
410
- }
411
-
412
- // is the entity in the list?
413
- const isEntity = this.entityInList(entityId, data.response, callback);
414
- const res = [];
415
-
416
- // not found
417
- for (let i = 0; i < isEntity.length; i += 1) {
418
- if (vcapable) {
419
- res.push(isEntity[i]);
420
- } else {
421
- res.push(false);
422
- }
423
- }
424
-
425
- return callback(res);
426
- });
427
- });
428
- }
429
- default: {
430
- // unsupported entity type
431
- const result = [false];
432
-
433
- // put false in array for all entities
434
- if (Array.isArray(entityId)) {
435
- for (let e = 1; e < entityId.length; e += 1) {
436
- result.push(false);
437
- }
438
- }
337
+ /* CACHE CALLS */
338
+ /**
339
+ * @summary Populate the cache for the given entities
340
+ *
341
+ * @function iapPopulateEntityCache
342
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
343
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
344
+ *
345
+ * @returns status of the populate
346
+ */
347
+ iapPopulateEntityCache(entityTypes, callback) {
348
+ const meth = 'adapter-iapPopulateEntityCache';
349
+ const origin = `${this.id}-${meth}`;
350
+ log.trace(origin);
439
351
 
440
- return callback(result);
441
- }
352
+ try {
353
+ return super.iapPopulateEntityCache(entityTypes, callback);
354
+ } catch (err) {
355
+ log.error(`${origin}: ${err}`);
356
+ return callback(null, err);
442
357
  }
443
358
  }
444
359
 
445
360
  /**
446
- * @summary Updates the cache for all entities by call the get All entity method
447
- *
448
- * @function iapUpdateAdapterEntityCache
361
+ * @summary Retrieves data from cache for specified entity type
449
362
  *
363
+ * @function iapRetrieveEntitiesCache
364
+ * @param {String} entityType - entity of which to retrieve
365
+ * @param {Object} options - settings of which data to return and how to return it
366
+ * @param {Callback} callback - the data if it was retrieved
450
367
  */
451
- iapUpdateAdapterEntityCache() {
452
- const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
368
+ iapRetrieveEntitiesCache(entityType, options, callback) {
369
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
370
+ const origin = `${this.id}-${meth}`;
453
371
  log.trace(origin);
454
372
 
455
- if (this.caching) {
456
- // if the cache is invalid, update the cache
457
- this.getEntities(null, null, null, null, (data, err) => {
458
- if (err) {
459
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
460
- }
461
- });
373
+ try {
374
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
375
+ } catch (err) {
376
+ log.error(`${origin}: ${err}`);
377
+ return callback(null, err);
462
378
  }
463
379
  }
464
380
 
381
+ /* BROKER CALLS */
465
382
  /**
466
383
  * @summary Determines if this adapter supports any in a list of entities
467
384
  *
@@ -596,6 +513,38 @@ class MicrosoftGraph extends AdapterBaseCl {
596
513
  }
597
514
 
598
515
  /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
516
+ /**
517
+ * Makes the requested generic call
518
+ *
519
+ * @function iapExpandedGenericAdapterRequest
520
+ * @param {Object} metadata - metadata for the call (optional).
521
+ * Can be a stringified Object.
522
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
523
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
524
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
525
+ * Can be a stringified Object.
526
+ * @param {Object} queryData - the parameters to be put on the url (optional).
527
+ * Can be a stringified Object.
528
+ * @param {Object} requestBody - the body to add to the request (optional).
529
+ * Can be a stringified Object.
530
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
531
+ * Can be a stringified Object.
532
+ * @param {getCallback} callback - a callback function to return the result (Generics)
533
+ * or the error
534
+ */
535
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
536
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
537
+ const origin = `${this.id}-${meth}`;
538
+ log.trace(origin);
539
+
540
+ try {
541
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
542
+ } catch (err) {
543
+ log.error(`${origin}: ${err}`);
544
+ return callback(null, err);
545
+ }
546
+ }
547
+
599
548
  /**
600
549
  * Makes the requested generic call
601
550
  *
@@ -616,93 +565,11 @@ class MicrosoftGraph extends AdapterBaseCl {
616
565
  const origin = `${this.id}-${meth}`;
617
566
  log.trace(origin);
618
567
 
619
- if (this.suspended && this.suspendMode === 'error') {
620
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
621
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
622
- return callback(null, errorObj);
623
- }
624
-
625
- /* HERE IS WHERE YOU VALIDATE DATA */
626
- if (uriPath === undefined || uriPath === null || uriPath === '') {
627
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
628
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
629
- return callback(null, errorObj);
630
- }
631
- if (restMethod === undefined || restMethod === null || restMethod === '') {
632
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
633
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
634
- return callback(null, errorObj);
635
- }
636
-
637
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
638
- // remove any leading / and split the uripath into path variables
639
- let myPath = uriPath;
640
- while (myPath.indexOf('/') === 0) {
641
- myPath = myPath.substring(1);
642
- }
643
- const pathVars = myPath.split('/');
644
- const queryParamsAvailable = queryData;
645
- const queryParams = {};
646
- const bodyVars = requestBody;
647
-
648
- // loop in template. long callback arg name to avoid identifier conflicts
649
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
650
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
651
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
652
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
653
- }
654
- });
655
-
656
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
657
- const reqObj = {
658
- payload: bodyVars,
659
- uriPathVars: pathVars,
660
- uriQuery: queryParams,
661
- uriOptions: {}
662
- };
663
- // add headers if provided
664
- if (addlHeaders) {
665
- reqObj.addlHeaders = addlHeaders;
666
- }
667
-
668
- // determine the call and return flag
669
- let action = 'getGenerics';
670
- let returnF = true;
671
- if (restMethod.toUpperCase() === 'POST') {
672
- action = 'createGeneric';
673
- } else if (restMethod.toUpperCase() === 'PUT') {
674
- action = 'updateGeneric';
675
- } else if (restMethod.toUpperCase() === 'PATCH') {
676
- action = 'patchGeneric';
677
- } else if (restMethod.toUpperCase() === 'DELETE') {
678
- action = 'deleteGeneric';
679
- returnF = false;
680
- }
681
-
682
568
  try {
683
- // Make the call -
684
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
685
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
686
- // if we received an error or their is no response on the results
687
- // return an error
688
- if (irReturnError) {
689
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
690
- return callback(null, irReturnError);
691
- }
692
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
693
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
694
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
695
- return callback(null, errorObj);
696
- }
697
-
698
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
699
- // return the response
700
- return callback(irReturnData, null);
701
- });
702
- } catch (ex) {
703
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
704
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
705
- return callback(null, errorObj);
569
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
570
+ } catch (err) {
571
+ log.error(`${origin}: ${err}`);
572
+ return callback(null, err);
706
573
  }
707
574
  }
708
575
 
@@ -726,94 +593,56 @@ class MicrosoftGraph extends AdapterBaseCl {
726
593
  const origin = `${this.id}-${meth}`;
727
594
  log.trace(origin);
728
595
 
729
- if (this.suspended && this.suspendMode === 'error') {
730
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
731
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
732
- return callback(null, errorObj);
733
- }
734
-
735
- /* HERE IS WHERE YOU VALIDATE DATA */
736
- if (uriPath === undefined || uriPath === null || uriPath === '') {
737
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
738
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
739
- return callback(null, errorObj);
740
- }
741
- if (restMethod === undefined || restMethod === null || restMethod === '') {
742
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
743
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
744
- return callback(null, errorObj);
596
+ try {
597
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
598
+ } catch (err) {
599
+ log.error(`${origin}: ${err}`);
600
+ return callback(null, err);
745
601
  }
602
+ }
746
603
 
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);
752
- }
753
- const pathVars = myPath.split('/');
754
- const queryParamsAvailable = queryData;
755
- const queryParams = {};
756
- const bodyVars = requestBody;
604
+ /* INVENTORY CALLS */
605
+ /**
606
+ * @summary run the adapter lint script to return the results.
607
+ *
608
+ * @function iapRunAdapterLint
609
+ * @param {Callback} callback - callback function
610
+ */
611
+ iapRunAdapterLint(callback) {
612
+ const meth = 'adapter-iapRunAdapterLint';
613
+ const origin = `${this.id}-${meth}`;
614
+ log.trace(origin);
757
615
 
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];
763
- }
764
- });
616
+ return super.iapRunAdapterLint(callback);
617
+ }
765
618
 
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;
776
- }
619
+ /**
620
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
621
+ * can not run integration as there can be implications with that.
622
+ *
623
+ * @function iapRunAdapterTests
624
+ * @param {Callback} callback - callback function
625
+ */
626
+ iapRunAdapterTests(callback) {
627
+ const meth = 'adapter-iapRunAdapterTests';
628
+ const origin = `${this.id}-${meth}`;
629
+ log.trace(origin);
777
630
 
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;
790
- }
631
+ return super.iapRunAdapterTests(callback);
632
+ }
791
633
 
792
- try {
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);
801
- }
802
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
803
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
804
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
805
- return callback(null, errorObj);
806
- }
634
+ /**
635
+ * @summary provide inventory information abbout the adapter
636
+ *
637
+ * @function iapGetAdapterInventory
638
+ * @param {Callback} callback - callback function
639
+ */
640
+ iapGetAdapterInventory(callback) {
641
+ const meth = 'adapter-iapGetAdapterInventory';
642
+ const origin = `${this.id}-${meth}`;
643
+ log.trace(origin);
807
644
 
808
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
809
- // return the response
810
- return callback(irReturnData, null);
811
- });
812
- } catch (ex) {
813
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
814
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
815
- return callback(null, errorObj);
816
- }
645
+ return super.iapGetAdapterInventory(callback);
817
646
  }
818
647
 
819
648
  /**
@@ -7210,6 +7039,95 @@ class MicrosoftGraph extends AdapterBaseCl {
7210
7039
  }
7211
7040
  }
7212
7041
 
7042
+ /**
7043
+ * @function sendmailApplication
7044
+ * @pronghornType method
7045
+ * @name sendmailApplication
7046
+ * @summary Send mail
7047
+ *
7048
+ * @param {object} body - body param
7049
+ * @param {string} userId - user id or userPrincipalName to sendmail from
7050
+ * @param {getCallback} callback - a callback function to return the result
7051
+ * @return {object} results - An object containing the response of the action
7052
+ *
7053
+ * @route {POST} /sendmailApplication
7054
+ * @roles admin
7055
+ * @task true
7056
+ */
7057
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
7058
+ sendmailApplication(body, userId, callback) {
7059
+ const meth = 'adapter-sendmailApplication';
7060
+ const origin = `${this.id}-${meth}`;
7061
+ log.trace(origin);
7062
+
7063
+ if (this.suspended && this.suspendMode === 'error') {
7064
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
7065
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7066
+ return callback(null, errorObj);
7067
+ }
7068
+
7069
+ /* HERE IS WHERE YOU VALIDATE DATA */
7070
+ if (body === undefined || body === null || body === '') {
7071
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
7072
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7073
+ return callback(null, errorObj);
7074
+ }
7075
+ /* HERE IS WHERE YOU VALIDATE DATA */
7076
+ if (userId === undefined || userId === null || userId === '') {
7077
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['userId'], null, null, null);
7078
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7079
+ return callback(null, errorObj);
7080
+ }
7081
+
7082
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
7083
+ const queryParamsAvailable = {};
7084
+ const queryParams = {};
7085
+ const pathVars = [userId];
7086
+ const bodyVars = body;
7087
+
7088
+ // loop in template. long callback arg name to avoid identifier conflicts
7089
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
7090
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
7091
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
7092
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
7093
+ }
7094
+ });
7095
+
7096
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
7097
+ // see adapter code documentation for more information on the request object's fields
7098
+ const reqObj = {
7099
+ payload: bodyVars,
7100
+ uriPathVars: pathVars,
7101
+ uriQuery: queryParams
7102
+ };
7103
+
7104
+ try {
7105
+ // Make the call -
7106
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
7107
+ return this.requestHandlerInst.identifyRequest('Mail', 'sendmailApplication', reqObj, true, (irReturnData, irReturnError) => {
7108
+ // if we received an error or their is no response on the results
7109
+ // return an error
7110
+ if (irReturnError) {
7111
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
7112
+ return callback(null, irReturnError);
7113
+ }
7114
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
7115
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['sendmail'], null, null, null);
7116
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7117
+ return callback(null, errorObj);
7118
+ }
7119
+
7120
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
7121
+ // return the response
7122
+ return callback(irReturnData, null);
7123
+ });
7124
+ } catch (ex) {
7125
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
7126
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
7127
+ return callback(null, errorObj);
7128
+ }
7129
+ }
7130
+
7213
7131
  /**
7214
7132
  * @function getmailboxsettings
7215
7133
  * @pronghornType method