@itentialopensource/adapter-digicert_pki 0.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 (87) hide show
  1. package/.eslintignore +6 -0
  2. package/.eslintrc.js +18 -0
  3. package/.gitlab/.gitkeep +0 -0
  4. package/.gitlab/issue_templates/.gitkeep +0 -0
  5. package/.gitlab/issue_templates/Default.md +17 -0
  6. package/.gitlab/issue_templates/bugReportTemplate.md +76 -0
  7. package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
  8. package/.jshintrc +0 -0
  9. package/AUTH.md +39 -0
  10. package/BROKER.md +199 -0
  11. package/CALLS.md +356 -0
  12. package/CHANGELOG.md +9 -0
  13. package/CODE_OF_CONDUCT.md +43 -0
  14. package/CONTRIBUTING.md +172 -0
  15. package/ENHANCE.md +69 -0
  16. package/LICENSE +201 -0
  17. package/PROPERTIES.md +641 -0
  18. package/README.md +337 -0
  19. package/SUMMARY.md +9 -0
  20. package/SYSTEMINFO.md +11 -0
  21. package/TROUBLESHOOT.md +47 -0
  22. package/adapter.js +3945 -0
  23. package/adapterBase.js +1787 -0
  24. package/entities/.generic/action.json +214 -0
  25. package/entities/.generic/schema.json +28 -0
  26. package/entities/.system/action.json +50 -0
  27. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  28. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  29. package/entities/.system/schema.json +19 -0
  30. package/entities/.system/schemaTokenReq.json +53 -0
  31. package/entities/.system/schemaTokenResp.json +53 -0
  32. package/entities/AuditAPI/action.json +46 -0
  33. package/entities/AuditAPI/schema.json +20 -0
  34. package/entities/CAAPI/action.json +46 -0
  35. package/entities/CAAPI/schema.json +20 -0
  36. package/entities/CertificateEnrollmentAPI/action.json +166 -0
  37. package/entities/CertificateEnrollmentAPI/schema.json +26 -0
  38. package/entities/CertificateProfileAPI/action.json +46 -0
  39. package/entities/CertificateProfileAPI/mockdatafiles/getAllProfilesUsingGET-default.json +1288 -0
  40. package/entities/CertificateProfileAPI/schema.json +20 -0
  41. package/entities/EnrollStatusAPI/action.json +25 -0
  42. package/entities/EnrollStatusAPI/mockdatafiles/enrollStatusUsingGET-default.json +17 -0
  43. package/entities/EnrollStatusAPI/schema.json +30 -0
  44. package/entities/HelloAPI/action.json +25 -0
  45. package/entities/HelloAPI/schema.json +19 -0
  46. package/entities/PROFILEAPI/action.json +124 -0
  47. package/entities/PROFILEAPI/schema.json +24 -0
  48. package/entities/SearchCertificateAPI/action.json +24 -0
  49. package/entities/SearchCertificateAPI/schema.json +19 -0
  50. package/entities/SeatManagementAPI/action.json +85 -0
  51. package/entities/SeatManagementAPI/schema.json +22 -0
  52. package/entities/UserManagementAPI/action.json +85 -0
  53. package/entities/UserManagementAPI/schema.json +33 -0
  54. package/error.json +190 -0
  55. package/package.json +86 -0
  56. package/pronghorn.json +4141 -0
  57. package/propertiesDecorators.json +14 -0
  58. package/propertiesSchema.json +1248 -0
  59. package/refs?service=git-upload-pack +0 -0
  60. package/report/DigiCert One Swagger v1.0.44.json +1 -0
  61. package/report/adapterInfo.json +10 -0
  62. package/report/creationReport.json +490 -0
  63. package/sampleProperties.json +195 -0
  64. package/test/integration/adapterTestBasicGet.js +83 -0
  65. package/test/integration/adapterTestConnectivity.js +93 -0
  66. package/test/integration/adapterTestIntegration.js +1867 -0
  67. package/test/unit/adapterBaseTestUnit.js +949 -0
  68. package/test/unit/adapterTestUnit.js +2278 -0
  69. package/utils/adapterInfo.js +206 -0
  70. package/utils/addAuth.js +94 -0
  71. package/utils/artifactize.js +146 -0
  72. package/utils/basicGet.js +50 -0
  73. package/utils/checkMigrate.js +63 -0
  74. package/utils/entitiesToDB.js +178 -0
  75. package/utils/findPath.js +74 -0
  76. package/utils/methodDocumentor.js +225 -0
  77. package/utils/modify.js +154 -0
  78. package/utils/packModificationScript.js +35 -0
  79. package/utils/patches2bundledDeps.js +90 -0
  80. package/utils/pre-commit.sh +32 -0
  81. package/utils/removeHooks.js +20 -0
  82. package/utils/setup.js +33 -0
  83. package/utils/tbScript.js +246 -0
  84. package/utils/tbUtils.js +490 -0
  85. package/utils/testRunner.js +298 -0
  86. package/utils/troubleshootingAdapter.js +195 -0
  87. package/workflows/README.md +3 -0
package/adapter.js ADDED
@@ -0,0 +1,3945 @@
1
+ /* @copyright Itential, LLC 2019 (pre-modifications) */
2
+
3
+ /* eslint import/no-dynamic-require: warn */
4
+ /* eslint object-curly-newline: warn */
5
+
6
+ // Set globals
7
+ /* global log */
8
+
9
+ /* Required libraries. */
10
+ const path = require('path');
11
+
12
+ /* Fetch in the other needed components for the this Adaptor */
13
+ const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
14
+
15
+ /**
16
+ * This is the adapter/interface into Digicert
17
+ */
18
+
19
+ /* GENERAL ADAPTER FUNCTIONS */
20
+ class Digicert extends AdapterBaseCl {
21
+ /**
22
+ * Digicert Adapter
23
+ * @constructor
24
+ */
25
+ /* Working on changing the way we do Emit methods due to size and time constrainsts
26
+ constructor(prongid, properties) {
27
+ // Instantiate the AdapterBase super class
28
+ super(prongid, properties);
29
+
30
+ const restFunctionNames = this.iapGetAdapterWorkflowFunctions();
31
+
32
+ // Dynamically bind emit functions
33
+ for (let i = 0; i < restFunctionNames.length; i += 1) {
34
+ // Bind function to have name fnNameEmit for fnName
35
+ const version = restFunctionNames[i].match(/__v[0-9]+/);
36
+ const baseFnName = restFunctionNames[i].replace(/__v[0-9]+/, '');
37
+ const fnNameEmit = version ? `${baseFnName}Emit${version}` : `${baseFnName}Emit`;
38
+ this[fnNameEmit] = function (...args) {
39
+ // extract the callback
40
+ const callback = args[args.length - 1];
41
+ // slice the callback from args so we can insert our own
42
+ const functionArgs = args.slice(0, args.length - 1);
43
+ // create a random name for the listener
44
+ const eventName = `${restFunctionNames[i]}:${Math.random().toString(36)}`;
45
+ // tell the calling class to start listening
46
+ callback({ event: eventName, status: 'received' });
47
+ // store parent for use of this context later
48
+ const parent = this;
49
+ // store emission function
50
+ const func = function (val, err) {
51
+ parent.removeListener(eventName, func);
52
+ parent.emit(eventName, val, err);
53
+ };
54
+ // Use apply to call the function in a specific context
55
+ this[restFunctionNames[i]].apply(this, functionArgs.concat([func])); // eslint-disable-line prefer-spread
56
+ };
57
+ }
58
+
59
+ // Uncomment if you have things to add to the constructor like using your own properties.
60
+ // Otherwise the constructor in the adapterBase will be used.
61
+ // Capture my own properties - they need to be defined in propertiesSchema.json
62
+ // if (this.allProps && this.allProps.myownproperty) {
63
+ // mypropvariable = this.allProps.myownproperty;
64
+ // }
65
+ }
66
+ */
67
+
68
+ /**
69
+ * @callback healthCallback
70
+ * @param {Object} reqObj - the request to send into the healthcheck
71
+ * @param {Callback} callback - The results of the call
72
+ */
73
+ healthCheck(reqObj, callback) {
74
+ // you can modify what is passed into the healthcheck by changing things in the newReq
75
+ let newReq = null;
76
+ if (reqObj) {
77
+ newReq = Object.assign(...reqObj);
78
+ }
79
+ super.healthCheck(newReq, callback);
80
+ }
81
+
82
+ /**
83
+ * @iapGetAdapterWorkflowFunctions
84
+ */
85
+ iapGetAdapterWorkflowFunctions(inIgnore) {
86
+ let myIgnore = [
87
+ 'healthCheck',
88
+ 'iapGetAdapterWorkflowFunctions',
89
+ 'iapHasAdapterEntity',
90
+ 'iapVerifyAdapterCapability',
91
+ 'iapUpdateAdapterEntityCache',
92
+ 'hasEntities'
93
+ ];
94
+ if (!inIgnore && Array.isArray(inIgnore)) {
95
+ myIgnore = inIgnore;
96
+ } else if (!inIgnore && typeof inIgnore === 'string') {
97
+ myIgnore = [inIgnore];
98
+ }
99
+
100
+ // The generic adapter functions should already be ignored (e.g. healthCheck)
101
+ // you can add specific methods that you do not want to be workflow functions to ignore like below
102
+ // myIgnore.push('myMethodNotInWorkflow');
103
+
104
+ return super.iapGetAdapterWorkflowFunctions(myIgnore);
105
+ }
106
+
107
+ /**
108
+ * iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
109
+ * allows customers to make changes to adapter configuration without having to be on the
110
+ * file system.
111
+ *
112
+ * @function iapUpdateAdapterConfiguration
113
+ * @param {string} configFile - the name of the file being updated (required)
114
+ * @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
115
+ * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
116
+ * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
117
+ * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
118
+ * @param {Callback} callback - The results of the call
119
+ */
120
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
121
+ const meth = 'adapter-iapUpdateAdapterConfiguration';
122
+ const origin = `${this.id}-${meth}`;
123
+ log.trace(origin);
124
+
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);
141
+ }
142
+
143
+ /**
144
+ * @summary Suspends adapter
145
+ *
146
+ * @function iapSuspendAdapter
147
+ * @param {Callback} callback - callback function
148
+ */
149
+ iapSuspendAdapter(mode, callback) {
150
+ const meth = 'adapter-iapSuspendAdapter';
151
+ const origin = `${this.id}-${meth}`;
152
+ log.trace(origin);
153
+
154
+ try {
155
+ return super.iapSuspendAdapter(mode, callback);
156
+ } catch (error) {
157
+ log.error(`${origin}: ${error}`);
158
+ return callback(null, error);
159
+ }
160
+ }
161
+
162
+ /**
163
+ * @summary Unsuspends adapter
164
+ *
165
+ * @function iapUnsuspendAdapter
166
+ * @param {Callback} callback - callback function
167
+ */
168
+ iapUnsuspendAdapter(callback) {
169
+ const meth = 'adapter-iapUnsuspendAdapter';
170
+ const origin = `${this.id}-${meth}`;
171
+ log.trace(origin);
172
+
173
+ try {
174
+ return super.iapUnsuspendAdapter(callback);
175
+ } catch (error) {
176
+ log.error(`${origin}: ${error}`);
177
+ return callback(null, error);
178
+ }
179
+ }
180
+
181
+ /**
182
+ * @summary Get the Adaoter Queue
183
+ *
184
+ * @function iapGetAdapterQueue
185
+ * @param {Callback} callback - callback function
186
+ */
187
+ iapGetAdapterQueue(callback) {
188
+ const meth = 'adapter-iapGetAdapterQueue';
189
+ const origin = `${this.id}-${meth}`;
190
+ log.trace(origin);
191
+
192
+ return super.iapGetAdapterQueue(callback);
193
+ }
194
+
195
+ /**
196
+ * @summary Runs troubleshoot scripts for adapter
197
+ *
198
+ * @function iapTroubleshootAdapter
199
+ * @param {Object} props - the connection, healthcheck and authentication properties
200
+ *
201
+ * @param {boolean} persistFlag - whether the adapter properties should be updated
202
+ * @param {Callback} callback - The results of the call
203
+ */
204
+ iapTroubleshootAdapter(props, persistFlag, callback) {
205
+ const meth = 'adapter-iapTroubleshootAdapter';
206
+ const origin = `${this.id}-${meth}`;
207
+ log.trace(origin);
208
+
209
+ try {
210
+ return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
211
+ } catch (error) {
212
+ log.error(`${origin}: ${error}`);
213
+ return callback(null, error);
214
+ }
215
+ }
216
+
217
+ /**
218
+ * @summary runs healthcheck script for adapter
219
+ *
220
+ * @function iapRunAdapterHealthcheck
221
+ * @param {Adapter} adapter - adapter instance to troubleshoot
222
+ * @param {Callback} callback - callback function
223
+ */
224
+ iapRunAdapterHealthcheck(callback) {
225
+ const meth = 'adapter-iapRunAdapterHealthcheck';
226
+ const origin = `${this.id}-${meth}`;
227
+ log.trace(origin);
228
+
229
+ try {
230
+ return super.iapRunAdapterHealthcheck(this, callback);
231
+ } catch (error) {
232
+ log.error(`${origin}: ${error}`);
233
+ return callback(null, error);
234
+ }
235
+ }
236
+
237
+ /**
238
+ * @summary runs connectivity check script for adapter
239
+ *
240
+ * @function iapRunAdapterConnectivity
241
+ * @param {Callback} callback - callback function
242
+ */
243
+ iapRunAdapterConnectivity(callback) {
244
+ const meth = 'adapter-iapRunAdapterConnectivity';
245
+ const origin = `${this.id}-${meth}`;
246
+ log.trace(origin);
247
+
248
+ try {
249
+ return super.iapRunAdapterConnectivity(callback);
250
+ } catch (error) {
251
+ log.error(`${origin}: ${error}`);
252
+ return callback(null, error);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * @summary runs basicGet script for adapter
258
+ *
259
+ * @function iapRunAdapterBasicGet
260
+ * @param {Callback} callback - callback function
261
+ */
262
+ iapRunAdapterBasicGet(callback) {
263
+ const meth = 'adapter-iapRunAdapterBasicGet';
264
+ const origin = `${this.id}-${meth}`;
265
+ log.trace(origin);
266
+
267
+ try {
268
+ return super.iapRunAdapterBasicGet(callback);
269
+ } catch (error) {
270
+ log.error(`${origin}: ${error}`);
271
+ return callback(null, error);
272
+ }
273
+ }
274
+
275
+ /**
276
+ * @summary moves entites into Mongo DB
277
+ *
278
+ * @function iapMoveAdapterEntitiesToDB
279
+ * @param {getCallback} callback - a callback function to return the result (Generics)
280
+ * or the error
281
+ */
282
+ iapMoveAdapterEntitiesToDB(callback) {
283
+ const meth = 'adapter-iapMoveAdapterEntitiesToDB';
284
+ const origin = `${this.id}-${meth}`;
285
+ log.trace(origin);
286
+
287
+ try {
288
+ return super.iapMoveAdapterEntitiesToDB(callback);
289
+ } catch (err) {
290
+ log.error(`${origin}: ${err}`);
291
+ return callback(null, err);
292
+ }
293
+ }
294
+
295
+ /* BROKER CALLS */
296
+ /**
297
+ * @summary Determines if this adapter supports the specific entity
298
+ *
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
302
+ *
303
+ * @param {Callback} callback - An array of whether the adapter can has the
304
+ * desired capability or an error
305
+ */
306
+ iapHasAdapterEntity(entityType, entityId, callback) {
307
+ const origin = `${this.id}-adapter-iapHasAdapterEntity`;
308
+ log.trace(origin);
309
+
310
+ // Make the call -
311
+ // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
312
+ return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
313
+ }
314
+
315
+ /**
316
+ * @summary Provides a way for the adapter to tell north bound integrations
317
+ * whether the adapter supports type, action and specific entity
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
323
+ *
324
+ * @param {Callback} callback - An array of whether the adapter can has the
325
+ * desired capability or an error
326
+ */
327
+ iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
328
+ const meth = 'adapterBase-iapVerifyAdapterCapability';
329
+ const origin = `${this.id}-${meth}`;
330
+ log.trace(origin);
331
+
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
+ });
393
+ }
394
+
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
+ }
439
+
440
+ return callback(result);
441
+ }
442
+ }
443
+ }
444
+
445
+ /**
446
+ * @summary Updates the cache for all entities by call the get All entity method
447
+ *
448
+ * @function iapUpdateAdapterEntityCache
449
+ *
450
+ */
451
+ iapUpdateAdapterEntityCache() {
452
+ const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
453
+ log.trace(origin);
454
+
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
+ });
462
+ }
463
+ }
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 */
599
+ /**
600
+ * Makes the requested generic call
601
+ *
602
+ * @function genericAdapterRequest
603
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
604
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
605
+ * @param {Object} queryData - the parameters to be put on the url (optional).
606
+ * Can be a stringified Object.
607
+ * @param {Object} requestBody - the body to add to the request (optional).
608
+ * Can be a stringified Object.
609
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
610
+ * Can be a stringified Object.
611
+ * @param {getCallback} callback - a callback function to return the result (Generics)
612
+ * or the error
613
+ */
614
+ genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
615
+ const meth = 'adapter-genericAdapterRequest';
616
+ const origin = `${this.id}-${meth}`;
617
+ log.trace(origin);
618
+
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
+ 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);
706
+ }
707
+ }
708
+
709
+ /**
710
+ * Makes the requested generic call with no base path or version
711
+ *
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
723
+ */
724
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
725
+ const meth = 'adapter-genericAdapterRequestNoBasePath';
726
+ const origin = `${this.id}-${meth}`;
727
+ log.trace(origin);
728
+
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);
745
+ }
746
+
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;
757
+
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
+ });
765
+
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
+ }
777
+
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
+ }
791
+
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
+ }
807
+
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
+ }
817
+ }
818
+
819
+ /**
820
+ * @callback healthCallback
821
+ * @param {Object} result - the result of the get request (contains an id and a status)
822
+ */
823
+ /**
824
+ * @callback getCallback
825
+ * @param {Object} result - the result of the get request (entity/ies)
826
+ * @param {String} error - any error that occurred
827
+ */
828
+ /**
829
+ * @callback createCallback
830
+ * @param {Object} item - the newly created entity
831
+ * @param {String} error - any error that occurred
832
+ */
833
+ /**
834
+ * @callback updateCallback
835
+ * @param {String} status - the status of the update action
836
+ * @param {String} error - any error that occurred
837
+ */
838
+ /**
839
+ * @callback deleteCallback
840
+ * @param {String} status - the status of the delete action
841
+ * @param {String} error - any error that occurred
842
+ */
843
+
844
+ /**
845
+ * @function getAuditsUsingGET
846
+ * @pronghornType method
847
+ * @name getAuditsUsingGET
848
+ * @summary This API is used to get audit details for given query param
849
+ *
850
+ * @param {array} [action] - Available values : USER_ENROLLED, USER_INFO_EDIT, USER_CREATED , USER_DELETED etc.
851
+ Please refer API Docs for available values.
852
+ * @param {array} [adminRA] - Administrator userName or RA common name
853
+ * @param {string} dateFrom - Datetime in ISO format
854
+ * @param {string} dateTo - Datetime in ISO format. Time span from dateFrom cannot exceed 365 days.
855
+ * @param {number} [limit] - Default Limit is 100
856
+ * @param {number} [offset] - Default value is 0
857
+ * @param {getCallback} callback - a callback function to return the result
858
+ * @return {object} results - An object containing the response of the action
859
+ *
860
+ * @route {POST} /getAuditsUsingGET
861
+ * @roles admin
862
+ * @task true
863
+ */
864
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
865
+ getAuditsUsingGET(action, adminRA, dateFrom, dateTo, limit, offset, callback) {
866
+ const meth = 'adapter-getAuditsUsingGET';
867
+ const origin = `${this.id}-${meth}`;
868
+ log.trace(origin);
869
+
870
+ if (this.suspended && this.suspendMode === 'error') {
871
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
872
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
873
+ return callback(null, errorObj);
874
+ }
875
+
876
+ /* HERE IS WHERE YOU VALIDATE DATA */
877
+ if (dateFrom === undefined || dateFrom === null || dateFrom === '') {
878
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dateFrom'], null, null, null);
879
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
880
+ return callback(null, errorObj);
881
+ }
882
+ if (dateTo === undefined || dateTo === null || dateTo === '') {
883
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dateTo'], null, null, null);
884
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
885
+ return callback(null, errorObj);
886
+ }
887
+
888
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
889
+ const queryParamsAvailable = { action, adminRA, dateFrom, dateTo, limit, offset };
890
+ const queryParams = {};
891
+ const pathVars = [];
892
+ const bodyVars = {};
893
+
894
+ // loop in template. long callback arg name to avoid identifier conflicts
895
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
896
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
897
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
898
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
899
+ }
900
+ });
901
+
902
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
903
+ let thisHeaderData = null;
904
+ // if the additional headers was passed in as a string parse the json into an object
905
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
906
+ try {
907
+ // parse the additional headers object that was passed in
908
+ thisHeaderData = JSON.parse(thisHeaderData);
909
+ } catch (err) {
910
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
911
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
912
+ return callback(null, errorObj);
913
+ }
914
+ } else if (thisHeaderData === null) {
915
+ thisHeaderData = { xAPIKey: '' };
916
+ }
917
+
918
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
919
+ // see adapter code documentation for more information on the request object's fields
920
+ const reqObj = {
921
+ payload: bodyVars,
922
+ uriPathVars: pathVars,
923
+ uriQuery: queryParams,
924
+ addlHeaders: thisHeaderData
925
+ };
926
+
927
+ try {
928
+ // Make the call -
929
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
930
+ return this.requestHandlerInst.identifyRequest('AuditAPI', 'getAuditsUsingGET', reqObj, true, (irReturnData, irReturnError) => {
931
+ // if we received an error or their is no response on the results
932
+ // return an error
933
+ if (irReturnError) {
934
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
935
+ return callback(null, irReturnError);
936
+ }
937
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
938
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAuditsUsingGET'], null, null, null);
939
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
940
+ return callback(null, errorObj);
941
+ }
942
+
943
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
944
+ // return the response
945
+ return callback(irReturnData, null);
946
+ });
947
+ } catch (ex) {
948
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
949
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
950
+ return callback(null, errorObj);
951
+ }
952
+ }
953
+
954
+ /**
955
+ * @function getAuditUsingGET
956
+ * @pronghornType method
957
+ * @name getAuditUsingGET
958
+ * @summary This API is used to get audit details for given audit Id.
959
+ *
960
+ * @param {number} auditId - auditId
961
+ * @param {getCallback} callback - a callback function to return the result
962
+ * @return {object} results - An object containing the response of the action
963
+ *
964
+ * @route {POST} /getAuditUsingGET
965
+ * @roles admin
966
+ * @task true
967
+ */
968
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
969
+ getAuditUsingGET(auditId, callback) {
970
+ const meth = 'adapter-getAuditUsingGET';
971
+ const origin = `${this.id}-${meth}`;
972
+ log.trace(origin);
973
+
974
+ if (this.suspended && this.suspendMode === 'error') {
975
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
976
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
977
+ return callback(null, errorObj);
978
+ }
979
+
980
+ /* HERE IS WHERE YOU VALIDATE DATA */
981
+ if (auditId === undefined || auditId === null || auditId === '') {
982
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['auditId'], null, null, null);
983
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
984
+ return callback(null, errorObj);
985
+ }
986
+
987
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
988
+ const queryParamsAvailable = {};
989
+ const queryParams = {};
990
+ const pathVars = [auditId];
991
+ const bodyVars = {};
992
+
993
+ // loop in template. long callback arg name to avoid identifier conflicts
994
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
995
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
996
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
997
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
998
+ }
999
+ });
1000
+
1001
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1002
+ let thisHeaderData = null;
1003
+ // if the additional headers was passed in as a string parse the json into an object
1004
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1005
+ try {
1006
+ // parse the additional headers object that was passed in
1007
+ thisHeaderData = JSON.parse(thisHeaderData);
1008
+ } catch (err) {
1009
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1010
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1011
+ return callback(null, errorObj);
1012
+ }
1013
+ } else if (thisHeaderData === null) {
1014
+ thisHeaderData = { xAPIKey: '' };
1015
+ }
1016
+
1017
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1018
+ // see adapter code documentation for more information on the request object's fields
1019
+ const reqObj = {
1020
+ payload: bodyVars,
1021
+ uriPathVars: pathVars,
1022
+ uriQuery: queryParams,
1023
+ addlHeaders: thisHeaderData
1024
+ };
1025
+
1026
+ try {
1027
+ // Make the call -
1028
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1029
+ return this.requestHandlerInst.identifyRequest('AuditAPI', 'getAuditUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1030
+ // if we received an error or their is no response on the results
1031
+ // return an error
1032
+ if (irReturnError) {
1033
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1034
+ return callback(null, irReturnError);
1035
+ }
1036
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1037
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAuditUsingGET'], null, null, null);
1038
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1039
+ return callback(null, errorObj);
1040
+ }
1041
+
1042
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1043
+ // return the response
1044
+ return callback(irReturnData, null);
1045
+ });
1046
+ } catch (ex) {
1047
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1048
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1049
+ return callback(null, errorObj);
1050
+ }
1051
+ }
1052
+
1053
+ /**
1054
+ * @function getCAInfoUsingGET
1055
+ * @pronghornType method
1056
+ * @name getCAInfoUsingGET
1057
+ * @summary This API is used to get public CA details for a given ca identifier
1058
+ *
1059
+ * @param {string} caId - caId
1060
+ * @param {getCallback} callback - a callback function to return the result
1061
+ * @return {object} results - An object containing the response of the action
1062
+ *
1063
+ * @route {POST} /getCAInfoUsingGET
1064
+ * @roles admin
1065
+ * @task true
1066
+ */
1067
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1068
+ getCAInfoUsingGET(caId, callback) {
1069
+ const meth = 'adapter-getCAInfoUsingGET';
1070
+ const origin = `${this.id}-${meth}`;
1071
+ log.trace(origin);
1072
+
1073
+ if (this.suspended && this.suspendMode === 'error') {
1074
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1075
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1076
+ return callback(null, errorObj);
1077
+ }
1078
+
1079
+ /* HERE IS WHERE YOU VALIDATE DATA */
1080
+ if (caId === undefined || caId === null || caId === '') {
1081
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['caId'], null, null, null);
1082
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1083
+ return callback(null, errorObj);
1084
+ }
1085
+
1086
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1087
+ const queryParamsAvailable = {};
1088
+ const queryParams = {};
1089
+ const pathVars = [caId];
1090
+ const bodyVars = {};
1091
+
1092
+ // loop in template. long callback arg name to avoid identifier conflicts
1093
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1094
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1095
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1096
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1097
+ }
1098
+ });
1099
+
1100
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1101
+ let thisHeaderData = null;
1102
+ // if the additional headers was passed in as a string parse the json into an object
1103
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1104
+ try {
1105
+ // parse the additional headers object that was passed in
1106
+ thisHeaderData = JSON.parse(thisHeaderData);
1107
+ } catch (err) {
1108
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1109
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1110
+ return callback(null, errorObj);
1111
+ }
1112
+ } else if (thisHeaderData === null) {
1113
+ thisHeaderData = { xAPIKey: '' };
1114
+ }
1115
+
1116
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1117
+ // see adapter code documentation for more information on the request object's fields
1118
+ const reqObj = {
1119
+ payload: bodyVars,
1120
+ uriPathVars: pathVars,
1121
+ uriQuery: queryParams,
1122
+ addlHeaders: thisHeaderData
1123
+ };
1124
+
1125
+ try {
1126
+ // Make the call -
1127
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1128
+ return this.requestHandlerInst.identifyRequest('CAAPI', 'getCAInfoUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1129
+ // if we received an error or their is no response on the results
1130
+ // return an error
1131
+ if (irReturnError) {
1132
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1133
+ return callback(null, irReturnError);
1134
+ }
1135
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1136
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCAInfoUsingGET'], null, null, null);
1137
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1138
+ return callback(null, errorObj);
1139
+ }
1140
+
1141
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1142
+ // return the response
1143
+ return callback(irReturnData, null);
1144
+ });
1145
+ } catch (ex) {
1146
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1147
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1148
+ return callback(null, errorObj);
1149
+ }
1150
+ }
1151
+
1152
+ /**
1153
+ * @function getCAUsingGET
1154
+ * @pronghornType method
1155
+ * @name getCAUsingGET
1156
+ * @summary This API is used to get public CA details for a given account api key
1157
+ *
1158
+ * @param {string} seatType - seatType
1159
+ * @param {getCallback} callback - a callback function to return the result
1160
+ * @return {object} results - An object containing the response of the action
1161
+ *
1162
+ * @route {POST} /getCAUsingGET
1163
+ * @roles admin
1164
+ * @task true
1165
+ */
1166
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1167
+ getCAUsingGET(seatType, callback) {
1168
+ const meth = 'adapter-getCAUsingGET';
1169
+ const origin = `${this.id}-${meth}`;
1170
+ log.trace(origin);
1171
+
1172
+ if (this.suspended && this.suspendMode === 'error') {
1173
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1174
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1175
+ return callback(null, errorObj);
1176
+ }
1177
+
1178
+ /* HERE IS WHERE YOU VALIDATE DATA */
1179
+ if (seatType === undefined || seatType === null || seatType === '') {
1180
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['seatType'], null, null, null);
1181
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1182
+ return callback(null, errorObj);
1183
+ }
1184
+
1185
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1186
+ const queryParamsAvailable = {};
1187
+ const queryParams = {};
1188
+ const pathVars = [seatType];
1189
+ const bodyVars = {};
1190
+
1191
+ // loop in template. long callback arg name to avoid identifier conflicts
1192
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1193
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1194
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1195
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1196
+ }
1197
+ });
1198
+
1199
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1200
+ let thisHeaderData = null;
1201
+ // if the additional headers was passed in as a string parse the json into an object
1202
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1203
+ try {
1204
+ // parse the additional headers object that was passed in
1205
+ thisHeaderData = JSON.parse(thisHeaderData);
1206
+ } catch (err) {
1207
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1208
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1209
+ return callback(null, errorObj);
1210
+ }
1211
+ } else if (thisHeaderData === null) {
1212
+ thisHeaderData = { xAPIKey: '' };
1213
+ }
1214
+
1215
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1216
+ // see adapter code documentation for more information on the request object's fields
1217
+ const reqObj = {
1218
+ payload: bodyVars,
1219
+ uriPathVars: pathVars,
1220
+ uriQuery: queryParams,
1221
+ addlHeaders: thisHeaderData
1222
+ };
1223
+
1224
+ try {
1225
+ // Make the call -
1226
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1227
+ return this.requestHandlerInst.identifyRequest('CAAPI', 'getCAUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1228
+ // if we received an error or their is no response on the results
1229
+ // return an error
1230
+ if (irReturnError) {
1231
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1232
+ return callback(null, irReturnError);
1233
+ }
1234
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1235
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCAUsingGET'], null, null, null);
1236
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1237
+ return callback(null, errorObj);
1238
+ }
1239
+
1240
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1241
+ // return the response
1242
+ return callback(irReturnData, null);
1243
+ });
1244
+ } catch (ex) {
1245
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1246
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1247
+ return callback(null, errorObj);
1248
+ }
1249
+ }
1250
+
1251
+ /**
1252
+ * @function enrollCertificateUsingPOST
1253
+ * @pronghornType method
1254
+ * @name enrollCertificateUsingPOST
1255
+ * @summary This API is used to enroll a certificate for a given profile.
1256
+ *
1257
+ * @param {object} enrollCertificateRequest - enrollCertificateRequest
1258
+ * @param {getCallback} callback - a callback function to return the result
1259
+ * @return {object} results - An object containing the response of the action
1260
+ *
1261
+ * @route {POST} /enrollCertificateUsingPOST
1262
+ * @roles admin
1263
+ * @task true
1264
+ */
1265
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1266
+ enrollCertificateUsingPOST(enrollCertificateRequest, callback) {
1267
+ const meth = 'adapter-enrollCertificateUsingPOST';
1268
+ const origin = `${this.id}-${meth}`;
1269
+ log.trace(origin);
1270
+
1271
+ if (this.suspended && this.suspendMode === 'error') {
1272
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1273
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1274
+ return callback(null, errorObj);
1275
+ }
1276
+
1277
+ /* HERE IS WHERE YOU VALIDATE DATA */
1278
+ if (enrollCertificateRequest === undefined || enrollCertificateRequest === null || enrollCertificateRequest === '') {
1279
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['enrollCertificateRequest'], null, null, null);
1280
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1281
+ return callback(null, errorObj);
1282
+ }
1283
+
1284
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1285
+ const queryParamsAvailable = {};
1286
+ const queryParams = {};
1287
+ const pathVars = [];
1288
+ const bodyVars = enrollCertificateRequest;
1289
+
1290
+ // loop in template. long callback arg name to avoid identifier conflicts
1291
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1292
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1293
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1294
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1295
+ }
1296
+ });
1297
+
1298
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1299
+ let thisHeaderData = null;
1300
+ // if the additional headers was passed in as a string parse the json into an object
1301
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1302
+ try {
1303
+ // parse the additional headers object that was passed in
1304
+ thisHeaderData = JSON.parse(thisHeaderData);
1305
+ } catch (err) {
1306
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1307
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1308
+ return callback(null, errorObj);
1309
+ }
1310
+ } else if (thisHeaderData === null) {
1311
+ thisHeaderData = { xAPIKey: '' };
1312
+ }
1313
+
1314
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1315
+ // see adapter code documentation for more information on the request object's fields
1316
+ const reqObj = {
1317
+ payload: bodyVars,
1318
+ uriPathVars: pathVars,
1319
+ uriQuery: queryParams,
1320
+ addlHeaders: thisHeaderData
1321
+ };
1322
+
1323
+ try {
1324
+ // Make the call -
1325
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1326
+ return this.requestHandlerInst.identifyRequest('CertificateEnrollmentAPI', 'enrollCertificateUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
1327
+ // if we received an error or their is no response on the results
1328
+ // return an error
1329
+ if (irReturnError) {
1330
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1331
+ return callback(null, irReturnError);
1332
+ }
1333
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1334
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['enrollCertificateUsingPOST'], null, null, null);
1335
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1336
+ return callback(null, errorObj);
1337
+ }
1338
+
1339
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1340
+ // return the response
1341
+ return callback(irReturnData, null);
1342
+ });
1343
+ } catch (ex) {
1344
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1345
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1346
+ return callback(null, errorObj);
1347
+ }
1348
+ }
1349
+
1350
+ /**
1351
+ * @function createCertificateUsingPOST
1352
+ * @pronghornType method
1353
+ * @name createCertificateUsingPOST
1354
+ * @summary This API is used to enroll a certificate for a given profile.
1355
+ *
1356
+ * @param {object} enrollCertificateRequest - enrollCertificateRequest
1357
+ * @param {getCallback} callback - a callback function to return the result
1358
+ * @return {object} results - An object containing the response of the action
1359
+ *
1360
+ * @route {POST} /createCertificateUsingPOST
1361
+ * @roles admin
1362
+ * @task true
1363
+ */
1364
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1365
+ createCertificateUsingPOST(enrollCertificateRequest, callback) {
1366
+ const meth = 'adapter-createCertificateUsingPOST';
1367
+ const origin = `${this.id}-${meth}`;
1368
+ log.trace(origin);
1369
+
1370
+ if (this.suspended && this.suspendMode === 'error') {
1371
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1372
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1373
+ return callback(null, errorObj);
1374
+ }
1375
+
1376
+ /* HERE IS WHERE YOU VALIDATE DATA */
1377
+ if (enrollCertificateRequest === undefined || enrollCertificateRequest === null || enrollCertificateRequest === '') {
1378
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['enrollCertificateRequest'], null, null, null);
1379
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1380
+ return callback(null, errorObj);
1381
+ }
1382
+
1383
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1384
+ const queryParamsAvailable = {};
1385
+ const queryParams = {};
1386
+ const pathVars = [];
1387
+ const bodyVars = enrollCertificateRequest;
1388
+
1389
+ // loop in template. long callback arg name to avoid identifier conflicts
1390
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1391
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1392
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1393
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1394
+ }
1395
+ });
1396
+
1397
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1398
+ let thisHeaderData = null;
1399
+ // if the additional headers was passed in as a string parse the json into an object
1400
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1401
+ try {
1402
+ // parse the additional headers object that was passed in
1403
+ thisHeaderData = JSON.parse(thisHeaderData);
1404
+ } catch (err) {
1405
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1406
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1407
+ return callback(null, errorObj);
1408
+ }
1409
+ } else if (thisHeaderData === null) {
1410
+ thisHeaderData = { xAPIKey: '' };
1411
+ }
1412
+
1413
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1414
+ // see adapter code documentation for more information on the request object's fields
1415
+ const reqObj = {
1416
+ payload: bodyVars,
1417
+ uriPathVars: pathVars,
1418
+ uriQuery: queryParams,
1419
+ addlHeaders: thisHeaderData
1420
+ };
1421
+
1422
+ try {
1423
+ // Make the call -
1424
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1425
+ return this.requestHandlerInst.identifyRequest('CertificateEnrollmentAPI', 'createCertificateUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
1426
+ // if we received an error or their is no response on the results
1427
+ // return an error
1428
+ if (irReturnError) {
1429
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1430
+ return callback(null, irReturnError);
1431
+ }
1432
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1433
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createCertificateUsingPOST'], null, null, null);
1434
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1435
+ return callback(null, errorObj);
1436
+ }
1437
+
1438
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1439
+ // return the response
1440
+ return callback(irReturnData, null);
1441
+ });
1442
+ } catch (ex) {
1443
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1444
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1445
+ return callback(null, errorObj);
1446
+ }
1447
+ }
1448
+
1449
+ /**
1450
+ * @function renewExternalCertificateUsingPOST
1451
+ * @pronghornType method
1452
+ * @name renewExternalCertificateUsingPOST
1453
+ * @summary This API is used to enroll a certificate for a given profile.
1454
+ *
1455
+ * @param {object} enrollCertificateRequest - enrollCertificateRequest
1456
+ * @param {string} serialNumber - serialNumber
1457
+ * @param {getCallback} callback - a callback function to return the result
1458
+ * @return {object} results - An object containing the response of the action
1459
+ *
1460
+ * @route {POST} /renewExternalCertificateUsingPOST
1461
+ * @roles admin
1462
+ * @task true
1463
+ */
1464
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1465
+ renewExternalCertificateUsingPOST(enrollCertificateRequest, serialNumber, callback) {
1466
+ const meth = 'adapter-renewExternalCertificateUsingPOST';
1467
+ const origin = `${this.id}-${meth}`;
1468
+ log.trace(origin);
1469
+
1470
+ if (this.suspended && this.suspendMode === 'error') {
1471
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1472
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1473
+ return callback(null, errorObj);
1474
+ }
1475
+
1476
+ /* HERE IS WHERE YOU VALIDATE DATA */
1477
+ if (enrollCertificateRequest === undefined || enrollCertificateRequest === null || enrollCertificateRequest === '') {
1478
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['enrollCertificateRequest'], null, null, null);
1479
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1480
+ return callback(null, errorObj);
1481
+ }
1482
+ if (serialNumber === undefined || serialNumber === null || serialNumber === '') {
1483
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['serialNumber'], null, null, null);
1484
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1485
+ return callback(null, errorObj);
1486
+ }
1487
+
1488
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1489
+ const queryParamsAvailable = {};
1490
+ const queryParams = {};
1491
+ const pathVars = [serialNumber];
1492
+ const bodyVars = enrollCertificateRequest;
1493
+
1494
+ // loop in template. long callback arg name to avoid identifier conflicts
1495
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1496
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1497
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1498
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1499
+ }
1500
+ });
1501
+
1502
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1503
+ let thisHeaderData = null;
1504
+ // if the additional headers was passed in as a string parse the json into an object
1505
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1506
+ try {
1507
+ // parse the additional headers object that was passed in
1508
+ thisHeaderData = JSON.parse(thisHeaderData);
1509
+ } catch (err) {
1510
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1511
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1512
+ return callback(null, errorObj);
1513
+ }
1514
+ } else if (thisHeaderData === null) {
1515
+ thisHeaderData = { xAPIKey: '' };
1516
+ }
1517
+
1518
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1519
+ // see adapter code documentation for more information on the request object's fields
1520
+ const reqObj = {
1521
+ payload: bodyVars,
1522
+ uriPathVars: pathVars,
1523
+ uriQuery: queryParams,
1524
+ addlHeaders: thisHeaderData
1525
+ };
1526
+
1527
+ try {
1528
+ // Make the call -
1529
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1530
+ return this.requestHandlerInst.identifyRequest('CertificateEnrollmentAPI', 'renewExternalCertificateUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
1531
+ // if we received an error or their is no response on the results
1532
+ // return an error
1533
+ if (irReturnError) {
1534
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1535
+ return callback(null, irReturnError);
1536
+ }
1537
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1538
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['renewExternalCertificateUsingPOST'], null, null, null);
1539
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1540
+ return callback(null, errorObj);
1541
+ }
1542
+
1543
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1544
+ // return the response
1545
+ return callback(irReturnData, null);
1546
+ });
1547
+ } catch (ex) {
1548
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1549
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1550
+ return callback(null, errorObj);
1551
+ }
1552
+ }
1553
+
1554
+ /**
1555
+ * @function getCertificateUsingGET
1556
+ * @pronghornType method
1557
+ * @name getCertificateUsingGET
1558
+ * @summary This API is used to get certificate details for a given certificate serial number
1559
+ *
1560
+ * @param {string} serialNumber - serialNumber
1561
+ * @param {getCallback} callback - a callback function to return the result
1562
+ * @return {object} results - An object containing the response of the action
1563
+ *
1564
+ * @route {POST} /getCertificateUsingGET
1565
+ * @roles admin
1566
+ * @task true
1567
+ */
1568
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1569
+ getCertificateUsingGET(serialNumber, callback) {
1570
+ const meth = 'adapter-getCertificateUsingGET';
1571
+ const origin = `${this.id}-${meth}`;
1572
+ log.trace(origin);
1573
+
1574
+ if (this.suspended && this.suspendMode === 'error') {
1575
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1576
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1577
+ return callback(null, errorObj);
1578
+ }
1579
+
1580
+ /* HERE IS WHERE YOU VALIDATE DATA */
1581
+ if (serialNumber === undefined || serialNumber === null || serialNumber === '') {
1582
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['serialNumber'], null, null, null);
1583
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1584
+ return callback(null, errorObj);
1585
+ }
1586
+
1587
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1588
+ const queryParamsAvailable = {};
1589
+ const queryParams = {};
1590
+ const pathVars = [serialNumber];
1591
+ const bodyVars = {};
1592
+
1593
+ // loop in template. long callback arg name to avoid identifier conflicts
1594
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1595
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1596
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1597
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1598
+ }
1599
+ });
1600
+
1601
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1602
+ let thisHeaderData = null;
1603
+ // if the additional headers was passed in as a string parse the json into an object
1604
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1605
+ try {
1606
+ // parse the additional headers object that was passed in
1607
+ thisHeaderData = JSON.parse(thisHeaderData);
1608
+ } catch (err) {
1609
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1610
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1611
+ return callback(null, errorObj);
1612
+ }
1613
+ } else if (thisHeaderData === null) {
1614
+ thisHeaderData = { xAPIKey: '' };
1615
+ }
1616
+
1617
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1618
+ // see adapter code documentation for more information on the request object's fields
1619
+ const reqObj = {
1620
+ payload: bodyVars,
1621
+ uriPathVars: pathVars,
1622
+ uriQuery: queryParams,
1623
+ addlHeaders: thisHeaderData
1624
+ };
1625
+
1626
+ try {
1627
+ // Make the call -
1628
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1629
+ return this.requestHandlerInst.identifyRequest('CertificateEnrollmentAPI', 'getCertificateUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1630
+ // if we received an error or their is no response on the results
1631
+ // return an error
1632
+ if (irReturnError) {
1633
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1634
+ return callback(null, irReturnError);
1635
+ }
1636
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1637
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCertificateUsingGET'], null, null, null);
1638
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1639
+ return callback(null, errorObj);
1640
+ }
1641
+
1642
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1643
+ // return the response
1644
+ return callback(irReturnData, null);
1645
+ });
1646
+ } catch (ex) {
1647
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1648
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1649
+ return callback(null, errorObj);
1650
+ }
1651
+ }
1652
+
1653
+ /**
1654
+ * @function recoverKeyUsingGET
1655
+ * @pronghornType method
1656
+ * @name recoverKeyUsingGET
1657
+ * @summary This API is used to get private key information for key-escrowed certificate with given serial number
1658
+ *
1659
+ * @param {string} serialNumber - serialNumber
1660
+ * @param {getCallback} callback - a callback function to return the result
1661
+ * @return {object} results - An object containing the response of the action
1662
+ *
1663
+ * @route {POST} /recoverKeyUsingGET
1664
+ * @roles admin
1665
+ * @task true
1666
+ */
1667
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1668
+ recoverKeyUsingGET(serialNumber, callback) {
1669
+ const meth = 'adapter-recoverKeyUsingGET';
1670
+ const origin = `${this.id}-${meth}`;
1671
+ log.trace(origin);
1672
+
1673
+ if (this.suspended && this.suspendMode === 'error') {
1674
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1675
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1676
+ return callback(null, errorObj);
1677
+ }
1678
+
1679
+ /* HERE IS WHERE YOU VALIDATE DATA */
1680
+ if (serialNumber === undefined || serialNumber === null || serialNumber === '') {
1681
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['serialNumber'], null, null, null);
1682
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1683
+ return callback(null, errorObj);
1684
+ }
1685
+
1686
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1687
+ const queryParamsAvailable = {};
1688
+ const queryParams = {};
1689
+ const pathVars = [serialNumber];
1690
+ const bodyVars = {};
1691
+
1692
+ // loop in template. long callback arg name to avoid identifier conflicts
1693
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1694
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1695
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1696
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1697
+ }
1698
+ });
1699
+
1700
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1701
+ let thisHeaderData = null;
1702
+ // if the additional headers was passed in as a string parse the json into an object
1703
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1704
+ try {
1705
+ // parse the additional headers object that was passed in
1706
+ thisHeaderData = JSON.parse(thisHeaderData);
1707
+ } catch (err) {
1708
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1709
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1710
+ return callback(null, errorObj);
1711
+ }
1712
+ } else if (thisHeaderData === null) {
1713
+ thisHeaderData = { xAPIKey: '' };
1714
+ }
1715
+
1716
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1717
+ // see adapter code documentation for more information on the request object's fields
1718
+ const reqObj = {
1719
+ payload: bodyVars,
1720
+ uriPathVars: pathVars,
1721
+ uriQuery: queryParams,
1722
+ addlHeaders: thisHeaderData
1723
+ };
1724
+
1725
+ try {
1726
+ // Make the call -
1727
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1728
+ return this.requestHandlerInst.identifyRequest('CertificateEnrollmentAPI', 'recoverKeyUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1729
+ // if we received an error or their is no response on the results
1730
+ // return an error
1731
+ if (irReturnError) {
1732
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1733
+ return callback(null, irReturnError);
1734
+ }
1735
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1736
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['recoverKeyUsingGET'], null, null, null);
1737
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1738
+ return callback(null, errorObj);
1739
+ }
1740
+
1741
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1742
+ // return the response
1743
+ return callback(irReturnData, null);
1744
+ });
1745
+ } catch (ex) {
1746
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1747
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1748
+ return callback(null, errorObj);
1749
+ }
1750
+ }
1751
+
1752
+ /**
1753
+ * @function renewCertificateUsingPOST
1754
+ * @pronghornType method
1755
+ * @name renewCertificateUsingPOST
1756
+ * @summary This API is used to renew certificate with the given serial number.
1757
+ *
1758
+ * @param {object} enrollCertificateRequest - enrollCertificateRequest
1759
+ * @param {string} serialNumber - serialNumber
1760
+ * @param {getCallback} callback - a callback function to return the result
1761
+ * @return {object} results - An object containing the response of the action
1762
+ *
1763
+ * @route {POST} /renewCertificateUsingPOST
1764
+ * @roles admin
1765
+ * @task true
1766
+ */
1767
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1768
+ renewCertificateUsingPOST(enrollCertificateRequest, serialNumber, callback) {
1769
+ const meth = 'adapter-renewCertificateUsingPOST';
1770
+ const origin = `${this.id}-${meth}`;
1771
+ log.trace(origin);
1772
+
1773
+ if (this.suspended && this.suspendMode === 'error') {
1774
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1775
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1776
+ return callback(null, errorObj);
1777
+ }
1778
+
1779
+ /* HERE IS WHERE YOU VALIDATE DATA */
1780
+ if (enrollCertificateRequest === undefined || enrollCertificateRequest === null || enrollCertificateRequest === '') {
1781
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['enrollCertificateRequest'], null, null, null);
1782
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1783
+ return callback(null, errorObj);
1784
+ }
1785
+ if (serialNumber === undefined || serialNumber === null || serialNumber === '') {
1786
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['serialNumber'], null, null, null);
1787
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1788
+ return callback(null, errorObj);
1789
+ }
1790
+
1791
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1792
+ const queryParamsAvailable = {};
1793
+ const queryParams = {};
1794
+ const pathVars = [serialNumber];
1795
+ const bodyVars = enrollCertificateRequest;
1796
+
1797
+ // loop in template. long callback arg name to avoid identifier conflicts
1798
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1799
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1800
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1801
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1802
+ }
1803
+ });
1804
+
1805
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1806
+ let thisHeaderData = null;
1807
+ // if the additional headers was passed in as a string parse the json into an object
1808
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1809
+ try {
1810
+ // parse the additional headers object that was passed in
1811
+ thisHeaderData = JSON.parse(thisHeaderData);
1812
+ } catch (err) {
1813
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1814
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1815
+ return callback(null, errorObj);
1816
+ }
1817
+ } else if (thisHeaderData === null) {
1818
+ thisHeaderData = { xAPIKey: '' };
1819
+ }
1820
+
1821
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1822
+ // see adapter code documentation for more information on the request object's fields
1823
+ const reqObj = {
1824
+ payload: bodyVars,
1825
+ uriPathVars: pathVars,
1826
+ uriQuery: queryParams,
1827
+ addlHeaders: thisHeaderData
1828
+ };
1829
+
1830
+ try {
1831
+ // Make the call -
1832
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1833
+ return this.requestHandlerInst.identifyRequest('CertificateEnrollmentAPI', 'renewCertificateUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
1834
+ // if we received an error or their is no response on the results
1835
+ // return an error
1836
+ if (irReturnError) {
1837
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1838
+ return callback(null, irReturnError);
1839
+ }
1840
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1841
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['renewCertificateUsingPOST'], null, null, null);
1842
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1843
+ return callback(null, errorObj);
1844
+ }
1845
+
1846
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1847
+ // return the response
1848
+ return callback(irReturnData, null);
1849
+ });
1850
+ } catch (ex) {
1851
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1852
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1853
+ return callback(null, errorObj);
1854
+ }
1855
+ }
1856
+
1857
+ /**
1858
+ * @function revokeCertificateUsingPUT
1859
+ * @pronghornType method
1860
+ * @name revokeCertificateUsingPUT
1861
+ * @summary This API can revoke certificate with the given serial number
1862
+ *
1863
+ * @param {object} [revokeCertificateRequest] - revokeCertificateRequest
1864
+ * @param {string} serialNumber - serialNumber
1865
+ * @param {getCallback} callback - a callback function to return the result
1866
+ * @return {object} results - An object containing the response of the action
1867
+ *
1868
+ * @route {POST} /revokeCertificateUsingPUT
1869
+ * @roles admin
1870
+ * @task true
1871
+ */
1872
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1873
+ revokeCertificateUsingPUT(revokeCertificateRequest, serialNumber, callback) {
1874
+ const meth = 'adapter-revokeCertificateUsingPUT';
1875
+ const origin = `${this.id}-${meth}`;
1876
+ log.trace(origin);
1877
+
1878
+ if (this.suspended && this.suspendMode === 'error') {
1879
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1880
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1881
+ return callback(null, errorObj);
1882
+ }
1883
+
1884
+ /* HERE IS WHERE YOU VALIDATE DATA */
1885
+ if (serialNumber === undefined || serialNumber === null || serialNumber === '') {
1886
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['serialNumber'], null, null, null);
1887
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1888
+ return callback(null, errorObj);
1889
+ }
1890
+
1891
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1892
+ const queryParamsAvailable = {};
1893
+ const queryParams = {};
1894
+ const pathVars = [serialNumber];
1895
+ const bodyVars = revokeCertificateRequest;
1896
+
1897
+ // loop in template. long callback arg name to avoid identifier conflicts
1898
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1899
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1900
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1901
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1902
+ }
1903
+ });
1904
+
1905
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1906
+ let thisHeaderData = null;
1907
+ // if the additional headers was passed in as a string parse the json into an object
1908
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1909
+ try {
1910
+ // parse the additional headers object that was passed in
1911
+ thisHeaderData = JSON.parse(thisHeaderData);
1912
+ } catch (err) {
1913
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1914
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1915
+ return callback(null, errorObj);
1916
+ }
1917
+ } else if (thisHeaderData === null) {
1918
+ thisHeaderData = { xAPIKey: '' };
1919
+ }
1920
+
1921
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1922
+ // see adapter code documentation for more information on the request object's fields
1923
+ const reqObj = {
1924
+ payload: bodyVars,
1925
+ uriPathVars: pathVars,
1926
+ uriQuery: queryParams,
1927
+ addlHeaders: thisHeaderData
1928
+ };
1929
+
1930
+ try {
1931
+ // Make the call -
1932
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1933
+ return this.requestHandlerInst.identifyRequest('CertificateEnrollmentAPI', 'revokeCertificateUsingPUT', reqObj, false, (irReturnData, irReturnError) => {
1934
+ // if we received an error or their is no response on the results
1935
+ // return an error
1936
+ if (irReturnError) {
1937
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1938
+ return callback(null, irReturnError);
1939
+ }
1940
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1941
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['revokeCertificateUsingPUT'], null, null, null);
1942
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1943
+ return callback(null, errorObj);
1944
+ }
1945
+
1946
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1947
+ // return the response
1948
+ return callback(irReturnData, null);
1949
+ });
1950
+ } catch (ex) {
1951
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1952
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1953
+ return callback(null, errorObj);
1954
+ }
1955
+ }
1956
+
1957
+ /**
1958
+ * @function unRevokeCertificateUsingDELETE
1959
+ * @pronghornType method
1960
+ * @name unRevokeCertificateUsingDELETE
1961
+ * @summary This API can resume certificate with the given serial number.
1962
+ *
1963
+ * @param {string} serialNumber - serialNumber
1964
+ * @param {getCallback} callback - a callback function to return the result
1965
+ * @return {object} results - An object containing the response of the action
1966
+ *
1967
+ * @route {POST} /unRevokeCertificateUsingDELETE
1968
+ * @roles admin
1969
+ * @task true
1970
+ */
1971
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1972
+ unRevokeCertificateUsingDELETE(serialNumber, callback) {
1973
+ const meth = 'adapter-unRevokeCertificateUsingDELETE';
1974
+ const origin = `${this.id}-${meth}`;
1975
+ log.trace(origin);
1976
+
1977
+ if (this.suspended && this.suspendMode === 'error') {
1978
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1979
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1980
+ return callback(null, errorObj);
1981
+ }
1982
+
1983
+ /* HERE IS WHERE YOU VALIDATE DATA */
1984
+ if (serialNumber === undefined || serialNumber === null || serialNumber === '') {
1985
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['serialNumber'], null, null, null);
1986
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1987
+ return callback(null, errorObj);
1988
+ }
1989
+
1990
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1991
+ const queryParamsAvailable = {};
1992
+ const queryParams = {};
1993
+ const pathVars = [serialNumber];
1994
+ const bodyVars = {};
1995
+
1996
+ // loop in template. long callback arg name to avoid identifier conflicts
1997
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1998
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1999
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2000
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2001
+ }
2002
+ });
2003
+
2004
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2005
+ let thisHeaderData = null;
2006
+ // if the additional headers was passed in as a string parse the json into an object
2007
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2008
+ try {
2009
+ // parse the additional headers object that was passed in
2010
+ thisHeaderData = JSON.parse(thisHeaderData);
2011
+ } catch (err) {
2012
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2013
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2014
+ return callback(null, errorObj);
2015
+ }
2016
+ } else if (thisHeaderData === null) {
2017
+ thisHeaderData = { xAPIKey: '' };
2018
+ }
2019
+
2020
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2021
+ // see adapter code documentation for more information on the request object's fields
2022
+ const reqObj = {
2023
+ payload: bodyVars,
2024
+ uriPathVars: pathVars,
2025
+ uriQuery: queryParams,
2026
+ addlHeaders: thisHeaderData
2027
+ };
2028
+
2029
+ try {
2030
+ // Make the call -
2031
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2032
+ return this.requestHandlerInst.identifyRequest('CertificateEnrollmentAPI', 'unRevokeCertificateUsingDELETE', reqObj, false, (irReturnData, irReturnError) => {
2033
+ // if we received an error or their is no response on the results
2034
+ // return an error
2035
+ if (irReturnError) {
2036
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2037
+ return callback(null, irReturnError);
2038
+ }
2039
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2040
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['unRevokeCertificateUsingDELETE'], null, null, null);
2041
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2042
+ return callback(null, errorObj);
2043
+ }
2044
+
2045
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2046
+ // return the response
2047
+ return callback(irReturnData, null);
2048
+ });
2049
+ } catch (ex) {
2050
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2051
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2052
+ return callback(null, errorObj);
2053
+ }
2054
+ }
2055
+
2056
+ /**
2057
+ * @function createPasscodeUsingPOST
2058
+ * @pronghornType method
2059
+ * @name createPasscodeUsingPOST
2060
+ * @summary This API is used to enroll user for profile.
2061
+ *
2062
+ * @param {object} createPasscodeRequest - createPasscodeRequest
2063
+ * @param {getCallback} callback - a callback function to return the result
2064
+ * @return {object} results - An object containing the response of the action
2065
+ *
2066
+ * @route {POST} /createPasscodeUsingPOST
2067
+ * @roles admin
2068
+ * @task true
2069
+ */
2070
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2071
+ createPasscodeUsingPOST(createPasscodeRequest, callback) {
2072
+ const meth = 'adapter-createPasscodeUsingPOST';
2073
+ const origin = `${this.id}-${meth}`;
2074
+ log.trace(origin);
2075
+
2076
+ if (this.suspended && this.suspendMode === 'error') {
2077
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2078
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2079
+ return callback(null, errorObj);
2080
+ }
2081
+
2082
+ /* HERE IS WHERE YOU VALIDATE DATA */
2083
+ if (createPasscodeRequest === undefined || createPasscodeRequest === null || createPasscodeRequest === '') {
2084
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['createPasscodeRequest'], null, null, null);
2085
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2086
+ return callback(null, errorObj);
2087
+ }
2088
+
2089
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2090
+ const queryParamsAvailable = {};
2091
+ const queryParams = {};
2092
+ const pathVars = [];
2093
+ const bodyVars = createPasscodeRequest;
2094
+
2095
+ // loop in template. long callback arg name to avoid identifier conflicts
2096
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2097
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2098
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2099
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2100
+ }
2101
+ });
2102
+
2103
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2104
+ let thisHeaderData = null;
2105
+ // if the additional headers was passed in as a string parse the json into an object
2106
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2107
+ try {
2108
+ // parse the additional headers object that was passed in
2109
+ thisHeaderData = JSON.parse(thisHeaderData);
2110
+ } catch (err) {
2111
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2112
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2113
+ return callback(null, errorObj);
2114
+ }
2115
+ } else if (thisHeaderData === null) {
2116
+ thisHeaderData = { xAPIKey: '' };
2117
+ }
2118
+
2119
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2120
+ // see adapter code documentation for more information on the request object's fields
2121
+ const reqObj = {
2122
+ payload: bodyVars,
2123
+ uriPathVars: pathVars,
2124
+ uriQuery: queryParams,
2125
+ addlHeaders: thisHeaderData
2126
+ };
2127
+
2128
+ try {
2129
+ // Make the call -
2130
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2131
+ return this.requestHandlerInst.identifyRequest('UserManagementAPI', 'createPasscodeUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
2132
+ // if we received an error or their is no response on the results
2133
+ // return an error
2134
+ if (irReturnError) {
2135
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2136
+ return callback(null, irReturnError);
2137
+ }
2138
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2139
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createPasscodeUsingPOST'], null, null, null);
2140
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2141
+ return callback(null, errorObj);
2142
+ }
2143
+
2144
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2145
+ // return the response
2146
+ return callback(irReturnData, null);
2147
+ });
2148
+ } catch (ex) {
2149
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2150
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2151
+ return callback(null, errorObj);
2152
+ }
2153
+ }
2154
+
2155
+ /**
2156
+ * @function getEnrollmentUsingGET
2157
+ * @pronghornType method
2158
+ * @name getEnrollmentUsingGET
2159
+ * @summary This API is used to get details of an existing enrollment.
2160
+ *
2161
+ * @param {string} enrollCode - enrollCode
2162
+ * @param {string} seatId - seat_id
2163
+ * @param {getCallback} callback - a callback function to return the result
2164
+ * @return {object} results - An object containing the response of the action
2165
+ *
2166
+ * @route {POST} /getEnrollmentUsingGET
2167
+ * @roles admin
2168
+ * @task true
2169
+ */
2170
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2171
+ getEnrollmentUsingGET(enrollCode, seatId, callback) {
2172
+ const meth = 'adapter-getEnrollmentUsingGET';
2173
+ const origin = `${this.id}-${meth}`;
2174
+ log.trace(origin);
2175
+
2176
+ if (this.suspended && this.suspendMode === 'error') {
2177
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2178
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2179
+ return callback(null, errorObj);
2180
+ }
2181
+
2182
+ /* HERE IS WHERE YOU VALIDATE DATA */
2183
+ if (enrollCode === undefined || enrollCode === null || enrollCode === '') {
2184
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['enrollCode'], null, null, null);
2185
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2186
+ return callback(null, errorObj);
2187
+ }
2188
+ if (seatId === undefined || seatId === null || seatId === '') {
2189
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['seatId'], null, null, null);
2190
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2191
+ return callback(null, errorObj);
2192
+ }
2193
+
2194
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2195
+ const queryParamsAvailable = { seatId };
2196
+ const queryParams = {};
2197
+ const pathVars = [enrollCode];
2198
+ const bodyVars = {};
2199
+
2200
+ // loop in template. long callback arg name to avoid identifier conflicts
2201
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2202
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2203
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2204
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2205
+ }
2206
+ });
2207
+
2208
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2209
+ let thisHeaderData = null;
2210
+ // if the additional headers was passed in as a string parse the json into an object
2211
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2212
+ try {
2213
+ // parse the additional headers object that was passed in
2214
+ thisHeaderData = JSON.parse(thisHeaderData);
2215
+ } catch (err) {
2216
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2217
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2218
+ return callback(null, errorObj);
2219
+ }
2220
+ } else if (thisHeaderData === null) {
2221
+ thisHeaderData = { xAPIKey: '' };
2222
+ }
2223
+
2224
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2225
+ // see adapter code documentation for more information on the request object's fields
2226
+ const reqObj = {
2227
+ payload: bodyVars,
2228
+ uriPathVars: pathVars,
2229
+ uriQuery: queryParams,
2230
+ addlHeaders: thisHeaderData
2231
+ };
2232
+
2233
+ try {
2234
+ // Make the call -
2235
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2236
+ return this.requestHandlerInst.identifyRequest('UserManagementAPI', 'getEnrollmentUsingGET', reqObj, true, (irReturnData, irReturnError) => {
2237
+ // if we received an error or their is no response on the results
2238
+ // return an error
2239
+ if (irReturnError) {
2240
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2241
+ return callback(null, irReturnError);
2242
+ }
2243
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2244
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getEnrollmentUsingGET'], null, null, null);
2245
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2246
+ return callback(null, errorObj);
2247
+ }
2248
+
2249
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2250
+ // return the response
2251
+ return callback(irReturnData, null);
2252
+ });
2253
+ } catch (ex) {
2254
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2255
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2256
+ return callback(null, errorObj);
2257
+ }
2258
+ }
2259
+
2260
+ /**
2261
+ * @function resetPasscodeUsingPUT
2262
+ * @pronghornType method
2263
+ * @name resetPasscodeUsingPUT
2264
+ * @summary This API is used to reset enrollment code.
2265
+ *
2266
+ * @param {string} enrollCode - enrollCode
2267
+ * @param {object} resetPasscodeRequest - resetPasscodeRequest
2268
+ * @param {getCallback} callback - a callback function to return the result
2269
+ * @return {object} results - An object containing the response of the action
2270
+ *
2271
+ * @route {POST} /resetPasscodeUsingPUT
2272
+ * @roles admin
2273
+ * @task true
2274
+ */
2275
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2276
+ resetPasscodeUsingPUT(enrollCode, resetPasscodeRequest, callback) {
2277
+ const meth = 'adapter-resetPasscodeUsingPUT';
2278
+ const origin = `${this.id}-${meth}`;
2279
+ log.trace(origin);
2280
+
2281
+ if (this.suspended && this.suspendMode === 'error') {
2282
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2283
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2284
+ return callback(null, errorObj);
2285
+ }
2286
+
2287
+ /* HERE IS WHERE YOU VALIDATE DATA */
2288
+ if (enrollCode === undefined || enrollCode === null || enrollCode === '') {
2289
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['enrollCode'], null, null, null);
2290
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2291
+ return callback(null, errorObj);
2292
+ }
2293
+ if (resetPasscodeRequest === undefined || resetPasscodeRequest === null || resetPasscodeRequest === '') {
2294
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['resetPasscodeRequest'], null, null, null);
2295
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2296
+ return callback(null, errorObj);
2297
+ }
2298
+
2299
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2300
+ const queryParamsAvailable = {};
2301
+ const queryParams = {};
2302
+ const pathVars = [enrollCode];
2303
+ const bodyVars = resetPasscodeRequest;
2304
+
2305
+ // loop in template. long callback arg name to avoid identifier conflicts
2306
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2307
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2308
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2309
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2310
+ }
2311
+ });
2312
+
2313
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2314
+ let thisHeaderData = null;
2315
+ // if the additional headers was passed in as a string parse the json into an object
2316
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2317
+ try {
2318
+ // parse the additional headers object that was passed in
2319
+ thisHeaderData = JSON.parse(thisHeaderData);
2320
+ } catch (err) {
2321
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2322
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2323
+ return callback(null, errorObj);
2324
+ }
2325
+ } else if (thisHeaderData === null) {
2326
+ thisHeaderData = { xAPIKey: '' };
2327
+ }
2328
+
2329
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2330
+ // see adapter code documentation for more information on the request object's fields
2331
+ const reqObj = {
2332
+ payload: bodyVars,
2333
+ uriPathVars: pathVars,
2334
+ uriQuery: queryParams,
2335
+ addlHeaders: thisHeaderData
2336
+ };
2337
+
2338
+ try {
2339
+ // Make the call -
2340
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2341
+ return this.requestHandlerInst.identifyRequest('UserManagementAPI', 'resetPasscodeUsingPUT', reqObj, false, (irReturnData, irReturnError) => {
2342
+ // if we received an error or their is no response on the results
2343
+ // return an error
2344
+ if (irReturnError) {
2345
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2346
+ return callback(null, irReturnError);
2347
+ }
2348
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2349
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['resetPasscodeUsingPUT'], null, null, null);
2350
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2351
+ return callback(null, errorObj);
2352
+ }
2353
+
2354
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2355
+ // return the response
2356
+ return callback(irReturnData, null);
2357
+ });
2358
+ } catch (ex) {
2359
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2360
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2361
+ return callback(null, errorObj);
2362
+ }
2363
+ }
2364
+
2365
+ /**
2366
+ * @function deleteEnrollmentUsingDELETE
2367
+ * @pronghornType method
2368
+ * @name deleteEnrollmentUsingDELETE
2369
+ * @summary This API can delete an enrollment for given enrollment id
2370
+ *
2371
+ * @param {object} deleteEnrollRequest - deleteEnrollRequest
2372
+ * @param {string} enrollCode - enrollCode
2373
+ * @param {getCallback} callback - a callback function to return the result
2374
+ * @return {object} results - An object containing the response of the action
2375
+ *
2376
+ * @route {POST} /deleteEnrollmentUsingDELETE
2377
+ * @roles admin
2378
+ * @task true
2379
+ */
2380
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2381
+ deleteEnrollmentUsingDELETE(deleteEnrollRequest, enrollCode, callback) {
2382
+ const meth = 'adapter-deleteEnrollmentUsingDELETE';
2383
+ const origin = `${this.id}-${meth}`;
2384
+ log.trace(origin);
2385
+
2386
+ if (this.suspended && this.suspendMode === 'error') {
2387
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2388
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2389
+ return callback(null, errorObj);
2390
+ }
2391
+
2392
+ /* HERE IS WHERE YOU VALIDATE DATA */
2393
+ if (deleteEnrollRequest === undefined || deleteEnrollRequest === null || deleteEnrollRequest === '') {
2394
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deleteEnrollRequest'], null, null, null);
2395
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2396
+ return callback(null, errorObj);
2397
+ }
2398
+ if (enrollCode === undefined || enrollCode === null || enrollCode === '') {
2399
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['enrollCode'], null, null, null);
2400
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2401
+ return callback(null, errorObj);
2402
+ }
2403
+
2404
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2405
+ const queryParamsAvailable = {};
2406
+ const queryParams = {};
2407
+ const pathVars = [enrollCode];
2408
+ const bodyVars = deleteEnrollRequest;
2409
+
2410
+ // loop in template. long callback arg name to avoid identifier conflicts
2411
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2412
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2413
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2414
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2415
+ }
2416
+ });
2417
+
2418
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2419
+ let thisHeaderData = null;
2420
+ // if the additional headers was passed in as a string parse the json into an object
2421
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2422
+ try {
2423
+ // parse the additional headers object that was passed in
2424
+ thisHeaderData = JSON.parse(thisHeaderData);
2425
+ } catch (err) {
2426
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2427
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2428
+ return callback(null, errorObj);
2429
+ }
2430
+ } else if (thisHeaderData === null) {
2431
+ thisHeaderData = { xAPIKey: '' };
2432
+ }
2433
+
2434
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2435
+ // see adapter code documentation for more information on the request object's fields
2436
+ const reqObj = {
2437
+ payload: bodyVars,
2438
+ uriPathVars: pathVars,
2439
+ uriQuery: queryParams,
2440
+ addlHeaders: thisHeaderData
2441
+ };
2442
+
2443
+ try {
2444
+ // Make the call -
2445
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2446
+ return this.requestHandlerInst.identifyRequest('UserManagementAPI', 'deleteEnrollmentUsingDELETE', reqObj, false, (irReturnData, irReturnError) => {
2447
+ // if we received an error or their is no response on the results
2448
+ // return an error
2449
+ if (irReturnError) {
2450
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2451
+ return callback(null, irReturnError);
2452
+ }
2453
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2454
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteEnrollmentUsingDELETE'], null, null, null);
2455
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2456
+ return callback(null, errorObj);
2457
+ }
2458
+
2459
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2460
+ // return the response
2461
+ return callback(irReturnData, null);
2462
+ });
2463
+ } catch (ex) {
2464
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2465
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2466
+ return callback(null, errorObj);
2467
+ }
2468
+ }
2469
+
2470
+ /**
2471
+ * @function enrollStatusUsingGET
2472
+ * @pronghornType method
2473
+ * @name enrollStatusUsingGET
2474
+ * @summary This API is used to get certificate enrollment status.
2475
+ *
2476
+ * @param {string} [profileId] - profile_id
2477
+ * @param {string} seatId - seatId
2478
+ * @param {getCallback} callback - a callback function to return the result
2479
+ * @return {object} results - An object containing the response of the action
2480
+ *
2481
+ * @route {POST} /enrollStatusUsingGET
2482
+ * @roles admin
2483
+ * @task true
2484
+ */
2485
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2486
+ enrollStatusUsingGET(profileId, seatId, callback) {
2487
+ const meth = 'adapter-enrollStatusUsingGET';
2488
+ const origin = `${this.id}-${meth}`;
2489
+ log.trace(origin);
2490
+
2491
+ if (this.suspended && this.suspendMode === 'error') {
2492
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2493
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2494
+ return callback(null, errorObj);
2495
+ }
2496
+
2497
+ /* HERE IS WHERE YOU VALIDATE DATA */
2498
+ if (seatId === undefined || seatId === null || seatId === '') {
2499
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['seatId'], null, null, null);
2500
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2501
+ return callback(null, errorObj);
2502
+ }
2503
+
2504
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2505
+ const queryParamsAvailable = { profileId };
2506
+ const queryParams = {};
2507
+ const pathVars = [seatId];
2508
+ const bodyVars = {};
2509
+
2510
+ // loop in template. long callback arg name to avoid identifier conflicts
2511
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2512
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2513
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2514
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2515
+ }
2516
+ });
2517
+
2518
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2519
+ let thisHeaderData = null;
2520
+ // if the additional headers was passed in as a string parse the json into an object
2521
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2522
+ try {
2523
+ // parse the additional headers object that was passed in
2524
+ thisHeaderData = JSON.parse(thisHeaderData);
2525
+ } catch (err) {
2526
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2527
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2528
+ return callback(null, errorObj);
2529
+ }
2530
+ } else if (thisHeaderData === null) {
2531
+ thisHeaderData = { xAPIKey: '' };
2532
+ }
2533
+
2534
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2535
+ // see adapter code documentation for more information on the request object's fields
2536
+ const reqObj = {
2537
+ payload: bodyVars,
2538
+ uriPathVars: pathVars,
2539
+ uriQuery: queryParams,
2540
+ addlHeaders: thisHeaderData
2541
+ };
2542
+
2543
+ try {
2544
+ // Make the call -
2545
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2546
+ return this.requestHandlerInst.identifyRequest('EnrollStatusAPI', 'enrollStatusUsingGET', reqObj, true, (irReturnData, irReturnError) => {
2547
+ // if we received an error or their is no response on the results
2548
+ // return an error
2549
+ if (irReturnError) {
2550
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2551
+ return callback(null, irReturnError);
2552
+ }
2553
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2554
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['enrollStatusUsingGET'], null, null, null);
2555
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2556
+ return callback(null, errorObj);
2557
+ }
2558
+
2559
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2560
+ // return the response
2561
+ return callback(irReturnData, null);
2562
+ });
2563
+ } catch (ex) {
2564
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2565
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2566
+ return callback(null, errorObj);
2567
+ }
2568
+ }
2569
+
2570
+ /**
2571
+ * @function helloUsingGET
2572
+ * @pronghornType method
2573
+ * @name helloUsingGET
2574
+ * @summary Hello API
2575
+ *
2576
+ * @param {getCallback} callback - a callback function to return the result
2577
+ * @return {object} results - An object containing the response of the action
2578
+ *
2579
+ * @route {GET} /helloUsingGET
2580
+ * @roles admin
2581
+ * @task true
2582
+ */
2583
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2584
+ helloUsingGET(callback) {
2585
+ const meth = 'adapter-helloUsingGET';
2586
+ const origin = `${this.id}-${meth}`;
2587
+ log.trace(origin);
2588
+
2589
+ if (this.suspended && this.suspendMode === 'error') {
2590
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2591
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2592
+ return callback(null, errorObj);
2593
+ }
2594
+
2595
+ /* HERE IS WHERE YOU VALIDATE DATA */
2596
+
2597
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2598
+ const queryParamsAvailable = {};
2599
+ const queryParams = {};
2600
+ const pathVars = [];
2601
+ const bodyVars = {};
2602
+
2603
+ // loop in template. long callback arg name to avoid identifier conflicts
2604
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2605
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2606
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2607
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2608
+ }
2609
+ });
2610
+
2611
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2612
+ let thisHeaderData = null;
2613
+ // if the additional headers was passed in as a string parse the json into an object
2614
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2615
+ try {
2616
+ // parse the additional headers object that was passed in
2617
+ thisHeaderData = JSON.parse(thisHeaderData);
2618
+ } catch (err) {
2619
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2620
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2621
+ return callback(null, errorObj);
2622
+ }
2623
+ } else if (thisHeaderData === null) {
2624
+ thisHeaderData = { xAPIKey: '' };
2625
+ }
2626
+
2627
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2628
+ // see adapter code documentation for more information on the request object's fields
2629
+ const reqObj = {
2630
+ payload: bodyVars,
2631
+ uriPathVars: pathVars,
2632
+ uriQuery: queryParams,
2633
+ addlHeaders: thisHeaderData
2634
+ };
2635
+
2636
+ try {
2637
+ // Make the call -
2638
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2639
+ return this.requestHandlerInst.identifyRequest('HelloAPI', 'helloUsingGET', reqObj, true, (irReturnData, irReturnError) => {
2640
+ // if we received an error or their is no response on the results
2641
+ // return an error
2642
+ if (irReturnError) {
2643
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2644
+ return callback(null, irReturnError);
2645
+ }
2646
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2647
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['helloUsingGET'], null, null, null);
2648
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2649
+ return callback(null, errorObj);
2650
+ }
2651
+
2652
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2653
+ // return the response
2654
+ return callback(irReturnData, null);
2655
+ });
2656
+ } catch (ex) {
2657
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2658
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2659
+ return callback(null, errorObj);
2660
+ }
2661
+ }
2662
+
2663
+ /**
2664
+ * @function getAllProfilesUsingGET
2665
+ * @pronghornType method
2666
+ * @name getAllProfilesUsingGET
2667
+ * @summary This API is used to get profile details of all profiles in an account and its subaccounts
2668
+ *
2669
+ * @param {getCallback} callback - a callback function to return the result
2670
+ * @return {object} results - An object containing the response of the action
2671
+ *
2672
+ * @route {GET} /getAllProfilesUsingGET
2673
+ * @roles admin
2674
+ * @task true
2675
+ */
2676
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2677
+ getAllProfilesUsingGET(callback) {
2678
+ const meth = 'adapter-getAllProfilesUsingGET';
2679
+ const origin = `${this.id}-${meth}`;
2680
+ log.trace(origin);
2681
+
2682
+ if (this.suspended && this.suspendMode === 'error') {
2683
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2684
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2685
+ return callback(null, errorObj);
2686
+ }
2687
+
2688
+ /* HERE IS WHERE YOU VALIDATE DATA */
2689
+
2690
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2691
+ const queryParamsAvailable = {};
2692
+ const queryParams = {};
2693
+ const pathVars = [];
2694
+ const bodyVars = {};
2695
+
2696
+ // loop in template. long callback arg name to avoid identifier conflicts
2697
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2698
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2699
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2700
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2701
+ }
2702
+ });
2703
+
2704
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2705
+ let thisHeaderData = null;
2706
+ // if the additional headers was passed in as a string parse the json into an object
2707
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2708
+ try {
2709
+ // parse the additional headers object that was passed in
2710
+ thisHeaderData = JSON.parse(thisHeaderData);
2711
+ } catch (err) {
2712
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2713
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2714
+ return callback(null, errorObj);
2715
+ }
2716
+ } else if (thisHeaderData === null) {
2717
+ thisHeaderData = { xAPIKey: '' };
2718
+ }
2719
+
2720
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2721
+ // see adapter code documentation for more information on the request object's fields
2722
+ const reqObj = {
2723
+ payload: bodyVars,
2724
+ uriPathVars: pathVars,
2725
+ uriQuery: queryParams,
2726
+ addlHeaders: thisHeaderData
2727
+ };
2728
+
2729
+ try {
2730
+ // Make the call -
2731
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2732
+ return this.requestHandlerInst.identifyRequest('CertificateProfileAPI', 'getAllProfilesUsingGET', reqObj, true, (irReturnData, irReturnError) => {
2733
+ // if we received an error or their is no response on the results
2734
+ // return an error
2735
+ if (irReturnError) {
2736
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2737
+ return callback(null, irReturnError);
2738
+ }
2739
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2740
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAllProfilesUsingGET'], null, null, null);
2741
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2742
+ return callback(null, errorObj);
2743
+ }
2744
+
2745
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2746
+ // return the response
2747
+ return callback(irReturnData, null);
2748
+ });
2749
+ } catch (ex) {
2750
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2751
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2752
+ return callback(null, errorObj);
2753
+ }
2754
+ }
2755
+
2756
+ /**
2757
+ * @function getProfileUsingGET
2758
+ * @pronghornType method
2759
+ * @name getProfileUsingGET
2760
+ * @summary This API is used to get profile details for a given profile id
2761
+ *
2762
+ * @param {string} profileId - profileId
2763
+ * @param {getCallback} callback - a callback function to return the result
2764
+ * @return {object} results - An object containing the response of the action
2765
+ *
2766
+ * @route {POST} /getProfileUsingGET
2767
+ * @roles admin
2768
+ * @task true
2769
+ */
2770
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2771
+ getProfileUsingGET(profileId, callback) {
2772
+ const meth = 'adapter-getProfileUsingGET';
2773
+ const origin = `${this.id}-${meth}`;
2774
+ log.trace(origin);
2775
+
2776
+ if (this.suspended && this.suspendMode === 'error') {
2777
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2778
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2779
+ return callback(null, errorObj);
2780
+ }
2781
+
2782
+ /* HERE IS WHERE YOU VALIDATE DATA */
2783
+ if (profileId === undefined || profileId === null || profileId === '') {
2784
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['profileId'], null, null, null);
2785
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2786
+ return callback(null, errorObj);
2787
+ }
2788
+
2789
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2790
+ const queryParamsAvailable = {};
2791
+ const queryParams = {};
2792
+ const pathVars = [profileId];
2793
+ const bodyVars = {};
2794
+
2795
+ // loop in template. long callback arg name to avoid identifier conflicts
2796
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2797
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2798
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2799
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2800
+ }
2801
+ });
2802
+
2803
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2804
+ let thisHeaderData = null;
2805
+ // if the additional headers was passed in as a string parse the json into an object
2806
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2807
+ try {
2808
+ // parse the additional headers object that was passed in
2809
+ thisHeaderData = JSON.parse(thisHeaderData);
2810
+ } catch (err) {
2811
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2812
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2813
+ return callback(null, errorObj);
2814
+ }
2815
+ } else if (thisHeaderData === null) {
2816
+ thisHeaderData = { xAPIKey: '' };
2817
+ }
2818
+
2819
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2820
+ // see adapter code documentation for more information on the request object's fields
2821
+ const reqObj = {
2822
+ payload: bodyVars,
2823
+ uriPathVars: pathVars,
2824
+ uriQuery: queryParams,
2825
+ addlHeaders: thisHeaderData
2826
+ };
2827
+
2828
+ try {
2829
+ // Make the call -
2830
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2831
+ return this.requestHandlerInst.identifyRequest('CertificateProfileAPI', 'getProfileUsingGET', reqObj, true, (irReturnData, irReturnError) => {
2832
+ // if we received an error or their is no response on the results
2833
+ // return an error
2834
+ if (irReturnError) {
2835
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2836
+ return callback(null, irReturnError);
2837
+ }
2838
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2839
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getProfileUsingGET'], null, null, null);
2840
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2841
+ return callback(null, errorObj);
2842
+ }
2843
+
2844
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2845
+ // return the response
2846
+ return callback(irReturnData, null);
2847
+ });
2848
+ } catch (ex) {
2849
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2850
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2851
+ return callback(null, errorObj);
2852
+ }
2853
+ }
2854
+
2855
+ /**
2856
+ * @function activateProfileUsingPUT
2857
+ * @pronghornType method
2858
+ * @name activateProfileUsingPUT
2859
+ * @summary This API is used to suspend a profile
2860
+ *
2861
+ * @param {object} profileCreationRequest - profileCreationRequest
2862
+ * @param {getCallback} callback - a callback function to return the result
2863
+ * @return {object} results - An object containing the response of the action
2864
+ *
2865
+ * @route {POST} /activateProfileUsingPUT
2866
+ * @roles admin
2867
+ * @task true
2868
+ */
2869
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2870
+ activateProfileUsingPUT(profileCreationRequest, callback) {
2871
+ const meth = 'adapter-activateProfileUsingPUT';
2872
+ const origin = `${this.id}-${meth}`;
2873
+ log.trace(origin);
2874
+
2875
+ if (this.suspended && this.suspendMode === 'error') {
2876
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2877
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2878
+ return callback(null, errorObj);
2879
+ }
2880
+
2881
+ /* HERE IS WHERE YOU VALIDATE DATA */
2882
+ if (profileCreationRequest === undefined || profileCreationRequest === null || profileCreationRequest === '') {
2883
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['profileCreationRequest'], null, null, null);
2884
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2885
+ return callback(null, errorObj);
2886
+ }
2887
+
2888
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2889
+ const queryParamsAvailable = {};
2890
+ const queryParams = {};
2891
+ const pathVars = [];
2892
+ const bodyVars = profileCreationRequest;
2893
+
2894
+ // loop in template. long callback arg name to avoid identifier conflicts
2895
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2896
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2897
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2898
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2899
+ }
2900
+ });
2901
+
2902
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2903
+ let thisHeaderData = null;
2904
+ // if the additional headers was passed in as a string parse the json into an object
2905
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2906
+ try {
2907
+ // parse the additional headers object that was passed in
2908
+ thisHeaderData = JSON.parse(thisHeaderData);
2909
+ } catch (err) {
2910
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2911
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2912
+ return callback(null, errorObj);
2913
+ }
2914
+ } else if (thisHeaderData === null) {
2915
+ thisHeaderData = { xAPIKey: '' };
2916
+ }
2917
+
2918
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2919
+ // see adapter code documentation for more information on the request object's fields
2920
+ const reqObj = {
2921
+ payload: bodyVars,
2922
+ uriPathVars: pathVars,
2923
+ uriQuery: queryParams,
2924
+ addlHeaders: thisHeaderData
2925
+ };
2926
+
2927
+ try {
2928
+ // Make the call -
2929
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2930
+ return this.requestHandlerInst.identifyRequest('PROFILEAPI', 'activateProfileUsingPUT', reqObj, false, (irReturnData, irReturnError) => {
2931
+ // if we received an error or their is no response on the results
2932
+ // return an error
2933
+ if (irReturnError) {
2934
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2935
+ return callback(null, irReturnError);
2936
+ }
2937
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2938
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['activateProfileUsingPUT'], null, null, null);
2939
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2940
+ return callback(null, errorObj);
2941
+ }
2942
+
2943
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2944
+ // return the response
2945
+ return callback(irReturnData, null);
2946
+ });
2947
+ } catch (ex) {
2948
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2949
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2950
+ return callback(null, errorObj);
2951
+ }
2952
+ }
2953
+
2954
+ /**
2955
+ * @function createProfileUsingPOST
2956
+ * @pronghornType method
2957
+ * @name createProfileUsingPOST
2958
+ * @summary This API is used to create a profile
2959
+ *
2960
+ * @param {object} profileCreationRequest - profileCreationRequest
2961
+ * @param {getCallback} callback - a callback function to return the result
2962
+ * @return {object} results - An object containing the response of the action
2963
+ *
2964
+ * @route {POST} /createProfileUsingPOST
2965
+ * @roles admin
2966
+ * @task true
2967
+ */
2968
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2969
+ createProfileUsingPOST(profileCreationRequest, callback) {
2970
+ const meth = 'adapter-createProfileUsingPOST';
2971
+ const origin = `${this.id}-${meth}`;
2972
+ log.trace(origin);
2973
+
2974
+ if (this.suspended && this.suspendMode === 'error') {
2975
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2976
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2977
+ return callback(null, errorObj);
2978
+ }
2979
+
2980
+ /* HERE IS WHERE YOU VALIDATE DATA */
2981
+ if (profileCreationRequest === undefined || profileCreationRequest === null || profileCreationRequest === '') {
2982
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['profileCreationRequest'], null, null, null);
2983
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2984
+ return callback(null, errorObj);
2985
+ }
2986
+
2987
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2988
+ const queryParamsAvailable = {};
2989
+ const queryParams = {};
2990
+ const pathVars = [];
2991
+ const bodyVars = profileCreationRequest;
2992
+
2993
+ // loop in template. long callback arg name to avoid identifier conflicts
2994
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2995
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2996
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2997
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2998
+ }
2999
+ });
3000
+
3001
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3002
+ let thisHeaderData = null;
3003
+ // if the additional headers was passed in as a string parse the json into an object
3004
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3005
+ try {
3006
+ // parse the additional headers object that was passed in
3007
+ thisHeaderData = JSON.parse(thisHeaderData);
3008
+ } catch (err) {
3009
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3010
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3011
+ return callback(null, errorObj);
3012
+ }
3013
+ } else if (thisHeaderData === null) {
3014
+ thisHeaderData = { xAPIKey: '' };
3015
+ }
3016
+
3017
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3018
+ // see adapter code documentation for more information on the request object's fields
3019
+ const reqObj = {
3020
+ payload: bodyVars,
3021
+ uriPathVars: pathVars,
3022
+ uriQuery: queryParams,
3023
+ addlHeaders: thisHeaderData
3024
+ };
3025
+
3026
+ try {
3027
+ // Make the call -
3028
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3029
+ return this.requestHandlerInst.identifyRequest('PROFILEAPI', 'createProfileUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
3030
+ // if we received an error or their is no response on the results
3031
+ // return an error
3032
+ if (irReturnError) {
3033
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3034
+ return callback(null, irReturnError);
3035
+ }
3036
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3037
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createProfileUsingPOST'], null, null, null);
3038
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3039
+ return callback(null, errorObj);
3040
+ }
3041
+
3042
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3043
+ // return the response
3044
+ return callback(irReturnData, null);
3045
+ });
3046
+ } catch (ex) {
3047
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3048
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3049
+ return callback(null, errorObj);
3050
+ }
3051
+ }
3052
+
3053
+ /**
3054
+ * @function deleteProfileUsingPUT
3055
+ * @pronghornType method
3056
+ * @name deleteProfileUsingPUT
3057
+ * @summary This API is used to delete a profile
3058
+ *
3059
+ * @param {object} profileCreationRequest - profileCreationRequest
3060
+ * @param {getCallback} callback - a callback function to return the result
3061
+ * @return {object} results - An object containing the response of the action
3062
+ *
3063
+ * @route {POST} /deleteProfileUsingPUT
3064
+ * @roles admin
3065
+ * @task true
3066
+ */
3067
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3068
+ deleteProfileUsingPUT(profileCreationRequest, callback) {
3069
+ const meth = 'adapter-deleteProfileUsingPUT';
3070
+ const origin = `${this.id}-${meth}`;
3071
+ log.trace(origin);
3072
+
3073
+ if (this.suspended && this.suspendMode === 'error') {
3074
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3075
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3076
+ return callback(null, errorObj);
3077
+ }
3078
+
3079
+ /* HERE IS WHERE YOU VALIDATE DATA */
3080
+ if (profileCreationRequest === undefined || profileCreationRequest === null || profileCreationRequest === '') {
3081
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['profileCreationRequest'], null, null, null);
3082
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3083
+ return callback(null, errorObj);
3084
+ }
3085
+
3086
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3087
+ const queryParamsAvailable = {};
3088
+ const queryParams = {};
3089
+ const pathVars = [];
3090
+ const bodyVars = profileCreationRequest;
3091
+
3092
+ // loop in template. long callback arg name to avoid identifier conflicts
3093
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3094
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3095
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3096
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3097
+ }
3098
+ });
3099
+
3100
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3101
+ let thisHeaderData = null;
3102
+ // if the additional headers was passed in as a string parse the json into an object
3103
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3104
+ try {
3105
+ // parse the additional headers object that was passed in
3106
+ thisHeaderData = JSON.parse(thisHeaderData);
3107
+ } catch (err) {
3108
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3109
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3110
+ return callback(null, errorObj);
3111
+ }
3112
+ } else if (thisHeaderData === null) {
3113
+ thisHeaderData = { xAPIKey: '' };
3114
+ }
3115
+
3116
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3117
+ // see adapter code documentation for more information on the request object's fields
3118
+ const reqObj = {
3119
+ payload: bodyVars,
3120
+ uriPathVars: pathVars,
3121
+ uriQuery: queryParams,
3122
+ addlHeaders: thisHeaderData
3123
+ };
3124
+
3125
+ try {
3126
+ // Make the call -
3127
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3128
+ return this.requestHandlerInst.identifyRequest('PROFILEAPI', 'deleteProfileUsingPUT', reqObj, false, (irReturnData, irReturnError) => {
3129
+ // if we received an error or their is no response on the results
3130
+ // return an error
3131
+ if (irReturnError) {
3132
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3133
+ return callback(null, irReturnError);
3134
+ }
3135
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3136
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteProfileUsingPUT'], null, null, null);
3137
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3138
+ return callback(null, errorObj);
3139
+ }
3140
+
3141
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3142
+ // return the response
3143
+ return callback(irReturnData, null);
3144
+ });
3145
+ } catch (ex) {
3146
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3147
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3148
+ return callback(null, errorObj);
3149
+ }
3150
+ }
3151
+
3152
+ /**
3153
+ * @function updateProfileUsingPUT
3154
+ * @pronghornType method
3155
+ * @name updateProfileUsingPUT
3156
+ * @summary This API is used to create a profile
3157
+ *
3158
+ * @param {object} profileCreationRequest - profileCreationRequest
3159
+ * @param {getCallback} callback - a callback function to return the result
3160
+ * @return {object} results - An object containing the response of the action
3161
+ *
3162
+ * @route {POST} /updateProfileUsingPUT
3163
+ * @roles admin
3164
+ * @task true
3165
+ */
3166
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3167
+ updateProfileUsingPUT(profileCreationRequest, callback) {
3168
+ const meth = 'adapter-updateProfileUsingPUT';
3169
+ const origin = `${this.id}-${meth}`;
3170
+ log.trace(origin);
3171
+
3172
+ if (this.suspended && this.suspendMode === 'error') {
3173
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3174
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3175
+ return callback(null, errorObj);
3176
+ }
3177
+
3178
+ /* HERE IS WHERE YOU VALIDATE DATA */
3179
+ if (profileCreationRequest === undefined || profileCreationRequest === null || profileCreationRequest === '') {
3180
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['profileCreationRequest'], null, null, null);
3181
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3182
+ return callback(null, errorObj);
3183
+ }
3184
+
3185
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3186
+ const queryParamsAvailable = {};
3187
+ const queryParams = {};
3188
+ const pathVars = [];
3189
+ const bodyVars = profileCreationRequest;
3190
+
3191
+ // loop in template. long callback arg name to avoid identifier conflicts
3192
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3193
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3194
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3195
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3196
+ }
3197
+ });
3198
+
3199
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3200
+ let thisHeaderData = null;
3201
+ // if the additional headers was passed in as a string parse the json into an object
3202
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3203
+ try {
3204
+ // parse the additional headers object that was passed in
3205
+ thisHeaderData = JSON.parse(thisHeaderData);
3206
+ } catch (err) {
3207
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3208
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3209
+ return callback(null, errorObj);
3210
+ }
3211
+ } else if (thisHeaderData === null) {
3212
+ thisHeaderData = { xAPIKey: '' };
3213
+ }
3214
+
3215
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3216
+ // see adapter code documentation for more information on the request object's fields
3217
+ const reqObj = {
3218
+ payload: bodyVars,
3219
+ uriPathVars: pathVars,
3220
+ uriQuery: queryParams,
3221
+ addlHeaders: thisHeaderData
3222
+ };
3223
+
3224
+ try {
3225
+ // Make the call -
3226
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3227
+ return this.requestHandlerInst.identifyRequest('PROFILEAPI', 'updateProfileUsingPUT', reqObj, false, (irReturnData, irReturnError) => {
3228
+ // if we received an error or their is no response on the results
3229
+ // return an error
3230
+ if (irReturnError) {
3231
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3232
+ return callback(null, irReturnError);
3233
+ }
3234
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3235
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateProfileUsingPUT'], null, null, null);
3236
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3237
+ return callback(null, errorObj);
3238
+ }
3239
+
3240
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3241
+ // return the response
3242
+ return callback(irReturnData, null);
3243
+ });
3244
+ } catch (ex) {
3245
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3246
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3247
+ return callback(null, errorObj);
3248
+ }
3249
+ }
3250
+
3251
+ /**
3252
+ * @function suspendProfileUsingPUT
3253
+ * @pronghornType method
3254
+ * @name suspendProfileUsingPUT
3255
+ * @summary This API is used to suspend a profile
3256
+ *
3257
+ * @param {object} profileCreationRequest - profileCreationRequest
3258
+ * @param {getCallback} callback - a callback function to return the result
3259
+ * @return {object} results - An object containing the response of the action
3260
+ *
3261
+ * @route {POST} /suspendProfileUsingPUT
3262
+ * @roles admin
3263
+ * @task true
3264
+ */
3265
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3266
+ suspendProfileUsingPUT(profileCreationRequest, callback) {
3267
+ const meth = 'adapter-suspendProfileUsingPUT';
3268
+ const origin = `${this.id}-${meth}`;
3269
+ log.trace(origin);
3270
+
3271
+ if (this.suspended && this.suspendMode === 'error') {
3272
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3273
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3274
+ return callback(null, errorObj);
3275
+ }
3276
+
3277
+ /* HERE IS WHERE YOU VALIDATE DATA */
3278
+ if (profileCreationRequest === undefined || profileCreationRequest === null || profileCreationRequest === '') {
3279
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['profileCreationRequest'], null, null, null);
3280
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3281
+ return callback(null, errorObj);
3282
+ }
3283
+
3284
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3285
+ const queryParamsAvailable = {};
3286
+ const queryParams = {};
3287
+ const pathVars = [];
3288
+ const bodyVars = profileCreationRequest;
3289
+
3290
+ // loop in template. long callback arg name to avoid identifier conflicts
3291
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3292
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3293
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3294
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3295
+ }
3296
+ });
3297
+
3298
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3299
+ let thisHeaderData = null;
3300
+ // if the additional headers was passed in as a string parse the json into an object
3301
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3302
+ try {
3303
+ // parse the additional headers object that was passed in
3304
+ thisHeaderData = JSON.parse(thisHeaderData);
3305
+ } catch (err) {
3306
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3307
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3308
+ return callback(null, errorObj);
3309
+ }
3310
+ } else if (thisHeaderData === null) {
3311
+ thisHeaderData = { xAPIKey: '' };
3312
+ }
3313
+
3314
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3315
+ // see adapter code documentation for more information on the request object's fields
3316
+ const reqObj = {
3317
+ payload: bodyVars,
3318
+ uriPathVars: pathVars,
3319
+ uriQuery: queryParams,
3320
+ addlHeaders: thisHeaderData
3321
+ };
3322
+
3323
+ try {
3324
+ // Make the call -
3325
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3326
+ return this.requestHandlerInst.identifyRequest('PROFILEAPI', 'suspendProfileUsingPUT', reqObj, false, (irReturnData, irReturnError) => {
3327
+ // if we received an error or their is no response on the results
3328
+ // return an error
3329
+ if (irReturnError) {
3330
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3331
+ return callback(null, irReturnError);
3332
+ }
3333
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3334
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['suspendProfileUsingPUT'], null, null, null);
3335
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3336
+ return callback(null, errorObj);
3337
+ }
3338
+
3339
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3340
+ // return the response
3341
+ return callback(irReturnData, null);
3342
+ });
3343
+ } catch (ex) {
3344
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3345
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3346
+ return callback(null, errorObj);
3347
+ }
3348
+ }
3349
+
3350
+ /**
3351
+ * @function testCreateUsingPOST
3352
+ * @pronghornType method
3353
+ * @name testCreateUsingPOST
3354
+ * @summary This API is used to create a profile
3355
+ *
3356
+ * @param {getCallback} callback - a callback function to return the result
3357
+ * @return {object} results - An object containing the response of the action
3358
+ *
3359
+ * @route {GET} /testCreateUsingPOST
3360
+ * @roles admin
3361
+ * @task true
3362
+ */
3363
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3364
+ testCreateUsingPOST(callback) {
3365
+ const meth = 'adapter-testCreateUsingPOST';
3366
+ const origin = `${this.id}-${meth}`;
3367
+ log.trace(origin);
3368
+
3369
+ if (this.suspended && this.suspendMode === 'error') {
3370
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3371
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3372
+ return callback(null, errorObj);
3373
+ }
3374
+
3375
+ /* HERE IS WHERE YOU VALIDATE DATA */
3376
+
3377
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3378
+ const queryParamsAvailable = {};
3379
+ const queryParams = {};
3380
+ const pathVars = [];
3381
+ const bodyVars = {};
3382
+
3383
+ // loop in template. long callback arg name to avoid identifier conflicts
3384
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3385
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3386
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3387
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3388
+ }
3389
+ });
3390
+
3391
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3392
+ let thisHeaderData = null;
3393
+ // if the additional headers was passed in as a string parse the json into an object
3394
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3395
+ try {
3396
+ // parse the additional headers object that was passed in
3397
+ thisHeaderData = JSON.parse(thisHeaderData);
3398
+ } catch (err) {
3399
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3400
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3401
+ return callback(null, errorObj);
3402
+ }
3403
+ } else if (thisHeaderData === null) {
3404
+ thisHeaderData = { xAPIKey: '' };
3405
+ }
3406
+
3407
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3408
+ // see adapter code documentation for more information on the request object's fields
3409
+ const reqObj = {
3410
+ payload: bodyVars,
3411
+ uriPathVars: pathVars,
3412
+ uriQuery: queryParams,
3413
+ addlHeaders: thisHeaderData
3414
+ };
3415
+
3416
+ try {
3417
+ // Make the call -
3418
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3419
+ return this.requestHandlerInst.identifyRequest('PROFILEAPI', 'testCreateUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
3420
+ // if we received an error or their is no response on the results
3421
+ // return an error
3422
+ if (irReturnError) {
3423
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3424
+ return callback(null, irReturnError);
3425
+ }
3426
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3427
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['testCreateUsingPOST'], null, null, null);
3428
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3429
+ return callback(null, errorObj);
3430
+ }
3431
+
3432
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3433
+ // return the response
3434
+ return callback(irReturnData, null);
3435
+ });
3436
+ } catch (ex) {
3437
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3438
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3439
+ return callback(null, errorObj);
3440
+ }
3441
+ }
3442
+
3443
+ /**
3444
+ * @function searchCertUsingPOST
3445
+ * @pronghornType method
3446
+ * @name searchCertUsingPOST
3447
+ * @summary This API is used to search for certificates.
3448
+ *
3449
+ * @param {object} searchReq - searchReq
3450
+ * @param {getCallback} callback - a callback function to return the result
3451
+ * @return {object} results - An object containing the response of the action
3452
+ *
3453
+ * @route {POST} /searchCertUsingPOST
3454
+ * @roles admin
3455
+ * @task true
3456
+ */
3457
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3458
+ searchCertUsingPOST(searchReq, callback) {
3459
+ const meth = 'adapter-searchCertUsingPOST';
3460
+ const origin = `${this.id}-${meth}`;
3461
+ log.trace(origin);
3462
+
3463
+ if (this.suspended && this.suspendMode === 'error') {
3464
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3465
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3466
+ return callback(null, errorObj);
3467
+ }
3468
+
3469
+ /* HERE IS WHERE YOU VALIDATE DATA */
3470
+ if (searchReq === undefined || searchReq === null || searchReq === '') {
3471
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['searchReq'], null, null, null);
3472
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3473
+ return callback(null, errorObj);
3474
+ }
3475
+
3476
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3477
+ const queryParamsAvailable = {};
3478
+ const queryParams = {};
3479
+ const pathVars = [];
3480
+ const bodyVars = searchReq;
3481
+
3482
+ // loop in template. long callback arg name to avoid identifier conflicts
3483
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3484
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3485
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3486
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3487
+ }
3488
+ });
3489
+
3490
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3491
+ let thisHeaderData = null;
3492
+ // if the additional headers was passed in as a string parse the json into an object
3493
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3494
+ try {
3495
+ // parse the additional headers object that was passed in
3496
+ thisHeaderData = JSON.parse(thisHeaderData);
3497
+ } catch (err) {
3498
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3499
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3500
+ return callback(null, errorObj);
3501
+ }
3502
+ } else if (thisHeaderData === null) {
3503
+ thisHeaderData = { xAPIKey: '' };
3504
+ }
3505
+
3506
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3507
+ // see adapter code documentation for more information on the request object's fields
3508
+ const reqObj = {
3509
+ payload: bodyVars,
3510
+ uriPathVars: pathVars,
3511
+ uriQuery: queryParams,
3512
+ addlHeaders: thisHeaderData
3513
+ };
3514
+
3515
+ try {
3516
+ // Make the call -
3517
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3518
+ return this.requestHandlerInst.identifyRequest('SearchCertificateAPI', 'searchCertUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
3519
+ // if we received an error or their is no response on the results
3520
+ // return an error
3521
+ if (irReturnError) {
3522
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3523
+ return callback(null, irReturnError);
3524
+ }
3525
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3526
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['searchCertUsingPOST'], null, null, null);
3527
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3528
+ return callback(null, errorObj);
3529
+ }
3530
+
3531
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3532
+ // return the response
3533
+ return callback(irReturnData, null);
3534
+ });
3535
+ } catch (ex) {
3536
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3537
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3538
+ return callback(null, errorObj);
3539
+ }
3540
+ }
3541
+
3542
+ /**
3543
+ * @function createSeatUsingPOST
3544
+ * @pronghornType method
3545
+ * @name createSeatUsingPOST
3546
+ * @summary This API is used to create a seat. This seat can be used for a user, device, server or organization seat pool.
3547
+ *
3548
+ * @param {object} createSeatRequest - createSeatRequest
3549
+ * @param {getCallback} callback - a callback function to return the result
3550
+ * @return {object} results - An object containing the response of the action
3551
+ *
3552
+ * @route {POST} /createSeatUsingPOST
3553
+ * @roles admin
3554
+ * @task true
3555
+ */
3556
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3557
+ createSeatUsingPOST(createSeatRequest, callback) {
3558
+ const meth = 'adapter-createSeatUsingPOST';
3559
+ const origin = `${this.id}-${meth}`;
3560
+ log.trace(origin);
3561
+
3562
+ if (this.suspended && this.suspendMode === 'error') {
3563
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3564
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3565
+ return callback(null, errorObj);
3566
+ }
3567
+
3568
+ /* HERE IS WHERE YOU VALIDATE DATA */
3569
+ if (createSeatRequest === undefined || createSeatRequest === null || createSeatRequest === '') {
3570
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['createSeatRequest'], null, null, null);
3571
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3572
+ return callback(null, errorObj);
3573
+ }
3574
+
3575
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3576
+ const queryParamsAvailable = {};
3577
+ const queryParams = {};
3578
+ const pathVars = [];
3579
+ const bodyVars = createSeatRequest;
3580
+
3581
+ // loop in template. long callback arg name to avoid identifier conflicts
3582
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3583
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3584
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3585
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3586
+ }
3587
+ });
3588
+
3589
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3590
+ let thisHeaderData = null;
3591
+ // if the additional headers was passed in as a string parse the json into an object
3592
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3593
+ try {
3594
+ // parse the additional headers object that was passed in
3595
+ thisHeaderData = JSON.parse(thisHeaderData);
3596
+ } catch (err) {
3597
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3598
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3599
+ return callback(null, errorObj);
3600
+ }
3601
+ } else if (thisHeaderData === null) {
3602
+ thisHeaderData = { xAPIKey: '' };
3603
+ }
3604
+
3605
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3606
+ // see adapter code documentation for more information on the request object's fields
3607
+ const reqObj = {
3608
+ payload: bodyVars,
3609
+ uriPathVars: pathVars,
3610
+ uriQuery: queryParams,
3611
+ addlHeaders: thisHeaderData
3612
+ };
3613
+
3614
+ try {
3615
+ // Make the call -
3616
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3617
+ return this.requestHandlerInst.identifyRequest('SeatManagementAPI', 'createSeatUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
3618
+ // if we received an error or their is no response on the results
3619
+ // return an error
3620
+ if (irReturnError) {
3621
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3622
+ return callback(null, irReturnError);
3623
+ }
3624
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3625
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createSeatUsingPOST'], null, null, null);
3626
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3627
+ return callback(null, errorObj);
3628
+ }
3629
+
3630
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3631
+ // return the response
3632
+ return callback(irReturnData, null);
3633
+ });
3634
+ } catch (ex) {
3635
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3636
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3637
+ return callback(null, errorObj);
3638
+ }
3639
+ }
3640
+
3641
+ /**
3642
+ * @function getSeatUsingGET
3643
+ * @pronghornType method
3644
+ * @name getSeatUsingGET
3645
+ * @summary This API is used to get information regarding a seat.
3646
+ *
3647
+ * @param {string} seatId - seatId
3648
+ * @param {getCallback} callback - a callback function to return the result
3649
+ * @return {object} results - An object containing the response of the action
3650
+ *
3651
+ * @route {POST} /getSeatUsingGET
3652
+ * @roles admin
3653
+ * @task true
3654
+ */
3655
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3656
+ getSeatUsingGET(seatId, callback) {
3657
+ const meth = 'adapter-getSeatUsingGET';
3658
+ const origin = `${this.id}-${meth}`;
3659
+ log.trace(origin);
3660
+
3661
+ if (this.suspended && this.suspendMode === 'error') {
3662
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3663
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3664
+ return callback(null, errorObj);
3665
+ }
3666
+
3667
+ /* HERE IS WHERE YOU VALIDATE DATA */
3668
+ if (seatId === undefined || seatId === null || seatId === '') {
3669
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['seatId'], null, null, null);
3670
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3671
+ return callback(null, errorObj);
3672
+ }
3673
+
3674
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3675
+ const queryParamsAvailable = {};
3676
+ const queryParams = {};
3677
+ const pathVars = [seatId];
3678
+ const bodyVars = {};
3679
+
3680
+ // loop in template. long callback arg name to avoid identifier conflicts
3681
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3682
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3683
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3684
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3685
+ }
3686
+ });
3687
+
3688
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3689
+ let thisHeaderData = null;
3690
+ // if the additional headers was passed in as a string parse the json into an object
3691
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3692
+ try {
3693
+ // parse the additional headers object that was passed in
3694
+ thisHeaderData = JSON.parse(thisHeaderData);
3695
+ } catch (err) {
3696
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3697
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3698
+ return callback(null, errorObj);
3699
+ }
3700
+ } else if (thisHeaderData === null) {
3701
+ thisHeaderData = { xAPIKey: '' };
3702
+ }
3703
+
3704
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3705
+ // see adapter code documentation for more information on the request object's fields
3706
+ const reqObj = {
3707
+ payload: bodyVars,
3708
+ uriPathVars: pathVars,
3709
+ uriQuery: queryParams,
3710
+ addlHeaders: thisHeaderData
3711
+ };
3712
+
3713
+ try {
3714
+ // Make the call -
3715
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3716
+ return this.requestHandlerInst.identifyRequest('SeatManagementAPI', 'getSeatUsingGET', reqObj, true, (irReturnData, irReturnError) => {
3717
+ // if we received an error or their is no response on the results
3718
+ // return an error
3719
+ if (irReturnError) {
3720
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3721
+ return callback(null, irReturnError);
3722
+ }
3723
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3724
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSeatUsingGET'], null, null, null);
3725
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3726
+ return callback(null, errorObj);
3727
+ }
3728
+
3729
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3730
+ // return the response
3731
+ return callback(irReturnData, null);
3732
+ });
3733
+ } catch (ex) {
3734
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3735
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3736
+ return callback(null, errorObj);
3737
+ }
3738
+ }
3739
+
3740
+ /**
3741
+ * @function updateSeatUsingPUT
3742
+ * @pronghornType method
3743
+ * @name updateSeatUsingPUT
3744
+ * @summary This API is used to change the seat details.
3745
+ *
3746
+ * @param {string} seatId - seatId
3747
+ * @param {object} updateSeatRequest - updateSeatRequest
3748
+ * @param {getCallback} callback - a callback function to return the result
3749
+ * @return {object} results - An object containing the response of the action
3750
+ *
3751
+ * @route {POST} /updateSeatUsingPUT
3752
+ * @roles admin
3753
+ * @task true
3754
+ */
3755
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3756
+ updateSeatUsingPUT(seatId, updateSeatRequest, callback) {
3757
+ const meth = 'adapter-updateSeatUsingPUT';
3758
+ const origin = `${this.id}-${meth}`;
3759
+ log.trace(origin);
3760
+
3761
+ if (this.suspended && this.suspendMode === 'error') {
3762
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3763
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3764
+ return callback(null, errorObj);
3765
+ }
3766
+
3767
+ /* HERE IS WHERE YOU VALIDATE DATA */
3768
+ if (seatId === undefined || seatId === null || seatId === '') {
3769
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['seatId'], null, null, null);
3770
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3771
+ return callback(null, errorObj);
3772
+ }
3773
+ if (updateSeatRequest === undefined || updateSeatRequest === null || updateSeatRequest === '') {
3774
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['updateSeatRequest'], null, null, null);
3775
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3776
+ return callback(null, errorObj);
3777
+ }
3778
+
3779
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3780
+ const queryParamsAvailable = {};
3781
+ const queryParams = {};
3782
+ const pathVars = [seatId];
3783
+ const bodyVars = updateSeatRequest;
3784
+
3785
+ // loop in template. long callback arg name to avoid identifier conflicts
3786
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3787
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3788
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3789
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3790
+ }
3791
+ });
3792
+
3793
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3794
+ let thisHeaderData = null;
3795
+ // if the additional headers was passed in as a string parse the json into an object
3796
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3797
+ try {
3798
+ // parse the additional headers object that was passed in
3799
+ thisHeaderData = JSON.parse(thisHeaderData);
3800
+ } catch (err) {
3801
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3802
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3803
+ return callback(null, errorObj);
3804
+ }
3805
+ } else if (thisHeaderData === null) {
3806
+ thisHeaderData = { xAPIKey: '' };
3807
+ }
3808
+
3809
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3810
+ // see adapter code documentation for more information on the request object's fields
3811
+ const reqObj = {
3812
+ payload: bodyVars,
3813
+ uriPathVars: pathVars,
3814
+ uriQuery: queryParams,
3815
+ addlHeaders: thisHeaderData
3816
+ };
3817
+
3818
+ try {
3819
+ // Make the call -
3820
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3821
+ return this.requestHandlerInst.identifyRequest('SeatManagementAPI', 'updateSeatUsingPUT', reqObj, false, (irReturnData, irReturnError) => {
3822
+ // if we received an error or their is no response on the results
3823
+ // return an error
3824
+ if (irReturnError) {
3825
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3826
+ return callback(null, irReturnError);
3827
+ }
3828
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3829
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateSeatUsingPUT'], null, null, null);
3830
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3831
+ return callback(null, errorObj);
3832
+ }
3833
+
3834
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3835
+ // return the response
3836
+ return callback(irReturnData, null);
3837
+ });
3838
+ } catch (ex) {
3839
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3840
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3841
+ return callback(null, errorObj);
3842
+ }
3843
+ }
3844
+
3845
+ /**
3846
+ * @function deleteSeatUsingDELETE
3847
+ * @pronghornType method
3848
+ * @name deleteSeatUsingDELETE
3849
+ * @summary This API is used to delete a seat. Deleting a seat will revoke all the certificates associated to the specified seat.
3850
+ *
3851
+ * @param {string} seatId - seatId
3852
+ * @param {getCallback} callback - a callback function to return the result
3853
+ * @return {object} results - An object containing the response of the action
3854
+ *
3855
+ * @route {POST} /deleteSeatUsingDELETE
3856
+ * @roles admin
3857
+ * @task true
3858
+ */
3859
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3860
+ deleteSeatUsingDELETE(seatId, callback) {
3861
+ const meth = 'adapter-deleteSeatUsingDELETE';
3862
+ const origin = `${this.id}-${meth}`;
3863
+ log.trace(origin);
3864
+
3865
+ if (this.suspended && this.suspendMode === 'error') {
3866
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3867
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3868
+ return callback(null, errorObj);
3869
+ }
3870
+
3871
+ /* HERE IS WHERE YOU VALIDATE DATA */
3872
+ if (seatId === undefined || seatId === null || seatId === '') {
3873
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['seatId'], null, null, null);
3874
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3875
+ return callback(null, errorObj);
3876
+ }
3877
+
3878
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3879
+ const queryParamsAvailable = {};
3880
+ const queryParams = {};
3881
+ const pathVars = [seatId];
3882
+ const bodyVars = {};
3883
+
3884
+ // loop in template. long callback arg name to avoid identifier conflicts
3885
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3886
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3887
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3888
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3889
+ }
3890
+ });
3891
+
3892
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3893
+ let thisHeaderData = null;
3894
+ // if the additional headers was passed in as a string parse the json into an object
3895
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3896
+ try {
3897
+ // parse the additional headers object that was passed in
3898
+ thisHeaderData = JSON.parse(thisHeaderData);
3899
+ } catch (err) {
3900
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3901
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3902
+ return callback(null, errorObj);
3903
+ }
3904
+ } else if (thisHeaderData === null) {
3905
+ thisHeaderData = { xAPIKey: '' };
3906
+ }
3907
+
3908
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3909
+ // see adapter code documentation for more information on the request object's fields
3910
+ const reqObj = {
3911
+ payload: bodyVars,
3912
+ uriPathVars: pathVars,
3913
+ uriQuery: queryParams,
3914
+ addlHeaders: thisHeaderData
3915
+ };
3916
+
3917
+ try {
3918
+ // Make the call -
3919
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3920
+ return this.requestHandlerInst.identifyRequest('SeatManagementAPI', 'deleteSeatUsingDELETE', reqObj, false, (irReturnData, irReturnError) => {
3921
+ // if we received an error or their is no response on the results
3922
+ // return an error
3923
+ if (irReturnError) {
3924
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3925
+ return callback(null, irReturnError);
3926
+ }
3927
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3928
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSeatUsingDELETE'], null, null, null);
3929
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3930
+ return callback(null, errorObj);
3931
+ }
3932
+
3933
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3934
+ // return the response
3935
+ return callback(irReturnData, null);
3936
+ });
3937
+ } catch (ex) {
3938
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3939
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3940
+ return callback(null, errorObj);
3941
+ }
3942
+ }
3943
+ }
3944
+
3945
+ module.exports = Digicert;