@itentialopensource/adapter-calix_support_cloud 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 (98) hide show
  1. package/.eslintignore +5 -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 +3 -0
  9. package/AUTH.md +39 -0
  10. package/BROKER.md +199 -0
  11. package/CALLS.md +170 -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 +3628 -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/DeviceDataManagement/action.json +150 -0
  33. package/entities/DeviceDataManagement/mockdatafiles/retrieveAllDevices-default.json +89 -0
  34. package/entities/DeviceDataManagement/mockdatafiles/retrieveDeviceByID-default.json +28 -0
  35. package/entities/DeviceDataManagement/mockdatafiles/retrieveDeviceByIPAddress-default.json +28 -0
  36. package/entities/DeviceDataManagement/mockdatafiles/retrieveDeviceByMACAddress-default.json +28 -0
  37. package/entities/DeviceDataManagement/mockdatafiles/retrieveDeviceBySerialNumber-default.json +28 -0
  38. package/entities/DeviceDataManagement/schema.json +25 -0
  39. package/entities/DeviceGroupManagement/action.json +189 -0
  40. package/entities/DeviceGroupManagement/mockdatafiles/addADeviceOrProvisioningRecordToAStaticGroup-default.json +1 -0
  41. package/entities/DeviceGroupManagement/mockdatafiles/removeADeviceFromAllStaticGroups-default.json +3 -0
  42. package/entities/DeviceGroupManagement/mockdatafiles/retrieveAllDeviceGroups-default.json +34 -0
  43. package/entities/DeviceGroupManagement/mockdatafiles/retrieveAllStaticGroupMemberships-default.json +11 -0
  44. package/entities/DeviceGroupManagement/mockdatafiles/retrieveDeviceGroupByID-default.json +7 -0
  45. package/entities/DeviceGroupManagement/mockdatafiles/retrieveSingleStaticGroupMembershipRecord-default.json +9 -0
  46. package/entities/DeviceGroupManagement/mockdatafiles/retrieveStaticGroupMembershipsByDevice-default.json +11 -0
  47. package/entities/DeviceGroupManagement/schema.json +27 -0
  48. package/entities/DeviceProvisioningRecordManagement/action.json +148 -0
  49. package/entities/DeviceProvisioningRecordManagement/mockdatafiles/createProvisioningRecord-default.json +1 -0
  50. package/entities/DeviceProvisioningRecordManagement/mockdatafiles/retrieveAllProvisioningRecords-default.json +77 -0
  51. package/entities/DeviceProvisioningRecordManagement/mockdatafiles/retrieveProvisioningRecordByInternalID-default.json +77 -0
  52. package/entities/DeviceProvisioningRecordManagement/mockdatafiles/retrieveProvisioningRecordsByDevice-default.json +82 -0
  53. package/entities/DeviceProvisioningRecordManagement/mockdatafiles/retrieveProvisioningRecordsBySubscriber-default.json +82 -0
  54. package/entities/DeviceProvisioningRecordManagement/schema.json +25 -0
  55. package/entities/SubscriberManagement/action.json +190 -0
  56. package/entities/SubscriberManagement/mockdatafiles/retrieveAllSubscribers-default.json +27 -0
  57. package/entities/SubscriberManagement/mockdatafiles/retrieveSubscriberByCustomIdSubscriberID-default.json +25 -0
  58. package/entities/SubscriberManagement/mockdatafiles/retrieveSubscriberByEmailAddress-default.json +27 -0
  59. package/entities/SubscriberManagement/mockdatafiles/retrieveSubscriberByInternalID-default.json +25 -0
  60. package/entities/SubscriberManagement/mockdatafiles/retrieveSubscriberByName-default.json +27 -0
  61. package/entities/SubscriberManagement/mockdatafiles/retrieveSubscribersByPhoneNumber-default.json +27 -0
  62. package/entities/SubscriberManagement/mockdatafiles/updateSubscriberOrReplaceAssociatedSystem-default.json +25 -0
  63. package/entities/SubscriberManagement/schema.json +27 -0
  64. package/entities/TR69DeviceOperations/action.json +24 -0
  65. package/entities/TR69DeviceOperations/schema.json +19 -0
  66. package/error.json +190 -0
  67. package/package.json +85 -0
  68. package/pronghorn.json +1780 -0
  69. package/propertiesDecorators.json +14 -0
  70. package/propertiesSchema.json +1248 -0
  71. package/refs?service=git-upload-pack +0 -0
  72. package/report/Calix Support Cloud - Subscriber-Device API.postman_collection.json +2696 -0
  73. package/report/creationReport.json +314 -0
  74. package/sampleProperties.json +195 -0
  75. package/test/integration/adapterTestBasicGet.js +83 -0
  76. package/test/integration/adapterTestConnectivity.js +93 -0
  77. package/test/integration/adapterTestIntegration.js +1336 -0
  78. package/test/unit/adapterBaseTestUnit.js +949 -0
  79. package/test/unit/adapterTestUnit.js +2234 -0
  80. package/utils/adapterInfo.js +206 -0
  81. package/utils/addAuth.js +94 -0
  82. package/utils/artifactize.js +146 -0
  83. package/utils/basicGet.js +50 -0
  84. package/utils/checkMigrate.js +63 -0
  85. package/utils/entitiesToDB.js +178 -0
  86. package/utils/findPath.js +74 -0
  87. package/utils/methodDocumentor.js +225 -0
  88. package/utils/modify.js +154 -0
  89. package/utils/packModificationScript.js +35 -0
  90. package/utils/patches2bundledDeps.js +90 -0
  91. package/utils/pre-commit.sh +32 -0
  92. package/utils/removeHooks.js +20 -0
  93. package/utils/setup.js +33 -0
  94. package/utils/tbScript.js +246 -0
  95. package/utils/tbUtils.js +490 -0
  96. package/utils/testRunner.js +298 -0
  97. package/utils/troubleshootingAdapter.js +195 -0
  98. package/workflows/README.md +3 -0
package/adapter.js ADDED
@@ -0,0 +1,3628 @@
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 Calix_support_cloud
17
+ */
18
+
19
+ /* GENERAL ADAPTER FUNCTIONS */
20
+ class CalixSupportCloud extends AdapterBaseCl {
21
+ /**
22
+ * CalixSupportCloud 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 retrieveAllDevices
846
+ * @pronghornType method
847
+ * @name retrieveAllDevices
848
+ * @summary Retrieve All Devices
849
+ *
850
+ * @param {getCallback} callback - a callback function to return the result
851
+ * @return {object} results - An object containing the response of the action
852
+ *
853
+ * @route {GET} /retrieveAllDevices
854
+ * @roles admin
855
+ * @task true
856
+ */
857
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
858
+ retrieveAllDevices(callback) {
859
+ const meth = 'adapter-retrieveAllDevices';
860
+ const origin = `${this.id}-${meth}`;
861
+ log.trace(origin);
862
+
863
+ if (this.suspended && this.suspendMode === 'error') {
864
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
865
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
866
+ return callback(null, errorObj);
867
+ }
868
+
869
+ /* HERE IS WHERE YOU VALIDATE DATA */
870
+
871
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
872
+ const queryParamsAvailable = {};
873
+ const queryParams = {};
874
+ const pathVars = [];
875
+ const bodyVars = {};
876
+
877
+ // loop in template. long callback arg name to avoid identifier conflicts
878
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
879
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
880
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
881
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
882
+ }
883
+ });
884
+
885
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
886
+ // see adapter code documentation for more information on the request object's fields
887
+ const reqObj = {
888
+ payload: bodyVars,
889
+ uriPathVars: pathVars,
890
+ uriQuery: queryParams
891
+ };
892
+
893
+ try {
894
+ // Make the call -
895
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
896
+ return this.requestHandlerInst.identifyRequest('DeviceDataManagement', 'retrieveAllDevices', reqObj, true, (irReturnData, irReturnError) => {
897
+ // if we received an error or their is no response on the results
898
+ // return an error
899
+ if (irReturnError) {
900
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
901
+ return callback(null, irReturnError);
902
+ }
903
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
904
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveAllDevices'], null, null, null);
905
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
906
+ return callback(null, errorObj);
907
+ }
908
+
909
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
910
+ // return the response
911
+ return callback(irReturnData, null);
912
+ });
913
+ } catch (ex) {
914
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
915
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
916
+ return callback(null, errorObj);
917
+ }
918
+ }
919
+
920
+ /**
921
+ * @function retrieveDeviceByID
922
+ * @pronghornType method
923
+ * @name retrieveDeviceByID
924
+ * @summary Retrieve Device By ID
925
+ *
926
+ * @param {string} deviceid - path parameter
927
+ * @param {getCallback} callback - a callback function to return the result
928
+ * @return {object} results - An object containing the response of the action
929
+ *
930
+ * @route {POST} /retrieveDeviceByID
931
+ * @roles admin
932
+ * @task true
933
+ */
934
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
935
+ retrieveDeviceByID(deviceid, callback) {
936
+ const meth = 'adapter-retrieveDeviceByID';
937
+ const origin = `${this.id}-${meth}`;
938
+ log.trace(origin);
939
+
940
+ if (this.suspended && this.suspendMode === 'error') {
941
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
942
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
943
+ return callback(null, errorObj);
944
+ }
945
+
946
+ /* HERE IS WHERE YOU VALIDATE DATA */
947
+ if (deviceid === undefined || deviceid === null || deviceid === '') {
948
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceid'], null, null, null);
949
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
950
+ return callback(null, errorObj);
951
+ }
952
+
953
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
954
+ const queryParamsAvailable = {};
955
+ const queryParams = {};
956
+ const pathVars = [deviceid];
957
+ const bodyVars = {};
958
+
959
+ // loop in template. long callback arg name to avoid identifier conflicts
960
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
961
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
962
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
963
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
964
+ }
965
+ });
966
+
967
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
968
+ // see adapter code documentation for more information on the request object's fields
969
+ const reqObj = {
970
+ payload: bodyVars,
971
+ uriPathVars: pathVars,
972
+ uriQuery: queryParams
973
+ };
974
+
975
+ try {
976
+ // Make the call -
977
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
978
+ return this.requestHandlerInst.identifyRequest('DeviceDataManagement', 'retrieveDeviceByID', reqObj, true, (irReturnData, irReturnError) => {
979
+ // if we received an error or their is no response on the results
980
+ // return an error
981
+ if (irReturnError) {
982
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
983
+ return callback(null, irReturnError);
984
+ }
985
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
986
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveDeviceByID'], null, null, null);
987
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
988
+ return callback(null, errorObj);
989
+ }
990
+
991
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
992
+ // return the response
993
+ return callback(irReturnData, null);
994
+ });
995
+ } catch (ex) {
996
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
997
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
998
+ return callback(null, errorObj);
999
+ }
1000
+ }
1001
+
1002
+ /**
1003
+ * @function deleteDevice
1004
+ * @pronghornType method
1005
+ * @name deleteDevice
1006
+ * @summary Delete Device
1007
+ *
1008
+ * @param {string} deviceid - path parameter
1009
+ * @param {getCallback} callback - a callback function to return the result
1010
+ * @return {object} results - An object containing the response of the action
1011
+ *
1012
+ * @route {POST} /deleteDevice
1013
+ * @roles admin
1014
+ * @task true
1015
+ */
1016
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1017
+ deleteDevice(deviceid, callback) {
1018
+ const meth = 'adapter-deleteDevice';
1019
+ const origin = `${this.id}-${meth}`;
1020
+ log.trace(origin);
1021
+
1022
+ if (this.suspended && this.suspendMode === 'error') {
1023
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1024
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1025
+ return callback(null, errorObj);
1026
+ }
1027
+
1028
+ /* HERE IS WHERE YOU VALIDATE DATA */
1029
+ if (deviceid === undefined || deviceid === null || deviceid === '') {
1030
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceid'], null, null, null);
1031
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1032
+ return callback(null, errorObj);
1033
+ }
1034
+
1035
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1036
+ const queryParamsAvailable = {};
1037
+ const queryParams = {};
1038
+ const pathVars = [deviceid];
1039
+ const bodyVars = {};
1040
+
1041
+ // loop in template. long callback arg name to avoid identifier conflicts
1042
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1043
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1044
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1045
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1046
+ }
1047
+ });
1048
+
1049
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1050
+ // see adapter code documentation for more information on the request object's fields
1051
+ const reqObj = {
1052
+ payload: bodyVars,
1053
+ uriPathVars: pathVars,
1054
+ uriQuery: queryParams
1055
+ };
1056
+
1057
+ try {
1058
+ // Make the call -
1059
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1060
+ return this.requestHandlerInst.identifyRequest('DeviceDataManagement', 'deleteDevice', reqObj, false, (irReturnData, irReturnError) => {
1061
+ // if we received an error or their is no response on the results
1062
+ // return an error
1063
+ if (irReturnError) {
1064
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1065
+ return callback(null, irReturnError);
1066
+ }
1067
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1068
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteDevice'], null, null, null);
1069
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1070
+ return callback(null, errorObj);
1071
+ }
1072
+
1073
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1074
+ // return the response
1075
+ return callback(irReturnData, null);
1076
+ });
1077
+ } catch (ex) {
1078
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1079
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1080
+ return callback(null, errorObj);
1081
+ }
1082
+ }
1083
+
1084
+ /**
1085
+ * @function retrieveDeviceBySerialNumber
1086
+ * @pronghornType method
1087
+ * @name retrieveDeviceBySerialNumber
1088
+ * @summary Retrieve Device By Serial Number
1089
+ *
1090
+ * @param {string} serialNumber - The device serial number as reported in the TR-69 INFORM. For most Calix devices, this is the FSAN Serial Number starting with CXNK, not the Manufacturing Serial Number.
1091
+ * @param {getCallback} callback - a callback function to return the result
1092
+ * @return {object} results - An object containing the response of the action
1093
+ *
1094
+ * @route {POST} /retrieveDeviceBySerialNumber
1095
+ * @roles admin
1096
+ * @task true
1097
+ */
1098
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1099
+ retrieveDeviceBySerialNumber(serialNumber, callback) {
1100
+ const meth = 'adapter-retrieveDeviceBySerialNumber';
1101
+ const origin = `${this.id}-${meth}`;
1102
+ log.trace(origin);
1103
+
1104
+ if (this.suspended && this.suspendMode === 'error') {
1105
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1106
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1107
+ return callback(null, errorObj);
1108
+ }
1109
+
1110
+ /* HERE IS WHERE YOU VALIDATE DATA */
1111
+ if (serialNumber === undefined || serialNumber === null || serialNumber === '') {
1112
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['serialNumber'], null, null, null);
1113
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1114
+ return callback(null, errorObj);
1115
+ }
1116
+
1117
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1118
+ const queryParamsAvailable = { serialNumber };
1119
+ const queryParams = {};
1120
+ const pathVars = [];
1121
+ const bodyVars = {};
1122
+
1123
+ // loop in template. long callback arg name to avoid identifier conflicts
1124
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1125
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1126
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1127
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1128
+ }
1129
+ });
1130
+
1131
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1132
+ // see adapter code documentation for more information on the request object's fields
1133
+ const reqObj = {
1134
+ payload: bodyVars,
1135
+ uriPathVars: pathVars,
1136
+ uriQuery: queryParams
1137
+ };
1138
+
1139
+ try {
1140
+ // Make the call -
1141
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1142
+ return this.requestHandlerInst.identifyRequest('DeviceDataManagement', 'retrieveDeviceBySerialNumber', reqObj, true, (irReturnData, irReturnError) => {
1143
+ // if we received an error or their is no response on the results
1144
+ // return an error
1145
+ if (irReturnError) {
1146
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1147
+ return callback(null, irReturnError);
1148
+ }
1149
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1150
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveDeviceBySerialNumber'], null, null, null);
1151
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1152
+ return callback(null, errorObj);
1153
+ }
1154
+
1155
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1156
+ // return the response
1157
+ return callback(irReturnData, null);
1158
+ });
1159
+ } catch (ex) {
1160
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1161
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1162
+ return callback(null, errorObj);
1163
+ }
1164
+ }
1165
+
1166
+ /**
1167
+ * @function retrieveDeviceByMACAddress
1168
+ * @pronghornType method
1169
+ * @name retrieveDeviceByMACAddress
1170
+ * @summary Retrieve Device By MAC Address
1171
+ *
1172
+ * @param {string} macAddress - The hardware MAC address as reported in the TR-69 INFORM, in the format 00:11:22:33:44:55
1173
+ * @param {getCallback} callback - a callback function to return the result
1174
+ * @return {object} results - An object containing the response of the action
1175
+ *
1176
+ * @route {POST} /retrieveDeviceByMACAddress
1177
+ * @roles admin
1178
+ * @task true
1179
+ */
1180
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1181
+ retrieveDeviceByMACAddress(macAddress, callback) {
1182
+ const meth = 'adapter-retrieveDeviceByMACAddress';
1183
+ const origin = `${this.id}-${meth}`;
1184
+ log.trace(origin);
1185
+
1186
+ if (this.suspended && this.suspendMode === 'error') {
1187
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1188
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1189
+ return callback(null, errorObj);
1190
+ }
1191
+
1192
+ /* HERE IS WHERE YOU VALIDATE DATA */
1193
+ if (macAddress === undefined || macAddress === null || macAddress === '') {
1194
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['macAddress'], null, null, null);
1195
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1196
+ return callback(null, errorObj);
1197
+ }
1198
+
1199
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1200
+ const queryParamsAvailable = { macAddress };
1201
+ const queryParams = {};
1202
+ const pathVars = [];
1203
+ const bodyVars = {};
1204
+
1205
+ // loop in template. long callback arg name to avoid identifier conflicts
1206
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1207
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1208
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1209
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1210
+ }
1211
+ });
1212
+
1213
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1214
+ // see adapter code documentation for more information on the request object's fields
1215
+ const reqObj = {
1216
+ payload: bodyVars,
1217
+ uriPathVars: pathVars,
1218
+ uriQuery: queryParams
1219
+ };
1220
+
1221
+ try {
1222
+ // Make the call -
1223
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1224
+ return this.requestHandlerInst.identifyRequest('DeviceDataManagement', 'retrieveDeviceByMACAddress', reqObj, true, (irReturnData, irReturnError) => {
1225
+ // if we received an error or their is no response on the results
1226
+ // return an error
1227
+ if (irReturnError) {
1228
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1229
+ return callback(null, irReturnError);
1230
+ }
1231
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1232
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveDeviceByMACAddress'], null, null, null);
1233
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1234
+ return callback(null, errorObj);
1235
+ }
1236
+
1237
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1238
+ // return the response
1239
+ return callback(irReturnData, null);
1240
+ });
1241
+ } catch (ex) {
1242
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1243
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1244
+ return callback(null, errorObj);
1245
+ }
1246
+ }
1247
+
1248
+ /**
1249
+ * @function retrieveDeviceByRegistrationID
1250
+ * @pronghornType method
1251
+ * @name retrieveDeviceByRegistrationID
1252
+ * @summary Retrieve Device By Registration ID
1253
+ *
1254
+ * @param {string} registrationId - The Calix ONT Registration ID (aka RONTA) as programmed locally on the device
1255
+ * @param {getCallback} callback - a callback function to return the result
1256
+ * @return {object} results - An object containing the response of the action
1257
+ *
1258
+ * @route {POST} /retrieveDeviceByRegistrationID
1259
+ * @roles admin
1260
+ * @task true
1261
+ */
1262
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1263
+ retrieveDeviceByRegistrationID(registrationId, callback) {
1264
+ const meth = 'adapter-retrieveDeviceByRegistrationID';
1265
+ const origin = `${this.id}-${meth}`;
1266
+ log.trace(origin);
1267
+
1268
+ if (this.suspended && this.suspendMode === 'error') {
1269
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1270
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1271
+ return callback(null, errorObj);
1272
+ }
1273
+
1274
+ /* HERE IS WHERE YOU VALIDATE DATA */
1275
+ if (registrationId === undefined || registrationId === null || registrationId === '') {
1276
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['registrationId'], null, null, null);
1277
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1278
+ return callback(null, errorObj);
1279
+ }
1280
+
1281
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1282
+ const queryParamsAvailable = { registrationId };
1283
+ const queryParams = {};
1284
+ const pathVars = [];
1285
+ const bodyVars = {};
1286
+
1287
+ // loop in template. long callback arg name to avoid identifier conflicts
1288
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1289
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1290
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1291
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1292
+ }
1293
+ });
1294
+
1295
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1296
+ // see adapter code documentation for more information on the request object's fields
1297
+ const reqObj = {
1298
+ payload: bodyVars,
1299
+ uriPathVars: pathVars,
1300
+ uriQuery: queryParams
1301
+ };
1302
+
1303
+ try {
1304
+ // Make the call -
1305
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1306
+ return this.requestHandlerInst.identifyRequest('DeviceDataManagement', 'retrieveDeviceByRegistrationID', reqObj, true, (irReturnData, irReturnError) => {
1307
+ // if we received an error or their is no response on the results
1308
+ // return an error
1309
+ if (irReturnError) {
1310
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1311
+ return callback(null, irReturnError);
1312
+ }
1313
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1314
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveDeviceByRegistrationID'], null, null, null);
1315
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1316
+ return callback(null, errorObj);
1317
+ }
1318
+
1319
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1320
+ // return the response
1321
+ return callback(irReturnData, null);
1322
+ });
1323
+ } catch (ex) {
1324
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1325
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1326
+ return callback(null, errorObj);
1327
+ }
1328
+ }
1329
+
1330
+ /**
1331
+ * @function retrieveDeviceByIPAddress
1332
+ * @pronghornType method
1333
+ * @name retrieveDeviceByIPAddress
1334
+ * @summary Retrieve Device By IP Address
1335
+ *
1336
+ * @param {string} ipAddress - The WAN IP address as reported by TR-69 INFORM
1337
+ * @param {getCallback} callback - a callback function to return the result
1338
+ * @return {object} results - An object containing the response of the action
1339
+ *
1340
+ * @route {POST} /retrieveDeviceByIPAddress
1341
+ * @roles admin
1342
+ * @task true
1343
+ */
1344
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1345
+ retrieveDeviceByIPAddress(ipAddress, callback) {
1346
+ const meth = 'adapter-retrieveDeviceByIPAddress';
1347
+ const origin = `${this.id}-${meth}`;
1348
+ log.trace(origin);
1349
+
1350
+ if (this.suspended && this.suspendMode === 'error') {
1351
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1352
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1353
+ return callback(null, errorObj);
1354
+ }
1355
+
1356
+ /* HERE IS WHERE YOU VALIDATE DATA */
1357
+ if (ipAddress === undefined || ipAddress === null || ipAddress === '') {
1358
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['ipAddress'], null, null, null);
1359
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1360
+ return callback(null, errorObj);
1361
+ }
1362
+
1363
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1364
+ const queryParamsAvailable = { ipAddress };
1365
+ const queryParams = {};
1366
+ const pathVars = [];
1367
+ const bodyVars = {};
1368
+
1369
+ // loop in template. long callback arg name to avoid identifier conflicts
1370
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1371
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1372
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1373
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1374
+ }
1375
+ });
1376
+
1377
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1378
+ // see adapter code documentation for more information on the request object's fields
1379
+ const reqObj = {
1380
+ payload: bodyVars,
1381
+ uriPathVars: pathVars,
1382
+ uriQuery: queryParams
1383
+ };
1384
+
1385
+ try {
1386
+ // Make the call -
1387
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1388
+ return this.requestHandlerInst.identifyRequest('DeviceDataManagement', 'retrieveDeviceByIPAddress', reqObj, true, (irReturnData, irReturnError) => {
1389
+ // if we received an error or their is no response on the results
1390
+ // return an error
1391
+ if (irReturnError) {
1392
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1393
+ return callback(null, irReturnError);
1394
+ }
1395
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1396
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveDeviceByIPAddress'], null, null, null);
1397
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1398
+ return callback(null, errorObj);
1399
+ }
1400
+
1401
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1402
+ // return the response
1403
+ return callback(irReturnData, null);
1404
+ });
1405
+ } catch (ex) {
1406
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1407
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1408
+ return callback(null, errorObj);
1409
+ }
1410
+ }
1411
+
1412
+ /**
1413
+ * @function createSubscriber
1414
+ * @pronghornType method
1415
+ * @name createSubscriber
1416
+ * @summary Create Subscriber
1417
+ *
1418
+ * @param {object} body - POST body parameter
1419
+ * @param {getCallback} callback - a callback function to return the result
1420
+ * @return {object} results - An object containing the response of the action
1421
+ *
1422
+ * @route {POST} /createSubscriber
1423
+ * @roles admin
1424
+ * @task true
1425
+ */
1426
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1427
+ createSubscriber(body, callback) {
1428
+ const meth = 'adapter-createSubscriber';
1429
+ const origin = `${this.id}-${meth}`;
1430
+ log.trace(origin);
1431
+
1432
+ if (this.suspended && this.suspendMode === 'error') {
1433
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1434
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1435
+ return callback(null, errorObj);
1436
+ }
1437
+
1438
+ /* HERE IS WHERE YOU VALIDATE DATA */
1439
+ if (body === undefined || body === null || body === '') {
1440
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1441
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1442
+ return callback(null, errorObj);
1443
+ }
1444
+
1445
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1446
+ const queryParamsAvailable = {};
1447
+ const queryParams = {};
1448
+ const pathVars = [];
1449
+ const bodyVars = body;
1450
+
1451
+ // loop in template. long callback arg name to avoid identifier conflicts
1452
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1453
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1454
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1455
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1456
+ }
1457
+ });
1458
+
1459
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1460
+ let thisHeaderData = null;
1461
+ // if the additional headers was passed in as a string parse the json into an object
1462
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1463
+ try {
1464
+ // parse the additional headers object that was passed in
1465
+ thisHeaderData = JSON.parse(thisHeaderData);
1466
+ } catch (err) {
1467
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1468
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1469
+ return callback(null, errorObj);
1470
+ }
1471
+ } else if (thisHeaderData === null) {
1472
+ thisHeaderData = { contentType: '' };
1473
+ }
1474
+
1475
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1476
+ // see adapter code documentation for more information on the request object's fields
1477
+ const reqObj = {
1478
+ payload: bodyVars,
1479
+ uriPathVars: pathVars,
1480
+ uriQuery: queryParams,
1481
+ addlHeaders: thisHeaderData
1482
+ };
1483
+
1484
+ try {
1485
+ // Make the call -
1486
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1487
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'createSubscriber', reqObj, true, (irReturnData, irReturnError) => {
1488
+ // if we received an error or their is no response on the results
1489
+ // return an error
1490
+ if (irReturnError) {
1491
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1492
+ return callback(null, irReturnError);
1493
+ }
1494
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1495
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createSubscriber'], null, null, null);
1496
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1497
+ return callback(null, errorObj);
1498
+ }
1499
+
1500
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1501
+ // return the response
1502
+ return callback(irReturnData, null);
1503
+ });
1504
+ } catch (ex) {
1505
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1506
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1507
+ return callback(null, errorObj);
1508
+ }
1509
+ }
1510
+
1511
+ /**
1512
+ * @function retrieveAllSubscribers
1513
+ * @pronghornType method
1514
+ * @name retrieveAllSubscribers
1515
+ * @summary Retrieve All Subscribers
1516
+ *
1517
+ * @param {getCallback} callback - a callback function to return the result
1518
+ * @return {object} results - An object containing the response of the action
1519
+ *
1520
+ * @route {GET} /retrieveAllSubscribers
1521
+ * @roles admin
1522
+ * @task true
1523
+ */
1524
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1525
+ retrieveAllSubscribers(callback) {
1526
+ const meth = 'adapter-retrieveAllSubscribers';
1527
+ const origin = `${this.id}-${meth}`;
1528
+ log.trace(origin);
1529
+
1530
+ if (this.suspended && this.suspendMode === 'error') {
1531
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1532
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1533
+ return callback(null, errorObj);
1534
+ }
1535
+
1536
+ /* HERE IS WHERE YOU VALIDATE DATA */
1537
+
1538
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1539
+ const queryParamsAvailable = {};
1540
+ const queryParams = {};
1541
+ const pathVars = [];
1542
+ const bodyVars = {};
1543
+
1544
+ // loop in template. long callback arg name to avoid identifier conflicts
1545
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1546
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1547
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1548
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1549
+ }
1550
+ });
1551
+
1552
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1553
+ // see adapter code documentation for more information on the request object's fields
1554
+ const reqObj = {
1555
+ payload: bodyVars,
1556
+ uriPathVars: pathVars,
1557
+ uriQuery: queryParams
1558
+ };
1559
+
1560
+ try {
1561
+ // Make the call -
1562
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1563
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'retrieveAllSubscribers', reqObj, true, (irReturnData, irReturnError) => {
1564
+ // if we received an error or their is no response on the results
1565
+ // return an error
1566
+ if (irReturnError) {
1567
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1568
+ return callback(null, irReturnError);
1569
+ }
1570
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1571
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveAllSubscribers'], null, null, null);
1572
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1573
+ return callback(null, errorObj);
1574
+ }
1575
+
1576
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1577
+ // return the response
1578
+ return callback(irReturnData, null);
1579
+ });
1580
+ } catch (ex) {
1581
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1582
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1583
+ return callback(null, errorObj);
1584
+ }
1585
+ }
1586
+
1587
+ /**
1588
+ * @function retrieveSubscriberByInternalID
1589
+ * @pronghornType method
1590
+ * @name retrieveSubscriberByInternalID
1591
+ * @summary Retrieve Subscriber by Internal ID
1592
+ *
1593
+ * @param {string} id - path parameter
1594
+ * @param {getCallback} callback - a callback function to return the result
1595
+ * @return {object} results - An object containing the response of the action
1596
+ *
1597
+ * @route {POST} /retrieveSubscriberByInternalID
1598
+ * @roles admin
1599
+ * @task true
1600
+ */
1601
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1602
+ retrieveSubscriberByInternalID(id, callback) {
1603
+ const meth = 'adapter-retrieveSubscriberByInternalID';
1604
+ const origin = `${this.id}-${meth}`;
1605
+ log.trace(origin);
1606
+
1607
+ if (this.suspended && this.suspendMode === 'error') {
1608
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1609
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1610
+ return callback(null, errorObj);
1611
+ }
1612
+
1613
+ /* HERE IS WHERE YOU VALIDATE DATA */
1614
+ if (id === undefined || id === null || id === '') {
1615
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['Id'], null, null, null);
1616
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1617
+ return callback(null, errorObj);
1618
+ }
1619
+
1620
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1621
+ const queryParamsAvailable = {};
1622
+ const queryParams = {};
1623
+ const pathVars = [id];
1624
+ const bodyVars = {};
1625
+
1626
+ // loop in template. long callback arg name to avoid identifier conflicts
1627
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1628
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1629
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1630
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1631
+ }
1632
+ });
1633
+
1634
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1635
+ // see adapter code documentation for more information on the request object's fields
1636
+ const reqObj = {
1637
+ payload: bodyVars,
1638
+ uriPathVars: pathVars,
1639
+ uriQuery: queryParams
1640
+ };
1641
+
1642
+ try {
1643
+ // Make the call -
1644
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1645
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'retrieveSubscriberByInternalID', reqObj, true, (irReturnData, irReturnError) => {
1646
+ // if we received an error or their is no response on the results
1647
+ // return an error
1648
+ if (irReturnError) {
1649
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1650
+ return callback(null, irReturnError);
1651
+ }
1652
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1653
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveSubscriberByInternalID'], null, null, null);
1654
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1655
+ return callback(null, errorObj);
1656
+ }
1657
+
1658
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1659
+ // return the response
1660
+ return callback(irReturnData, null);
1661
+ });
1662
+ } catch (ex) {
1663
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1664
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1665
+ return callback(null, errorObj);
1666
+ }
1667
+ }
1668
+
1669
+ /**
1670
+ * @function deleteSubscriber
1671
+ * @pronghornType method
1672
+ * @name deleteSubscriber
1673
+ * @summary Delete Subscriber
1674
+ *
1675
+ * @param {string} id - path parameter
1676
+ * @param {getCallback} callback - a callback function to return the result
1677
+ * @return {object} results - An object containing the response of the action
1678
+ *
1679
+ * @route {POST} /deleteSubscriber
1680
+ * @roles admin
1681
+ * @task true
1682
+ */
1683
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1684
+ deleteSubscriber(id, callback) {
1685
+ const meth = 'adapter-deleteSubscriber';
1686
+ const origin = `${this.id}-${meth}`;
1687
+ log.trace(origin);
1688
+
1689
+ if (this.suspended && this.suspendMode === 'error') {
1690
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1691
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1692
+ return callback(null, errorObj);
1693
+ }
1694
+
1695
+ /* HERE IS WHERE YOU VALIDATE DATA */
1696
+ if (id === undefined || id === null || id === '') {
1697
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['Id'], null, null, null);
1698
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1699
+ return callback(null, errorObj);
1700
+ }
1701
+
1702
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1703
+ const queryParamsAvailable = {};
1704
+ const queryParams = {};
1705
+ const pathVars = [id];
1706
+ const bodyVars = {};
1707
+
1708
+ // loop in template. long callback arg name to avoid identifier conflicts
1709
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1710
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1711
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1712
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1713
+ }
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
+ };
1723
+
1724
+ try {
1725
+ // Make the call -
1726
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1727
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'deleteSubscriber', reqObj, false, (irReturnData, irReturnError) => {
1728
+ // if we received an error or their is no response on the results
1729
+ // return an error
1730
+ if (irReturnError) {
1731
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1732
+ return callback(null, irReturnError);
1733
+ }
1734
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1735
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSubscriber'], null, null, null);
1736
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1737
+ return callback(null, errorObj);
1738
+ }
1739
+
1740
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1741
+ // return the response
1742
+ return callback(irReturnData, null);
1743
+ });
1744
+ } catch (ex) {
1745
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1746
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1747
+ return callback(null, errorObj);
1748
+ }
1749
+ }
1750
+
1751
+ /**
1752
+ * @function retrieveSubscriberByCustomIdSubscriberID
1753
+ * @pronghornType method
1754
+ * @name retrieveSubscriberByCustomIdSubscriberID
1755
+ * @summary Retrieve Subscriber by customId/SubscriberID
1756
+ *
1757
+ * @param {string} customId - customId param
1758
+ * @param {getCallback} callback - a callback function to return the result
1759
+ * @return {object} results - An object containing the response of the action
1760
+ *
1761
+ * @route {POST} /retrieveSubscriberByCustomIdSubscriberID
1762
+ * @roles admin
1763
+ * @task true
1764
+ */
1765
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1766
+ retrieveSubscriberByCustomIdSubscriberID(customId, callback) {
1767
+ const meth = 'adapter-retrieveSubscriberByCustomIdSubscriberID';
1768
+ const origin = `${this.id}-${meth}`;
1769
+ log.trace(origin);
1770
+
1771
+ if (this.suspended && this.suspendMode === 'error') {
1772
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1773
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1774
+ return callback(null, errorObj);
1775
+ }
1776
+
1777
+ /* HERE IS WHERE YOU VALIDATE DATA */
1778
+ if (customId === undefined || customId === null || customId === '') {
1779
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customId'], null, null, null);
1780
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1781
+ return callback(null, errorObj);
1782
+ }
1783
+
1784
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1785
+ const queryParamsAvailable = { customId };
1786
+ const queryParams = {};
1787
+ const pathVars = [];
1788
+ const bodyVars = {};
1789
+
1790
+ // loop in template. long callback arg name to avoid identifier conflicts
1791
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1792
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1793
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1794
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1795
+ }
1796
+ });
1797
+
1798
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1799
+ // see adapter code documentation for more information on the request object's fields
1800
+ const reqObj = {
1801
+ payload: bodyVars,
1802
+ uriPathVars: pathVars,
1803
+ uriQuery: queryParams
1804
+ };
1805
+
1806
+ try {
1807
+ // Make the call -
1808
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1809
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'retrieveSubscriberByCustomIdSubscriberID', reqObj, true, (irReturnData, irReturnError) => {
1810
+ // if we received an error or their is no response on the results
1811
+ // return an error
1812
+ if (irReturnError) {
1813
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1814
+ return callback(null, irReturnError);
1815
+ }
1816
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1817
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveSubscriberByCustomIdSubscriberID'], null, null, null);
1818
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1819
+ return callback(null, errorObj);
1820
+ }
1821
+
1822
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1823
+ // return the response
1824
+ return callback(irReturnData, null);
1825
+ });
1826
+ } catch (ex) {
1827
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1828
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1829
+ return callback(null, errorObj);
1830
+ }
1831
+ }
1832
+
1833
+ /**
1834
+ * @function retrieveSubscriberByName
1835
+ * @pronghornType method
1836
+ * @name retrieveSubscriberByName
1837
+ * @summary Retrieve Subscriber by Name
1838
+ *
1839
+ * @param {string} name - name param
1840
+ * @param {getCallback} callback - a callback function to return the result
1841
+ * @return {object} results - An object containing the response of the action
1842
+ *
1843
+ * @route {POST} /retrieveSubscriberByName
1844
+ * @roles admin
1845
+ * @task true
1846
+ */
1847
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1848
+ retrieveSubscriberByName(name, callback) {
1849
+ const meth = 'adapter-retrieveSubscriberByName';
1850
+ const origin = `${this.id}-${meth}`;
1851
+ log.trace(origin);
1852
+
1853
+ if (this.suspended && this.suspendMode === 'error') {
1854
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1855
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1856
+ return callback(null, errorObj);
1857
+ }
1858
+
1859
+ /* HERE IS WHERE YOU VALIDATE DATA */
1860
+ if (name === undefined || name === null || name === '') {
1861
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1862
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1863
+ return callback(null, errorObj);
1864
+ }
1865
+
1866
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1867
+ const queryParamsAvailable = { name };
1868
+ const queryParams = {};
1869
+ const pathVars = [];
1870
+ const bodyVars = {};
1871
+
1872
+ // loop in template. long callback arg name to avoid identifier conflicts
1873
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1874
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1875
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1876
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1877
+ }
1878
+ });
1879
+
1880
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1881
+ // see adapter code documentation for more information on the request object's fields
1882
+ const reqObj = {
1883
+ payload: bodyVars,
1884
+ uriPathVars: pathVars,
1885
+ uriQuery: queryParams
1886
+ };
1887
+
1888
+ try {
1889
+ // Make the call -
1890
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1891
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'retrieveSubscriberByName', reqObj, true, (irReturnData, irReturnError) => {
1892
+ // if we received an error or their is no response on the results
1893
+ // return an error
1894
+ if (irReturnError) {
1895
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1896
+ return callback(null, irReturnError);
1897
+ }
1898
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1899
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveSubscriberByName'], null, null, null);
1900
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1901
+ return callback(null, errorObj);
1902
+ }
1903
+
1904
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1905
+ // return the response
1906
+ return callback(irReturnData, null);
1907
+ });
1908
+ } catch (ex) {
1909
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1910
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1911
+ return callback(null, errorObj);
1912
+ }
1913
+ }
1914
+
1915
+ /**
1916
+ * @function retrieveSubscribersByPhoneNumber
1917
+ * @pronghornType method
1918
+ * @name retrieveSubscribersByPhoneNumber
1919
+ * @summary Retrieve Subscribers by Phone Number
1920
+ *
1921
+ * @param {string} phone - phone param
1922
+ * @param {getCallback} callback - a callback function to return the result
1923
+ * @return {object} results - An object containing the response of the action
1924
+ *
1925
+ * @route {POST} /retrieveSubscribersByPhoneNumber
1926
+ * @roles admin
1927
+ * @task true
1928
+ */
1929
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1930
+ retrieveSubscribersByPhoneNumber(phone, callback) {
1931
+ const meth = 'adapter-retrieveSubscribersByPhoneNumber';
1932
+ const origin = `${this.id}-${meth}`;
1933
+ log.trace(origin);
1934
+
1935
+ if (this.suspended && this.suspendMode === 'error') {
1936
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1937
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1938
+ return callback(null, errorObj);
1939
+ }
1940
+
1941
+ /* HERE IS WHERE YOU VALIDATE DATA */
1942
+ if (phone === undefined || phone === null || phone === '') {
1943
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['phone'], null, null, null);
1944
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1945
+ return callback(null, errorObj);
1946
+ }
1947
+
1948
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1949
+ const queryParamsAvailable = { phone };
1950
+ const queryParams = {};
1951
+ const pathVars = [];
1952
+ const bodyVars = {};
1953
+
1954
+ // loop in template. long callback arg name to avoid identifier conflicts
1955
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1956
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1957
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1958
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1959
+ }
1960
+ });
1961
+
1962
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1963
+ // see adapter code documentation for more information on the request object's fields
1964
+ const reqObj = {
1965
+ payload: bodyVars,
1966
+ uriPathVars: pathVars,
1967
+ uriQuery: queryParams
1968
+ };
1969
+
1970
+ try {
1971
+ // Make the call -
1972
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1973
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'retrieveSubscribersByPhoneNumber', reqObj, true, (irReturnData, irReturnError) => {
1974
+ // if we received an error or their is no response on the results
1975
+ // return an error
1976
+ if (irReturnError) {
1977
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1978
+ return callback(null, irReturnError);
1979
+ }
1980
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1981
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveSubscribersByPhoneNumber'], null, null, null);
1982
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1983
+ return callback(null, errorObj);
1984
+ }
1985
+
1986
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1987
+ // return the response
1988
+ return callback(irReturnData, null);
1989
+ });
1990
+ } catch (ex) {
1991
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1992
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1993
+ return callback(null, errorObj);
1994
+ }
1995
+ }
1996
+
1997
+ /**
1998
+ * @function retrieveSubscriberByEmailAddress
1999
+ * @pronghornType method
2000
+ * @name retrieveSubscriberByEmailAddress
2001
+ * @summary Retrieve Subscriber by Email Address
2002
+ *
2003
+ * @param {string} email - email param
2004
+ * @param {getCallback} callback - a callback function to return the result
2005
+ * @return {object} results - An object containing the response of the action
2006
+ *
2007
+ * @route {POST} /retrieveSubscriberByEmailAddress
2008
+ * @roles admin
2009
+ * @task true
2010
+ */
2011
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2012
+ retrieveSubscriberByEmailAddress(email, callback) {
2013
+ const meth = 'adapter-retrieveSubscriberByEmailAddress';
2014
+ const origin = `${this.id}-${meth}`;
2015
+ log.trace(origin);
2016
+
2017
+ if (this.suspended && this.suspendMode === 'error') {
2018
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2019
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2020
+ return callback(null, errorObj);
2021
+ }
2022
+
2023
+ /* HERE IS WHERE YOU VALIDATE DATA */
2024
+ if (email === undefined || email === null || email === '') {
2025
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['email'], null, null, null);
2026
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2027
+ return callback(null, errorObj);
2028
+ }
2029
+
2030
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2031
+ const queryParamsAvailable = { email };
2032
+ const queryParams = {};
2033
+ const pathVars = [];
2034
+ const bodyVars = {};
2035
+
2036
+ // loop in template. long callback arg name to avoid identifier conflicts
2037
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2038
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2039
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2040
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2041
+ }
2042
+ });
2043
+
2044
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2045
+ // see adapter code documentation for more information on the request object's fields
2046
+ const reqObj = {
2047
+ payload: bodyVars,
2048
+ uriPathVars: pathVars,
2049
+ uriQuery: queryParams
2050
+ };
2051
+
2052
+ try {
2053
+ // Make the call -
2054
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2055
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'retrieveSubscriberByEmailAddress', reqObj, true, (irReturnData, irReturnError) => {
2056
+ // if we received an error or their is no response on the results
2057
+ // return an error
2058
+ if (irReturnError) {
2059
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2060
+ return callback(null, irReturnError);
2061
+ }
2062
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2063
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveSubscriberByEmailAddress'], null, null, null);
2064
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2065
+ return callback(null, errorObj);
2066
+ }
2067
+
2068
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2069
+ // return the response
2070
+ return callback(irReturnData, null);
2071
+ });
2072
+ } catch (ex) {
2073
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2074
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2075
+ return callback(null, errorObj);
2076
+ }
2077
+ }
2078
+
2079
+ /**
2080
+ * @function updateSubscriberOrReplaceAssociatedSystem
2081
+ * @pronghornType method
2082
+ * @name updateSubscriberOrReplaceAssociatedSystem
2083
+ * @summary Update Subscriber or replace associated system
2084
+ *
2085
+ * @param {object} body - PUT body parameter
2086
+ * @param {string} customId - customId param
2087
+ * @param {getCallback} callback - a callback function to return the result
2088
+ * @return {object} results - An object containing the response of the action
2089
+ *
2090
+ * @route {POST} /updateSubscriberOrReplaceAssociatedSystem
2091
+ * @roles admin
2092
+ * @task true
2093
+ */
2094
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2095
+ updateSubscriberOrReplaceAssociatedSystem(body, customId, callback) {
2096
+ const meth = 'adapter-updateSubscriberOrReplaceAssociatedSystem';
2097
+ const origin = `${this.id}-${meth}`;
2098
+ log.trace(origin);
2099
+
2100
+ if (this.suspended && this.suspendMode === 'error') {
2101
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2102
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2103
+ return callback(null, errorObj);
2104
+ }
2105
+
2106
+ /* HERE IS WHERE YOU VALIDATE DATA */
2107
+ if (body === undefined || body === null || body === '') {
2108
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2109
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2110
+ return callback(null, errorObj);
2111
+ }
2112
+ if (customId === undefined || customId === null || customId === '') {
2113
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customId'], null, null, null);
2114
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2115
+ return callback(null, errorObj);
2116
+ }
2117
+
2118
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2119
+ const queryParamsAvailable = { customId };
2120
+ const queryParams = {};
2121
+ const pathVars = [];
2122
+ const bodyVars = body;
2123
+
2124
+ // loop in template. long callback arg name to avoid identifier conflicts
2125
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2126
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2127
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2128
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2129
+ }
2130
+ });
2131
+
2132
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2133
+ // see adapter code documentation for more information on the request object's fields
2134
+ const reqObj = {
2135
+ payload: bodyVars,
2136
+ uriPathVars: pathVars,
2137
+ uriQuery: queryParams
2138
+ };
2139
+
2140
+ try {
2141
+ // Make the call -
2142
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2143
+ return this.requestHandlerInst.identifyRequest('SubscriberManagement', 'updateSubscriberOrReplaceAssociatedSystem', reqObj, false, (irReturnData, irReturnError) => {
2144
+ // if we received an error or their is no response on the results
2145
+ // return an error
2146
+ if (irReturnError) {
2147
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2148
+ return callback(null, irReturnError);
2149
+ }
2150
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2151
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateSubscriberOrReplaceAssociatedSystem'], null, null, null);
2152
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2153
+ return callback(null, errorObj);
2154
+ }
2155
+
2156
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2157
+ // return the response
2158
+ return callback(irReturnData, null);
2159
+ });
2160
+ } catch (ex) {
2161
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2162
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2163
+ return callback(null, errorObj);
2164
+ }
2165
+ }
2166
+
2167
+ /**
2168
+ * @function createProvisioningRecord
2169
+ * @pronghornType method
2170
+ * @name createProvisioningRecord
2171
+ * @summary Create Provisioning Record
2172
+ *
2173
+ * @param {object} body - POST body parameter
2174
+ * @param {getCallback} callback - a callback function to return the result
2175
+ * @return {object} results - An object containing the response of the action
2176
+ *
2177
+ * @route {POST} /createProvisioningRecord
2178
+ * @roles admin
2179
+ * @task true
2180
+ */
2181
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2182
+ createProvisioningRecord(body, callback) {
2183
+ const meth = 'adapter-createProvisioningRecord';
2184
+ const origin = `${this.id}-${meth}`;
2185
+ log.trace(origin);
2186
+
2187
+ if (this.suspended && this.suspendMode === 'error') {
2188
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2189
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2190
+ return callback(null, errorObj);
2191
+ }
2192
+
2193
+ /* HERE IS WHERE YOU VALIDATE DATA */
2194
+ if (body === undefined || body === null || body === '') {
2195
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2196
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2197
+ return callback(null, errorObj);
2198
+ }
2199
+
2200
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2201
+ const queryParamsAvailable = {};
2202
+ const queryParams = {};
2203
+ const pathVars = [];
2204
+ const bodyVars = body;
2205
+
2206
+ // loop in template. long callback arg name to avoid identifier conflicts
2207
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2208
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2209
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2210
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2211
+ }
2212
+ });
2213
+
2214
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2215
+ let thisHeaderData = null;
2216
+ // if the additional headers was passed in as a string parse the json into an object
2217
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2218
+ try {
2219
+ // parse the additional headers object that was passed in
2220
+ thisHeaderData = JSON.parse(thisHeaderData);
2221
+ } catch (err) {
2222
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2223
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2224
+ return callback(null, errorObj);
2225
+ }
2226
+ } else if (thisHeaderData === null) {
2227
+ thisHeaderData = { contentType: '' };
2228
+ }
2229
+
2230
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2231
+ // see adapter code documentation for more information on the request object's fields
2232
+ const reqObj = {
2233
+ payload: bodyVars,
2234
+ uriPathVars: pathVars,
2235
+ uriQuery: queryParams,
2236
+ addlHeaders: thisHeaderData
2237
+ };
2238
+
2239
+ try {
2240
+ // Make the call -
2241
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2242
+ return this.requestHandlerInst.identifyRequest('DeviceProvisioningRecordManagement', 'createProvisioningRecord', reqObj, true, (irReturnData, irReturnError) => {
2243
+ // if we received an error or their is no response on the results
2244
+ // return an error
2245
+ if (irReturnError) {
2246
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2247
+ return callback(null, irReturnError);
2248
+ }
2249
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2250
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createProvisioningRecord'], null, null, null);
2251
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2252
+ return callback(null, errorObj);
2253
+ }
2254
+
2255
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2256
+ // return the response
2257
+ return callback(irReturnData, null);
2258
+ });
2259
+ } catch (ex) {
2260
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2261
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2262
+ return callback(null, errorObj);
2263
+ }
2264
+ }
2265
+
2266
+ /**
2267
+ * @function retrieveAllProvisioningRecords
2268
+ * @pronghornType method
2269
+ * @name retrieveAllProvisioningRecords
2270
+ * @summary Retrieve All Provisioning Records
2271
+ *
2272
+ * @param {getCallback} callback - a callback function to return the result
2273
+ * @return {object} results - An object containing the response of the action
2274
+ *
2275
+ * @route {GET} /retrieveAllProvisioningRecords
2276
+ * @roles admin
2277
+ * @task true
2278
+ */
2279
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2280
+ retrieveAllProvisioningRecords(callback) {
2281
+ const meth = 'adapter-retrieveAllProvisioningRecords';
2282
+ const origin = `${this.id}-${meth}`;
2283
+ log.trace(origin);
2284
+
2285
+ if (this.suspended && this.suspendMode === 'error') {
2286
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2287
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2288
+ return callback(null, errorObj);
2289
+ }
2290
+
2291
+ /* HERE IS WHERE YOU VALIDATE DATA */
2292
+
2293
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2294
+ const queryParamsAvailable = {};
2295
+ const queryParams = {};
2296
+ const pathVars = [];
2297
+ const bodyVars = {};
2298
+
2299
+ // loop in template. long callback arg name to avoid identifier conflicts
2300
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2301
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2302
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2303
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2304
+ }
2305
+ });
2306
+
2307
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2308
+ // see adapter code documentation for more information on the request object's fields
2309
+ const reqObj = {
2310
+ payload: bodyVars,
2311
+ uriPathVars: pathVars,
2312
+ uriQuery: queryParams
2313
+ };
2314
+
2315
+ try {
2316
+ // Make the call -
2317
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2318
+ return this.requestHandlerInst.identifyRequest('DeviceProvisioningRecordManagement', 'retrieveAllProvisioningRecords', reqObj, true, (irReturnData, irReturnError) => {
2319
+ // if we received an error or their is no response on the results
2320
+ // return an error
2321
+ if (irReturnError) {
2322
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2323
+ return callback(null, irReturnError);
2324
+ }
2325
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2326
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveAllProvisioningRecords'], null, null, null);
2327
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2328
+ return callback(null, errorObj);
2329
+ }
2330
+
2331
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2332
+ // return the response
2333
+ return callback(irReturnData, null);
2334
+ });
2335
+ } catch (ex) {
2336
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2337
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2338
+ return callback(null, errorObj);
2339
+ }
2340
+ }
2341
+
2342
+ /**
2343
+ * @function retrieveProvisioningRecordByInternalID
2344
+ * @pronghornType method
2345
+ * @name retrieveProvisioningRecordByInternalID
2346
+ * @summary Retrieve Provisioning Record by Internal ID
2347
+ *
2348
+ * @param {string} provisioningRecordId - path parameter
2349
+ * @param {getCallback} callback - a callback function to return the result
2350
+ * @return {object} results - An object containing the response of the action
2351
+ *
2352
+ * @route {POST} /retrieveProvisioningRecordByInternalID
2353
+ * @roles admin
2354
+ * @task true
2355
+ */
2356
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2357
+ retrieveProvisioningRecordByInternalID(provisioningRecordId, callback) {
2358
+ const meth = 'adapter-retrieveProvisioningRecordByInternalID';
2359
+ const origin = `${this.id}-${meth}`;
2360
+ log.trace(origin);
2361
+
2362
+ if (this.suspended && this.suspendMode === 'error') {
2363
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2364
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2365
+ return callback(null, errorObj);
2366
+ }
2367
+
2368
+ /* HERE IS WHERE YOU VALIDATE DATA */
2369
+ if (provisioningRecordId === undefined || provisioningRecordId === null || provisioningRecordId === '') {
2370
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['provisioningRecordId'], null, null, null);
2371
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2372
+ return callback(null, errorObj);
2373
+ }
2374
+
2375
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2376
+ const queryParamsAvailable = {};
2377
+ const queryParams = {};
2378
+ const pathVars = [provisioningRecordId];
2379
+ const bodyVars = {};
2380
+
2381
+ // loop in template. long callback arg name to avoid identifier conflicts
2382
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2383
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2384
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2385
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2386
+ }
2387
+ });
2388
+
2389
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2390
+ // see adapter code documentation for more information on the request object's fields
2391
+ const reqObj = {
2392
+ payload: bodyVars,
2393
+ uriPathVars: pathVars,
2394
+ uriQuery: queryParams
2395
+ };
2396
+
2397
+ try {
2398
+ // Make the call -
2399
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2400
+ return this.requestHandlerInst.identifyRequest('DeviceProvisioningRecordManagement', 'retrieveProvisioningRecordByInternalID', reqObj, true, (irReturnData, irReturnError) => {
2401
+ // if we received an error or their is no response on the results
2402
+ // return an error
2403
+ if (irReturnError) {
2404
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2405
+ return callback(null, irReturnError);
2406
+ }
2407
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2408
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveProvisioningRecordByInternalID'], null, null, null);
2409
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2410
+ return callback(null, errorObj);
2411
+ }
2412
+
2413
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2414
+ // return the response
2415
+ return callback(irReturnData, null);
2416
+ });
2417
+ } catch (ex) {
2418
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2419
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2420
+ return callback(null, errorObj);
2421
+ }
2422
+ }
2423
+
2424
+ /**
2425
+ * @function deleteProvisioningRecord
2426
+ * @pronghornType method
2427
+ * @name deleteProvisioningRecord
2428
+ * @summary Delete Provisioning Record
2429
+ *
2430
+ * @param {string} provisioningRecordId - path parameter
2431
+ * @param {getCallback} callback - a callback function to return the result
2432
+ * @return {object} results - An object containing the response of the action
2433
+ *
2434
+ * @route {POST} /deleteProvisioningRecord
2435
+ * @roles admin
2436
+ * @task true
2437
+ */
2438
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2439
+ deleteProvisioningRecord(provisioningRecordId, callback) {
2440
+ const meth = 'adapter-deleteProvisioningRecord';
2441
+ const origin = `${this.id}-${meth}`;
2442
+ log.trace(origin);
2443
+
2444
+ if (this.suspended && this.suspendMode === 'error') {
2445
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2446
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2447
+ return callback(null, errorObj);
2448
+ }
2449
+
2450
+ /* HERE IS WHERE YOU VALIDATE DATA */
2451
+ if (provisioningRecordId === undefined || provisioningRecordId === null || provisioningRecordId === '') {
2452
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['provisioningRecordId'], null, null, null);
2453
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2454
+ return callback(null, errorObj);
2455
+ }
2456
+
2457
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2458
+ const queryParamsAvailable = {};
2459
+ const queryParams = {};
2460
+ const pathVars = [provisioningRecordId];
2461
+ const bodyVars = {};
2462
+
2463
+ // loop in template. long callback arg name to avoid identifier conflicts
2464
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2465
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2466
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2467
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2468
+ }
2469
+ });
2470
+
2471
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2472
+ // see adapter code documentation for more information on the request object's fields
2473
+ const reqObj = {
2474
+ payload: bodyVars,
2475
+ uriPathVars: pathVars,
2476
+ uriQuery: queryParams
2477
+ };
2478
+
2479
+ try {
2480
+ // Make the call -
2481
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2482
+ return this.requestHandlerInst.identifyRequest('DeviceProvisioningRecordManagement', 'deleteProvisioningRecord', reqObj, false, (irReturnData, irReturnError) => {
2483
+ // if we received an error or their is no response on the results
2484
+ // return an error
2485
+ if (irReturnError) {
2486
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2487
+ return callback(null, irReturnError);
2488
+ }
2489
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2490
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteProvisioningRecord'], null, null, null);
2491
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2492
+ return callback(null, errorObj);
2493
+ }
2494
+
2495
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2496
+ // return the response
2497
+ return callback(irReturnData, null);
2498
+ });
2499
+ } catch (ex) {
2500
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2501
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2502
+ return callback(null, errorObj);
2503
+ }
2504
+ }
2505
+
2506
+ /**
2507
+ * @function retrieveProvisioningRecordsByDevice
2508
+ * @pronghornType method
2509
+ * @name retrieveProvisioningRecordsByDevice
2510
+ * @summary Retrieve Provisioning Records by Device
2511
+ *
2512
+ * @param {string} deviceId - Device ID (FSAN/serial/RegID/MAC)
2513
+ * @param {getCallback} callback - a callback function to return the result
2514
+ * @return {object} results - An object containing the response of the action
2515
+ *
2516
+ * @route {POST} /retrieveProvisioningRecordsByDevice
2517
+ * @roles admin
2518
+ * @task true
2519
+ */
2520
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2521
+ retrieveProvisioningRecordsByDevice(deviceId, callback) {
2522
+ const meth = 'adapter-retrieveProvisioningRecordsByDevice';
2523
+ const origin = `${this.id}-${meth}`;
2524
+ log.trace(origin);
2525
+
2526
+ if (this.suspended && this.suspendMode === 'error') {
2527
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2528
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2529
+ return callback(null, errorObj);
2530
+ }
2531
+
2532
+ /* HERE IS WHERE YOU VALIDATE DATA */
2533
+ if (deviceId === undefined || deviceId === null || deviceId === '') {
2534
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceId'], null, null, null);
2535
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2536
+ return callback(null, errorObj);
2537
+ }
2538
+
2539
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2540
+ const queryParamsAvailable = { deviceId };
2541
+ const queryParams = {};
2542
+ const pathVars = [];
2543
+ const bodyVars = {};
2544
+
2545
+ // loop in template. long callback arg name to avoid identifier conflicts
2546
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2547
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2548
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2549
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2550
+ }
2551
+ });
2552
+
2553
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2554
+ // see adapter code documentation for more information on the request object's fields
2555
+ const reqObj = {
2556
+ payload: bodyVars,
2557
+ uriPathVars: pathVars,
2558
+ uriQuery: queryParams
2559
+ };
2560
+
2561
+ try {
2562
+ // Make the call -
2563
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2564
+ return this.requestHandlerInst.identifyRequest('DeviceProvisioningRecordManagement', 'retrieveProvisioningRecordsByDevice', reqObj, true, (irReturnData, irReturnError) => {
2565
+ // if we received an error or their is no response on the results
2566
+ // return an error
2567
+ if (irReturnError) {
2568
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2569
+ return callback(null, irReturnError);
2570
+ }
2571
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2572
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveProvisioningRecordsByDevice'], null, null, null);
2573
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2574
+ return callback(null, errorObj);
2575
+ }
2576
+
2577
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2578
+ // return the response
2579
+ return callback(irReturnData, null);
2580
+ });
2581
+ } catch (ex) {
2582
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2583
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2584
+ return callback(null, errorObj);
2585
+ }
2586
+ }
2587
+
2588
+ /**
2589
+ * @function retrieveProvisioningRecordsBySubscriber
2590
+ * @pronghornType method
2591
+ * @name retrieveProvisioningRecordsBySubscriber
2592
+ * @summary Retrieve Provisioning Records by Subscriber
2593
+ *
2594
+ * @param {string} subscriberId - Internal ID value of the associated Subscriber record
2595
+ * @param {getCallback} callback - a callback function to return the result
2596
+ * @return {object} results - An object containing the response of the action
2597
+ *
2598
+ * @route {POST} /retrieveProvisioningRecordsBySubscriber
2599
+ * @roles admin
2600
+ * @task true
2601
+ */
2602
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2603
+ retrieveProvisioningRecordsBySubscriber(subscriberId, callback) {
2604
+ const meth = 'adapter-retrieveProvisioningRecordsBySubscriber';
2605
+ const origin = `${this.id}-${meth}`;
2606
+ log.trace(origin);
2607
+
2608
+ if (this.suspended && this.suspendMode === 'error') {
2609
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2610
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2611
+ return callback(null, errorObj);
2612
+ }
2613
+
2614
+ /* HERE IS WHERE YOU VALIDATE DATA */
2615
+ if (subscriberId === undefined || subscriberId === null || subscriberId === '') {
2616
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['subscriberId'], null, null, null);
2617
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2618
+ return callback(null, errorObj);
2619
+ }
2620
+
2621
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2622
+ const queryParamsAvailable = { subscriberId };
2623
+ const queryParams = {};
2624
+ const pathVars = [];
2625
+ const bodyVars = {};
2626
+
2627
+ // loop in template. long callback arg name to avoid identifier conflicts
2628
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2629
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2630
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2631
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2632
+ }
2633
+ });
2634
+
2635
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2636
+ // see adapter code documentation for more information on the request object's fields
2637
+ const reqObj = {
2638
+ payload: bodyVars,
2639
+ uriPathVars: pathVars,
2640
+ uriQuery: queryParams
2641
+ };
2642
+
2643
+ try {
2644
+ // Make the call -
2645
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2646
+ return this.requestHandlerInst.identifyRequest('DeviceProvisioningRecordManagement', 'retrieveProvisioningRecordsBySubscriber', reqObj, true, (irReturnData, irReturnError) => {
2647
+ // if we received an error or their is no response on the results
2648
+ // return an error
2649
+ if (irReturnError) {
2650
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2651
+ return callback(null, irReturnError);
2652
+ }
2653
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2654
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveProvisioningRecordsBySubscriber'], null, null, null);
2655
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2656
+ return callback(null, errorObj);
2657
+ }
2658
+
2659
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2660
+ // return the response
2661
+ return callback(irReturnData, null);
2662
+ });
2663
+ } catch (ex) {
2664
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2665
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2666
+ return callback(null, errorObj);
2667
+ }
2668
+ }
2669
+
2670
+ /**
2671
+ * @function modifyProvisioningRecord
2672
+ * @pronghornType method
2673
+ * @name modifyProvisioningRecord
2674
+ * @summary Modify Provisioning Record
2675
+ *
2676
+ * @param {object} body - PUT body parameter
2677
+ * @param {string} provRecordId - path parameter
2678
+ * @param {getCallback} callback - a callback function to return the result
2679
+ * @return {object} results - An object containing the response of the action
2680
+ *
2681
+ * @route {POST} /modifyProvisioningRecord
2682
+ * @roles admin
2683
+ * @task true
2684
+ */
2685
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2686
+ modifyProvisioningRecord(body, provRecordId, callback) {
2687
+ const meth = 'adapter-modifyProvisioningRecord';
2688
+ const origin = `${this.id}-${meth}`;
2689
+ log.trace(origin);
2690
+
2691
+ if (this.suspended && this.suspendMode === 'error') {
2692
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2693
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2694
+ return callback(null, errorObj);
2695
+ }
2696
+
2697
+ /* HERE IS WHERE YOU VALIDATE DATA */
2698
+ if (body === undefined || body === null || body === '') {
2699
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2700
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2701
+ return callback(null, errorObj);
2702
+ }
2703
+ if (provRecordId === undefined || provRecordId === null || provRecordId === '') {
2704
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['provRecordId'], null, null, null);
2705
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2706
+ return callback(null, errorObj);
2707
+ }
2708
+
2709
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2710
+ const queryParamsAvailable = {};
2711
+ const queryParams = {};
2712
+ const pathVars = [provRecordId];
2713
+ const bodyVars = body;
2714
+
2715
+ // loop in template. long callback arg name to avoid identifier conflicts
2716
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2717
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2718
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2719
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2720
+ }
2721
+ });
2722
+
2723
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2724
+ let thisHeaderData = null;
2725
+ // if the additional headers was passed in as a string parse the json into an object
2726
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2727
+ try {
2728
+ // parse the additional headers object that was passed in
2729
+ thisHeaderData = JSON.parse(thisHeaderData);
2730
+ } catch (err) {
2731
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2732
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2733
+ return callback(null, errorObj);
2734
+ }
2735
+ } else if (thisHeaderData === null) {
2736
+ thisHeaderData = { contentType: '' };
2737
+ }
2738
+
2739
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2740
+ // see adapter code documentation for more information on the request object's fields
2741
+ const reqObj = {
2742
+ payload: bodyVars,
2743
+ uriPathVars: pathVars,
2744
+ uriQuery: queryParams,
2745
+ addlHeaders: thisHeaderData
2746
+ };
2747
+
2748
+ try {
2749
+ // Make the call -
2750
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2751
+ return this.requestHandlerInst.identifyRequest('DeviceProvisioningRecordManagement', 'modifyProvisioningRecord', reqObj, false, (irReturnData, irReturnError) => {
2752
+ // if we received an error or their is no response on the results
2753
+ // return an error
2754
+ if (irReturnError) {
2755
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2756
+ return callback(null, irReturnError);
2757
+ }
2758
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2759
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['modifyProvisioningRecord'], null, null, null);
2760
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2761
+ return callback(null, errorObj);
2762
+ }
2763
+
2764
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2765
+ // return the response
2766
+ return callback(irReturnData, null);
2767
+ });
2768
+ } catch (ex) {
2769
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2770
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2771
+ return callback(null, errorObj);
2772
+ }
2773
+ }
2774
+
2775
+ /**
2776
+ * @function operateTR69Device
2777
+ * @pronghornType method
2778
+ * @name operateTR69Device
2779
+ * @summary operateTR69Device
2780
+ *
2781
+ * @param {object} body - POST body parameter
2782
+ * @param {getCallback} callback - a callback function to return the result
2783
+ * @return {object} results - An object containing the response of the action
2784
+ *
2785
+ * @route {POST} /operateTR69Device
2786
+ * @roles admin
2787
+ * @task true
2788
+ */
2789
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2790
+ operateTR69Device(body, callback) {
2791
+ const meth = 'adapter-operateTR69Device';
2792
+ const origin = `${this.id}-${meth}`;
2793
+ log.trace(origin);
2794
+
2795
+ if (this.suspended && this.suspendMode === 'error') {
2796
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2797
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2798
+ return callback(null, errorObj);
2799
+ }
2800
+
2801
+ /* HERE IS WHERE YOU VALIDATE DATA */
2802
+ if (body === undefined || body === null || body === '') {
2803
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2804
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2805
+ return callback(null, errorObj);
2806
+ }
2807
+
2808
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2809
+ const queryParamsAvailable = {};
2810
+ const queryParams = {};
2811
+ const pathVars = [];
2812
+ const bodyVars = body;
2813
+
2814
+ // loop in template. long callback arg name to avoid identifier conflicts
2815
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2816
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2817
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2818
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2819
+ }
2820
+ });
2821
+
2822
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2823
+ let thisHeaderData = null;
2824
+ // if the additional headers was passed in as a string parse the json into an object
2825
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2826
+ try {
2827
+ // parse the additional headers object that was passed in
2828
+ thisHeaderData = JSON.parse(thisHeaderData);
2829
+ } catch (err) {
2830
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2831
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2832
+ return callback(null, errorObj);
2833
+ }
2834
+ } else if (thisHeaderData === null) {
2835
+ thisHeaderData = { contentType: '' };
2836
+ }
2837
+
2838
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2839
+ // see adapter code documentation for more information on the request object's fields
2840
+ const reqObj = {
2841
+ payload: bodyVars,
2842
+ uriPathVars: pathVars,
2843
+ uriQuery: queryParams,
2844
+ addlHeaders: thisHeaderData
2845
+ };
2846
+
2847
+ try {
2848
+ // Make the call -
2849
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2850
+ return this.requestHandlerInst.identifyRequest('TR69DeviceOperations', 'operateTR69Device', reqObj, true, (irReturnData, irReturnError) => {
2851
+ // if we received an error or their is no response on the results
2852
+ // return an error
2853
+ if (irReturnError) {
2854
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2855
+ return callback(null, irReturnError);
2856
+ }
2857
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2858
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['operateTR69Device'], null, null, null);
2859
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2860
+ return callback(null, errorObj);
2861
+ }
2862
+
2863
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2864
+ // return the response
2865
+ return callback(irReturnData, null);
2866
+ });
2867
+ } catch (ex) {
2868
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2869
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2870
+ return callback(null, errorObj);
2871
+ }
2872
+ }
2873
+
2874
+ /**
2875
+ * @function retrieveAllDeviceGroups
2876
+ * @pronghornType method
2877
+ * @name retrieveAllDeviceGroups
2878
+ * @summary Retrieve All Device Groups
2879
+ *
2880
+ * @param {getCallback} callback - a callback function to return the result
2881
+ * @return {object} results - An object containing the response of the action
2882
+ *
2883
+ * @route {GET} /retrieveAllDeviceGroups
2884
+ * @roles admin
2885
+ * @task true
2886
+ */
2887
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2888
+ retrieveAllDeviceGroups(callback) {
2889
+ const meth = 'adapter-retrieveAllDeviceGroups';
2890
+ const origin = `${this.id}-${meth}`;
2891
+ log.trace(origin);
2892
+
2893
+ if (this.suspended && this.suspendMode === 'error') {
2894
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2895
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2896
+ return callback(null, errorObj);
2897
+ }
2898
+
2899
+ /* HERE IS WHERE YOU VALIDATE DATA */
2900
+
2901
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2902
+ const queryParamsAvailable = {};
2903
+ const queryParams = {};
2904
+ const pathVars = [];
2905
+ const bodyVars = {};
2906
+
2907
+ // loop in template. long callback arg name to avoid identifier conflicts
2908
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2909
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2910
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2911
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2912
+ }
2913
+ });
2914
+
2915
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2916
+ // see adapter code documentation for more information on the request object's fields
2917
+ const reqObj = {
2918
+ payload: bodyVars,
2919
+ uriPathVars: pathVars,
2920
+ uriQuery: queryParams
2921
+ };
2922
+
2923
+ try {
2924
+ // Make the call -
2925
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2926
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'retrieveAllDeviceGroups', reqObj, true, (irReturnData, irReturnError) => {
2927
+ // if we received an error or their is no response on the results
2928
+ // return an error
2929
+ if (irReturnError) {
2930
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2931
+ return callback(null, irReturnError);
2932
+ }
2933
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2934
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveAllDeviceGroups'], null, null, null);
2935
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2936
+ return callback(null, errorObj);
2937
+ }
2938
+
2939
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2940
+ // return the response
2941
+ return callback(irReturnData, null);
2942
+ });
2943
+ } catch (ex) {
2944
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2945
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2946
+ return callback(null, errorObj);
2947
+ }
2948
+ }
2949
+
2950
+ /**
2951
+ * @function retrieveDeviceGroupByID
2952
+ * @pronghornType method
2953
+ * @name retrieveDeviceGroupByID
2954
+ * @summary Retrieve Device Group by ID
2955
+ *
2956
+ * @param {string} groupId - path parameter
2957
+ * @param {getCallback} callback - a callback function to return the result
2958
+ * @return {object} results - An object containing the response of the action
2959
+ *
2960
+ * @route {POST} /retrieveDeviceGroupByID
2961
+ * @roles admin
2962
+ * @task true
2963
+ */
2964
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2965
+ retrieveDeviceGroupByID(groupId, callback) {
2966
+ const meth = 'adapter-retrieveDeviceGroupByID';
2967
+ const origin = `${this.id}-${meth}`;
2968
+ log.trace(origin);
2969
+
2970
+ if (this.suspended && this.suspendMode === 'error') {
2971
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2972
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2973
+ return callback(null, errorObj);
2974
+ }
2975
+
2976
+ /* HERE IS WHERE YOU VALIDATE DATA */
2977
+ if (groupId === undefined || groupId === null || groupId === '') {
2978
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['groupId'], null, null, null);
2979
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2980
+ return callback(null, errorObj);
2981
+ }
2982
+
2983
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2984
+ const queryParamsAvailable = {};
2985
+ const queryParams = {};
2986
+ const pathVars = [groupId];
2987
+ const bodyVars = {};
2988
+
2989
+ // loop in template. long callback arg name to avoid identifier conflicts
2990
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2991
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2992
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2993
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2994
+ }
2995
+ });
2996
+
2997
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2998
+ // see adapter code documentation for more information on the request object's fields
2999
+ const reqObj = {
3000
+ payload: bodyVars,
3001
+ uriPathVars: pathVars,
3002
+ uriQuery: queryParams
3003
+ };
3004
+
3005
+ try {
3006
+ // Make the call -
3007
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3008
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'retrieveDeviceGroupByID', reqObj, true, (irReturnData, irReturnError) => {
3009
+ // if we received an error or their is no response on the results
3010
+ // return an error
3011
+ if (irReturnError) {
3012
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3013
+ return callback(null, irReturnError);
3014
+ }
3015
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3016
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveDeviceGroupByID'], null, null, null);
3017
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3018
+ return callback(null, errorObj);
3019
+ }
3020
+
3021
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3022
+ // return the response
3023
+ return callback(irReturnData, null);
3024
+ });
3025
+ } catch (ex) {
3026
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3027
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3028
+ return callback(null, errorObj);
3029
+ }
3030
+ }
3031
+
3032
+ /**
3033
+ * @function retrieveAllStaticGroupMemberships
3034
+ * @pronghornType method
3035
+ * @name retrieveAllStaticGroupMemberships
3036
+ * @summary Retrieve All Static Group Memberships
3037
+ *
3038
+ * @param {string} bDiscovered - If present, this flag returns only Discovered devices (those which have successfully checked in to the ACS).
3039
+ * @param {string} bUndiscovered - If present, this flag returns only devices which have not checked in to the ACS).
3040
+ * @param {getCallback} callback - a callback function to return the result
3041
+ * @return {object} results - An object containing the response of the action
3042
+ *
3043
+ * @route {POST} /retrieveAllStaticGroupMemberships
3044
+ * @roles admin
3045
+ * @task true
3046
+ */
3047
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3048
+ retrieveAllStaticGroupMemberships(bDiscovered, bUndiscovered, callback) {
3049
+ const meth = 'adapter-retrieveAllStaticGroupMemberships';
3050
+ const origin = `${this.id}-${meth}`;
3051
+ log.trace(origin);
3052
+
3053
+ if (this.suspended && this.suspendMode === 'error') {
3054
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3055
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3056
+ return callback(null, errorObj);
3057
+ }
3058
+
3059
+ /* HERE IS WHERE YOU VALIDATE DATA */
3060
+
3061
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3062
+ const queryParamsAvailable = { bDiscovered, bUndiscovered };
3063
+ const queryParams = {};
3064
+ const pathVars = [];
3065
+ const bodyVars = {};
3066
+
3067
+ // loop in template. long callback arg name to avoid identifier conflicts
3068
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3069
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3070
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3071
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3072
+ }
3073
+ });
3074
+
3075
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3076
+ // see adapter code documentation for more information on the request object's fields
3077
+ const reqObj = {
3078
+ payload: bodyVars,
3079
+ uriPathVars: pathVars,
3080
+ uriQuery: queryParams
3081
+ };
3082
+
3083
+ try {
3084
+ // Make the call -
3085
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3086
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'retrieveAllStaticGroupMemberships', reqObj, true, (irReturnData, irReturnError) => {
3087
+ // if we received an error or their is no response on the results
3088
+ // return an error
3089
+ if (irReturnError) {
3090
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3091
+ return callback(null, irReturnError);
3092
+ }
3093
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3094
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveAllStaticGroupMemberships'], null, null, null);
3095
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3096
+ return callback(null, errorObj);
3097
+ }
3098
+
3099
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3100
+ // return the response
3101
+ return callback(irReturnData, null);
3102
+ });
3103
+ } catch (ex) {
3104
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3105
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3106
+ return callback(null, errorObj);
3107
+ }
3108
+ }
3109
+
3110
+ /**
3111
+ * @function addADeviceOrProvisioningRecordToAStaticGroup
3112
+ * @pronghornType method
3113
+ * @name addADeviceOrProvisioningRecordToAStaticGroup
3114
+ * @summary Add a Device or Provisioning Record to a Static Group
3115
+ *
3116
+ * @param {object} body - POST body parameter
3117
+ * @param {getCallback} callback - a callback function to return the result
3118
+ * @return {object} results - An object containing the response of the action
3119
+ *
3120
+ * @route {POST} /addADeviceOrProvisioningRecordToAStaticGroup
3121
+ * @roles admin
3122
+ * @task true
3123
+ */
3124
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3125
+ addADeviceOrProvisioningRecordToAStaticGroup(body, callback) {
3126
+ const meth = 'adapter-addADeviceOrProvisioningRecordToAStaticGroup';
3127
+ const origin = `${this.id}-${meth}`;
3128
+ log.trace(origin);
3129
+
3130
+ if (this.suspended && this.suspendMode === 'error') {
3131
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3132
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3133
+ return callback(null, errorObj);
3134
+ }
3135
+
3136
+ /* HERE IS WHERE YOU VALIDATE DATA */
3137
+ if (body === undefined || body === null || body === '') {
3138
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
3139
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3140
+ return callback(null, errorObj);
3141
+ }
3142
+
3143
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3144
+ const queryParamsAvailable = {};
3145
+ const queryParams = {};
3146
+ const pathVars = [];
3147
+ const bodyVars = body;
3148
+
3149
+ // loop in template. long callback arg name to avoid identifier conflicts
3150
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3151
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3152
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3153
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3154
+ }
3155
+ });
3156
+
3157
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3158
+ let thisHeaderData = null;
3159
+ // if the additional headers was passed in as a string parse the json into an object
3160
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3161
+ try {
3162
+ // parse the additional headers object that was passed in
3163
+ thisHeaderData = JSON.parse(thisHeaderData);
3164
+ } catch (err) {
3165
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3166
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3167
+ return callback(null, errorObj);
3168
+ }
3169
+ } else if (thisHeaderData === null) {
3170
+ thisHeaderData = { contentType: '' };
3171
+ }
3172
+
3173
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3174
+ // see adapter code documentation for more information on the request object's fields
3175
+ const reqObj = {
3176
+ payload: bodyVars,
3177
+ uriPathVars: pathVars,
3178
+ uriQuery: queryParams,
3179
+ addlHeaders: thisHeaderData
3180
+ };
3181
+
3182
+ try {
3183
+ // Make the call -
3184
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3185
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'addADeviceOrProvisioningRecordToAStaticGroup', reqObj, true, (irReturnData, irReturnError) => {
3186
+ // if we received an error or their is no response on the results
3187
+ // return an error
3188
+ if (irReturnError) {
3189
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3190
+ return callback(null, irReturnError);
3191
+ }
3192
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3193
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['addADeviceOrProvisioningRecordToAStaticGroup'], null, null, null);
3194
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3195
+ return callback(null, errorObj);
3196
+ }
3197
+
3198
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3199
+ // return the response
3200
+ return callback(irReturnData, null);
3201
+ });
3202
+ } catch (ex) {
3203
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3204
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3205
+ return callback(null, errorObj);
3206
+ }
3207
+ }
3208
+
3209
+ /**
3210
+ * @function retrieveStaticGroupMembershipsByDevice
3211
+ * @pronghornType method
3212
+ * @name retrieveStaticGroupMembershipsByDevice
3213
+ * @summary Retrieve Static Group Memberships by Device
3214
+ *
3215
+ * @param {string} memberInfo - One of: FSAN ID, Serial number, Registration ID, or MAC address.
3216
+ Use any of these strings to search for membership information for a matching device.
3217
+ * @param {getCallback} callback - a callback function to return the result
3218
+ * @return {object} results - An object containing the response of the action
3219
+ *
3220
+ * @route {POST} /retrieveStaticGroupMembershipsByDevice
3221
+ * @roles admin
3222
+ * @task true
3223
+ */
3224
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3225
+ retrieveStaticGroupMembershipsByDevice(memberInfo, callback) {
3226
+ const meth = 'adapter-retrieveStaticGroupMembershipsByDevice';
3227
+ const origin = `${this.id}-${meth}`;
3228
+ log.trace(origin);
3229
+
3230
+ if (this.suspended && this.suspendMode === 'error') {
3231
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3232
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3233
+ return callback(null, errorObj);
3234
+ }
3235
+
3236
+ /* HERE IS WHERE YOU VALIDATE DATA */
3237
+ if (memberInfo === undefined || memberInfo === null || memberInfo === '') {
3238
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['memberInfo'], null, null, null);
3239
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3240
+ return callback(null, errorObj);
3241
+ }
3242
+
3243
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3244
+ const queryParamsAvailable = { memberInfo };
3245
+ const queryParams = {};
3246
+ const pathVars = [];
3247
+ const bodyVars = {};
3248
+
3249
+ // loop in template. long callback arg name to avoid identifier conflicts
3250
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3251
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3252
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3253
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3254
+ }
3255
+ });
3256
+
3257
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3258
+ // see adapter code documentation for more information on the request object's fields
3259
+ const reqObj = {
3260
+ payload: bodyVars,
3261
+ uriPathVars: pathVars,
3262
+ uriQuery: queryParams
3263
+ };
3264
+
3265
+ try {
3266
+ // Make the call -
3267
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3268
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'retrieveStaticGroupMembershipsByDevice', reqObj, true, (irReturnData, irReturnError) => {
3269
+ // if we received an error or their is no response on the results
3270
+ // return an error
3271
+ if (irReturnError) {
3272
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3273
+ return callback(null, irReturnError);
3274
+ }
3275
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3276
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveStaticGroupMembershipsByDevice'], null, null, null);
3277
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3278
+ return callback(null, errorObj);
3279
+ }
3280
+
3281
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3282
+ // return the response
3283
+ return callback(irReturnData, null);
3284
+ });
3285
+ } catch (ex) {
3286
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3287
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3288
+ return callback(null, errorObj);
3289
+ }
3290
+ }
3291
+
3292
+ /**
3293
+ * @function removeADeviceFromAllStaticGroups
3294
+ * @pronghornType method
3295
+ * @name removeADeviceFromAllStaticGroups
3296
+ * @summary Remove a device from all Static Groups
3297
+ *
3298
+ * @param {string} memberInfo - memberInfo param
3299
+ * @param {getCallback} callback - a callback function to return the result
3300
+ * @return {object} results - An object containing the response of the action
3301
+ *
3302
+ * @route {POST} /removeADeviceFromAllStaticGroups
3303
+ * @roles admin
3304
+ * @task true
3305
+ */
3306
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3307
+ removeADeviceFromAllStaticGroups(memberInfo, callback) {
3308
+ const meth = 'adapter-removeADeviceFromAllStaticGroups';
3309
+ const origin = `${this.id}-${meth}`;
3310
+ log.trace(origin);
3311
+
3312
+ if (this.suspended && this.suspendMode === 'error') {
3313
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3314
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3315
+ return callback(null, errorObj);
3316
+ }
3317
+
3318
+ /* HERE IS WHERE YOU VALIDATE DATA */
3319
+ if (memberInfo === undefined || memberInfo === null || memberInfo === '') {
3320
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['memberInfo'], null, null, null);
3321
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3322
+ return callback(null, errorObj);
3323
+ }
3324
+
3325
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3326
+ const queryParamsAvailable = { memberInfo };
3327
+ const queryParams = {};
3328
+ const pathVars = [];
3329
+ const bodyVars = {};
3330
+
3331
+ // loop in template. long callback arg name to avoid identifier conflicts
3332
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3333
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3334
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3335
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3336
+ }
3337
+ });
3338
+
3339
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3340
+ // see adapter code documentation for more information on the request object's fields
3341
+ const reqObj = {
3342
+ payload: bodyVars,
3343
+ uriPathVars: pathVars,
3344
+ uriQuery: queryParams
3345
+ };
3346
+
3347
+ try {
3348
+ // Make the call -
3349
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3350
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'removeADeviceFromAllStaticGroups', reqObj, false, (irReturnData, irReturnError) => {
3351
+ // if we received an error or their is no response on the results
3352
+ // return an error
3353
+ if (irReturnError) {
3354
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3355
+ return callback(null, irReturnError);
3356
+ }
3357
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3358
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['removeADeviceFromAllStaticGroups'], null, null, null);
3359
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3360
+ return callback(null, errorObj);
3361
+ }
3362
+
3363
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3364
+ // return the response
3365
+ return callback(irReturnData, null);
3366
+ });
3367
+ } catch (ex) {
3368
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3369
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3370
+ return callback(null, errorObj);
3371
+ }
3372
+ }
3373
+
3374
+ /**
3375
+ * @function retrieveSingleStaticGroupMembershipRecord
3376
+ * @pronghornType method
3377
+ * @name retrieveSingleStaticGroupMembershipRecord
3378
+ * @summary Retrieve Single Static Group Membership Record
3379
+ *
3380
+ * @param {string} groupMembershipId - path parameter
3381
+ * @param {getCallback} callback - a callback function to return the result
3382
+ * @return {object} results - An object containing the response of the action
3383
+ *
3384
+ * @route {POST} /retrieveSingleStaticGroupMembershipRecord
3385
+ * @roles admin
3386
+ * @task true
3387
+ */
3388
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3389
+ retrieveSingleStaticGroupMembershipRecord(groupMembershipId, callback) {
3390
+ const meth = 'adapter-retrieveSingleStaticGroupMembershipRecord';
3391
+ const origin = `${this.id}-${meth}`;
3392
+ log.trace(origin);
3393
+
3394
+ if (this.suspended && this.suspendMode === 'error') {
3395
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3396
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3397
+ return callback(null, errorObj);
3398
+ }
3399
+
3400
+ /* HERE IS WHERE YOU VALIDATE DATA */
3401
+ if (groupMembershipId === undefined || groupMembershipId === null || groupMembershipId === '') {
3402
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['groupMembershipId'], null, null, null);
3403
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3404
+ return callback(null, errorObj);
3405
+ }
3406
+
3407
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3408
+ const queryParamsAvailable = {};
3409
+ const queryParams = {};
3410
+ const pathVars = [groupMembershipId];
3411
+ const bodyVars = {};
3412
+
3413
+ // loop in template. long callback arg name to avoid identifier conflicts
3414
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3415
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3416
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3417
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3418
+ }
3419
+ });
3420
+
3421
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3422
+ // see adapter code documentation for more information on the request object's fields
3423
+ const reqObj = {
3424
+ payload: bodyVars,
3425
+ uriPathVars: pathVars,
3426
+ uriQuery: queryParams
3427
+ };
3428
+
3429
+ try {
3430
+ // Make the call -
3431
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3432
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'retrieveSingleStaticGroupMembershipRecord', reqObj, true, (irReturnData, irReturnError) => {
3433
+ // if we received an error or their is no response on the results
3434
+ // return an error
3435
+ if (irReturnError) {
3436
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3437
+ return callback(null, irReturnError);
3438
+ }
3439
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3440
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveSingleStaticGroupMembershipRecord'], null, null, null);
3441
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3442
+ return callback(null, errorObj);
3443
+ }
3444
+
3445
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3446
+ // return the response
3447
+ return callback(irReturnData, null);
3448
+ });
3449
+ } catch (ex) {
3450
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3451
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3452
+ return callback(null, errorObj);
3453
+ }
3454
+ }
3455
+
3456
+ /**
3457
+ * @function removeADeviceFromAStaticGroupByMembershipID
3458
+ * @pronghornType method
3459
+ * @name removeADeviceFromAStaticGroupByMembershipID
3460
+ * @summary Remove a device from a Static Group by membership ID
3461
+ *
3462
+ * @param {string} membershipId - path parameter
3463
+ * @param {getCallback} callback - a callback function to return the result
3464
+ * @return {object} results - An object containing the response of the action
3465
+ *
3466
+ * @route {POST} /removeADeviceFromAStaticGroupByMembershipID
3467
+ * @roles admin
3468
+ * @task true
3469
+ */
3470
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3471
+ removeADeviceFromAStaticGroupByMembershipID(membershipId, callback) {
3472
+ const meth = 'adapter-removeADeviceFromAStaticGroupByMembershipID';
3473
+ const origin = `${this.id}-${meth}`;
3474
+ log.trace(origin);
3475
+
3476
+ if (this.suspended && this.suspendMode === 'error') {
3477
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3478
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3479
+ return callback(null, errorObj);
3480
+ }
3481
+
3482
+ /* HERE IS WHERE YOU VALIDATE DATA */
3483
+ if (membershipId === undefined || membershipId === null || membershipId === '') {
3484
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['membershipId'], null, null, null);
3485
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3486
+ return callback(null, errorObj);
3487
+ }
3488
+
3489
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3490
+ const queryParamsAvailable = {};
3491
+ const queryParams = {};
3492
+ const pathVars = [membershipId];
3493
+ const bodyVars = {};
3494
+
3495
+ // loop in template. long callback arg name to avoid identifier conflicts
3496
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3497
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3498
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3499
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3500
+ }
3501
+ });
3502
+
3503
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3504
+ // see adapter code documentation for more information on the request object's fields
3505
+ const reqObj = {
3506
+ payload: bodyVars,
3507
+ uriPathVars: pathVars,
3508
+ uriQuery: queryParams
3509
+ };
3510
+
3511
+ try {
3512
+ // Make the call -
3513
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3514
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'removeADeviceFromAStaticGroupByMembershipID', reqObj, false, (irReturnData, irReturnError) => {
3515
+ // if we received an error or their is no response on the results
3516
+ // return an error
3517
+ if (irReturnError) {
3518
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3519
+ return callback(null, irReturnError);
3520
+ }
3521
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3522
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['removeADeviceFromAStaticGroupByMembershipID'], null, null, null);
3523
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3524
+ return callback(null, errorObj);
3525
+ }
3526
+
3527
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3528
+ // return the response
3529
+ return callback(irReturnData, null);
3530
+ });
3531
+ } catch (ex) {
3532
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3533
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3534
+ return callback(null, errorObj);
3535
+ }
3536
+ }
3537
+
3538
+ /**
3539
+ * @function removeADeviceFromAStaticGroupByGroupIDAndDevice
3540
+ * @pronghornType method
3541
+ * @name removeADeviceFromAStaticGroupByGroupIDAndDevice
3542
+ * @summary Remove a device from a Static Group by group ID and device
3543
+ *
3544
+ * @param {string} groupId - The _id value of the Static Group to remove the device from.
3545
+ * @param {string} memberInfo - One of: FSAN ID, Serial number, Registration ID, or MAC address.
3546
+ Use any of these strings to select the device to remove.
3547
+ * @param {getCallback} callback - a callback function to return the result
3548
+ * @return {object} results - An object containing the response of the action
3549
+ *
3550
+ * @route {POST} /removeADeviceFromAStaticGroupByGroupIDAndDevice
3551
+ * @roles admin
3552
+ * @task true
3553
+ */
3554
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3555
+ removeADeviceFromAStaticGroupByGroupIDAndDevice(groupId, memberInfo, callback) {
3556
+ const meth = 'adapter-removeADeviceFromAStaticGroupByGroupIDAndDevice';
3557
+ const origin = `${this.id}-${meth}`;
3558
+ log.trace(origin);
3559
+
3560
+ if (this.suspended && this.suspendMode === 'error') {
3561
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3562
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3563
+ return callback(null, errorObj);
3564
+ }
3565
+
3566
+ /* HERE IS WHERE YOU VALIDATE DATA */
3567
+ if (groupId === undefined || groupId === null || groupId === '') {
3568
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['groupId'], null, null, null);
3569
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3570
+ return callback(null, errorObj);
3571
+ }
3572
+ if (memberInfo === undefined || memberInfo === null || memberInfo === '') {
3573
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['memberInfo'], null, null, null);
3574
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3575
+ return callback(null, errorObj);
3576
+ }
3577
+
3578
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3579
+ const queryParamsAvailable = { groupId, memberInfo };
3580
+ const queryParams = {};
3581
+ const pathVars = [];
3582
+ const bodyVars = {};
3583
+
3584
+ // loop in template. long callback arg name to avoid identifier conflicts
3585
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3586
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3587
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3588
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3589
+ }
3590
+ });
3591
+
3592
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3593
+ // see adapter code documentation for more information on the request object's fields
3594
+ const reqObj = {
3595
+ payload: bodyVars,
3596
+ uriPathVars: pathVars,
3597
+ uriQuery: queryParams
3598
+ };
3599
+
3600
+ try {
3601
+ // Make the call -
3602
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3603
+ return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'removeADeviceFromAStaticGroupByGroupIDAndDevice', reqObj, false, (irReturnData, irReturnError) => {
3604
+ // if we received an error or their is no response on the results
3605
+ // return an error
3606
+ if (irReturnError) {
3607
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3608
+ return callback(null, irReturnError);
3609
+ }
3610
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3611
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['removeADeviceFromAStaticGroupByGroupIDAndDevice'], null, null, null);
3612
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3613
+ return callback(null, errorObj);
3614
+ }
3615
+
3616
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3617
+ // return the response
3618
+ return callback(irReturnData, null);
3619
+ });
3620
+ } catch (ex) {
3621
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3622
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3623
+ return callback(null, errorObj);
3624
+ }
3625
+ }
3626
+ }
3627
+
3628
+ module.exports = CalixSupportCloud;