@itentialopensource/adapter-aruba_airwave 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.
- package/.eslintignore +6 -0
- package/.eslintrc.js +18 -0
- package/.gitlab/.gitkeep +0 -0
- package/.gitlab/issue_templates/.gitkeep +0 -0
- package/.gitlab/issue_templates/Default.md +17 -0
- package/.gitlab/issue_templates/bugReportTemplate.md +76 -0
- package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
- package/.jshintrc +0 -0
- package/CHANGELOG.md +9 -0
- package/CODE_OF_CONDUCT.md +48 -0
- package/CONTRIBUTING.md +158 -0
- package/LICENSE +201 -0
- package/README.md +544 -0
- package/adapter.js +2860 -0
- package/adapterBase.js +906 -0
- package/entities/.system/action.json +50 -0
- package/entities/.system/mockdatafiles/getToken-default.json +3 -0
- package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
- package/entities/.system/schema.json +19 -0
- package/entities/.system/schemaTokenReq.json +77 -0
- package/entities/.system/schemaTokenResp.json +65 -0
- package/entities/BatchExecuteAPCommandsAPIS/action.json +45 -0
- package/entities/BatchExecuteAPCommandsAPIS/schema.json +20 -0
- package/entities/ConfigurationAPIS/action.json +126 -0
- package/entities/ConfigurationAPIS/schema.json +90 -0
- package/entities/DeviceAPIS/action.json +46 -0
- package/entities/DeviceAPIS/schema.json +20 -0
- package/entities/LOGIN/action.json +24 -0
- package/entities/LOGIN/schema.json +41 -0
- package/entities/QueryAPIS/action.json +298 -0
- package/entities/QueryAPIS/schema.json +32 -0
- package/entities/ReportAPIS/action.json +25 -0
- package/entities/ReportAPIS/schema.json +30 -0
- package/entities/SearchAPIS/action.json +67 -0
- package/entities/SearchAPIS/schema.json +21 -0
- package/error.json +184 -0
- package/package.json +86 -0
- package/pronghorn.json +1589 -0
- package/propertiesSchema.json +801 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/ArubaAirwavePostman.json-OpenApi3Json.json +1583 -0
- package/report/creationReport.json +381 -0
- package/sampleProperties.json +97 -0
- package/test/integration/adapterTestBasicGet.js +85 -0
- package/test/integration/adapterTestConnectivity.js +93 -0
- package/test/integration/adapterTestIntegration.js +1125 -0
- package/test/unit/adapterBaseTestUnit.js +929 -0
- package/test/unit/adapterTestUnit.js +1413 -0
- package/utils/artifactize.js +146 -0
- package/utils/basicGet.js +63 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/pre-commit.sh +27 -0
- package/utils/setup.js +33 -0
- package/utils/tbScript.js +163 -0
- package/utils/tbUtils.js +372 -0
- package/utils/testRunner.js +298 -0
- package/utils/troubleshootingAdapter.js +219 -0
- package/workflows/README.md +3 -0
package/adapter.js
ADDED
|
@@ -0,0 +1,2860 @@
|
|
|
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 Aruba_airwave
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/* GENERAL ADAPTER FUNCTIONS */
|
|
20
|
+
class ArubaAirwave extends AdapterBaseCl {
|
|
21
|
+
/**
|
|
22
|
+
* ArubaAirwave 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.getWorkflowFunctions();
|
|
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
|
+
* @getWorkflowFunctions
|
|
84
|
+
*/
|
|
85
|
+
getWorkflowFunctions(inIgnore) {
|
|
86
|
+
let myIgnore = [];
|
|
87
|
+
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
88
|
+
myIgnore = inIgnore;
|
|
89
|
+
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
90
|
+
myIgnore = [inIgnore];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// The generic adapter functions should already be ignored (e.g. healthCheck)
|
|
94
|
+
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
95
|
+
// myIgnore.push('myMethodNotInWorkflow');
|
|
96
|
+
|
|
97
|
+
return super.getWorkflowFunctions(myIgnore);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @callback healthCallback
|
|
102
|
+
* @param {Object} result - the result of the get request (contains an id and a status)
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* @callback getCallback
|
|
106
|
+
* @param {Object} result - the result of the get request (entity/ies)
|
|
107
|
+
* @param {String} error - any error that occurred
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* @callback createCallback
|
|
111
|
+
* @param {Object} item - the newly created entity
|
|
112
|
+
* @param {String} error - any error that occurred
|
|
113
|
+
*/
|
|
114
|
+
/**
|
|
115
|
+
* @callback updateCallback
|
|
116
|
+
* @param {String} status - the status of the update action
|
|
117
|
+
* @param {String} error - any error that occurred
|
|
118
|
+
*/
|
|
119
|
+
/**
|
|
120
|
+
* @callback deleteCallback
|
|
121
|
+
* @param {String} status - the status of the delete action
|
|
122
|
+
* @param {String} error - any error that occurred
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @summary Determines if this adapter supports the specific entity
|
|
127
|
+
*
|
|
128
|
+
* @function hasEntity
|
|
129
|
+
* @param {String} entityType - the entity type to check for
|
|
130
|
+
* @param {String/Array} entityId - the specific entity we are looking for
|
|
131
|
+
*
|
|
132
|
+
* @param {Callback} callback - An array of whether the adapter can has the
|
|
133
|
+
* desired capability or an error
|
|
134
|
+
*/
|
|
135
|
+
hasEntity(entityType, entityId, callback) {
|
|
136
|
+
const origin = `${this.id}-adapter-hasEntity`;
|
|
137
|
+
log.trace(origin);
|
|
138
|
+
|
|
139
|
+
// Make the call -
|
|
140
|
+
// verifyCapability(entityType, actionType, entityId, callback)
|
|
141
|
+
return this.verifyCapability(entityType, null, entityId, callback);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @summary Provides a way for the adapter to tell north bound integrations
|
|
146
|
+
* whether the adapter supports type, action and specific entity
|
|
147
|
+
*
|
|
148
|
+
* @function verifyCapability
|
|
149
|
+
* @param {String} entityType - the entity type to check for
|
|
150
|
+
* @param {String} actionType - the action type to check for
|
|
151
|
+
* @param {String/Array} entityId - the specific entity we are looking for
|
|
152
|
+
*
|
|
153
|
+
* @param {Callback} callback - An array of whether the adapter can has the
|
|
154
|
+
* desired capability or an error
|
|
155
|
+
*/
|
|
156
|
+
verifyCapability(entityType, actionType, entityId, callback) {
|
|
157
|
+
const meth = 'adapterBase-verifyCapability';
|
|
158
|
+
const origin = `${this.id}-${meth}`;
|
|
159
|
+
log.trace(origin);
|
|
160
|
+
|
|
161
|
+
// if caching
|
|
162
|
+
if (this.caching) {
|
|
163
|
+
// Make the call - verifyCapability(entityType, actionType, entityId, callback)
|
|
164
|
+
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (results, error) => {
|
|
165
|
+
if (error) {
|
|
166
|
+
return callback(null, error);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// if the cache needs to be updated, update and try again
|
|
170
|
+
if (results && results[0] === 'needupdate') {
|
|
171
|
+
switch (entityType) {
|
|
172
|
+
case 'template_entity': {
|
|
173
|
+
// if the cache is invalid, update the cache
|
|
174
|
+
return this.getEntities(null, null, null, null, (data, err) => {
|
|
175
|
+
if (err) {
|
|
176
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
177
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
178
|
+
return callback(null, errorObj);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// need to check the cache again since it has been updated
|
|
182
|
+
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
183
|
+
if (verror) {
|
|
184
|
+
return callback(null, verror);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return this.capabilityResults(vcapable, callback);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
default: {
|
|
192
|
+
// unsupported entity type
|
|
193
|
+
const result = [false];
|
|
194
|
+
|
|
195
|
+
// put false in array for all entities
|
|
196
|
+
if (Array.isArray(entityId)) {
|
|
197
|
+
for (let e = 1; e < entityId.length; e += 1) {
|
|
198
|
+
result.push(false);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return callback(result);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// return the results
|
|
208
|
+
return this.capabilityResults(results, callback);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// if no entity id
|
|
213
|
+
if (!entityId) {
|
|
214
|
+
// need to check the cache again since it has been updated
|
|
215
|
+
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
216
|
+
if (verror) {
|
|
217
|
+
return callback(null, verror);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return this.capabilityResults(vcapable, callback);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// if not caching
|
|
225
|
+
switch (entityType) {
|
|
226
|
+
case 'template_entity': {
|
|
227
|
+
// need to get the entities to check
|
|
228
|
+
return this.getEntities(null, null, null, null, (data, err) => {
|
|
229
|
+
if (err) {
|
|
230
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
231
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
232
|
+
return callback(null, errorObj);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// need to check the cache again since it has been updated
|
|
236
|
+
return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
237
|
+
if (verror) {
|
|
238
|
+
return callback(null, verror);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// is the entity in the list?
|
|
242
|
+
const isEntity = this.entityInList(entityId, data.response, callback);
|
|
243
|
+
const res = [];
|
|
244
|
+
|
|
245
|
+
// not found
|
|
246
|
+
for (let i = 0; i < isEntity.length; i += 1) {
|
|
247
|
+
if (vcapable) {
|
|
248
|
+
res.push(isEntity[i]);
|
|
249
|
+
} else {
|
|
250
|
+
res.push(false);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return callback(res);
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
default: {
|
|
259
|
+
// unsupported entity type
|
|
260
|
+
const result = [false];
|
|
261
|
+
|
|
262
|
+
// put false in array for all entities
|
|
263
|
+
if (Array.isArray(entityId)) {
|
|
264
|
+
for (let e = 1; e < entityId.length; e += 1) {
|
|
265
|
+
result.push(false);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return callback(result);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @summary Updates the cache for all entities by call the get All entity method
|
|
276
|
+
*
|
|
277
|
+
* @function updateEntityCache
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
280
|
+
updateEntityCache() {
|
|
281
|
+
const origin = `${this.id}-adapter-updateEntityCache`;
|
|
282
|
+
log.trace(origin);
|
|
283
|
+
|
|
284
|
+
if (this.caching) {
|
|
285
|
+
// if the cache is invalid, update the cache
|
|
286
|
+
this.getEntities(null, null, null, null, (data, err) => {
|
|
287
|
+
if (err) {
|
|
288
|
+
log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* updateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
296
|
+
* allows customers to make changes to adapter configuration without having to be on the
|
|
297
|
+
* file system.
|
|
298
|
+
*
|
|
299
|
+
* @function updateAdapterConfiguration
|
|
300
|
+
* @param {string} configFile - the name of the file being updated (required)
|
|
301
|
+
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
302
|
+
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
303
|
+
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
304
|
+
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
305
|
+
* @param {Callback} callback - The results of the call
|
|
306
|
+
*/
|
|
307
|
+
updateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
308
|
+
super.updateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @summary Suspends adapter
|
|
313
|
+
*
|
|
314
|
+
* @function suspend
|
|
315
|
+
* @param {Callback} callback - callback function
|
|
316
|
+
*/
|
|
317
|
+
suspend(mode, callback) {
|
|
318
|
+
const origin = `${this.id}-adapter-suspend`;
|
|
319
|
+
log.trace(origin);
|
|
320
|
+
try {
|
|
321
|
+
return super.suspend(mode, callback);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
log.error(`${origin}: ${error}`);
|
|
324
|
+
return callback(null, error);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @summary Unsuspends adapter
|
|
330
|
+
*
|
|
331
|
+
* @function unsuspend
|
|
332
|
+
* @param {Callback} callback - callback function
|
|
333
|
+
*/
|
|
334
|
+
unsuspend(callback) {
|
|
335
|
+
const origin = `${this.id}-adapter-unsuspend`;
|
|
336
|
+
log.trace(origin);
|
|
337
|
+
try {
|
|
338
|
+
return super.unsuspend(callback);
|
|
339
|
+
} catch (error) {
|
|
340
|
+
log.error(`${origin}: ${error}`);
|
|
341
|
+
return callback(null, error);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* @summary Runs troubleshoot scripts for adapter
|
|
347
|
+
*
|
|
348
|
+
* @function troubleshoot
|
|
349
|
+
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
350
|
+
*
|
|
351
|
+
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
352
|
+
* @param {Callback} callback - The results of the call
|
|
353
|
+
*/
|
|
354
|
+
troubleshoot(props, persistFlag, callback) {
|
|
355
|
+
const origin = `${this.id}-adapter-troubleshoot`;
|
|
356
|
+
log.trace(origin);
|
|
357
|
+
try {
|
|
358
|
+
return super.troubleshoot(props, persistFlag, this, callback);
|
|
359
|
+
} catch (error) {
|
|
360
|
+
log.error(`${origin}: ${error}`);
|
|
361
|
+
return callback(null, error);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* @summary runs healthcheck script for adapter
|
|
367
|
+
*
|
|
368
|
+
* @function runHealthcheck
|
|
369
|
+
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
370
|
+
* @param {Callback} callback - callback function
|
|
371
|
+
*/
|
|
372
|
+
runHealthcheck(callback) {
|
|
373
|
+
const origin = `${this.id}-adapter-runHealthcheck`;
|
|
374
|
+
log.trace(origin);
|
|
375
|
+
try {
|
|
376
|
+
return super.runHealthcheck(this, callback);
|
|
377
|
+
} catch (error) {
|
|
378
|
+
log.error(`${origin}: ${error}`);
|
|
379
|
+
return callback(null, error);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @summary runs connectivity check script for adapter
|
|
385
|
+
*
|
|
386
|
+
* @function runConnectivity
|
|
387
|
+
* @param {Callback} callback - callback function
|
|
388
|
+
*/
|
|
389
|
+
runConnectivity(callback) {
|
|
390
|
+
const origin = `${this.id}-adapter-runConnectivity`;
|
|
391
|
+
log.trace(origin);
|
|
392
|
+
try {
|
|
393
|
+
return super.runConnectivity(callback);
|
|
394
|
+
} catch (error) {
|
|
395
|
+
log.error(`${origin}: ${error}`);
|
|
396
|
+
return callback(null, error);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @summary runs basicGet script for adapter
|
|
402
|
+
*
|
|
403
|
+
* @function runBasicGet
|
|
404
|
+
* @param {Callback} callback - callback function
|
|
405
|
+
*/
|
|
406
|
+
runBasicGet(callback) {
|
|
407
|
+
const origin = `${this.id}-adapter-runBasicGet`;
|
|
408
|
+
log.trace(origin);
|
|
409
|
+
try {
|
|
410
|
+
return super.runBasicGet(callback);
|
|
411
|
+
} catch (error) {
|
|
412
|
+
log.error(`${origin}: ${error}`);
|
|
413
|
+
return callback(null, error);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* @function aMPStats
|
|
419
|
+
* @pronghornType method
|
|
420
|
+
* @name aMPStats
|
|
421
|
+
* @summary AMP Stats
|
|
422
|
+
*
|
|
423
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
424
|
+
* @return {object} results - An object containing the response of the action
|
|
425
|
+
*
|
|
426
|
+
* @route {GET} /aMPStats
|
|
427
|
+
* @roles admin
|
|
428
|
+
* @task true
|
|
429
|
+
*/
|
|
430
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
431
|
+
aMPStats(callback) {
|
|
432
|
+
const meth = 'adapter-aMPStats';
|
|
433
|
+
const origin = `${this.id}-${meth}`;
|
|
434
|
+
log.trace(origin);
|
|
435
|
+
|
|
436
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
437
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
438
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
439
|
+
return callback(null, errorObj);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
443
|
+
|
|
444
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
445
|
+
const queryParamsAvailable = {};
|
|
446
|
+
const queryParams = {};
|
|
447
|
+
const pathVars = [];
|
|
448
|
+
const bodyVars = {};
|
|
449
|
+
|
|
450
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
451
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
452
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
453
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
454
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
459
|
+
// see adapter code documentation for more information on the request object's fields
|
|
460
|
+
const reqObj = {
|
|
461
|
+
payload: bodyVars,
|
|
462
|
+
uriPathVars: pathVars,
|
|
463
|
+
uriQuery: queryParams
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
try {
|
|
467
|
+
// Make the call -
|
|
468
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
469
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'aMPStats', reqObj, true, (irReturnData, irReturnError) => {
|
|
470
|
+
// if we received an error or their is no response on the results
|
|
471
|
+
// return an error
|
|
472
|
+
if (irReturnError) {
|
|
473
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
474
|
+
return callback(null, irReturnError);
|
|
475
|
+
}
|
|
476
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
477
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['aMPStats'], null, null, null);
|
|
478
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
479
|
+
return callback(null, errorObj);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
483
|
+
// return the response
|
|
484
|
+
return callback(irReturnData, null);
|
|
485
|
+
});
|
|
486
|
+
} catch (ex) {
|
|
487
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
488
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
489
|
+
return callback(null, errorObj);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* @function folderList
|
|
495
|
+
* @pronghornType method
|
|
496
|
+
* @name folderList
|
|
497
|
+
* @summary Folder List
|
|
498
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
499
|
+
* Can be a stringified Object.
|
|
500
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
501
|
+
* @return {object} results - An object containing the response of the action
|
|
502
|
+
*
|
|
503
|
+
* @route {GET} /folderList
|
|
504
|
+
* @roles admin
|
|
505
|
+
* @task true
|
|
506
|
+
*/
|
|
507
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
508
|
+
folderList(queryData, callback) {
|
|
509
|
+
const meth = 'adapter-folderList';
|
|
510
|
+
const origin = `${this.id}-${meth}`;
|
|
511
|
+
log.trace(origin);
|
|
512
|
+
|
|
513
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
514
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
515
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
516
|
+
return callback(null, errorObj);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
520
|
+
|
|
521
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
522
|
+
const queryParamsAvailable = queryData;
|
|
523
|
+
const queryParams = {};
|
|
524
|
+
const pathVars = [];
|
|
525
|
+
const bodyVars = {};
|
|
526
|
+
|
|
527
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
528
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
529
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
530
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
531
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
536
|
+
// see adapter code documentation for more information on the request object's fields
|
|
537
|
+
const reqObj = {
|
|
538
|
+
payload: bodyVars,
|
|
539
|
+
uriPathVars: pathVars,
|
|
540
|
+
uriQuery: queryParams
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
try {
|
|
544
|
+
// Make the call -
|
|
545
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
546
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'folderList', reqObj, true, (irReturnData, irReturnError) => {
|
|
547
|
+
// if we received an error or their is no response on the results
|
|
548
|
+
// return an error
|
|
549
|
+
if (irReturnError) {
|
|
550
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
551
|
+
return callback(null, irReturnError);
|
|
552
|
+
}
|
|
553
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
554
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['folderList'], null, null, null);
|
|
555
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
556
|
+
return callback(null, errorObj);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
560
|
+
// return the response
|
|
561
|
+
return callback(irReturnData, null);
|
|
562
|
+
});
|
|
563
|
+
} catch (ex) {
|
|
564
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
565
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
566
|
+
return callback(null, errorObj);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* @function catalogRepository
|
|
572
|
+
* @pronghornType method
|
|
573
|
+
* @name catalogRepository
|
|
574
|
+
* @summary Catalog Repository
|
|
575
|
+
*
|
|
576
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
577
|
+
* @return {object} results - An object containing the response of the action
|
|
578
|
+
*
|
|
579
|
+
* @route {GET} /catalogRepository
|
|
580
|
+
* @roles admin
|
|
581
|
+
* @task true
|
|
582
|
+
*/
|
|
583
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
584
|
+
catalogRepository(callback) {
|
|
585
|
+
const meth = 'adapter-catalogRepository';
|
|
586
|
+
const origin = `${this.id}-${meth}`;
|
|
587
|
+
log.trace(origin);
|
|
588
|
+
|
|
589
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
590
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
591
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
592
|
+
return callback(null, errorObj);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
596
|
+
|
|
597
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
598
|
+
const queryParamsAvailable = {};
|
|
599
|
+
const queryParams = {};
|
|
600
|
+
const pathVars = [];
|
|
601
|
+
const bodyVars = {};
|
|
602
|
+
|
|
603
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
604
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
605
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
606
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
607
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
612
|
+
// see adapter code documentation for more information on the request object's fields
|
|
613
|
+
const reqObj = {
|
|
614
|
+
payload: bodyVars,
|
|
615
|
+
uriPathVars: pathVars,
|
|
616
|
+
uriQuery: queryParams
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
try {
|
|
620
|
+
// Make the call -
|
|
621
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
622
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'catalogRepository', reqObj, true, (irReturnData, irReturnError) => {
|
|
623
|
+
// if we received an error or their is no response on the results
|
|
624
|
+
// return an error
|
|
625
|
+
if (irReturnError) {
|
|
626
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
627
|
+
return callback(null, irReturnError);
|
|
628
|
+
}
|
|
629
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
630
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['catalogRepository'], null, null, null);
|
|
631
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
632
|
+
return callback(null, errorObj);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
636
|
+
// return the response
|
|
637
|
+
return callback(irReturnData, null);
|
|
638
|
+
});
|
|
639
|
+
} catch (ex) {
|
|
640
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
641
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
642
|
+
return callback(null, errorObj);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* @function alertList
|
|
648
|
+
* @pronghornType method
|
|
649
|
+
* @name alertList
|
|
650
|
+
* @summary Alert List
|
|
651
|
+
*
|
|
652
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
653
|
+
* @return {object} results - An object containing the response of the action
|
|
654
|
+
*
|
|
655
|
+
* @route {GET} /alertList
|
|
656
|
+
* @roles admin
|
|
657
|
+
* @task true
|
|
658
|
+
*/
|
|
659
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
660
|
+
alertList(callback) {
|
|
661
|
+
const meth = 'adapter-alertList';
|
|
662
|
+
const origin = `${this.id}-${meth}`;
|
|
663
|
+
log.trace(origin);
|
|
664
|
+
|
|
665
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
666
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
667
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
668
|
+
return callback(null, errorObj);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
672
|
+
|
|
673
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
674
|
+
const queryParamsAvailable = {};
|
|
675
|
+
const queryParams = {};
|
|
676
|
+
const pathVars = [];
|
|
677
|
+
const bodyVars = {};
|
|
678
|
+
|
|
679
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
680
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
681
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
682
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
683
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
688
|
+
// see adapter code documentation for more information on the request object's fields
|
|
689
|
+
const reqObj = {
|
|
690
|
+
payload: bodyVars,
|
|
691
|
+
uriPathVars: pathVars,
|
|
692
|
+
uriQuery: queryParams
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
try {
|
|
696
|
+
// Make the call -
|
|
697
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
698
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'alertList', reqObj, true, (irReturnData, irReturnError) => {
|
|
699
|
+
// if we received an error or their is no response on the results
|
|
700
|
+
// return an error
|
|
701
|
+
if (irReturnError) {
|
|
702
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
703
|
+
return callback(null, irReturnError);
|
|
704
|
+
}
|
|
705
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
706
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['alertList'], null, null, null);
|
|
707
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
708
|
+
return callback(null, errorObj);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
712
|
+
// return the response
|
|
713
|
+
return callback(irReturnData, null);
|
|
714
|
+
});
|
|
715
|
+
} catch (ex) {
|
|
716
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
717
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
718
|
+
return callback(null, errorObj);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* @function aPList
|
|
724
|
+
* @pronghornType method
|
|
725
|
+
* @name aPList
|
|
726
|
+
* @summary AP List
|
|
727
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
728
|
+
* Can be a stringified Object.
|
|
729
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
730
|
+
* @return {object} results - An object containing the response of the action
|
|
731
|
+
*
|
|
732
|
+
* @route {GET} /aPList
|
|
733
|
+
* @roles admin
|
|
734
|
+
* @task true
|
|
735
|
+
*/
|
|
736
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
737
|
+
aPList(queryData, callback) {
|
|
738
|
+
const meth = 'adapter-aPList';
|
|
739
|
+
const origin = `${this.id}-${meth}`;
|
|
740
|
+
log.trace(origin);
|
|
741
|
+
|
|
742
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
743
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
744
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
745
|
+
return callback(null, errorObj);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
749
|
+
|
|
750
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
751
|
+
const queryParamsAvailable = queryData;
|
|
752
|
+
const queryParams = {};
|
|
753
|
+
const pathVars = [];
|
|
754
|
+
const bodyVars = {};
|
|
755
|
+
|
|
756
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
757
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
758
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
759
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
760
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
765
|
+
// see adapter code documentation for more information on the request object's fields
|
|
766
|
+
const reqObj = {
|
|
767
|
+
payload: bodyVars,
|
|
768
|
+
uriPathVars: pathVars,
|
|
769
|
+
uriQuery: queryParams
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
try {
|
|
773
|
+
// Make the call -
|
|
774
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
775
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'aPList', reqObj, true, (irReturnData, irReturnError) => {
|
|
776
|
+
// if we received an error or their is no response on the results
|
|
777
|
+
// return an error
|
|
778
|
+
if (irReturnError) {
|
|
779
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
780
|
+
return callback(null, irReturnError);
|
|
781
|
+
}
|
|
782
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
783
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['aPList'], null, null, null);
|
|
784
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
785
|
+
return callback(null, errorObj);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
789
|
+
// return the response
|
|
790
|
+
return callback(irReturnData, null);
|
|
791
|
+
});
|
|
792
|
+
} catch (ex) {
|
|
793
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
794
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
795
|
+
return callback(null, errorObj);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* @function aPBSSIDList
|
|
801
|
+
* @pronghornType method
|
|
802
|
+
* @name aPBSSIDList
|
|
803
|
+
* @summary AP BSSID List
|
|
804
|
+
*
|
|
805
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
806
|
+
* @return {object} results - An object containing the response of the action
|
|
807
|
+
*
|
|
808
|
+
* @route {GET} /aPBSSIDList
|
|
809
|
+
* @roles admin
|
|
810
|
+
* @task true
|
|
811
|
+
*/
|
|
812
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
813
|
+
aPBSSIDList(callback) {
|
|
814
|
+
const meth = 'adapter-aPBSSIDList';
|
|
815
|
+
const origin = `${this.id}-${meth}`;
|
|
816
|
+
log.trace(origin);
|
|
817
|
+
|
|
818
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
819
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
820
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
821
|
+
return callback(null, errorObj);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
825
|
+
|
|
826
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
827
|
+
const queryParamsAvailable = {};
|
|
828
|
+
const queryParams = {};
|
|
829
|
+
const pathVars = [];
|
|
830
|
+
const bodyVars = {};
|
|
831
|
+
|
|
832
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
833
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
834
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
835
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
836
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
|
|
840
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
841
|
+
// see adapter code documentation for more information on the request object's fields
|
|
842
|
+
const reqObj = {
|
|
843
|
+
payload: bodyVars,
|
|
844
|
+
uriPathVars: pathVars,
|
|
845
|
+
uriQuery: queryParams
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
try {
|
|
849
|
+
// Make the call -
|
|
850
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
851
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'aPBSSIDList', reqObj, true, (irReturnData, irReturnError) => {
|
|
852
|
+
// if we received an error or their is no response on the results
|
|
853
|
+
// return an error
|
|
854
|
+
if (irReturnError) {
|
|
855
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
856
|
+
return callback(null, irReturnError);
|
|
857
|
+
}
|
|
858
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
859
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['aPBSSIDList'], null, null, null);
|
|
860
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
861
|
+
return callback(null, errorObj);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
865
|
+
// return the response
|
|
866
|
+
return callback(irReturnData, null);
|
|
867
|
+
});
|
|
868
|
+
} catch (ex) {
|
|
869
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
870
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
871
|
+
return callback(null, errorObj);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* @function aPDetail
|
|
877
|
+
* @pronghornType method
|
|
878
|
+
* @name aPDetail
|
|
879
|
+
* @summary AP Detail
|
|
880
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
881
|
+
* Can be a stringified Object.
|
|
882
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
883
|
+
* @return {object} results - An object containing the response of the action
|
|
884
|
+
*
|
|
885
|
+
* @route {GET} /aPDetail
|
|
886
|
+
* @roles admin
|
|
887
|
+
* @task true
|
|
888
|
+
*/
|
|
889
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
890
|
+
aPDetail(queryData, callback) {
|
|
891
|
+
const meth = 'adapter-aPDetail';
|
|
892
|
+
const origin = `${this.id}-${meth}`;
|
|
893
|
+
log.trace(origin);
|
|
894
|
+
|
|
895
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
896
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
897
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
898
|
+
return callback(null, errorObj);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
902
|
+
|
|
903
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
904
|
+
const queryParamsAvailable = queryData;
|
|
905
|
+
const queryParams = {};
|
|
906
|
+
const pathVars = [];
|
|
907
|
+
const bodyVars = {};
|
|
908
|
+
|
|
909
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
910
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
911
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
912
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
913
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
918
|
+
// see adapter code documentation for more information on the request object's fields
|
|
919
|
+
const reqObj = {
|
|
920
|
+
payload: bodyVars,
|
|
921
|
+
uriPathVars: pathVars,
|
|
922
|
+
uriQuery: queryParams
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
try {
|
|
926
|
+
// Make the call -
|
|
927
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
928
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'aPDetail', reqObj, true, (irReturnData, irReturnError) => {
|
|
929
|
+
// if we received an error or their is no response on the results
|
|
930
|
+
// return an error
|
|
931
|
+
if (irReturnError) {
|
|
932
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
933
|
+
return callback(null, irReturnError);
|
|
934
|
+
}
|
|
935
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
936
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['aPDetail'], null, null, null);
|
|
937
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
938
|
+
return callback(null, errorObj);
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
942
|
+
// return the response
|
|
943
|
+
return callback(irReturnData, null);
|
|
944
|
+
});
|
|
945
|
+
} catch (ex) {
|
|
946
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
947
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
948
|
+
return callback(null, errorObj);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* @function deleteDevice
|
|
954
|
+
* @pronghornType method
|
|
955
|
+
* @name deleteDevice
|
|
956
|
+
* @summary Device delete
|
|
957
|
+
* @param {Object} body - device id
|
|
958
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
959
|
+
* @return {object} results - An object containing the response of the action
|
|
960
|
+
*
|
|
961
|
+
* @route {DELETE} /deleteDevice
|
|
962
|
+
* @roles admin
|
|
963
|
+
* @task true
|
|
964
|
+
*/
|
|
965
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
966
|
+
deleteDevice(body, callback) {
|
|
967
|
+
const meth = 'adapter-deleteDevice';
|
|
968
|
+
const origin = `${this.id}-${meth}`;
|
|
969
|
+
log.trace(origin);
|
|
970
|
+
|
|
971
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
972
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
973
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
974
|
+
return callback(null, errorObj);
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
978
|
+
if (body === undefined || body === null || body === '') {
|
|
979
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
980
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
981
|
+
return callback(null, errorObj);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
985
|
+
const queryParamsAvailable = {};
|
|
986
|
+
const queryParams = {};
|
|
987
|
+
const pathVars = [];
|
|
988
|
+
const bodyVars = body;
|
|
989
|
+
|
|
990
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
991
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
992
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
993
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
994
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
999
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1000
|
+
const reqObj = {
|
|
1001
|
+
payload: bodyVars,
|
|
1002
|
+
uriPathVars: pathVars,
|
|
1003
|
+
uriQuery: queryParams
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
try {
|
|
1007
|
+
// Make the call -
|
|
1008
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1009
|
+
return this.requestHandlerInst.identifyRequest('DeviceAPIS', 'deleteDevice', reqObj, true, (irReturnData, irReturnError) => {
|
|
1010
|
+
// if we received an error or their is no response on the results
|
|
1011
|
+
// return an error
|
|
1012
|
+
if (irReturnError) {
|
|
1013
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1014
|
+
return callback(null, irReturnError);
|
|
1015
|
+
}
|
|
1016
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1017
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteDevice'], null, null, null);
|
|
1018
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1019
|
+
return callback(null, errorObj);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1023
|
+
// return the response
|
|
1024
|
+
return callback(irReturnData, null);
|
|
1025
|
+
});
|
|
1026
|
+
} catch (ex) {
|
|
1027
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1028
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1029
|
+
return callback(null, errorObj);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* @function moveDeviceToFolder
|
|
1035
|
+
* @pronghornType method
|
|
1036
|
+
* @name moveDeviceToFolder
|
|
1037
|
+
* @summary Move device
|
|
1038
|
+
* @param {Object} body - device id and folder id
|
|
1039
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1040
|
+
* @return {object} results - An object containing the response of the action
|
|
1041
|
+
*
|
|
1042
|
+
* @route {PUT} /moveDeviceToFolder
|
|
1043
|
+
* @roles admin
|
|
1044
|
+
* @task true
|
|
1045
|
+
*/
|
|
1046
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1047
|
+
moveDeviceToFolder(body, callback) {
|
|
1048
|
+
const meth = 'adapter-moveDeviceToFolder';
|
|
1049
|
+
const origin = `${this.id}-${meth}`;
|
|
1050
|
+
log.trace(origin);
|
|
1051
|
+
|
|
1052
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1053
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1054
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1055
|
+
return callback(null, errorObj);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1059
|
+
if (body === undefined || body === null || body === '') {
|
|
1060
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1061
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1062
|
+
return callback(null, errorObj);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1066
|
+
const queryParamsAvailable = {};
|
|
1067
|
+
const queryParams = {};
|
|
1068
|
+
const pathVars = [];
|
|
1069
|
+
const bodyVars = body;
|
|
1070
|
+
|
|
1071
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1072
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1073
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1074
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1075
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1080
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1081
|
+
const reqObj = {
|
|
1082
|
+
payload: bodyVars,
|
|
1083
|
+
uriPathVars: pathVars,
|
|
1084
|
+
uriQuery: queryParams
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
try {
|
|
1088
|
+
// Make the call -
|
|
1089
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1090
|
+
return this.requestHandlerInst.identifyRequest('DeviceAPIS', 'moveDeviceToFolder', reqObj, true, (irReturnData, irReturnError) => {
|
|
1091
|
+
// if we received an error or their is no response on the results
|
|
1092
|
+
// return an error
|
|
1093
|
+
if (irReturnError) {
|
|
1094
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1095
|
+
return callback(null, irReturnError);
|
|
1096
|
+
}
|
|
1097
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1098
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['moveDeviceToFolder'], null, null, null);
|
|
1099
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1100
|
+
return callback(null, errorObj);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1104
|
+
// return the response
|
|
1105
|
+
return callback(irReturnData, null);
|
|
1106
|
+
});
|
|
1107
|
+
} catch (ex) {
|
|
1108
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1109
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1110
|
+
return callback(null, errorObj);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* @function aPLog
|
|
1116
|
+
* @pronghornType method
|
|
1117
|
+
* @name aPLog
|
|
1118
|
+
* @summary AP Log
|
|
1119
|
+
*
|
|
1120
|
+
* @param {number} id - id param
|
|
1121
|
+
* @param {number} limit - limit param
|
|
1122
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1123
|
+
* @return {object} results - An object containing the response of the action
|
|
1124
|
+
*
|
|
1125
|
+
* @route {POST} /aPLog
|
|
1126
|
+
* @roles admin
|
|
1127
|
+
* @task true
|
|
1128
|
+
*/
|
|
1129
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1130
|
+
aPLog(id, limit, callback) {
|
|
1131
|
+
const meth = 'adapter-aPLog';
|
|
1132
|
+
const origin = `${this.id}-${meth}`;
|
|
1133
|
+
log.trace(origin);
|
|
1134
|
+
|
|
1135
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1136
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1137
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1138
|
+
return callback(null, errorObj);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1142
|
+
if (id === undefined || id === null || id === '') {
|
|
1143
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
1144
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1145
|
+
return callback(null, errorObj);
|
|
1146
|
+
}
|
|
1147
|
+
if (limit === undefined || limit === null || limit === '') {
|
|
1148
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['limit'], null, null, null);
|
|
1149
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1150
|
+
return callback(null, errorObj);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1154
|
+
const queryParamsAvailable = { id, limit };
|
|
1155
|
+
const queryParams = {};
|
|
1156
|
+
const pathVars = [];
|
|
1157
|
+
const bodyVars = {};
|
|
1158
|
+
|
|
1159
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1160
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1161
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1162
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1163
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1168
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1169
|
+
const reqObj = {
|
|
1170
|
+
payload: bodyVars,
|
|
1171
|
+
uriPathVars: pathVars,
|
|
1172
|
+
uriQuery: queryParams
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
try {
|
|
1176
|
+
// Make the call -
|
|
1177
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1178
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'aPLog', reqObj, true, (irReturnData, irReturnError) => {
|
|
1179
|
+
// if we received an error or their is no response on the results
|
|
1180
|
+
// return an error
|
|
1181
|
+
if (irReturnError) {
|
|
1182
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1183
|
+
return callback(null, irReturnError);
|
|
1184
|
+
}
|
|
1185
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1186
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['aPLog'], null, null, null);
|
|
1187
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1188
|
+
return callback(null, errorObj);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1192
|
+
// return the response
|
|
1193
|
+
return callback(irReturnData, null);
|
|
1194
|
+
});
|
|
1195
|
+
} catch (ex) {
|
|
1196
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1197
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1198
|
+
return callback(null, errorObj);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* @function rogueDetail
|
|
1204
|
+
* @pronghornType method
|
|
1205
|
+
* @name rogueDetail
|
|
1206
|
+
* @summary Rogue Detail
|
|
1207
|
+
*
|
|
1208
|
+
* @param {number} id - id param
|
|
1209
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1210
|
+
* @return {object} results - An object containing the response of the action
|
|
1211
|
+
*
|
|
1212
|
+
* @route {POST} /rogueDetail
|
|
1213
|
+
* @roles admin
|
|
1214
|
+
* @task true
|
|
1215
|
+
*/
|
|
1216
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1217
|
+
rogueDetail(id, callback) {
|
|
1218
|
+
const meth = 'adapter-rogueDetail';
|
|
1219
|
+
const origin = `${this.id}-${meth}`;
|
|
1220
|
+
log.trace(origin);
|
|
1221
|
+
|
|
1222
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1223
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1224
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1225
|
+
return callback(null, errorObj);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1229
|
+
if (id === undefined || id === null || id === '') {
|
|
1230
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
1231
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1232
|
+
return callback(null, errorObj);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1236
|
+
const queryParamsAvailable = { id };
|
|
1237
|
+
const queryParams = {};
|
|
1238
|
+
const pathVars = [];
|
|
1239
|
+
const bodyVars = {};
|
|
1240
|
+
|
|
1241
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1242
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1243
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1244
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1245
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1250
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1251
|
+
const reqObj = {
|
|
1252
|
+
payload: bodyVars,
|
|
1253
|
+
uriPathVars: pathVars,
|
|
1254
|
+
uriQuery: queryParams
|
|
1255
|
+
};
|
|
1256
|
+
|
|
1257
|
+
try {
|
|
1258
|
+
// Make the call -
|
|
1259
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1260
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'rogueDetail', reqObj, true, (irReturnData, irReturnError) => {
|
|
1261
|
+
// if we received an error or their is no response on the results
|
|
1262
|
+
// return an error
|
|
1263
|
+
if (irReturnError) {
|
|
1264
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1265
|
+
return callback(null, irReturnError);
|
|
1266
|
+
}
|
|
1267
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1268
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['rogueDetail'], null, null, null);
|
|
1269
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1270
|
+
return callback(null, errorObj);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1274
|
+
// return the response
|
|
1275
|
+
return callback(irReturnData, null);
|
|
1276
|
+
});
|
|
1277
|
+
} catch (ex) {
|
|
1278
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1279
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1280
|
+
return callback(null, errorObj);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* @function clientDetail
|
|
1286
|
+
* @pronghornType method
|
|
1287
|
+
* @name clientDetail
|
|
1288
|
+
* @summary Client Detail
|
|
1289
|
+
*
|
|
1290
|
+
* @param {string} mac - mac param
|
|
1291
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1292
|
+
* @return {object} results - An object containing the response of the action
|
|
1293
|
+
*
|
|
1294
|
+
* @route {POST} /clientDetail
|
|
1295
|
+
* @roles admin
|
|
1296
|
+
* @task true
|
|
1297
|
+
*/
|
|
1298
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1299
|
+
clientDetail(mac, callback) {
|
|
1300
|
+
const meth = 'adapter-clientDetail';
|
|
1301
|
+
const origin = `${this.id}-${meth}`;
|
|
1302
|
+
log.trace(origin);
|
|
1303
|
+
|
|
1304
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1305
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1306
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1307
|
+
return callback(null, errorObj);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1311
|
+
if (mac === undefined || mac === null || mac === '') {
|
|
1312
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['mac'], null, null, null);
|
|
1313
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1314
|
+
return callback(null, errorObj);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1318
|
+
const queryParamsAvailable = { mac };
|
|
1319
|
+
const queryParams = {};
|
|
1320
|
+
const pathVars = [];
|
|
1321
|
+
const bodyVars = {};
|
|
1322
|
+
|
|
1323
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1324
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1325
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1326
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1327
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
|
|
1331
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1332
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1333
|
+
const reqObj = {
|
|
1334
|
+
payload: bodyVars,
|
|
1335
|
+
uriPathVars: pathVars,
|
|
1336
|
+
uriQuery: queryParams
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
try {
|
|
1340
|
+
// Make the call -
|
|
1341
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1342
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'clientDetail', reqObj, true, (irReturnData, irReturnError) => {
|
|
1343
|
+
// if we received an error or their is no response on the results
|
|
1344
|
+
// return an error
|
|
1345
|
+
if (irReturnError) {
|
|
1346
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1347
|
+
return callback(null, irReturnError);
|
|
1348
|
+
}
|
|
1349
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1350
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['clientDetail'], null, null, null);
|
|
1351
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1352
|
+
return callback(null, errorObj);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1356
|
+
// return the response
|
|
1357
|
+
return callback(irReturnData, null);
|
|
1358
|
+
});
|
|
1359
|
+
} catch (ex) {
|
|
1360
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1361
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1362
|
+
return callback(null, errorObj);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* @function visualRFConfig
|
|
1368
|
+
* @pronghornType method
|
|
1369
|
+
* @name visualRFConfig
|
|
1370
|
+
* @summary VisualRF Config
|
|
1371
|
+
*
|
|
1372
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1373
|
+
* @return {object} results - An object containing the response of the action
|
|
1374
|
+
*
|
|
1375
|
+
* @route {GET} /visualRFConfig
|
|
1376
|
+
* @roles admin
|
|
1377
|
+
* @task true
|
|
1378
|
+
*/
|
|
1379
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1380
|
+
visualRFConfig(callback) {
|
|
1381
|
+
const meth = 'adapter-visualRFConfig';
|
|
1382
|
+
const origin = `${this.id}-${meth}`;
|
|
1383
|
+
log.trace(origin);
|
|
1384
|
+
|
|
1385
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1386
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1387
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1388
|
+
return callback(null, errorObj);
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1392
|
+
|
|
1393
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1394
|
+
const queryParamsAvailable = {};
|
|
1395
|
+
const queryParams = {};
|
|
1396
|
+
const pathVars = [];
|
|
1397
|
+
const bodyVars = {};
|
|
1398
|
+
|
|
1399
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1400
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1401
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1402
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1403
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
|
|
1407
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1408
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1409
|
+
const reqObj = {
|
|
1410
|
+
payload: bodyVars,
|
|
1411
|
+
uriPathVars: pathVars,
|
|
1412
|
+
uriQuery: queryParams
|
|
1413
|
+
};
|
|
1414
|
+
|
|
1415
|
+
try {
|
|
1416
|
+
// Make the call -
|
|
1417
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1418
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'visualRFConfig', reqObj, true, (irReturnData, irReturnError) => {
|
|
1419
|
+
// if we received an error or their is no response on the results
|
|
1420
|
+
// return an error
|
|
1421
|
+
if (irReturnError) {
|
|
1422
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1423
|
+
return callback(null, irReturnError);
|
|
1424
|
+
}
|
|
1425
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1426
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['visualRFConfig'], null, null, null);
|
|
1427
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1428
|
+
return callback(null, errorObj);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1432
|
+
// return the response
|
|
1433
|
+
return callback(irReturnData, null);
|
|
1434
|
+
});
|
|
1435
|
+
} catch (ex) {
|
|
1436
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1437
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1438
|
+
return callback(null, errorObj);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* @function userInfo
|
|
1444
|
+
* @pronghornType method
|
|
1445
|
+
* @name userInfo
|
|
1446
|
+
* @summary User Info
|
|
1447
|
+
*
|
|
1448
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1449
|
+
* @return {object} results - An object containing the response of the action
|
|
1450
|
+
*
|
|
1451
|
+
* @route {GET} /userInfo
|
|
1452
|
+
* @roles admin
|
|
1453
|
+
* @task true
|
|
1454
|
+
*/
|
|
1455
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1456
|
+
userInfo(callback) {
|
|
1457
|
+
const meth = 'adapter-userInfo';
|
|
1458
|
+
const origin = `${this.id}-${meth}`;
|
|
1459
|
+
log.trace(origin);
|
|
1460
|
+
|
|
1461
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1462
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1463
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1464
|
+
return callback(null, errorObj);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1468
|
+
|
|
1469
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1470
|
+
const queryParamsAvailable = {};
|
|
1471
|
+
const queryParams = {};
|
|
1472
|
+
const pathVars = [];
|
|
1473
|
+
const bodyVars = {};
|
|
1474
|
+
|
|
1475
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1476
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1477
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1478
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1479
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
|
|
1483
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1484
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1485
|
+
const reqObj = {
|
|
1486
|
+
payload: bodyVars,
|
|
1487
|
+
uriPathVars: pathVars,
|
|
1488
|
+
uriQuery: queryParams
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
try {
|
|
1492
|
+
// Make the call -
|
|
1493
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1494
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'userInfo', reqObj, true, (irReturnData, irReturnError) => {
|
|
1495
|
+
// if we received an error or their is no response on the results
|
|
1496
|
+
// return an error
|
|
1497
|
+
if (irReturnError) {
|
|
1498
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1499
|
+
return callback(null, irReturnError);
|
|
1500
|
+
}
|
|
1501
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1502
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['userInfo'], null, null, null);
|
|
1503
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1504
|
+
return callback(null, errorObj);
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1508
|
+
// return the response
|
|
1509
|
+
return callback(irReturnData, null);
|
|
1510
|
+
});
|
|
1511
|
+
} catch (ex) {
|
|
1512
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1513
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1514
|
+
return callback(null, errorObj);
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* @function deviceRRDInfo
|
|
1520
|
+
* @pronghornType method
|
|
1521
|
+
* @name deviceRRDInfo
|
|
1522
|
+
* @summary Device RRD Info
|
|
1523
|
+
*
|
|
1524
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1525
|
+
* @return {object} results - An object containing the response of the action
|
|
1526
|
+
*
|
|
1527
|
+
* @route {GET} /deviceRRDInfo
|
|
1528
|
+
* @roles admin
|
|
1529
|
+
* @task true
|
|
1530
|
+
*/
|
|
1531
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1532
|
+
deviceRRDInfo(callback) {
|
|
1533
|
+
const meth = 'adapter-deviceRRDInfo';
|
|
1534
|
+
const origin = `${this.id}-${meth}`;
|
|
1535
|
+
log.trace(origin);
|
|
1536
|
+
|
|
1537
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1538
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1539
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1540
|
+
return callback(null, errorObj);
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1544
|
+
|
|
1545
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1546
|
+
const queryParamsAvailable = {};
|
|
1547
|
+
const queryParams = {};
|
|
1548
|
+
const pathVars = [];
|
|
1549
|
+
const bodyVars = {};
|
|
1550
|
+
|
|
1551
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1552
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1553
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1554
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1555
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1556
|
+
}
|
|
1557
|
+
});
|
|
1558
|
+
|
|
1559
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1560
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1561
|
+
const reqObj = {
|
|
1562
|
+
payload: bodyVars,
|
|
1563
|
+
uriPathVars: pathVars,
|
|
1564
|
+
uriQuery: queryParams
|
|
1565
|
+
};
|
|
1566
|
+
|
|
1567
|
+
try {
|
|
1568
|
+
// Make the call -
|
|
1569
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1570
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'deviceRRDInfo', reqObj, true, (irReturnData, irReturnError) => {
|
|
1571
|
+
// if we received an error or their is no response on the results
|
|
1572
|
+
// return an error
|
|
1573
|
+
if (irReturnError) {
|
|
1574
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1575
|
+
return callback(null, irReturnError);
|
|
1576
|
+
}
|
|
1577
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1578
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deviceRRDInfo'], null, null, null);
|
|
1579
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1580
|
+
return callback(null, errorObj);
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1584
|
+
// return the response
|
|
1585
|
+
return callback(irReturnData, null);
|
|
1586
|
+
});
|
|
1587
|
+
} catch (ex) {
|
|
1588
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1589
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1590
|
+
return callback(null, errorObj);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* @function clientRRDInfo
|
|
1596
|
+
* @pronghornType method
|
|
1597
|
+
* @name clientRRDInfo
|
|
1598
|
+
* @summary Client RRD Info
|
|
1599
|
+
*
|
|
1600
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1601
|
+
* @return {object} results - An object containing the response of the action
|
|
1602
|
+
*
|
|
1603
|
+
* @route {GET} /clientRRDInfo
|
|
1604
|
+
* @roles admin
|
|
1605
|
+
* @task true
|
|
1606
|
+
*/
|
|
1607
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1608
|
+
clientRRDInfo(callback) {
|
|
1609
|
+
const meth = 'adapter-clientRRDInfo';
|
|
1610
|
+
const origin = `${this.id}-${meth}`;
|
|
1611
|
+
log.trace(origin);
|
|
1612
|
+
|
|
1613
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1614
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1615
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1616
|
+
return callback(null, errorObj);
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1620
|
+
|
|
1621
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1622
|
+
const queryParamsAvailable = {};
|
|
1623
|
+
const queryParams = {};
|
|
1624
|
+
const pathVars = [];
|
|
1625
|
+
const bodyVars = {};
|
|
1626
|
+
|
|
1627
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1628
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1629
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1630
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1631
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
|
|
1635
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1636
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1637
|
+
const reqObj = {
|
|
1638
|
+
payload: bodyVars,
|
|
1639
|
+
uriPathVars: pathVars,
|
|
1640
|
+
uriQuery: queryParams
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
try {
|
|
1644
|
+
// Make the call -
|
|
1645
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1646
|
+
return this.requestHandlerInst.identifyRequest('QueryAPIS', 'clientRRDInfo', reqObj, true, (irReturnData, irReturnError) => {
|
|
1647
|
+
// if we received an error or their is no response on the results
|
|
1648
|
+
// return an error
|
|
1649
|
+
if (irReturnError) {
|
|
1650
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1651
|
+
return callback(null, irReturnError);
|
|
1652
|
+
}
|
|
1653
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1654
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['clientRRDInfo'], null, null, null);
|
|
1655
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1656
|
+
return callback(null, errorObj);
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1660
|
+
// return the response
|
|
1661
|
+
return callback(irReturnData, null);
|
|
1662
|
+
});
|
|
1663
|
+
} catch (ex) {
|
|
1664
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1665
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1666
|
+
return callback(null, errorObj);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
* @function changeSet
|
|
1672
|
+
* @pronghornType method
|
|
1673
|
+
* @name changeSet
|
|
1674
|
+
* @summary Change Set
|
|
1675
|
+
*
|
|
1676
|
+
* @param {object} body - body param
|
|
1677
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1678
|
+
* @return {object} results - An object containing the response of the action
|
|
1679
|
+
*
|
|
1680
|
+
* @route {POST} /changeSet
|
|
1681
|
+
* @roles admin
|
|
1682
|
+
* @task true
|
|
1683
|
+
*/
|
|
1684
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1685
|
+
changeSet(body, callback) {
|
|
1686
|
+
const meth = 'adapter-changeSet';
|
|
1687
|
+
const origin = `${this.id}-${meth}`;
|
|
1688
|
+
log.trace(origin);
|
|
1689
|
+
|
|
1690
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1691
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1692
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1693
|
+
return callback(null, errorObj);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1697
|
+
if (body === undefined || body === null || body === '') {
|
|
1698
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1699
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1700
|
+
return callback(null, errorObj);
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1704
|
+
const queryParamsAvailable = {};
|
|
1705
|
+
const queryParams = {};
|
|
1706
|
+
const pathVars = [];
|
|
1707
|
+
const bodyVars = body;
|
|
1708
|
+
|
|
1709
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1710
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1711
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1712
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1713
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
|
|
1717
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
1718
|
+
let thisHeaderData = null;
|
|
1719
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
1720
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
1721
|
+
try {
|
|
1722
|
+
// parse the additional headers object that was passed in
|
|
1723
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
1724
|
+
} catch (err) {
|
|
1725
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
1726
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1727
|
+
return callback(null, errorObj);
|
|
1728
|
+
}
|
|
1729
|
+
} else if (thisHeaderData === null) {
|
|
1730
|
+
thisHeaderData = { contentType: '', xBISCOTTI: '' };
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1734
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1735
|
+
const reqObj = {
|
|
1736
|
+
payload: bodyVars,
|
|
1737
|
+
uriPathVars: pathVars,
|
|
1738
|
+
uriQuery: queryParams,
|
|
1739
|
+
addlHeaders: thisHeaderData
|
|
1740
|
+
};
|
|
1741
|
+
|
|
1742
|
+
try {
|
|
1743
|
+
// Make the call -
|
|
1744
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1745
|
+
return this.requestHandlerInst.identifyRequest('ConfigurationAPIS', 'changeSet', reqObj, true, (irReturnData, irReturnError) => {
|
|
1746
|
+
// if we received an error or their is no response on the results
|
|
1747
|
+
// return an error
|
|
1748
|
+
if (irReturnError) {
|
|
1749
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1750
|
+
return callback(null, irReturnError);
|
|
1751
|
+
}
|
|
1752
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1753
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['changeSet'], null, null, null);
|
|
1754
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1755
|
+
return callback(null, errorObj);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1759
|
+
// return the response
|
|
1760
|
+
return callback(irReturnData, null);
|
|
1761
|
+
});
|
|
1762
|
+
} catch (ex) {
|
|
1763
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1764
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1765
|
+
return callback(null, errorObj);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* @function guestUserCreateUser
|
|
1771
|
+
* @pronghornType method
|
|
1772
|
+
* @name guestUserCreateUser
|
|
1773
|
+
* @summary Guest User: Create User
|
|
1774
|
+
*
|
|
1775
|
+
* @param {string} bodyFormData - bodyFormData param
|
|
1776
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1777
|
+
* @return {object} results - An object containing the response of the action
|
|
1778
|
+
*
|
|
1779
|
+
* @route {POST} /guestUserCreateUser
|
|
1780
|
+
* @roles admin
|
|
1781
|
+
* @task true
|
|
1782
|
+
*/
|
|
1783
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1784
|
+
guestUserCreateUser(bodyFormData, callback) {
|
|
1785
|
+
const meth = 'adapter-guestUserCreateUser';
|
|
1786
|
+
const origin = `${this.id}-${meth}`;
|
|
1787
|
+
log.trace(origin);
|
|
1788
|
+
|
|
1789
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1790
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1791
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1792
|
+
return callback(null, errorObj);
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1796
|
+
if (bodyFormData === undefined || bodyFormData === null || bodyFormData === '') {
|
|
1797
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['bodyFormData'], null, null, null);
|
|
1798
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1799
|
+
return callback(null, errorObj);
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1803
|
+
const queryParamsAvailable = {};
|
|
1804
|
+
const queryParams = {};
|
|
1805
|
+
const pathVars = [];
|
|
1806
|
+
const bodyVars = {};
|
|
1807
|
+
|
|
1808
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1809
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1810
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1811
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1812
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
|
|
1816
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
1817
|
+
let thisHeaderData = null;
|
|
1818
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
1819
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
1820
|
+
try {
|
|
1821
|
+
// parse the additional headers object that was passed in
|
|
1822
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
1823
|
+
} catch (err) {
|
|
1824
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
1825
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1826
|
+
return callback(null, errorObj);
|
|
1827
|
+
}
|
|
1828
|
+
} else if (thisHeaderData === null) {
|
|
1829
|
+
thisHeaderData = { xBISCOTTI: '' };
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1833
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1834
|
+
const reqObj = {
|
|
1835
|
+
payload: bodyVars,
|
|
1836
|
+
uriPathVars: pathVars,
|
|
1837
|
+
uriQuery: queryParams,
|
|
1838
|
+
addlHeaders: thisHeaderData
|
|
1839
|
+
};
|
|
1840
|
+
|
|
1841
|
+
try {
|
|
1842
|
+
// Make the call -
|
|
1843
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1844
|
+
return this.requestHandlerInst.identifyRequest('ConfigurationAPIS', 'guestUserCreateUser', reqObj, true, (irReturnData, irReturnError) => {
|
|
1845
|
+
// if we received an error or their is no response on the results
|
|
1846
|
+
// return an error
|
|
1847
|
+
if (irReturnError) {
|
|
1848
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1849
|
+
return callback(null, irReturnError);
|
|
1850
|
+
}
|
|
1851
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1852
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['guestUserCreateUser'], null, null, null);
|
|
1853
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1854
|
+
return callback(null, errorObj);
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1858
|
+
// return the response
|
|
1859
|
+
return callback(irReturnData, null);
|
|
1860
|
+
});
|
|
1861
|
+
} catch (ex) {
|
|
1862
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1863
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1864
|
+
return callback(null, errorObj);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
/**
|
|
1869
|
+
* @function modifyTemplateVariables
|
|
1870
|
+
* @pronghornType method
|
|
1871
|
+
* @name modifyTemplateVariables
|
|
1872
|
+
* @summary Modify Template Variables
|
|
1873
|
+
*
|
|
1874
|
+
* @param {object} body - body param
|
|
1875
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1876
|
+
* @return {object} results - An object containing the response of the action
|
|
1877
|
+
*
|
|
1878
|
+
* @route {POST} /modifyTemplateVariables
|
|
1879
|
+
* @roles admin
|
|
1880
|
+
* @task true
|
|
1881
|
+
*/
|
|
1882
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1883
|
+
modifyTemplateVariables(body, callback) {
|
|
1884
|
+
const meth = 'adapter-modifyTemplateVariables';
|
|
1885
|
+
const origin = `${this.id}-${meth}`;
|
|
1886
|
+
log.trace(origin);
|
|
1887
|
+
|
|
1888
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1889
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1890
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1891
|
+
return callback(null, errorObj);
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1895
|
+
if (body === undefined || body === null || body === '') {
|
|
1896
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1897
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1898
|
+
return callback(null, errorObj);
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1902
|
+
const queryParamsAvailable = {};
|
|
1903
|
+
const queryParams = {};
|
|
1904
|
+
const pathVars = [];
|
|
1905
|
+
const bodyVars = body;
|
|
1906
|
+
|
|
1907
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1908
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1909
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1910
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1911
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1912
|
+
}
|
|
1913
|
+
});
|
|
1914
|
+
|
|
1915
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
1916
|
+
let thisHeaderData = null;
|
|
1917
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
1918
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
1919
|
+
try {
|
|
1920
|
+
// parse the additional headers object that was passed in
|
|
1921
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
1922
|
+
} catch (err) {
|
|
1923
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
1924
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1925
|
+
return callback(null, errorObj);
|
|
1926
|
+
}
|
|
1927
|
+
} else if (thisHeaderData === null) {
|
|
1928
|
+
thisHeaderData = { contentType: '', xBISCOTTI: '' };
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1932
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1933
|
+
const reqObj = {
|
|
1934
|
+
payload: bodyVars,
|
|
1935
|
+
uriPathVars: pathVars,
|
|
1936
|
+
uriQuery: queryParams,
|
|
1937
|
+
addlHeaders: thisHeaderData
|
|
1938
|
+
};
|
|
1939
|
+
|
|
1940
|
+
try {
|
|
1941
|
+
// Make the call -
|
|
1942
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1943
|
+
return this.requestHandlerInst.identifyRequest('ConfigurationAPIS', 'modifyTemplateVariables', reqObj, true, (irReturnData, irReturnError) => {
|
|
1944
|
+
// if we received an error or their is no response on the results
|
|
1945
|
+
// return an error
|
|
1946
|
+
if (irReturnError) {
|
|
1947
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1948
|
+
return callback(null, irReturnError);
|
|
1949
|
+
}
|
|
1950
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1951
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['modifyTemplateVariables'], null, null, null);
|
|
1952
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1953
|
+
return callback(null, errorObj);
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1957
|
+
// return the response
|
|
1958
|
+
return callback(irReturnData, null);
|
|
1959
|
+
});
|
|
1960
|
+
} catch (ex) {
|
|
1961
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1962
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1963
|
+
return callback(null, errorObj);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* @function importAPWhitelist
|
|
1969
|
+
* @pronghornType method
|
|
1970
|
+
* @name importAPWhitelist
|
|
1971
|
+
* @summary Import AP Whitelist
|
|
1972
|
+
*
|
|
1973
|
+
* @param {number} appendWhitelist - appendWhitelist param
|
|
1974
|
+
* @param {string} body - body param
|
|
1975
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1976
|
+
* @return {object} results - An object containing the response of the action
|
|
1977
|
+
*
|
|
1978
|
+
* @route {POST} /importAPWhitelist
|
|
1979
|
+
* @roles admin
|
|
1980
|
+
* @task true
|
|
1981
|
+
*/
|
|
1982
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1983
|
+
importAPWhitelist(appendWhitelist, body, callback) {
|
|
1984
|
+
const meth = 'adapter-importAPWhitelist';
|
|
1985
|
+
const origin = `${this.id}-${meth}`;
|
|
1986
|
+
log.trace(origin);
|
|
1987
|
+
|
|
1988
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1989
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1990
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1991
|
+
return callback(null, errorObj);
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1995
|
+
if (appendWhitelist === undefined || appendWhitelist === null || appendWhitelist === '') {
|
|
1996
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['appendWhitelist'], null, null, null);
|
|
1997
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1998
|
+
return callback(null, errorObj);
|
|
1999
|
+
}
|
|
2000
|
+
if (body === undefined || body === null || body === '') {
|
|
2001
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
2002
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2003
|
+
return callback(null, errorObj);
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2007
|
+
const queryParamsAvailable = { appendWhitelist };
|
|
2008
|
+
const queryParams = {};
|
|
2009
|
+
const pathVars = [];
|
|
2010
|
+
const bodyVars = { body };
|
|
2011
|
+
|
|
2012
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2013
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2014
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2015
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2016
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2017
|
+
}
|
|
2018
|
+
});
|
|
2019
|
+
|
|
2020
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
2021
|
+
let thisHeaderData = null;
|
|
2022
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
2023
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
2024
|
+
try {
|
|
2025
|
+
// parse the additional headers object that was passed in
|
|
2026
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
2027
|
+
} catch (err) {
|
|
2028
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
2029
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2030
|
+
return callback(null, errorObj);
|
|
2031
|
+
}
|
|
2032
|
+
} else if (thisHeaderData === null) {
|
|
2033
|
+
thisHeaderData = { contentType: '', xBISCOTTI: '' };
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2037
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2038
|
+
const reqObj = {
|
|
2039
|
+
payload: bodyVars,
|
|
2040
|
+
uriPathVars: pathVars,
|
|
2041
|
+
uriQuery: queryParams,
|
|
2042
|
+
addlHeaders: thisHeaderData
|
|
2043
|
+
};
|
|
2044
|
+
|
|
2045
|
+
try {
|
|
2046
|
+
// Make the call -
|
|
2047
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2048
|
+
return this.requestHandlerInst.identifyRequest('ConfigurationAPIS', 'importAPWhitelist', reqObj, true, (irReturnData, irReturnError) => {
|
|
2049
|
+
// if we received an error or their is no response on the results
|
|
2050
|
+
// return an error
|
|
2051
|
+
if (irReturnError) {
|
|
2052
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2053
|
+
return callback(null, irReturnError);
|
|
2054
|
+
}
|
|
2055
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2056
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['importAPWhitelist'], null, null, null);
|
|
2057
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2058
|
+
return callback(null, errorObj);
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2062
|
+
// return the response
|
|
2063
|
+
return callback(irReturnData, null);
|
|
2064
|
+
});
|
|
2065
|
+
} catch (ex) {
|
|
2066
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2067
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2068
|
+
return callback(null, errorObj);
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
/**
|
|
2073
|
+
* @function deauthenticateClient
|
|
2074
|
+
* @pronghornType method
|
|
2075
|
+
* @name deauthenticateClient
|
|
2076
|
+
* @summary Deauthenticate Client
|
|
2077
|
+
*
|
|
2078
|
+
* @param {string} mac - mac param
|
|
2079
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2080
|
+
* @return {object} results - An object containing the response of the action
|
|
2081
|
+
*
|
|
2082
|
+
* @route {POST} /deauthenticateClient
|
|
2083
|
+
* @roles admin
|
|
2084
|
+
* @task true
|
|
2085
|
+
*/
|
|
2086
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2087
|
+
deauthenticateClient(mac, callback) {
|
|
2088
|
+
const meth = 'adapter-deauthenticateClient';
|
|
2089
|
+
const origin = `${this.id}-${meth}`;
|
|
2090
|
+
log.trace(origin);
|
|
2091
|
+
|
|
2092
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2093
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2094
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2095
|
+
return callback(null, errorObj);
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2099
|
+
if (mac === undefined || mac === null || mac === '') {
|
|
2100
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['mac'], null, null, null);
|
|
2101
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2102
|
+
return callback(null, errorObj);
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2106
|
+
const queryParamsAvailable = { mac };
|
|
2107
|
+
const queryParams = {};
|
|
2108
|
+
const pathVars = [];
|
|
2109
|
+
const bodyVars = {};
|
|
2110
|
+
|
|
2111
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2112
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2113
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2114
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2115
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
|
|
2119
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2120
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2121
|
+
const reqObj = {
|
|
2122
|
+
payload: bodyVars,
|
|
2123
|
+
uriPathVars: pathVars,
|
|
2124
|
+
uriQuery: queryParams
|
|
2125
|
+
};
|
|
2126
|
+
|
|
2127
|
+
try {
|
|
2128
|
+
// Make the call -
|
|
2129
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2130
|
+
return this.requestHandlerInst.identifyRequest('ConfigurationAPIS', 'deauthenticateClient', reqObj, true, (irReturnData, irReturnError) => {
|
|
2131
|
+
// if we received an error or their is no response on the results
|
|
2132
|
+
// return an error
|
|
2133
|
+
if (irReturnError) {
|
|
2134
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2135
|
+
return callback(null, irReturnError);
|
|
2136
|
+
}
|
|
2137
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2138
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deauthenticateClient'], null, null, null);
|
|
2139
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2140
|
+
return callback(null, errorObj);
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2144
|
+
// return the response
|
|
2145
|
+
return callback(irReturnData, null);
|
|
2146
|
+
});
|
|
2147
|
+
} catch (ex) {
|
|
2148
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2149
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2150
|
+
return callback(null, errorObj);
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
/**
|
|
2155
|
+
* @function downStatusMessage
|
|
2156
|
+
* @pronghornType method
|
|
2157
|
+
* @name downStatusMessage
|
|
2158
|
+
* @summary Down Status Message
|
|
2159
|
+
*
|
|
2160
|
+
* @param {number} apId - apId param
|
|
2161
|
+
* @param {number} apGroupId - apGroupId param
|
|
2162
|
+
* @param {string} downStatusMessage - downStatusMessage param
|
|
2163
|
+
* @param {number} autoClearDownStatusMessage - autoClearDownStatusMessage param
|
|
2164
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2165
|
+
* @return {object} results - An object containing the response of the action
|
|
2166
|
+
*
|
|
2167
|
+
* @route {POST} /downStatusMessage
|
|
2168
|
+
* @roles admin
|
|
2169
|
+
* @task true
|
|
2170
|
+
*/
|
|
2171
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2172
|
+
downStatusMessage(apId, apGroupId, downStatusMessage, autoClearDownStatusMessage, callback) {
|
|
2173
|
+
const meth = 'adapter-downStatusMessage';
|
|
2174
|
+
const origin = `${this.id}-${meth}`;
|
|
2175
|
+
log.trace(origin);
|
|
2176
|
+
|
|
2177
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2178
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2179
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2180
|
+
return callback(null, errorObj);
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2184
|
+
if (apId === undefined || apId === null || apId === '') {
|
|
2185
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apId'], null, null, null);
|
|
2186
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2187
|
+
return callback(null, errorObj);
|
|
2188
|
+
}
|
|
2189
|
+
if (apGroupId === undefined || apGroupId === null || apGroupId === '') {
|
|
2190
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apGroupId'], null, null, null);
|
|
2191
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2192
|
+
return callback(null, errorObj);
|
|
2193
|
+
}
|
|
2194
|
+
if (downStatusMessage === undefined || downStatusMessage === null || downStatusMessage === '') {
|
|
2195
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['downStatusMessage'], null, null, null);
|
|
2196
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2197
|
+
return callback(null, errorObj);
|
|
2198
|
+
}
|
|
2199
|
+
if (autoClearDownStatusMessage === undefined || autoClearDownStatusMessage === null || autoClearDownStatusMessage === '') {
|
|
2200
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['autoClearDownStatusMessage'], null, null, null);
|
|
2201
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2202
|
+
return callback(null, errorObj);
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2206
|
+
const queryParamsAvailable = { apId, apGroupId, downStatusMessage, autoClearDownStatusMessage };
|
|
2207
|
+
const queryParams = {};
|
|
2208
|
+
const pathVars = [];
|
|
2209
|
+
const bodyVars = {};
|
|
2210
|
+
|
|
2211
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2212
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2213
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2214
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2215
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
2218
|
+
|
|
2219
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2220
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2221
|
+
const reqObj = {
|
|
2222
|
+
payload: bodyVars,
|
|
2223
|
+
uriPathVars: pathVars,
|
|
2224
|
+
uriQuery: queryParams
|
|
2225
|
+
};
|
|
2226
|
+
|
|
2227
|
+
try {
|
|
2228
|
+
// Make the call -
|
|
2229
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2230
|
+
return this.requestHandlerInst.identifyRequest('ConfigurationAPIS', 'downStatusMessage', reqObj, true, (irReturnData, irReturnError) => {
|
|
2231
|
+
// if we received an error or their is no response on the results
|
|
2232
|
+
// return an error
|
|
2233
|
+
if (irReturnError) {
|
|
2234
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2235
|
+
return callback(null, irReturnError);
|
|
2236
|
+
}
|
|
2237
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2238
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['downStatusMessage'], null, null, null);
|
|
2239
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2240
|
+
return callback(null, errorObj);
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2244
|
+
// return the response
|
|
2245
|
+
return callback(irReturnData, null);
|
|
2246
|
+
});
|
|
2247
|
+
} catch (ex) {
|
|
2248
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2249
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2250
|
+
return callback(null, errorObj);
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
/**
|
|
2255
|
+
* @function aPSearch
|
|
2256
|
+
* @pronghornType method
|
|
2257
|
+
* @name aPSearch
|
|
2258
|
+
* @summary AP Search
|
|
2259
|
+
*
|
|
2260
|
+
* @param {string} query - query param
|
|
2261
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2262
|
+
* @return {object} results - An object containing the response of the action
|
|
2263
|
+
*
|
|
2264
|
+
* @route {POST} /aPSearch
|
|
2265
|
+
* @roles admin
|
|
2266
|
+
* @task true
|
|
2267
|
+
*/
|
|
2268
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2269
|
+
aPSearch(query, callback) {
|
|
2270
|
+
const meth = 'adapter-aPSearch';
|
|
2271
|
+
const origin = `${this.id}-${meth}`;
|
|
2272
|
+
log.trace(origin);
|
|
2273
|
+
|
|
2274
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2275
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2276
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2277
|
+
return callback(null, errorObj);
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2281
|
+
if (query === undefined || query === null || query === '') {
|
|
2282
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['query'], null, null, null);
|
|
2283
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2284
|
+
return callback(null, errorObj);
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2288
|
+
const queryParamsAvailable = { query };
|
|
2289
|
+
const queryParams = {};
|
|
2290
|
+
const pathVars = [];
|
|
2291
|
+
const bodyVars = {};
|
|
2292
|
+
|
|
2293
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2294
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2295
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2296
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2297
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2298
|
+
}
|
|
2299
|
+
});
|
|
2300
|
+
|
|
2301
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2302
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2303
|
+
const reqObj = {
|
|
2304
|
+
payload: bodyVars,
|
|
2305
|
+
uriPathVars: pathVars,
|
|
2306
|
+
uriQuery: queryParams
|
|
2307
|
+
};
|
|
2308
|
+
|
|
2309
|
+
try {
|
|
2310
|
+
// Make the call -
|
|
2311
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2312
|
+
return this.requestHandlerInst.identifyRequest('SearchAPIS', 'aPSearch', reqObj, true, (irReturnData, irReturnError) => {
|
|
2313
|
+
// if we received an error or their is no response on the results
|
|
2314
|
+
// return an error
|
|
2315
|
+
if (irReturnError) {
|
|
2316
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2317
|
+
return callback(null, irReturnError);
|
|
2318
|
+
}
|
|
2319
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2320
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['aPSearch'], null, null, null);
|
|
2321
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2322
|
+
return callback(null, errorObj);
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2326
|
+
// return the response
|
|
2327
|
+
return callback(irReturnData, null);
|
|
2328
|
+
});
|
|
2329
|
+
} catch (ex) {
|
|
2330
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2331
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2332
|
+
return callback(null, errorObj);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
/**
|
|
2337
|
+
* @function clientSearch
|
|
2338
|
+
* @pronghornType method
|
|
2339
|
+
* @name clientSearch
|
|
2340
|
+
* @summary Client Search
|
|
2341
|
+
*
|
|
2342
|
+
* @param {string} query - query param
|
|
2343
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2344
|
+
* @return {object} results - An object containing the response of the action
|
|
2345
|
+
*
|
|
2346
|
+
* @route {POST} /clientSearch
|
|
2347
|
+
* @roles admin
|
|
2348
|
+
* @task true
|
|
2349
|
+
*/
|
|
2350
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2351
|
+
clientSearch(query, callback) {
|
|
2352
|
+
const meth = 'adapter-clientSearch';
|
|
2353
|
+
const origin = `${this.id}-${meth}`;
|
|
2354
|
+
log.trace(origin);
|
|
2355
|
+
|
|
2356
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2357
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2358
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2359
|
+
return callback(null, errorObj);
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2363
|
+
if (query === undefined || query === null || query === '') {
|
|
2364
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['query'], null, null, null);
|
|
2365
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2366
|
+
return callback(null, errorObj);
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2370
|
+
const queryParamsAvailable = { query };
|
|
2371
|
+
const queryParams = {};
|
|
2372
|
+
const pathVars = [];
|
|
2373
|
+
const bodyVars = {};
|
|
2374
|
+
|
|
2375
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2376
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2377
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2378
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2379
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
|
|
2383
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2384
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2385
|
+
const reqObj = {
|
|
2386
|
+
payload: bodyVars,
|
|
2387
|
+
uriPathVars: pathVars,
|
|
2388
|
+
uriQuery: queryParams
|
|
2389
|
+
};
|
|
2390
|
+
|
|
2391
|
+
try {
|
|
2392
|
+
// Make the call -
|
|
2393
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2394
|
+
return this.requestHandlerInst.identifyRequest('SearchAPIS', 'clientSearch', reqObj, true, (irReturnData, irReturnError) => {
|
|
2395
|
+
// if we received an error or their is no response on the results
|
|
2396
|
+
// return an error
|
|
2397
|
+
if (irReturnError) {
|
|
2398
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2399
|
+
return callback(null, irReturnError);
|
|
2400
|
+
}
|
|
2401
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2402
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['clientSearch'], null, null, null);
|
|
2403
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2404
|
+
return callback(null, errorObj);
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2408
|
+
// return the response
|
|
2409
|
+
return callback(irReturnData, null);
|
|
2410
|
+
});
|
|
2411
|
+
} catch (ex) {
|
|
2412
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2413
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2414
|
+
return callback(null, errorObj);
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
/**
|
|
2419
|
+
* @function vPNUserSearch
|
|
2420
|
+
* @pronghornType method
|
|
2421
|
+
* @name vPNUserSearch
|
|
2422
|
+
* @summary VPN User Search
|
|
2423
|
+
*
|
|
2424
|
+
* @param {string} query - query param
|
|
2425
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2426
|
+
* @return {object} results - An object containing the response of the action
|
|
2427
|
+
*
|
|
2428
|
+
* @route {POST} /vPNUserSearch
|
|
2429
|
+
* @roles admin
|
|
2430
|
+
* @task true
|
|
2431
|
+
*/
|
|
2432
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2433
|
+
vPNUserSearch(query, callback) {
|
|
2434
|
+
const meth = 'adapter-vPNUserSearch';
|
|
2435
|
+
const origin = `${this.id}-${meth}`;
|
|
2436
|
+
log.trace(origin);
|
|
2437
|
+
|
|
2438
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2439
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2440
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2441
|
+
return callback(null, errorObj);
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2445
|
+
if (query === undefined || query === null || query === '') {
|
|
2446
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['query'], null, null, null);
|
|
2447
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2448
|
+
return callback(null, errorObj);
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2452
|
+
const queryParamsAvailable = { query };
|
|
2453
|
+
const queryParams = {};
|
|
2454
|
+
const pathVars = [];
|
|
2455
|
+
const bodyVars = {};
|
|
2456
|
+
|
|
2457
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2458
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2459
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2460
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2461
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2462
|
+
}
|
|
2463
|
+
});
|
|
2464
|
+
|
|
2465
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2466
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2467
|
+
const reqObj = {
|
|
2468
|
+
payload: bodyVars,
|
|
2469
|
+
uriPathVars: pathVars,
|
|
2470
|
+
uriQuery: queryParams
|
|
2471
|
+
};
|
|
2472
|
+
|
|
2473
|
+
try {
|
|
2474
|
+
// Make the call -
|
|
2475
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2476
|
+
return this.requestHandlerInst.identifyRequest('SearchAPIS', 'vPNUserSearch', reqObj, true, (irReturnData, irReturnError) => {
|
|
2477
|
+
// if we received an error or their is no response on the results
|
|
2478
|
+
// return an error
|
|
2479
|
+
if (irReturnError) {
|
|
2480
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2481
|
+
return callback(null, irReturnError);
|
|
2482
|
+
}
|
|
2483
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2484
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['vPNUserSearch'], null, null, null);
|
|
2485
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2486
|
+
return callback(null, errorObj);
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2490
|
+
// return the response
|
|
2491
|
+
return callback(irReturnData, null);
|
|
2492
|
+
});
|
|
2493
|
+
} catch (ex) {
|
|
2494
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2495
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2496
|
+
return callback(null, errorObj);
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
/**
|
|
2501
|
+
* @function latestReport
|
|
2502
|
+
* @pronghornType method
|
|
2503
|
+
* @name latestReport
|
|
2504
|
+
* @summary Latest Report
|
|
2505
|
+
*
|
|
2506
|
+
* @param {number} definitionsEdit - definitionsEdit param
|
|
2507
|
+
* @param {number} id - id param
|
|
2508
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2509
|
+
* @return {object} results - An object containing the response of the action
|
|
2510
|
+
*
|
|
2511
|
+
* @route {POST} /latestReport
|
|
2512
|
+
* @roles admin
|
|
2513
|
+
* @task true
|
|
2514
|
+
*/
|
|
2515
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2516
|
+
latestReport(definitionsEdit, id, callback) {
|
|
2517
|
+
const meth = 'adapter-latestReport';
|
|
2518
|
+
const origin = `${this.id}-${meth}`;
|
|
2519
|
+
log.trace(origin);
|
|
2520
|
+
|
|
2521
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2522
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2523
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2524
|
+
return callback(null, errorObj);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2528
|
+
if (definitionsEdit === undefined || definitionsEdit === null || definitionsEdit === '') {
|
|
2529
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['definitionsEdit'], null, null, null);
|
|
2530
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2531
|
+
return callback(null, errorObj);
|
|
2532
|
+
}
|
|
2533
|
+
if (id === undefined || id === null || id === '') {
|
|
2534
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], 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 = { definitionsEdit, id };
|
|
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('ReportAPIS', 'latestReport', 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', ['latestReport'], 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 batchExecuteAPCommand
|
|
2590
|
+
* @pronghornType method
|
|
2591
|
+
* @name batchExecuteAPCommand
|
|
2592
|
+
* @summary Batch Execute AP Command
|
|
2593
|
+
*
|
|
2594
|
+
* @param {object} body - body param
|
|
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} /batchExecuteAPCommand
|
|
2599
|
+
* @roles admin
|
|
2600
|
+
* @task true
|
|
2601
|
+
*/
|
|
2602
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2603
|
+
batchExecuteAPCommand(body, callback) {
|
|
2604
|
+
const meth = 'adapter-batchExecuteAPCommand';
|
|
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 (body === undefined || body === null || body === '') {
|
|
2616
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], 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 = {};
|
|
2623
|
+
const queryParams = {};
|
|
2624
|
+
const pathVars = [];
|
|
2625
|
+
const bodyVars = body;
|
|
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
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
2636
|
+
let thisHeaderData = null;
|
|
2637
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
2638
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
2639
|
+
try {
|
|
2640
|
+
// parse the additional headers object that was passed in
|
|
2641
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
2642
|
+
} catch (err) {
|
|
2643
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
2644
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2645
|
+
return callback(null, errorObj);
|
|
2646
|
+
}
|
|
2647
|
+
} else if (thisHeaderData === null) {
|
|
2648
|
+
thisHeaderData = { contentType: '', xBISCOTTI: '' };
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2652
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2653
|
+
const reqObj = {
|
|
2654
|
+
payload: bodyVars,
|
|
2655
|
+
uriPathVars: pathVars,
|
|
2656
|
+
uriQuery: queryParams,
|
|
2657
|
+
addlHeaders: thisHeaderData
|
|
2658
|
+
};
|
|
2659
|
+
|
|
2660
|
+
try {
|
|
2661
|
+
// Make the call -
|
|
2662
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2663
|
+
return this.requestHandlerInst.identifyRequest('BatchExecuteAPCommandsAPIS', 'batchExecuteAPCommand', reqObj, true, (irReturnData, irReturnError) => {
|
|
2664
|
+
// if we received an error or their is no response on the results
|
|
2665
|
+
// return an error
|
|
2666
|
+
if (irReturnError) {
|
|
2667
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2668
|
+
return callback(null, irReturnError);
|
|
2669
|
+
}
|
|
2670
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2671
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['batchExecuteAPCommand'], null, null, null);
|
|
2672
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2673
|
+
return callback(null, errorObj);
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2677
|
+
// return the response
|
|
2678
|
+
return callback(irReturnData, null);
|
|
2679
|
+
});
|
|
2680
|
+
} catch (ex) {
|
|
2681
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2682
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2683
|
+
return callback(null, errorObj);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
/**
|
|
2688
|
+
* @function batchExecuteAPCommandResult
|
|
2689
|
+
* @pronghornType method
|
|
2690
|
+
* @name batchExecuteAPCommandResult
|
|
2691
|
+
* @summary Batch Execute AP Command Result
|
|
2692
|
+
*
|
|
2693
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2694
|
+
* @return {object} results - An object containing the response of the action
|
|
2695
|
+
*
|
|
2696
|
+
* @route {GET} /batchExecuteAPCommandResult
|
|
2697
|
+
* @roles admin
|
|
2698
|
+
* @task true
|
|
2699
|
+
*/
|
|
2700
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2701
|
+
batchExecuteAPCommandResult(callback) {
|
|
2702
|
+
const meth = 'adapter-batchExecuteAPCommandResult';
|
|
2703
|
+
const origin = `${this.id}-${meth}`;
|
|
2704
|
+
log.trace(origin);
|
|
2705
|
+
|
|
2706
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2707
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2708
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2709
|
+
return callback(null, errorObj);
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2713
|
+
|
|
2714
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2715
|
+
const queryParamsAvailable = {};
|
|
2716
|
+
const queryParams = {};
|
|
2717
|
+
const pathVars = [];
|
|
2718
|
+
const bodyVars = {};
|
|
2719
|
+
|
|
2720
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2721
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2722
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2723
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2724
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2725
|
+
}
|
|
2726
|
+
});
|
|
2727
|
+
|
|
2728
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2729
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2730
|
+
const reqObj = {
|
|
2731
|
+
payload: bodyVars,
|
|
2732
|
+
uriPathVars: pathVars,
|
|
2733
|
+
uriQuery: queryParams
|
|
2734
|
+
};
|
|
2735
|
+
|
|
2736
|
+
try {
|
|
2737
|
+
// Make the call -
|
|
2738
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2739
|
+
return this.requestHandlerInst.identifyRequest('BatchExecuteAPCommandsAPIS', 'batchExecuteAPCommandResult', reqObj, true, (irReturnData, irReturnError) => {
|
|
2740
|
+
// if we received an error or their is no response on the results
|
|
2741
|
+
// return an error
|
|
2742
|
+
if (irReturnError) {
|
|
2743
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2744
|
+
return callback(null, irReturnError);
|
|
2745
|
+
}
|
|
2746
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2747
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['batchExecuteAPCommandResult'], null, null, null);
|
|
2748
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2749
|
+
return callback(null, errorObj);
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2753
|
+
// return the response
|
|
2754
|
+
return callback(irReturnData, null);
|
|
2755
|
+
});
|
|
2756
|
+
} catch (ex) {
|
|
2757
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2758
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2759
|
+
return callback(null, errorObj);
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
/**
|
|
2764
|
+
* @function aMPLogin
|
|
2765
|
+
* @pronghornType method
|
|
2766
|
+
* @name aMPLogin
|
|
2767
|
+
* @summary AMP: Login
|
|
2768
|
+
*
|
|
2769
|
+
* @param {string} [credential0] - credential0 param
|
|
2770
|
+
* @param {string} [credential1] - credential1 param
|
|
2771
|
+
* @param {string} [destination] - destination param
|
|
2772
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2773
|
+
* @return {object} results - An object containing the response of the action
|
|
2774
|
+
*
|
|
2775
|
+
* @route {POST} /aMPLogin
|
|
2776
|
+
* @roles admin
|
|
2777
|
+
* @task true
|
|
2778
|
+
*/
|
|
2779
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2780
|
+
aMPLogin(credential0, credential1, destination, callback) {
|
|
2781
|
+
const meth = 'adapter-aMPLogin';
|
|
2782
|
+
const origin = `${this.id}-${meth}`;
|
|
2783
|
+
log.trace(origin);
|
|
2784
|
+
|
|
2785
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2786
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2787
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2788
|
+
return callback(null, errorObj);
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2792
|
+
|
|
2793
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2794
|
+
const queryParamsAvailable = {};
|
|
2795
|
+
const queryParams = {};
|
|
2796
|
+
const pathVars = [];
|
|
2797
|
+
const bodyVars = {};
|
|
2798
|
+
|
|
2799
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2800
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2801
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2802
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2803
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2804
|
+
}
|
|
2805
|
+
});
|
|
2806
|
+
|
|
2807
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
2808
|
+
let thisHeaderData = null;
|
|
2809
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
2810
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
2811
|
+
try {
|
|
2812
|
+
// parse the additional headers object that was passed in
|
|
2813
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
2814
|
+
} catch (err) {
|
|
2815
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
2816
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2817
|
+
return callback(null, errorObj);
|
|
2818
|
+
}
|
|
2819
|
+
} else if (thisHeaderData === null) {
|
|
2820
|
+
thisHeaderData = { contentType: '' };
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2824
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2825
|
+
const reqObj = {
|
|
2826
|
+
payload: bodyVars,
|
|
2827
|
+
uriPathVars: pathVars,
|
|
2828
|
+
uriQuery: queryParams,
|
|
2829
|
+
addlHeaders: thisHeaderData
|
|
2830
|
+
};
|
|
2831
|
+
|
|
2832
|
+
try {
|
|
2833
|
+
// Make the call -
|
|
2834
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2835
|
+
return this.requestHandlerInst.identifyRequest('LOGIN', 'aMPLogin', reqObj, true, (irReturnData, irReturnError) => {
|
|
2836
|
+
// if we received an error or their is no response on the results
|
|
2837
|
+
// return an error
|
|
2838
|
+
if (irReturnError) {
|
|
2839
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2840
|
+
return callback(null, irReturnError);
|
|
2841
|
+
}
|
|
2842
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2843
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['aMPLogin'], null, null, null);
|
|
2844
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2845
|
+
return callback(null, errorObj);
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2849
|
+
// return the response
|
|
2850
|
+
return callback(irReturnData, null);
|
|
2851
|
+
});
|
|
2852
|
+
} catch (ex) {
|
|
2853
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2854
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2855
|
+
return callback(null, errorObj);
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
module.exports = ArubaAirwave;
|