@itentialopensource/adapter-tmf642_alarm_management 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +5 -0
- package/.eslintrc.js +18 -0
- package/.jshintrc +3 -0
- package/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +416 -0
- package/CHANGELOG.md +16 -0
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +172 -0
- package/ENHANCE.md +69 -0
- package/LICENSE +201 -0
- package/PROPERTIES.md +641 -0
- package/README.md +337 -0
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +4199 -0
- package/adapterBase.js +1787 -0
- package/entities/.generic/action.json +214 -0
- package/entities/.generic/schema.json +28 -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 +53 -0
- package/entities/.system/schemaTokenResp.json +53 -0
- package/entities/AckAlarms/action.json +66 -0
- package/entities/AckAlarms/mockdatafiles/listAckAlarms-default.json +7784 -0
- package/entities/AckAlarms/schema.json +21 -0
- package/entities/Alarm/action.json +106 -0
- package/entities/Alarm/mockdatafiles/listAlarm-default.json +1224 -0
- package/entities/Alarm/schema.json +23 -0
- package/entities/ClearAlarms/action.json +66 -0
- package/entities/ClearAlarms/mockdatafiles/listClearAlarms-default.json +5420 -0
- package/entities/ClearAlarms/schema.json +21 -0
- package/entities/CommentAlarms/action.json +66 -0
- package/entities/CommentAlarms/mockdatafiles/listCommentAlarms-default.json +5628 -0
- package/entities/CommentAlarms/schema.json +21 -0
- package/entities/EventsSubscription/action.json +44 -0
- package/entities/EventsSubscription/schema.json +20 -0
- package/entities/GroupAlarms/action.json +66 -0
- package/entities/GroupAlarms/mockdatafiles/listGroupAlarms-default.json +3303 -0
- package/entities/GroupAlarms/schema.json +21 -0
- package/entities/NotificationListenersClientSide/action.json +324 -0
- package/entities/NotificationListenersClientSide/schema.json +34 -0
- package/entities/UnAckAlarms/action.json +66 -0
- package/entities/UnAckAlarms/mockdatafiles/listUnAckAlarms-default.json +10140 -0
- package/entities/UnAckAlarms/schema.json +21 -0
- package/entities/UnGroupAlarms/action.json +66 -0
- package/entities/UnGroupAlarms/mockdatafiles/listUnGroupAlarms-default.json +1133 -0
- package/entities/UnGroupAlarms/schema.json +21 -0
- package/error.json +190 -0
- package/package.json +88 -0
- package/pronghorn.json +30547 -0
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +1248 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/TMF642-Alarm-v4.0.0.swagger.json +5901 -0
- package/report/adapterInfo.json +10 -0
- package/report/creationReport.json +500 -0
- package/sampleProperties.json +195 -0
- package/test/integration/adapterTestBasicGet.js +83 -0
- package/test/integration/adapterTestConnectivity.js +93 -0
- package/test/integration/adapterTestIntegration.js +5656 -0
- package/test/unit/adapterBaseTestUnit.js +949 -0
- package/test/unit/adapterTestUnit.js +2398 -0
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +146 -0
- package/utils/basicGet.js +50 -0
- package/utils/checkMigrate.js +63 -0
- package/utils/entitiesToDB.js +178 -0
- package/utils/findPath.js +74 -0
- package/utils/methodDocumentor.js +225 -0
- package/utils/modify.js +154 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +32 -0
- package/utils/removeHooks.js +20 -0
- package/utils/setup.js +33 -0
- package/utils/tbScript.js +246 -0
- package/utils/tbUtils.js +490 -0
- package/utils/testRunner.js +298 -0
- package/utils/troubleshootingAdapter.js +195 -0
- package/workflows/README.md +3 -0
package/adapter.js
ADDED
|
@@ -0,0 +1,4199 @@
|
|
|
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 tmf642_alarm_management
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/* GENERAL ADAPTER FUNCTIONS */
|
|
20
|
+
class Tmf642AlarmManagement extends AdapterBaseCl {
|
|
21
|
+
/**
|
|
22
|
+
* Tmf642AlarmManagement Adapter
|
|
23
|
+
* @constructor
|
|
24
|
+
*/
|
|
25
|
+
/* Working on changing the way we do Emit methods due to size and time constrainsts
|
|
26
|
+
constructor(prongid, properties) {
|
|
27
|
+
// Instantiate the AdapterBase super class
|
|
28
|
+
super(prongid, properties);
|
|
29
|
+
|
|
30
|
+
const restFunctionNames = this.iapGetAdapterWorkflowFunctions();
|
|
31
|
+
|
|
32
|
+
// Dynamically bind emit functions
|
|
33
|
+
for (let i = 0; i < restFunctionNames.length; i += 1) {
|
|
34
|
+
// Bind function to have name fnNameEmit for fnName
|
|
35
|
+
const version = restFunctionNames[i].match(/__v[0-9]+/);
|
|
36
|
+
const baseFnName = restFunctionNames[i].replace(/__v[0-9]+/, '');
|
|
37
|
+
const fnNameEmit = version ? `${baseFnName}Emit${version}` : `${baseFnName}Emit`;
|
|
38
|
+
this[fnNameEmit] = function (...args) {
|
|
39
|
+
// extract the callback
|
|
40
|
+
const callback = args[args.length - 1];
|
|
41
|
+
// slice the callback from args so we can insert our own
|
|
42
|
+
const functionArgs = args.slice(0, args.length - 1);
|
|
43
|
+
// create a random name for the listener
|
|
44
|
+
const eventName = `${restFunctionNames[i]}:${Math.random().toString(36)}`;
|
|
45
|
+
// tell the calling class to start listening
|
|
46
|
+
callback({ event: eventName, status: 'received' });
|
|
47
|
+
// store parent for use of this context later
|
|
48
|
+
const parent = this;
|
|
49
|
+
// store emission function
|
|
50
|
+
const func = function (val, err) {
|
|
51
|
+
parent.removeListener(eventName, func);
|
|
52
|
+
parent.emit(eventName, val, err);
|
|
53
|
+
};
|
|
54
|
+
// Use apply to call the function in a specific context
|
|
55
|
+
this[restFunctionNames[i]].apply(this, functionArgs.concat([func])); // eslint-disable-line prefer-spread
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Uncomment if you have things to add to the constructor like using your own properties.
|
|
60
|
+
// Otherwise the constructor in the adapterBase will be used.
|
|
61
|
+
// Capture my own properties - they need to be defined in propertiesSchema.json
|
|
62
|
+
// if (this.allProps && this.allProps.myownproperty) {
|
|
63
|
+
// mypropvariable = this.allProps.myownproperty;
|
|
64
|
+
// }
|
|
65
|
+
}
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @callback healthCallback
|
|
70
|
+
* @param {Object} reqObj - the request to send into the healthcheck
|
|
71
|
+
* @param {Callback} callback - The results of the call
|
|
72
|
+
*/
|
|
73
|
+
healthCheck(reqObj, callback) {
|
|
74
|
+
// you can modify what is passed into the healthcheck by changing things in the newReq
|
|
75
|
+
let newReq = null;
|
|
76
|
+
if (reqObj) {
|
|
77
|
+
newReq = Object.assign(...reqObj);
|
|
78
|
+
}
|
|
79
|
+
super.healthCheck(newReq, callback);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @iapGetAdapterWorkflowFunctions
|
|
84
|
+
*/
|
|
85
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
86
|
+
let myIgnore = [
|
|
87
|
+
'healthCheck',
|
|
88
|
+
'iapGetAdapterWorkflowFunctions',
|
|
89
|
+
'iapHasAdapterEntity',
|
|
90
|
+
'iapVerifyAdapterCapability',
|
|
91
|
+
'iapUpdateAdapterEntityCache',
|
|
92
|
+
'hasEntities'
|
|
93
|
+
];
|
|
94
|
+
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
95
|
+
myIgnore = inIgnore;
|
|
96
|
+
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
97
|
+
myIgnore = [inIgnore];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// The generic adapter functions should already be ignored (e.g. healthCheck)
|
|
101
|
+
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
102
|
+
// myIgnore.push('myMethodNotInWorkflow');
|
|
103
|
+
|
|
104
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
109
|
+
* allows customers to make changes to adapter configuration without having to be on the
|
|
110
|
+
* file system.
|
|
111
|
+
*
|
|
112
|
+
* @function iapUpdateAdapterConfiguration
|
|
113
|
+
* @param {string} configFile - the name of the file being updated (required)
|
|
114
|
+
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
115
|
+
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
116
|
+
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
117
|
+
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
118
|
+
* @param {Callback} callback - The results of the call
|
|
119
|
+
*/
|
|
120
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
121
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
122
|
+
const origin = `${this.id}-${meth}`;
|
|
123
|
+
log.trace(origin);
|
|
124
|
+
|
|
125
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* See if the API path provided is found in this adapter
|
|
130
|
+
*
|
|
131
|
+
* @function iapFindAdapterPath
|
|
132
|
+
* @param {string} apiPath - the api path to check on
|
|
133
|
+
* @param {Callback} callback - The results of the call
|
|
134
|
+
*/
|
|
135
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
136
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
137
|
+
const origin = `${this.id}-${meth}`;
|
|
138
|
+
log.trace(origin);
|
|
139
|
+
|
|
140
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @summary Suspends adapter
|
|
145
|
+
*
|
|
146
|
+
* @function iapSuspendAdapter
|
|
147
|
+
* @param {Callback} callback - callback function
|
|
148
|
+
*/
|
|
149
|
+
iapSuspendAdapter(mode, callback) {
|
|
150
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
151
|
+
const origin = `${this.id}-${meth}`;
|
|
152
|
+
log.trace(origin);
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
log.error(`${origin}: ${error}`);
|
|
158
|
+
return callback(null, error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @summary Unsuspends adapter
|
|
164
|
+
*
|
|
165
|
+
* @function iapUnsuspendAdapter
|
|
166
|
+
* @param {Callback} callback - callback function
|
|
167
|
+
*/
|
|
168
|
+
iapUnsuspendAdapter(callback) {
|
|
169
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
170
|
+
const origin = `${this.id}-${meth}`;
|
|
171
|
+
log.trace(origin);
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
return super.iapUnsuspendAdapter(callback);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
log.error(`${origin}: ${error}`);
|
|
177
|
+
return callback(null, error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @summary Get the Adaoter Queue
|
|
183
|
+
*
|
|
184
|
+
* @function iapGetAdapterQueue
|
|
185
|
+
* @param {Callback} callback - callback function
|
|
186
|
+
*/
|
|
187
|
+
iapGetAdapterQueue(callback) {
|
|
188
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
189
|
+
const origin = `${this.id}-${meth}`;
|
|
190
|
+
log.trace(origin);
|
|
191
|
+
|
|
192
|
+
return super.iapGetAdapterQueue(callback);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @summary Runs troubleshoot scripts for adapter
|
|
197
|
+
*
|
|
198
|
+
* @function iapTroubleshootAdapter
|
|
199
|
+
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
200
|
+
*
|
|
201
|
+
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
202
|
+
* @param {Callback} callback - The results of the call
|
|
203
|
+
*/
|
|
204
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
205
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
206
|
+
const origin = `${this.id}-${meth}`;
|
|
207
|
+
log.trace(origin);
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
log.error(`${origin}: ${error}`);
|
|
213
|
+
return callback(null, error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @summary runs healthcheck script for adapter
|
|
219
|
+
*
|
|
220
|
+
* @function iapRunAdapterHealthcheck
|
|
221
|
+
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
222
|
+
* @param {Callback} callback - callback function
|
|
223
|
+
*/
|
|
224
|
+
iapRunAdapterHealthcheck(callback) {
|
|
225
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
226
|
+
const origin = `${this.id}-${meth}`;
|
|
227
|
+
log.trace(origin);
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
log.error(`${origin}: ${error}`);
|
|
233
|
+
return callback(null, error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @summary runs connectivity check script for adapter
|
|
239
|
+
*
|
|
240
|
+
* @function iapRunAdapterConnectivity
|
|
241
|
+
* @param {Callback} callback - callback function
|
|
242
|
+
*/
|
|
243
|
+
iapRunAdapterConnectivity(callback) {
|
|
244
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
245
|
+
const origin = `${this.id}-${meth}`;
|
|
246
|
+
log.trace(origin);
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
log.error(`${origin}: ${error}`);
|
|
252
|
+
return callback(null, error);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @summary runs basicGet script for adapter
|
|
258
|
+
*
|
|
259
|
+
* @function iapRunAdapterBasicGet
|
|
260
|
+
* @param {Callback} callback - callback function
|
|
261
|
+
*/
|
|
262
|
+
iapRunAdapterBasicGet(callback) {
|
|
263
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
264
|
+
const origin = `${this.id}-${meth}`;
|
|
265
|
+
log.trace(origin);
|
|
266
|
+
|
|
267
|
+
try {
|
|
268
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
269
|
+
} catch (error) {
|
|
270
|
+
log.error(`${origin}: ${error}`);
|
|
271
|
+
return callback(null, error);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @summary moves entites into Mongo DB
|
|
277
|
+
*
|
|
278
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
279
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
280
|
+
* or the error
|
|
281
|
+
*/
|
|
282
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
283
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
284
|
+
const origin = `${this.id}-${meth}`;
|
|
285
|
+
log.trace(origin);
|
|
286
|
+
|
|
287
|
+
try {
|
|
288
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
289
|
+
} catch (err) {
|
|
290
|
+
log.error(`${origin}: ${err}`);
|
|
291
|
+
return callback(null, err);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* BROKER CALLS */
|
|
296
|
+
/**
|
|
297
|
+
* @summary Determines if this adapter supports the specific entity
|
|
298
|
+
*
|
|
299
|
+
* @function iapHasAdapterEntity
|
|
300
|
+
* @param {String} entityType - the entity type to check for
|
|
301
|
+
* @param {String/Array} entityId - the specific entity we are looking for
|
|
302
|
+
*
|
|
303
|
+
* @param {Callback} callback - An array of whether the adapter can has the
|
|
304
|
+
* desired capability or an error
|
|
305
|
+
*/
|
|
306
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
307
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
308
|
+
log.trace(origin);
|
|
309
|
+
|
|
310
|
+
// Make the call -
|
|
311
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
312
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @summary Provides a way for the adapter to tell north bound integrations
|
|
317
|
+
* whether the adapter supports type, action and specific entity
|
|
318
|
+
*
|
|
319
|
+
* @function iapVerifyAdapterCapability
|
|
320
|
+
* @param {String} entityType - the entity type to check for
|
|
321
|
+
* @param {String} actionType - the action type to check for
|
|
322
|
+
* @param {String/Array} entityId - the specific entity we are looking for
|
|
323
|
+
*
|
|
324
|
+
* @param {Callback} callback - An array of whether the adapter can has the
|
|
325
|
+
* desired capability or an error
|
|
326
|
+
*/
|
|
327
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
328
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
|
329
|
+
const origin = `${this.id}-${meth}`;
|
|
330
|
+
log.trace(origin);
|
|
331
|
+
|
|
332
|
+
// if caching
|
|
333
|
+
if (this.caching) {
|
|
334
|
+
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
335
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
|
336
|
+
if (error) {
|
|
337
|
+
return callback(null, error);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// if the cache needs to be updated, update and try again
|
|
341
|
+
if (results && results[0] === 'needupdate') {
|
|
342
|
+
switch (entityType) {
|
|
343
|
+
case 'template_entity': {
|
|
344
|
+
// if the cache is invalid, update the cache
|
|
345
|
+
return this.getEntities(null, null, null, null, (data, err) => {
|
|
346
|
+
if (err) {
|
|
347
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
348
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
349
|
+
return callback(null, errorObj);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// need to check the cache again since it has been updated
|
|
353
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
354
|
+
if (verror) {
|
|
355
|
+
return callback(null, verror);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
return this.capabilityResults(vcapable, callback);
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
default: {
|
|
363
|
+
// unsupported entity type
|
|
364
|
+
const result = [false];
|
|
365
|
+
|
|
366
|
+
// put false in array for all entities
|
|
367
|
+
if (Array.isArray(entityId)) {
|
|
368
|
+
for (let e = 1; e < entityId.length; e += 1) {
|
|
369
|
+
result.push(false);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return callback(result);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// return the results
|
|
379
|
+
return this.capabilityResults(results, callback);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// if no entity id
|
|
384
|
+
if (!entityId) {
|
|
385
|
+
// need to check the cache again since it has been updated
|
|
386
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
387
|
+
if (verror) {
|
|
388
|
+
return callback(null, verror);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return this.capabilityResults(vcapable, callback);
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// if not caching
|
|
396
|
+
switch (entityType) {
|
|
397
|
+
case 'template_entity': {
|
|
398
|
+
// need to get the entities to check
|
|
399
|
+
return this.getEntities(null, null, null, null, (data, err) => {
|
|
400
|
+
if (err) {
|
|
401
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
402
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
403
|
+
return callback(null, errorObj);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// need to check the cache again since it has been updated
|
|
407
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
408
|
+
if (verror) {
|
|
409
|
+
return callback(null, verror);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// is the entity in the list?
|
|
413
|
+
const isEntity = this.entityInList(entityId, data.response, callback);
|
|
414
|
+
const res = [];
|
|
415
|
+
|
|
416
|
+
// not found
|
|
417
|
+
for (let i = 0; i < isEntity.length; i += 1) {
|
|
418
|
+
if (vcapable) {
|
|
419
|
+
res.push(isEntity[i]);
|
|
420
|
+
} else {
|
|
421
|
+
res.push(false);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return callback(res);
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
default: {
|
|
430
|
+
// unsupported entity type
|
|
431
|
+
const result = [false];
|
|
432
|
+
|
|
433
|
+
// put false in array for all entities
|
|
434
|
+
if (Array.isArray(entityId)) {
|
|
435
|
+
for (let e = 1; e < entityId.length; e += 1) {
|
|
436
|
+
result.push(false);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
return callback(result);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @summary Updates the cache for all entities by call the get All entity method
|
|
447
|
+
*
|
|
448
|
+
* @function iapUpdateAdapterEntityCache
|
|
449
|
+
*
|
|
450
|
+
*/
|
|
451
|
+
iapUpdateAdapterEntityCache() {
|
|
452
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
|
453
|
+
log.trace(origin);
|
|
454
|
+
|
|
455
|
+
if (this.caching) {
|
|
456
|
+
// if the cache is invalid, update the cache
|
|
457
|
+
this.getEntities(null, null, null, null, (data, err) => {
|
|
458
|
+
if (err) {
|
|
459
|
+
log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
467
|
+
*
|
|
468
|
+
* @function hasEntities
|
|
469
|
+
* @param {String} entityType - the entity type to check for
|
|
470
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
471
|
+
*
|
|
472
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
473
|
+
* value is true or false
|
|
474
|
+
*/
|
|
475
|
+
hasEntities(entityType, entityList, callback) {
|
|
476
|
+
const meth = 'adapter-hasEntities';
|
|
477
|
+
const origin = `${this.id}-${meth}`;
|
|
478
|
+
log.trace(origin);
|
|
479
|
+
|
|
480
|
+
try {
|
|
481
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
482
|
+
} catch (err) {
|
|
483
|
+
log.error(`${origin}: ${err}`);
|
|
484
|
+
return callback(null, err);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* @summary Get Appliance that match the deviceName
|
|
490
|
+
*
|
|
491
|
+
* @function getDevice
|
|
492
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
493
|
+
*
|
|
494
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
495
|
+
* (appliance) or the error
|
|
496
|
+
*/
|
|
497
|
+
getDevice(deviceName, callback) {
|
|
498
|
+
const meth = 'adapter-getDevice';
|
|
499
|
+
const origin = `${this.id}-${meth}`;
|
|
500
|
+
log.trace(origin);
|
|
501
|
+
|
|
502
|
+
try {
|
|
503
|
+
return super.getDevice(deviceName, callback);
|
|
504
|
+
} catch (err) {
|
|
505
|
+
log.error(`${origin}: ${err}`);
|
|
506
|
+
return callback(null, err);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @summary Get Appliances that match the filter
|
|
512
|
+
*
|
|
513
|
+
* @function getDevicesFiltered
|
|
514
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
515
|
+
*
|
|
516
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
517
|
+
* (appliances) or the error
|
|
518
|
+
*/
|
|
519
|
+
getDevicesFiltered(options, callback) {
|
|
520
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
521
|
+
const origin = `${this.id}-${meth}`;
|
|
522
|
+
log.trace(origin);
|
|
523
|
+
|
|
524
|
+
try {
|
|
525
|
+
return super.getDevicesFiltered(options, callback);
|
|
526
|
+
} catch (err) {
|
|
527
|
+
log.error(`${origin}: ${err}`);
|
|
528
|
+
return callback(null, err);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* @summary Gets the status for the provided appliance
|
|
534
|
+
*
|
|
535
|
+
* @function isAlive
|
|
536
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
537
|
+
*
|
|
538
|
+
* @param {configCallback} callback - callback function to return the result
|
|
539
|
+
* (appliance isAlive) or the error
|
|
540
|
+
*/
|
|
541
|
+
isAlive(deviceName, callback) {
|
|
542
|
+
const meth = 'adapter-isAlive';
|
|
543
|
+
const origin = `${this.id}-${meth}`;
|
|
544
|
+
log.trace(origin);
|
|
545
|
+
|
|
546
|
+
try {
|
|
547
|
+
return super.isAlive(deviceName, callback);
|
|
548
|
+
} catch (err) {
|
|
549
|
+
log.error(`${origin}: ${err}`);
|
|
550
|
+
return callback(null, err);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* @summary Gets a config for the provided Appliance
|
|
556
|
+
*
|
|
557
|
+
* @function getConfig
|
|
558
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
559
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
560
|
+
*
|
|
561
|
+
* @param {configCallback} callback - callback function to return the result
|
|
562
|
+
* (appliance config) or the error
|
|
563
|
+
*/
|
|
564
|
+
getConfig(deviceName, format, callback) {
|
|
565
|
+
const meth = 'adapter-getConfig';
|
|
566
|
+
const origin = `${this.id}-${meth}`;
|
|
567
|
+
log.trace(origin);
|
|
568
|
+
|
|
569
|
+
try {
|
|
570
|
+
return super.getConfig(deviceName, format, callback);
|
|
571
|
+
} catch (err) {
|
|
572
|
+
log.error(`${origin}: ${err}`);
|
|
573
|
+
return callback(null, err);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* @summary Gets the device count from the system
|
|
579
|
+
*
|
|
580
|
+
* @function iapGetDeviceCount
|
|
581
|
+
*
|
|
582
|
+
* @param {getCallback} callback - callback function to return the result
|
|
583
|
+
* (count) or the error
|
|
584
|
+
*/
|
|
585
|
+
iapGetDeviceCount(callback) {
|
|
586
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
587
|
+
const origin = `${this.id}-${meth}`;
|
|
588
|
+
log.trace(origin);
|
|
589
|
+
|
|
590
|
+
try {
|
|
591
|
+
return super.iapGetDeviceCount(callback);
|
|
592
|
+
} catch (err) {
|
|
593
|
+
log.error(`${origin}: ${err}`);
|
|
594
|
+
return callback(null, err);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
599
|
+
/**
|
|
600
|
+
* Makes the requested generic call
|
|
601
|
+
*
|
|
602
|
+
* @function genericAdapterRequest
|
|
603
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
604
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
605
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
606
|
+
* Can be a stringified Object.
|
|
607
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
608
|
+
* Can be a stringified Object.
|
|
609
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
610
|
+
* Can be a stringified Object.
|
|
611
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
612
|
+
* or the error
|
|
613
|
+
*/
|
|
614
|
+
genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
615
|
+
const meth = 'adapter-genericAdapterRequest';
|
|
616
|
+
const origin = `${this.id}-${meth}`;
|
|
617
|
+
log.trace(origin);
|
|
618
|
+
|
|
619
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
620
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
621
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
622
|
+
return callback(null, errorObj);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
626
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
627
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
628
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
629
|
+
return callback(null, errorObj);
|
|
630
|
+
}
|
|
631
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
632
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
633
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
634
|
+
return callback(null, errorObj);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
638
|
+
// remove any leading / and split the uripath into path variables
|
|
639
|
+
let myPath = uriPath;
|
|
640
|
+
while (myPath.indexOf('/') === 0) {
|
|
641
|
+
myPath = myPath.substring(1);
|
|
642
|
+
}
|
|
643
|
+
const pathVars = myPath.split('/');
|
|
644
|
+
const queryParamsAvailable = queryData;
|
|
645
|
+
const queryParams = {};
|
|
646
|
+
const bodyVars = requestBody;
|
|
647
|
+
|
|
648
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
649
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
650
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
651
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
652
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
657
|
+
const reqObj = {
|
|
658
|
+
payload: bodyVars,
|
|
659
|
+
uriPathVars: pathVars,
|
|
660
|
+
uriQuery: queryParams,
|
|
661
|
+
uriOptions: {}
|
|
662
|
+
};
|
|
663
|
+
// add headers if provided
|
|
664
|
+
if (addlHeaders) {
|
|
665
|
+
reqObj.addlHeaders = addlHeaders;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// determine the call and return flag
|
|
669
|
+
let action = 'getGenerics';
|
|
670
|
+
let returnF = true;
|
|
671
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
672
|
+
action = 'createGeneric';
|
|
673
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
674
|
+
action = 'updateGeneric';
|
|
675
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
676
|
+
action = 'patchGeneric';
|
|
677
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
678
|
+
action = 'deleteGeneric';
|
|
679
|
+
returnF = false;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
try {
|
|
683
|
+
// Make the call -
|
|
684
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
685
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
686
|
+
// if we received an error or their is no response on the results
|
|
687
|
+
// return an error
|
|
688
|
+
if (irReturnError) {
|
|
689
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
690
|
+
return callback(null, irReturnError);
|
|
691
|
+
}
|
|
692
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
693
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
694
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
695
|
+
return callback(null, errorObj);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
699
|
+
// return the response
|
|
700
|
+
return callback(irReturnData, null);
|
|
701
|
+
});
|
|
702
|
+
} catch (ex) {
|
|
703
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
704
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
705
|
+
return callback(null, errorObj);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Makes the requested generic call with no base path or version
|
|
711
|
+
*
|
|
712
|
+
* @function genericAdapterRequestNoBasePath
|
|
713
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
714
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
715
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
716
|
+
* Can be a stringified Object.
|
|
717
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
718
|
+
* Can be a stringified Object.
|
|
719
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
720
|
+
* Can be a stringified Object.
|
|
721
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
722
|
+
* or the error
|
|
723
|
+
*/
|
|
724
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
725
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
726
|
+
const origin = `${this.id}-${meth}`;
|
|
727
|
+
log.trace(origin);
|
|
728
|
+
|
|
729
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
730
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
731
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
732
|
+
return callback(null, errorObj);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
736
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
737
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
738
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
739
|
+
return callback(null, errorObj);
|
|
740
|
+
}
|
|
741
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
742
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
743
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
744
|
+
return callback(null, errorObj);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
748
|
+
// remove any leading / and split the uripath into path variables
|
|
749
|
+
let myPath = uriPath;
|
|
750
|
+
while (myPath.indexOf('/') === 0) {
|
|
751
|
+
myPath = myPath.substring(1);
|
|
752
|
+
}
|
|
753
|
+
const pathVars = myPath.split('/');
|
|
754
|
+
const queryParamsAvailable = queryData;
|
|
755
|
+
const queryParams = {};
|
|
756
|
+
const bodyVars = requestBody;
|
|
757
|
+
|
|
758
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
759
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
760
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
761
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
762
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
767
|
+
const reqObj = {
|
|
768
|
+
payload: bodyVars,
|
|
769
|
+
uriPathVars: pathVars,
|
|
770
|
+
uriQuery: queryParams,
|
|
771
|
+
uriOptions: {}
|
|
772
|
+
};
|
|
773
|
+
// add headers if provided
|
|
774
|
+
if (addlHeaders) {
|
|
775
|
+
reqObj.addlHeaders = addlHeaders;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// determine the call and return flag
|
|
779
|
+
let action = 'getGenericsNoBase';
|
|
780
|
+
let returnF = true;
|
|
781
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
782
|
+
action = 'createGenericNoBase';
|
|
783
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
784
|
+
action = 'updateGenericNoBase';
|
|
785
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
786
|
+
action = 'patchGenericNoBase';
|
|
787
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
788
|
+
action = 'deleteGenericNoBase';
|
|
789
|
+
returnF = false;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
try {
|
|
793
|
+
// Make the call -
|
|
794
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
795
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
796
|
+
// if we received an error or their is no response on the results
|
|
797
|
+
// return an error
|
|
798
|
+
if (irReturnError) {
|
|
799
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
800
|
+
return callback(null, irReturnError);
|
|
801
|
+
}
|
|
802
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
803
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
|
804
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
805
|
+
return callback(null, errorObj);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
809
|
+
// return the response
|
|
810
|
+
return callback(irReturnData, null);
|
|
811
|
+
});
|
|
812
|
+
} catch (ex) {
|
|
813
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
814
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
815
|
+
return callback(null, errorObj);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* @callback healthCallback
|
|
821
|
+
* @param {Object} result - the result of the get request (contains an id and a status)
|
|
822
|
+
*/
|
|
823
|
+
/**
|
|
824
|
+
* @callback getCallback
|
|
825
|
+
* @param {Object} result - the result of the get request (entity/ies)
|
|
826
|
+
* @param {String} error - any error that occurred
|
|
827
|
+
*/
|
|
828
|
+
/**
|
|
829
|
+
* @callback createCallback
|
|
830
|
+
* @param {Object} item - the newly created entity
|
|
831
|
+
* @param {String} error - any error that occurred
|
|
832
|
+
*/
|
|
833
|
+
/**
|
|
834
|
+
* @callback updateCallback
|
|
835
|
+
* @param {String} status - the status of the update action
|
|
836
|
+
* @param {String} error - any error that occurred
|
|
837
|
+
*/
|
|
838
|
+
/**
|
|
839
|
+
* @callback deleteCallback
|
|
840
|
+
* @param {String} status - the status of the delete action
|
|
841
|
+
* @param {String} error - any error that occurred
|
|
842
|
+
*/
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* @function listAlarm
|
|
846
|
+
* @pronghornType method
|
|
847
|
+
* @name listAlarm
|
|
848
|
+
* @summary List or find Alarm objects
|
|
849
|
+
*
|
|
850
|
+
* @param {string} [fields] - Comma-separated properties to be provided in response
|
|
851
|
+
* @param {number} [offset] - Requested index for start of resources to be provided in response
|
|
852
|
+
* @param {number} [limit] - Requested number of resources to be provided in response
|
|
853
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
854
|
+
* @return {object} results - An object containing the response of the action
|
|
855
|
+
*
|
|
856
|
+
* @route {POST} /listAlarm
|
|
857
|
+
* @roles admin
|
|
858
|
+
* @task true
|
|
859
|
+
*/
|
|
860
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
861
|
+
listAlarm(fields, offset, limit, callback) {
|
|
862
|
+
const meth = 'adapter-listAlarm';
|
|
863
|
+
const origin = `${this.id}-${meth}`;
|
|
864
|
+
log.trace(origin);
|
|
865
|
+
|
|
866
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
867
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
868
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
869
|
+
return callback(null, errorObj);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
873
|
+
|
|
874
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
875
|
+
const queryParamsAvailable = { fields, offset, limit };
|
|
876
|
+
const queryParams = {};
|
|
877
|
+
const pathVars = [];
|
|
878
|
+
const bodyVars = {};
|
|
879
|
+
|
|
880
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
881
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
882
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
883
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
884
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
889
|
+
// see adapter code documentation for more information on the request object's fields
|
|
890
|
+
const reqObj = {
|
|
891
|
+
payload: bodyVars,
|
|
892
|
+
uriPathVars: pathVars,
|
|
893
|
+
uriQuery: queryParams
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
try {
|
|
897
|
+
// Make the call -
|
|
898
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
899
|
+
return this.requestHandlerInst.identifyRequest('Alarm', 'listAlarm', reqObj, true, (irReturnData, irReturnError) => {
|
|
900
|
+
// if we received an error or their is no response on the results
|
|
901
|
+
// return an error
|
|
902
|
+
if (irReturnError) {
|
|
903
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
904
|
+
return callback(null, irReturnError);
|
|
905
|
+
}
|
|
906
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
907
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listAlarm'], null, null, null);
|
|
908
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
909
|
+
return callback(null, errorObj);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
913
|
+
// return the response
|
|
914
|
+
return callback(irReturnData, null);
|
|
915
|
+
});
|
|
916
|
+
} catch (ex) {
|
|
917
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
918
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
919
|
+
return callback(null, errorObj);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* @function createAlarm
|
|
925
|
+
* @pronghornType method
|
|
926
|
+
* @name createAlarm
|
|
927
|
+
* @summary Creates a Alarm
|
|
928
|
+
*
|
|
929
|
+
* @param {object} alarm - The Alarm to be created
|
|
930
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
931
|
+
* @return {object} results - An object containing the response of the action
|
|
932
|
+
*
|
|
933
|
+
* @route {POST} /createAlarm
|
|
934
|
+
* @roles admin
|
|
935
|
+
* @task true
|
|
936
|
+
*/
|
|
937
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
938
|
+
createAlarm(alarm, callback) {
|
|
939
|
+
const meth = 'adapter-createAlarm';
|
|
940
|
+
const origin = `${this.id}-${meth}`;
|
|
941
|
+
log.trace(origin);
|
|
942
|
+
|
|
943
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
944
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
945
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
946
|
+
return callback(null, errorObj);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
950
|
+
if (alarm === undefined || alarm === null || alarm === '') {
|
|
951
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['alarm'], null, null, null);
|
|
952
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
953
|
+
return callback(null, errorObj);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
957
|
+
const queryParamsAvailable = {};
|
|
958
|
+
const queryParams = {};
|
|
959
|
+
const pathVars = [];
|
|
960
|
+
const bodyVars = alarm;
|
|
961
|
+
|
|
962
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
963
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
964
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
965
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
966
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
967
|
+
}
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
971
|
+
// see adapter code documentation for more information on the request object's fields
|
|
972
|
+
const reqObj = {
|
|
973
|
+
payload: bodyVars,
|
|
974
|
+
uriPathVars: pathVars,
|
|
975
|
+
uriQuery: queryParams
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
try {
|
|
979
|
+
// Make the call -
|
|
980
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
981
|
+
return this.requestHandlerInst.identifyRequest('Alarm', 'createAlarm', reqObj, true, (irReturnData, irReturnError) => {
|
|
982
|
+
// if we received an error or their is no response on the results
|
|
983
|
+
// return an error
|
|
984
|
+
if (irReturnError) {
|
|
985
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
986
|
+
return callback(null, irReturnError);
|
|
987
|
+
}
|
|
988
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
989
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createAlarm'], null, null, null);
|
|
990
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
991
|
+
return callback(null, errorObj);
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
995
|
+
// return the response
|
|
996
|
+
return callback(irReturnData, null);
|
|
997
|
+
});
|
|
998
|
+
} catch (ex) {
|
|
999
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1000
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1001
|
+
return callback(null, errorObj);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* @function retrieveAlarm
|
|
1007
|
+
* @pronghornType method
|
|
1008
|
+
* @name retrieveAlarm
|
|
1009
|
+
* @summary Retrieves a Alarm by ID
|
|
1010
|
+
*
|
|
1011
|
+
* @param {string} id - Identifier of the Alarm
|
|
1012
|
+
* @param {string} [fields] - Comma-separated properties to provide in response
|
|
1013
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1014
|
+
* @return {object} results - An object containing the response of the action
|
|
1015
|
+
*
|
|
1016
|
+
* @route {POST} /retrieveAlarm
|
|
1017
|
+
* @roles admin
|
|
1018
|
+
* @task true
|
|
1019
|
+
*/
|
|
1020
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1021
|
+
retrieveAlarm(id, fields, callback) {
|
|
1022
|
+
const meth = 'adapter-retrieveAlarm';
|
|
1023
|
+
const origin = `${this.id}-${meth}`;
|
|
1024
|
+
log.trace(origin);
|
|
1025
|
+
|
|
1026
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1027
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1028
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1029
|
+
return callback(null, errorObj);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1033
|
+
if (id === undefined || id === null || id === '') {
|
|
1034
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
1035
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1036
|
+
return callback(null, errorObj);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1040
|
+
const queryParamsAvailable = { fields };
|
|
1041
|
+
const queryParams = {};
|
|
1042
|
+
const pathVars = [id];
|
|
1043
|
+
const bodyVars = {};
|
|
1044
|
+
|
|
1045
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1046
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1047
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1048
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1049
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
|
|
1053
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1054
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1055
|
+
const reqObj = {
|
|
1056
|
+
payload: bodyVars,
|
|
1057
|
+
uriPathVars: pathVars,
|
|
1058
|
+
uriQuery: queryParams
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
try {
|
|
1062
|
+
// Make the call -
|
|
1063
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1064
|
+
return this.requestHandlerInst.identifyRequest('Alarm', 'retrieveAlarm', reqObj, true, (irReturnData, irReturnError) => {
|
|
1065
|
+
// if we received an error or their is no response on the results
|
|
1066
|
+
// return an error
|
|
1067
|
+
if (irReturnError) {
|
|
1068
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1069
|
+
return callback(null, irReturnError);
|
|
1070
|
+
}
|
|
1071
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1072
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveAlarm'], null, null, null);
|
|
1073
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1074
|
+
return callback(null, errorObj);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1078
|
+
// return the response
|
|
1079
|
+
return callback(irReturnData, null);
|
|
1080
|
+
});
|
|
1081
|
+
} catch (ex) {
|
|
1082
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1083
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1084
|
+
return callback(null, errorObj);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* @function patchAlarm
|
|
1090
|
+
* @pronghornType method
|
|
1091
|
+
* @name patchAlarm
|
|
1092
|
+
* @summary Updates partially a Alarm
|
|
1093
|
+
*
|
|
1094
|
+
* @param {string} id - Identifier of the Alarm
|
|
1095
|
+
* @param {object} alarm - The Alarm to be updated
|
|
1096
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1097
|
+
* @return {object} results - An object containing the response of the action
|
|
1098
|
+
*
|
|
1099
|
+
* @route {POST} /patchAlarm
|
|
1100
|
+
* @roles admin
|
|
1101
|
+
* @task true
|
|
1102
|
+
*/
|
|
1103
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1104
|
+
patchAlarm(id, alarm, callback) {
|
|
1105
|
+
const meth = 'adapter-patchAlarm';
|
|
1106
|
+
const origin = `${this.id}-${meth}`;
|
|
1107
|
+
log.trace(origin);
|
|
1108
|
+
|
|
1109
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1110
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1111
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1112
|
+
return callback(null, errorObj);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1116
|
+
if (id === undefined || id === null || id === '') {
|
|
1117
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
1118
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1119
|
+
return callback(null, errorObj);
|
|
1120
|
+
}
|
|
1121
|
+
if (alarm === undefined || alarm === null || alarm === '') {
|
|
1122
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['alarm'], null, null, null);
|
|
1123
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1124
|
+
return callback(null, errorObj);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1128
|
+
const queryParamsAvailable = {};
|
|
1129
|
+
const queryParams = {};
|
|
1130
|
+
const pathVars = [id];
|
|
1131
|
+
const bodyVars = alarm;
|
|
1132
|
+
|
|
1133
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1134
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1135
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1136
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1137
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1141
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1142
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1143
|
+
const reqObj = {
|
|
1144
|
+
payload: bodyVars,
|
|
1145
|
+
uriPathVars: pathVars,
|
|
1146
|
+
uriQuery: queryParams
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
try {
|
|
1150
|
+
// Make the call -
|
|
1151
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1152
|
+
return this.requestHandlerInst.identifyRequest('Alarm', 'patchAlarm', reqObj, false, (irReturnData, irReturnError) => {
|
|
1153
|
+
// if we received an error or their is no response on the results
|
|
1154
|
+
// return an error
|
|
1155
|
+
if (irReturnError) {
|
|
1156
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1157
|
+
return callback(null, irReturnError);
|
|
1158
|
+
}
|
|
1159
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1160
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchAlarm'], null, null, null);
|
|
1161
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1162
|
+
return callback(null, errorObj);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1166
|
+
// return the response
|
|
1167
|
+
return callback(irReturnData, null);
|
|
1168
|
+
});
|
|
1169
|
+
} catch (ex) {
|
|
1170
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1171
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1172
|
+
return callback(null, errorObj);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* @function deleteAlarm
|
|
1178
|
+
* @pronghornType method
|
|
1179
|
+
* @name deleteAlarm
|
|
1180
|
+
* @summary Deletes a Alarm
|
|
1181
|
+
*
|
|
1182
|
+
* @param {string} id - Identifier of the Alarm
|
|
1183
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1184
|
+
* @return {object} results - An object containing the response of the action
|
|
1185
|
+
*
|
|
1186
|
+
* @route {POST} /deleteAlarm
|
|
1187
|
+
* @roles admin
|
|
1188
|
+
* @task true
|
|
1189
|
+
*/
|
|
1190
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1191
|
+
deleteAlarm(id, callback) {
|
|
1192
|
+
const meth = 'adapter-deleteAlarm';
|
|
1193
|
+
const origin = `${this.id}-${meth}`;
|
|
1194
|
+
log.trace(origin);
|
|
1195
|
+
|
|
1196
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1197
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1198
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1199
|
+
return callback(null, errorObj);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1203
|
+
if (id === undefined || id === null || id === '') {
|
|
1204
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
1205
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1206
|
+
return callback(null, errorObj);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1210
|
+
const queryParamsAvailable = {};
|
|
1211
|
+
const queryParams = {};
|
|
1212
|
+
const pathVars = [id];
|
|
1213
|
+
const bodyVars = {};
|
|
1214
|
+
|
|
1215
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1216
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1217
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1218
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1219
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1220
|
+
}
|
|
1221
|
+
});
|
|
1222
|
+
|
|
1223
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1224
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1225
|
+
const reqObj = {
|
|
1226
|
+
payload: bodyVars,
|
|
1227
|
+
uriPathVars: pathVars,
|
|
1228
|
+
uriQuery: queryParams
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
try {
|
|
1232
|
+
// Make the call -
|
|
1233
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1234
|
+
return this.requestHandlerInst.identifyRequest('Alarm', 'deleteAlarm', reqObj, false, (irReturnData, irReturnError) => {
|
|
1235
|
+
// if we received an error or their is no response on the results
|
|
1236
|
+
// return an error
|
|
1237
|
+
if (irReturnError) {
|
|
1238
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1239
|
+
return callback(null, irReturnError);
|
|
1240
|
+
}
|
|
1241
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1242
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteAlarm'], null, null, null);
|
|
1243
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1244
|
+
return callback(null, errorObj);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1248
|
+
// return the response
|
|
1249
|
+
return callback(irReturnData, null);
|
|
1250
|
+
});
|
|
1251
|
+
} catch (ex) {
|
|
1252
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1253
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1254
|
+
return callback(null, errorObj);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* @function listAckAlarms
|
|
1260
|
+
* @pronghornType method
|
|
1261
|
+
* @name listAckAlarms
|
|
1262
|
+
* @summary List or find AckAlarms objects
|
|
1263
|
+
*
|
|
1264
|
+
* @param {string} [fields] - Comma-separated properties to be provided in response
|
|
1265
|
+
* @param {number} [offset] - Requested index for start of resources to be provided in response
|
|
1266
|
+
* @param {number} [limit] - Requested number of resources to be provided in response
|
|
1267
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1268
|
+
* @return {object} results - An object containing the response of the action
|
|
1269
|
+
*
|
|
1270
|
+
* @route {POST} /listAckAlarms
|
|
1271
|
+
* @roles admin
|
|
1272
|
+
* @task true
|
|
1273
|
+
*/
|
|
1274
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1275
|
+
listAckAlarms(fields, offset, limit, callback) {
|
|
1276
|
+
const meth = 'adapter-listAckAlarms';
|
|
1277
|
+
const origin = `${this.id}-${meth}`;
|
|
1278
|
+
log.trace(origin);
|
|
1279
|
+
|
|
1280
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1281
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1282
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1283
|
+
return callback(null, errorObj);
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1287
|
+
|
|
1288
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1289
|
+
const queryParamsAvailable = { fields, offset, limit };
|
|
1290
|
+
const queryParams = {};
|
|
1291
|
+
const pathVars = [];
|
|
1292
|
+
const bodyVars = {};
|
|
1293
|
+
|
|
1294
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1295
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1296
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1297
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1298
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
|
|
1302
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1303
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1304
|
+
const reqObj = {
|
|
1305
|
+
payload: bodyVars,
|
|
1306
|
+
uriPathVars: pathVars,
|
|
1307
|
+
uriQuery: queryParams
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
try {
|
|
1311
|
+
// Make the call -
|
|
1312
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1313
|
+
return this.requestHandlerInst.identifyRequest('AckAlarms', 'listAckAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1314
|
+
// if we received an error or their is no response on the results
|
|
1315
|
+
// return an error
|
|
1316
|
+
if (irReturnError) {
|
|
1317
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1318
|
+
return callback(null, irReturnError);
|
|
1319
|
+
}
|
|
1320
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1321
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listAckAlarms'], null, null, null);
|
|
1322
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1323
|
+
return callback(null, errorObj);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1327
|
+
// return the response
|
|
1328
|
+
return callback(irReturnData, null);
|
|
1329
|
+
});
|
|
1330
|
+
} catch (ex) {
|
|
1331
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1332
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1333
|
+
return callback(null, errorObj);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/**
|
|
1338
|
+
* @function createAckAlarms
|
|
1339
|
+
* @pronghornType method
|
|
1340
|
+
* @name createAckAlarms
|
|
1341
|
+
* @summary Creates a AckAlarms
|
|
1342
|
+
*
|
|
1343
|
+
* @param {object} ackAlarms - The AckAlarms to be created
|
|
1344
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1345
|
+
* @return {object} results - An object containing the response of the action
|
|
1346
|
+
*
|
|
1347
|
+
* @route {POST} /createAckAlarms
|
|
1348
|
+
* @roles admin
|
|
1349
|
+
* @task true
|
|
1350
|
+
*/
|
|
1351
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1352
|
+
createAckAlarms(ackAlarms, callback) {
|
|
1353
|
+
const meth = 'adapter-createAckAlarms';
|
|
1354
|
+
const origin = `${this.id}-${meth}`;
|
|
1355
|
+
log.trace(origin);
|
|
1356
|
+
|
|
1357
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1358
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1359
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1360
|
+
return callback(null, errorObj);
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1364
|
+
if (ackAlarms === undefined || ackAlarms === null || ackAlarms === '') {
|
|
1365
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['ackAlarms'], null, null, null);
|
|
1366
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1367
|
+
return callback(null, errorObj);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1371
|
+
const queryParamsAvailable = {};
|
|
1372
|
+
const queryParams = {};
|
|
1373
|
+
const pathVars = [];
|
|
1374
|
+
const bodyVars = ackAlarms;
|
|
1375
|
+
|
|
1376
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1377
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1378
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1379
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1380
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1381
|
+
}
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1385
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1386
|
+
const reqObj = {
|
|
1387
|
+
payload: bodyVars,
|
|
1388
|
+
uriPathVars: pathVars,
|
|
1389
|
+
uriQuery: queryParams
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
try {
|
|
1393
|
+
// Make the call -
|
|
1394
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1395
|
+
return this.requestHandlerInst.identifyRequest('AckAlarms', 'createAckAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1396
|
+
// if we received an error or their is no response on the results
|
|
1397
|
+
// return an error
|
|
1398
|
+
if (irReturnError) {
|
|
1399
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1400
|
+
return callback(null, irReturnError);
|
|
1401
|
+
}
|
|
1402
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1403
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createAckAlarms'], null, null, null);
|
|
1404
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1405
|
+
return callback(null, errorObj);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1409
|
+
// return the response
|
|
1410
|
+
return callback(irReturnData, null);
|
|
1411
|
+
});
|
|
1412
|
+
} catch (ex) {
|
|
1413
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1414
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1415
|
+
return callback(null, errorObj);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* @function retrieveAckAlarms
|
|
1421
|
+
* @pronghornType method
|
|
1422
|
+
* @name retrieveAckAlarms
|
|
1423
|
+
* @summary Retrieves a AckAlarms by ID
|
|
1424
|
+
*
|
|
1425
|
+
* @param {string} id - Identifier of the AckAlarms
|
|
1426
|
+
* @param {string} [fields] - Comma-separated properties to provide in response
|
|
1427
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1428
|
+
* @return {object} results - An object containing the response of the action
|
|
1429
|
+
*
|
|
1430
|
+
* @route {POST} /retrieveAckAlarms
|
|
1431
|
+
* @roles admin
|
|
1432
|
+
* @task true
|
|
1433
|
+
*/
|
|
1434
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1435
|
+
retrieveAckAlarms(id, fields, callback) {
|
|
1436
|
+
const meth = 'adapter-retrieveAckAlarms';
|
|
1437
|
+
const origin = `${this.id}-${meth}`;
|
|
1438
|
+
log.trace(origin);
|
|
1439
|
+
|
|
1440
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1441
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1442
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1443
|
+
return callback(null, errorObj);
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1447
|
+
if (id === undefined || id === null || id === '') {
|
|
1448
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
1449
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1450
|
+
return callback(null, errorObj);
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1454
|
+
const queryParamsAvailable = { fields };
|
|
1455
|
+
const queryParams = {};
|
|
1456
|
+
const pathVars = [id];
|
|
1457
|
+
const bodyVars = {};
|
|
1458
|
+
|
|
1459
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1460
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1461
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1462
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1463
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1468
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1469
|
+
const reqObj = {
|
|
1470
|
+
payload: bodyVars,
|
|
1471
|
+
uriPathVars: pathVars,
|
|
1472
|
+
uriQuery: queryParams
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1475
|
+
try {
|
|
1476
|
+
// Make the call -
|
|
1477
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1478
|
+
return this.requestHandlerInst.identifyRequest('AckAlarms', 'retrieveAckAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1479
|
+
// if we received an error or their is no response on the results
|
|
1480
|
+
// return an error
|
|
1481
|
+
if (irReturnError) {
|
|
1482
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1483
|
+
return callback(null, irReturnError);
|
|
1484
|
+
}
|
|
1485
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1486
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveAckAlarms'], null, null, null);
|
|
1487
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1488
|
+
return callback(null, errorObj);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1492
|
+
// return the response
|
|
1493
|
+
return callback(irReturnData, null);
|
|
1494
|
+
});
|
|
1495
|
+
} catch (ex) {
|
|
1496
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1497
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1498
|
+
return callback(null, errorObj);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* @function listUnAckAlarms
|
|
1504
|
+
* @pronghornType method
|
|
1505
|
+
* @name listUnAckAlarms
|
|
1506
|
+
* @summary List or find UnAckAlarms objects
|
|
1507
|
+
*
|
|
1508
|
+
* @param {string} [fields] - Comma-separated properties to be provided in response
|
|
1509
|
+
* @param {number} [offset] - Requested index for start of resources to be provided in response
|
|
1510
|
+
* @param {number} [limit] - Requested number of resources to be provided in response
|
|
1511
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1512
|
+
* @return {object} results - An object containing the response of the action
|
|
1513
|
+
*
|
|
1514
|
+
* @route {POST} /listUnAckAlarms
|
|
1515
|
+
* @roles admin
|
|
1516
|
+
* @task true
|
|
1517
|
+
*/
|
|
1518
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1519
|
+
listUnAckAlarms(fields, offset, limit, callback) {
|
|
1520
|
+
const meth = 'adapter-listUnAckAlarms';
|
|
1521
|
+
const origin = `${this.id}-${meth}`;
|
|
1522
|
+
log.trace(origin);
|
|
1523
|
+
|
|
1524
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1525
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1526
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1527
|
+
return callback(null, errorObj);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1531
|
+
|
|
1532
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1533
|
+
const queryParamsAvailable = { fields, offset, limit };
|
|
1534
|
+
const queryParams = {};
|
|
1535
|
+
const pathVars = [];
|
|
1536
|
+
const bodyVars = {};
|
|
1537
|
+
|
|
1538
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1539
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1540
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1541
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1542
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1545
|
+
|
|
1546
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1547
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1548
|
+
const reqObj = {
|
|
1549
|
+
payload: bodyVars,
|
|
1550
|
+
uriPathVars: pathVars,
|
|
1551
|
+
uriQuery: queryParams
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
try {
|
|
1555
|
+
// Make the call -
|
|
1556
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1557
|
+
return this.requestHandlerInst.identifyRequest('UnAckAlarms', 'listUnAckAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1558
|
+
// if we received an error or their is no response on the results
|
|
1559
|
+
// return an error
|
|
1560
|
+
if (irReturnError) {
|
|
1561
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1562
|
+
return callback(null, irReturnError);
|
|
1563
|
+
}
|
|
1564
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1565
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listUnAckAlarms'], null, null, null);
|
|
1566
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1567
|
+
return callback(null, errorObj);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1571
|
+
// return the response
|
|
1572
|
+
return callback(irReturnData, null);
|
|
1573
|
+
});
|
|
1574
|
+
} catch (ex) {
|
|
1575
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1576
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1577
|
+
return callback(null, errorObj);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* @function createUnAckAlarms
|
|
1583
|
+
* @pronghornType method
|
|
1584
|
+
* @name createUnAckAlarms
|
|
1585
|
+
* @summary Creates a UnAckAlarms
|
|
1586
|
+
*
|
|
1587
|
+
* @param {object} unAckAlarms - The UnAckAlarms to be created
|
|
1588
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1589
|
+
* @return {object} results - An object containing the response of the action
|
|
1590
|
+
*
|
|
1591
|
+
* @route {POST} /createUnAckAlarms
|
|
1592
|
+
* @roles admin
|
|
1593
|
+
* @task true
|
|
1594
|
+
*/
|
|
1595
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1596
|
+
createUnAckAlarms(unAckAlarms, callback) {
|
|
1597
|
+
const meth = 'adapter-createUnAckAlarms';
|
|
1598
|
+
const origin = `${this.id}-${meth}`;
|
|
1599
|
+
log.trace(origin);
|
|
1600
|
+
|
|
1601
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1602
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1603
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1604
|
+
return callback(null, errorObj);
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1608
|
+
if (unAckAlarms === undefined || unAckAlarms === null || unAckAlarms === '') {
|
|
1609
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['unAckAlarms'], null, null, null);
|
|
1610
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1611
|
+
return callback(null, errorObj);
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1615
|
+
const queryParamsAvailable = {};
|
|
1616
|
+
const queryParams = {};
|
|
1617
|
+
const pathVars = [];
|
|
1618
|
+
const bodyVars = unAckAlarms;
|
|
1619
|
+
|
|
1620
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1621
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1622
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1623
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1624
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
|
|
1628
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1629
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1630
|
+
const reqObj = {
|
|
1631
|
+
payload: bodyVars,
|
|
1632
|
+
uriPathVars: pathVars,
|
|
1633
|
+
uriQuery: queryParams
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
try {
|
|
1637
|
+
// Make the call -
|
|
1638
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1639
|
+
return this.requestHandlerInst.identifyRequest('UnAckAlarms', 'createUnAckAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1640
|
+
// if we received an error or their is no response on the results
|
|
1641
|
+
// return an error
|
|
1642
|
+
if (irReturnError) {
|
|
1643
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1644
|
+
return callback(null, irReturnError);
|
|
1645
|
+
}
|
|
1646
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1647
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createUnAckAlarms'], null, null, null);
|
|
1648
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1649
|
+
return callback(null, errorObj);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1653
|
+
// return the response
|
|
1654
|
+
return callback(irReturnData, null);
|
|
1655
|
+
});
|
|
1656
|
+
} catch (ex) {
|
|
1657
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1658
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1659
|
+
return callback(null, errorObj);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* @function retrieveUnAckAlarms
|
|
1665
|
+
* @pronghornType method
|
|
1666
|
+
* @name retrieveUnAckAlarms
|
|
1667
|
+
* @summary Retrieves a UnAckAlarms by ID
|
|
1668
|
+
*
|
|
1669
|
+
* @param {string} id - Identifier of the UnAckAlarms
|
|
1670
|
+
* @param {string} [fields] - Comma-separated properties to provide in response
|
|
1671
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1672
|
+
* @return {object} results - An object containing the response of the action
|
|
1673
|
+
*
|
|
1674
|
+
* @route {POST} /retrieveUnAckAlarms
|
|
1675
|
+
* @roles admin
|
|
1676
|
+
* @task true
|
|
1677
|
+
*/
|
|
1678
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1679
|
+
retrieveUnAckAlarms(id, fields, callback) {
|
|
1680
|
+
const meth = 'adapter-retrieveUnAckAlarms';
|
|
1681
|
+
const origin = `${this.id}-${meth}`;
|
|
1682
|
+
log.trace(origin);
|
|
1683
|
+
|
|
1684
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1685
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1686
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1687
|
+
return callback(null, errorObj);
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1691
|
+
if (id === undefined || id === null || id === '') {
|
|
1692
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
1693
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1694
|
+
return callback(null, errorObj);
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1698
|
+
const queryParamsAvailable = { fields };
|
|
1699
|
+
const queryParams = {};
|
|
1700
|
+
const pathVars = [id];
|
|
1701
|
+
const bodyVars = {};
|
|
1702
|
+
|
|
1703
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1704
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1705
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1706
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1707
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
|
|
1711
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1712
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1713
|
+
const reqObj = {
|
|
1714
|
+
payload: bodyVars,
|
|
1715
|
+
uriPathVars: pathVars,
|
|
1716
|
+
uriQuery: queryParams
|
|
1717
|
+
};
|
|
1718
|
+
|
|
1719
|
+
try {
|
|
1720
|
+
// Make the call -
|
|
1721
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1722
|
+
return this.requestHandlerInst.identifyRequest('UnAckAlarms', 'retrieveUnAckAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1723
|
+
// if we received an error or their is no response on the results
|
|
1724
|
+
// return an error
|
|
1725
|
+
if (irReturnError) {
|
|
1726
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1727
|
+
return callback(null, irReturnError);
|
|
1728
|
+
}
|
|
1729
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1730
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveUnAckAlarms'], null, null, null);
|
|
1731
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1732
|
+
return callback(null, errorObj);
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1736
|
+
// return the response
|
|
1737
|
+
return callback(irReturnData, null);
|
|
1738
|
+
});
|
|
1739
|
+
} catch (ex) {
|
|
1740
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1741
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1742
|
+
return callback(null, errorObj);
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* @function listClearAlarms
|
|
1748
|
+
* @pronghornType method
|
|
1749
|
+
* @name listClearAlarms
|
|
1750
|
+
* @summary List or find ClearAlarms objects
|
|
1751
|
+
*
|
|
1752
|
+
* @param {string} [fields] - Comma-separated properties to be provided in response
|
|
1753
|
+
* @param {number} [offset] - Requested index for start of resources to be provided in response
|
|
1754
|
+
* @param {number} [limit] - Requested number of resources to be provided in response
|
|
1755
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1756
|
+
* @return {object} results - An object containing the response of the action
|
|
1757
|
+
*
|
|
1758
|
+
* @route {POST} /listClearAlarms
|
|
1759
|
+
* @roles admin
|
|
1760
|
+
* @task true
|
|
1761
|
+
*/
|
|
1762
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1763
|
+
listClearAlarms(fields, offset, limit, callback) {
|
|
1764
|
+
const meth = 'adapter-listClearAlarms';
|
|
1765
|
+
const origin = `${this.id}-${meth}`;
|
|
1766
|
+
log.trace(origin);
|
|
1767
|
+
|
|
1768
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1769
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1770
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1771
|
+
return callback(null, errorObj);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1775
|
+
|
|
1776
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1777
|
+
const queryParamsAvailable = { fields, offset, limit };
|
|
1778
|
+
const queryParams = {};
|
|
1779
|
+
const pathVars = [];
|
|
1780
|
+
const bodyVars = {};
|
|
1781
|
+
|
|
1782
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1783
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1784
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1785
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1786
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1787
|
+
}
|
|
1788
|
+
});
|
|
1789
|
+
|
|
1790
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1791
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1792
|
+
const reqObj = {
|
|
1793
|
+
payload: bodyVars,
|
|
1794
|
+
uriPathVars: pathVars,
|
|
1795
|
+
uriQuery: queryParams
|
|
1796
|
+
};
|
|
1797
|
+
|
|
1798
|
+
try {
|
|
1799
|
+
// Make the call -
|
|
1800
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1801
|
+
return this.requestHandlerInst.identifyRequest('ClearAlarms', 'listClearAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1802
|
+
// if we received an error or their is no response on the results
|
|
1803
|
+
// return an error
|
|
1804
|
+
if (irReturnError) {
|
|
1805
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1806
|
+
return callback(null, irReturnError);
|
|
1807
|
+
}
|
|
1808
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1809
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listClearAlarms'], null, null, null);
|
|
1810
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1811
|
+
return callback(null, errorObj);
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1815
|
+
// return the response
|
|
1816
|
+
return callback(irReturnData, null);
|
|
1817
|
+
});
|
|
1818
|
+
} catch (ex) {
|
|
1819
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1820
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1821
|
+
return callback(null, errorObj);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
/**
|
|
1826
|
+
* @function createClearAlarms
|
|
1827
|
+
* @pronghornType method
|
|
1828
|
+
* @name createClearAlarms
|
|
1829
|
+
* @summary Creates a ClearAlarms
|
|
1830
|
+
*
|
|
1831
|
+
* @param {object} clearAlarms - The ClearAlarms to be created
|
|
1832
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1833
|
+
* @return {object} results - An object containing the response of the action
|
|
1834
|
+
*
|
|
1835
|
+
* @route {POST} /createClearAlarms
|
|
1836
|
+
* @roles admin
|
|
1837
|
+
* @task true
|
|
1838
|
+
*/
|
|
1839
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1840
|
+
createClearAlarms(clearAlarms, callback) {
|
|
1841
|
+
const meth = 'adapter-createClearAlarms';
|
|
1842
|
+
const origin = `${this.id}-${meth}`;
|
|
1843
|
+
log.trace(origin);
|
|
1844
|
+
|
|
1845
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1846
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1847
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1848
|
+
return callback(null, errorObj);
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1852
|
+
if (clearAlarms === undefined || clearAlarms === null || clearAlarms === '') {
|
|
1853
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['clearAlarms'], null, null, null);
|
|
1854
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1855
|
+
return callback(null, errorObj);
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1859
|
+
const queryParamsAvailable = {};
|
|
1860
|
+
const queryParams = {};
|
|
1861
|
+
const pathVars = [];
|
|
1862
|
+
const bodyVars = clearAlarms;
|
|
1863
|
+
|
|
1864
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1865
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1866
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1867
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1868
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
|
|
1872
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1873
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1874
|
+
const reqObj = {
|
|
1875
|
+
payload: bodyVars,
|
|
1876
|
+
uriPathVars: pathVars,
|
|
1877
|
+
uriQuery: queryParams
|
|
1878
|
+
};
|
|
1879
|
+
|
|
1880
|
+
try {
|
|
1881
|
+
// Make the call -
|
|
1882
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1883
|
+
return this.requestHandlerInst.identifyRequest('ClearAlarms', 'createClearAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1884
|
+
// if we received an error or their is no response on the results
|
|
1885
|
+
// return an error
|
|
1886
|
+
if (irReturnError) {
|
|
1887
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1888
|
+
return callback(null, irReturnError);
|
|
1889
|
+
}
|
|
1890
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1891
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createClearAlarms'], null, null, null);
|
|
1892
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1893
|
+
return callback(null, errorObj);
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1897
|
+
// return the response
|
|
1898
|
+
return callback(irReturnData, null);
|
|
1899
|
+
});
|
|
1900
|
+
} catch (ex) {
|
|
1901
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1902
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1903
|
+
return callback(null, errorObj);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
/**
|
|
1908
|
+
* @function retrieveClearAlarms
|
|
1909
|
+
* @pronghornType method
|
|
1910
|
+
* @name retrieveClearAlarms
|
|
1911
|
+
* @summary Retrieves a ClearAlarms by ID
|
|
1912
|
+
*
|
|
1913
|
+
* @param {string} id - Identifier of the ClearAlarms
|
|
1914
|
+
* @param {string} [fields] - Comma-separated properties to provide in response
|
|
1915
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1916
|
+
* @return {object} results - An object containing the response of the action
|
|
1917
|
+
*
|
|
1918
|
+
* @route {POST} /retrieveClearAlarms
|
|
1919
|
+
* @roles admin
|
|
1920
|
+
* @task true
|
|
1921
|
+
*/
|
|
1922
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1923
|
+
retrieveClearAlarms(id, fields, callback) {
|
|
1924
|
+
const meth = 'adapter-retrieveClearAlarms';
|
|
1925
|
+
const origin = `${this.id}-${meth}`;
|
|
1926
|
+
log.trace(origin);
|
|
1927
|
+
|
|
1928
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1929
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1930
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1931
|
+
return callback(null, errorObj);
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1935
|
+
if (id === undefined || id === null || id === '') {
|
|
1936
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
1937
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1938
|
+
return callback(null, errorObj);
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1942
|
+
const queryParamsAvailable = { fields };
|
|
1943
|
+
const queryParams = {};
|
|
1944
|
+
const pathVars = [id];
|
|
1945
|
+
const bodyVars = {};
|
|
1946
|
+
|
|
1947
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1948
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1949
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1950
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1951
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1952
|
+
}
|
|
1953
|
+
});
|
|
1954
|
+
|
|
1955
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1956
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1957
|
+
const reqObj = {
|
|
1958
|
+
payload: bodyVars,
|
|
1959
|
+
uriPathVars: pathVars,
|
|
1960
|
+
uriQuery: queryParams
|
|
1961
|
+
};
|
|
1962
|
+
|
|
1963
|
+
try {
|
|
1964
|
+
// Make the call -
|
|
1965
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1966
|
+
return this.requestHandlerInst.identifyRequest('ClearAlarms', 'retrieveClearAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
1967
|
+
// if we received an error or their is no response on the results
|
|
1968
|
+
// return an error
|
|
1969
|
+
if (irReturnError) {
|
|
1970
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1971
|
+
return callback(null, irReturnError);
|
|
1972
|
+
}
|
|
1973
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1974
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveClearAlarms'], null, null, null);
|
|
1975
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1976
|
+
return callback(null, errorObj);
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1980
|
+
// return the response
|
|
1981
|
+
return callback(irReturnData, null);
|
|
1982
|
+
});
|
|
1983
|
+
} catch (ex) {
|
|
1984
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1985
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1986
|
+
return callback(null, errorObj);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* @function listCommentAlarms
|
|
1992
|
+
* @pronghornType method
|
|
1993
|
+
* @name listCommentAlarms
|
|
1994
|
+
* @summary List or find CommentAlarms objects
|
|
1995
|
+
*
|
|
1996
|
+
* @param {string} [fields] - Comma-separated properties to be provided in response
|
|
1997
|
+
* @param {number} [offset] - Requested index for start of resources to be provided in response
|
|
1998
|
+
* @param {number} [limit] - Requested number of resources to be provided in response
|
|
1999
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2000
|
+
* @return {object} results - An object containing the response of the action
|
|
2001
|
+
*
|
|
2002
|
+
* @route {POST} /listCommentAlarms
|
|
2003
|
+
* @roles admin
|
|
2004
|
+
* @task true
|
|
2005
|
+
*/
|
|
2006
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2007
|
+
listCommentAlarms(fields, offset, limit, callback) {
|
|
2008
|
+
const meth = 'adapter-listCommentAlarms';
|
|
2009
|
+
const origin = `${this.id}-${meth}`;
|
|
2010
|
+
log.trace(origin);
|
|
2011
|
+
|
|
2012
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2013
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2014
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2015
|
+
return callback(null, errorObj);
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2019
|
+
|
|
2020
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2021
|
+
const queryParamsAvailable = { fields, offset, limit };
|
|
2022
|
+
const queryParams = {};
|
|
2023
|
+
const pathVars = [];
|
|
2024
|
+
const bodyVars = {};
|
|
2025
|
+
|
|
2026
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2027
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2028
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2029
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2030
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2031
|
+
}
|
|
2032
|
+
});
|
|
2033
|
+
|
|
2034
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2035
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2036
|
+
const reqObj = {
|
|
2037
|
+
payload: bodyVars,
|
|
2038
|
+
uriPathVars: pathVars,
|
|
2039
|
+
uriQuery: queryParams
|
|
2040
|
+
};
|
|
2041
|
+
|
|
2042
|
+
try {
|
|
2043
|
+
// Make the call -
|
|
2044
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2045
|
+
return this.requestHandlerInst.identifyRequest('CommentAlarms', 'listCommentAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2046
|
+
// if we received an error or their is no response on the results
|
|
2047
|
+
// return an error
|
|
2048
|
+
if (irReturnError) {
|
|
2049
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2050
|
+
return callback(null, irReturnError);
|
|
2051
|
+
}
|
|
2052
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2053
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCommentAlarms'], null, null, null);
|
|
2054
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2055
|
+
return callback(null, errorObj);
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2059
|
+
// return the response
|
|
2060
|
+
return callback(irReturnData, null);
|
|
2061
|
+
});
|
|
2062
|
+
} catch (ex) {
|
|
2063
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2064
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2065
|
+
return callback(null, errorObj);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
/**
|
|
2070
|
+
* @function createCommentAlarms
|
|
2071
|
+
* @pronghornType method
|
|
2072
|
+
* @name createCommentAlarms
|
|
2073
|
+
* @summary Creates a CommentAlarms
|
|
2074
|
+
*
|
|
2075
|
+
* @param {object} commentAlarms - The CommentAlarms to be created
|
|
2076
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2077
|
+
* @return {object} results - An object containing the response of the action
|
|
2078
|
+
*
|
|
2079
|
+
* @route {POST} /createCommentAlarms
|
|
2080
|
+
* @roles admin
|
|
2081
|
+
* @task true
|
|
2082
|
+
*/
|
|
2083
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2084
|
+
createCommentAlarms(commentAlarms, callback) {
|
|
2085
|
+
const meth = 'adapter-createCommentAlarms';
|
|
2086
|
+
const origin = `${this.id}-${meth}`;
|
|
2087
|
+
log.trace(origin);
|
|
2088
|
+
|
|
2089
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2090
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2091
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2092
|
+
return callback(null, errorObj);
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2096
|
+
if (commentAlarms === undefined || commentAlarms === null || commentAlarms === '') {
|
|
2097
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['commentAlarms'], null, null, null);
|
|
2098
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2099
|
+
return callback(null, errorObj);
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2103
|
+
const queryParamsAvailable = {};
|
|
2104
|
+
const queryParams = {};
|
|
2105
|
+
const pathVars = [];
|
|
2106
|
+
const bodyVars = commentAlarms;
|
|
2107
|
+
|
|
2108
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2109
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2110
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2111
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2112
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2113
|
+
}
|
|
2114
|
+
});
|
|
2115
|
+
|
|
2116
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2117
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2118
|
+
const reqObj = {
|
|
2119
|
+
payload: bodyVars,
|
|
2120
|
+
uriPathVars: pathVars,
|
|
2121
|
+
uriQuery: queryParams
|
|
2122
|
+
};
|
|
2123
|
+
|
|
2124
|
+
try {
|
|
2125
|
+
// Make the call -
|
|
2126
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2127
|
+
return this.requestHandlerInst.identifyRequest('CommentAlarms', 'createCommentAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2128
|
+
// if we received an error or their is no response on the results
|
|
2129
|
+
// return an error
|
|
2130
|
+
if (irReturnError) {
|
|
2131
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2132
|
+
return callback(null, irReturnError);
|
|
2133
|
+
}
|
|
2134
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2135
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createCommentAlarms'], null, null, null);
|
|
2136
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2137
|
+
return callback(null, errorObj);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2141
|
+
// return the response
|
|
2142
|
+
return callback(irReturnData, null);
|
|
2143
|
+
});
|
|
2144
|
+
} catch (ex) {
|
|
2145
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2146
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2147
|
+
return callback(null, errorObj);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
/**
|
|
2152
|
+
* @function retrieveCommentAlarms
|
|
2153
|
+
* @pronghornType method
|
|
2154
|
+
* @name retrieveCommentAlarms
|
|
2155
|
+
* @summary Retrieves a CommentAlarms by ID
|
|
2156
|
+
*
|
|
2157
|
+
* @param {string} id - Identifier of the CommentAlarms
|
|
2158
|
+
* @param {string} [fields] - Comma-separated properties to provide in response
|
|
2159
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2160
|
+
* @return {object} results - An object containing the response of the action
|
|
2161
|
+
*
|
|
2162
|
+
* @route {POST} /retrieveCommentAlarms
|
|
2163
|
+
* @roles admin
|
|
2164
|
+
* @task true
|
|
2165
|
+
*/
|
|
2166
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2167
|
+
retrieveCommentAlarms(id, fields, callback) {
|
|
2168
|
+
const meth = 'adapter-retrieveCommentAlarms';
|
|
2169
|
+
const origin = `${this.id}-${meth}`;
|
|
2170
|
+
log.trace(origin);
|
|
2171
|
+
|
|
2172
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2173
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2174
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2175
|
+
return callback(null, errorObj);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2179
|
+
if (id === undefined || id === null || id === '') {
|
|
2180
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
2181
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2182
|
+
return callback(null, errorObj);
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2186
|
+
const queryParamsAvailable = { fields };
|
|
2187
|
+
const queryParams = {};
|
|
2188
|
+
const pathVars = [id];
|
|
2189
|
+
const bodyVars = {};
|
|
2190
|
+
|
|
2191
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2192
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2193
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2194
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2195
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
|
|
2199
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2200
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2201
|
+
const reqObj = {
|
|
2202
|
+
payload: bodyVars,
|
|
2203
|
+
uriPathVars: pathVars,
|
|
2204
|
+
uriQuery: queryParams
|
|
2205
|
+
};
|
|
2206
|
+
|
|
2207
|
+
try {
|
|
2208
|
+
// Make the call -
|
|
2209
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2210
|
+
return this.requestHandlerInst.identifyRequest('CommentAlarms', 'retrieveCommentAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2211
|
+
// if we received an error or their is no response on the results
|
|
2212
|
+
// return an error
|
|
2213
|
+
if (irReturnError) {
|
|
2214
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2215
|
+
return callback(null, irReturnError);
|
|
2216
|
+
}
|
|
2217
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2218
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveCommentAlarms'], null, null, null);
|
|
2219
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2220
|
+
return callback(null, errorObj);
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2224
|
+
// return the response
|
|
2225
|
+
return callback(irReturnData, null);
|
|
2226
|
+
});
|
|
2227
|
+
} catch (ex) {
|
|
2228
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2229
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2230
|
+
return callback(null, errorObj);
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
/**
|
|
2235
|
+
* @function listGroupAlarms
|
|
2236
|
+
* @pronghornType method
|
|
2237
|
+
* @name listGroupAlarms
|
|
2238
|
+
* @summary List or find GroupAlarms objects
|
|
2239
|
+
*
|
|
2240
|
+
* @param {string} [fields] - Comma-separated properties to be provided in response
|
|
2241
|
+
* @param {number} [offset] - Requested index for start of resources to be provided in response
|
|
2242
|
+
* @param {number} [limit] - Requested number of resources to be provided in response
|
|
2243
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2244
|
+
* @return {object} results - An object containing the response of the action
|
|
2245
|
+
*
|
|
2246
|
+
* @route {POST} /listGroupAlarms
|
|
2247
|
+
* @roles admin
|
|
2248
|
+
* @task true
|
|
2249
|
+
*/
|
|
2250
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2251
|
+
listGroupAlarms(fields, offset, limit, callback) {
|
|
2252
|
+
const meth = 'adapter-listGroupAlarms';
|
|
2253
|
+
const origin = `${this.id}-${meth}`;
|
|
2254
|
+
log.trace(origin);
|
|
2255
|
+
|
|
2256
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2257
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2258
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2259
|
+
return callback(null, errorObj);
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2263
|
+
|
|
2264
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2265
|
+
const queryParamsAvailable = { fields, offset, limit };
|
|
2266
|
+
const queryParams = {};
|
|
2267
|
+
const pathVars = [];
|
|
2268
|
+
const bodyVars = {};
|
|
2269
|
+
|
|
2270
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2271
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2272
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2273
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2274
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
|
|
2278
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2279
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2280
|
+
const reqObj = {
|
|
2281
|
+
payload: bodyVars,
|
|
2282
|
+
uriPathVars: pathVars,
|
|
2283
|
+
uriQuery: queryParams
|
|
2284
|
+
};
|
|
2285
|
+
|
|
2286
|
+
try {
|
|
2287
|
+
// Make the call -
|
|
2288
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2289
|
+
return this.requestHandlerInst.identifyRequest('GroupAlarms', 'listGroupAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2290
|
+
// if we received an error or their is no response on the results
|
|
2291
|
+
// return an error
|
|
2292
|
+
if (irReturnError) {
|
|
2293
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2294
|
+
return callback(null, irReturnError);
|
|
2295
|
+
}
|
|
2296
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2297
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listGroupAlarms'], null, null, null);
|
|
2298
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2299
|
+
return callback(null, errorObj);
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2303
|
+
// return the response
|
|
2304
|
+
return callback(irReturnData, null);
|
|
2305
|
+
});
|
|
2306
|
+
} catch (ex) {
|
|
2307
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2308
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2309
|
+
return callback(null, errorObj);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
/**
|
|
2314
|
+
* @function createGroupAlarms
|
|
2315
|
+
* @pronghornType method
|
|
2316
|
+
* @name createGroupAlarms
|
|
2317
|
+
* @summary Creates a GroupAlarms
|
|
2318
|
+
*
|
|
2319
|
+
* @param {object} groupAlarms - The GroupAlarms to be created
|
|
2320
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2321
|
+
* @return {object} results - An object containing the response of the action
|
|
2322
|
+
*
|
|
2323
|
+
* @route {POST} /createGroupAlarms
|
|
2324
|
+
* @roles admin
|
|
2325
|
+
* @task true
|
|
2326
|
+
*/
|
|
2327
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2328
|
+
createGroupAlarms(groupAlarms, callback) {
|
|
2329
|
+
const meth = 'adapter-createGroupAlarms';
|
|
2330
|
+
const origin = `${this.id}-${meth}`;
|
|
2331
|
+
log.trace(origin);
|
|
2332
|
+
|
|
2333
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2334
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2335
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2336
|
+
return callback(null, errorObj);
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2340
|
+
if (groupAlarms === undefined || groupAlarms === null || groupAlarms === '') {
|
|
2341
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['groupAlarms'], null, null, null);
|
|
2342
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2343
|
+
return callback(null, errorObj);
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2347
|
+
const queryParamsAvailable = {};
|
|
2348
|
+
const queryParams = {};
|
|
2349
|
+
const pathVars = [];
|
|
2350
|
+
const bodyVars = groupAlarms;
|
|
2351
|
+
|
|
2352
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2353
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2354
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2355
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2356
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2357
|
+
}
|
|
2358
|
+
});
|
|
2359
|
+
|
|
2360
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2361
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2362
|
+
const reqObj = {
|
|
2363
|
+
payload: bodyVars,
|
|
2364
|
+
uriPathVars: pathVars,
|
|
2365
|
+
uriQuery: queryParams
|
|
2366
|
+
};
|
|
2367
|
+
|
|
2368
|
+
try {
|
|
2369
|
+
// Make the call -
|
|
2370
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2371
|
+
return this.requestHandlerInst.identifyRequest('GroupAlarms', 'createGroupAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2372
|
+
// if we received an error or their is no response on the results
|
|
2373
|
+
// return an error
|
|
2374
|
+
if (irReturnError) {
|
|
2375
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2376
|
+
return callback(null, irReturnError);
|
|
2377
|
+
}
|
|
2378
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2379
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createGroupAlarms'], null, null, null);
|
|
2380
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2381
|
+
return callback(null, errorObj);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2385
|
+
// return the response
|
|
2386
|
+
return callback(irReturnData, null);
|
|
2387
|
+
});
|
|
2388
|
+
} catch (ex) {
|
|
2389
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2390
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2391
|
+
return callback(null, errorObj);
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
/**
|
|
2396
|
+
* @function retrieveGroupAlarms
|
|
2397
|
+
* @pronghornType method
|
|
2398
|
+
* @name retrieveGroupAlarms
|
|
2399
|
+
* @summary Retrieves a GroupAlarms by ID
|
|
2400
|
+
*
|
|
2401
|
+
* @param {string} id - Identifier of the GroupAlarms
|
|
2402
|
+
* @param {string} [fields] - Comma-separated properties to provide in response
|
|
2403
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2404
|
+
* @return {object} results - An object containing the response of the action
|
|
2405
|
+
*
|
|
2406
|
+
* @route {POST} /retrieveGroupAlarms
|
|
2407
|
+
* @roles admin
|
|
2408
|
+
* @task true
|
|
2409
|
+
*/
|
|
2410
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2411
|
+
retrieveGroupAlarms(id, fields, callback) {
|
|
2412
|
+
const meth = 'adapter-retrieveGroupAlarms';
|
|
2413
|
+
const origin = `${this.id}-${meth}`;
|
|
2414
|
+
log.trace(origin);
|
|
2415
|
+
|
|
2416
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2417
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2418
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2419
|
+
return callback(null, errorObj);
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2423
|
+
if (id === undefined || id === null || id === '') {
|
|
2424
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
2425
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2426
|
+
return callback(null, errorObj);
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2429
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2430
|
+
const queryParamsAvailable = { fields };
|
|
2431
|
+
const queryParams = {};
|
|
2432
|
+
const pathVars = [id];
|
|
2433
|
+
const bodyVars = {};
|
|
2434
|
+
|
|
2435
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2436
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2437
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2438
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2439
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
|
|
2443
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2444
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2445
|
+
const reqObj = {
|
|
2446
|
+
payload: bodyVars,
|
|
2447
|
+
uriPathVars: pathVars,
|
|
2448
|
+
uriQuery: queryParams
|
|
2449
|
+
};
|
|
2450
|
+
|
|
2451
|
+
try {
|
|
2452
|
+
// Make the call -
|
|
2453
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2454
|
+
return this.requestHandlerInst.identifyRequest('GroupAlarms', 'retrieveGroupAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2455
|
+
// if we received an error or their is no response on the results
|
|
2456
|
+
// return an error
|
|
2457
|
+
if (irReturnError) {
|
|
2458
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2459
|
+
return callback(null, irReturnError);
|
|
2460
|
+
}
|
|
2461
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2462
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveGroupAlarms'], null, null, null);
|
|
2463
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2464
|
+
return callback(null, errorObj);
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2468
|
+
// return the response
|
|
2469
|
+
return callback(irReturnData, null);
|
|
2470
|
+
});
|
|
2471
|
+
} catch (ex) {
|
|
2472
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2473
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2474
|
+
return callback(null, errorObj);
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
/**
|
|
2479
|
+
* @function listUnGroupAlarms
|
|
2480
|
+
* @pronghornType method
|
|
2481
|
+
* @name listUnGroupAlarms
|
|
2482
|
+
* @summary List or find UnGroupAlarms objects
|
|
2483
|
+
*
|
|
2484
|
+
* @param {string} [fields] - Comma-separated properties to be provided in response
|
|
2485
|
+
* @param {number} [offset] - Requested index for start of resources to be provided in response
|
|
2486
|
+
* @param {number} [limit] - Requested number of resources to be provided in response
|
|
2487
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2488
|
+
* @return {object} results - An object containing the response of the action
|
|
2489
|
+
*
|
|
2490
|
+
* @route {POST} /listUnGroupAlarms
|
|
2491
|
+
* @roles admin
|
|
2492
|
+
* @task true
|
|
2493
|
+
*/
|
|
2494
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2495
|
+
listUnGroupAlarms(fields, offset, limit, callback) {
|
|
2496
|
+
const meth = 'adapter-listUnGroupAlarms';
|
|
2497
|
+
const origin = `${this.id}-${meth}`;
|
|
2498
|
+
log.trace(origin);
|
|
2499
|
+
|
|
2500
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2501
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2502
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2503
|
+
return callback(null, errorObj);
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2507
|
+
|
|
2508
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2509
|
+
const queryParamsAvailable = { fields, offset, limit };
|
|
2510
|
+
const queryParams = {};
|
|
2511
|
+
const pathVars = [];
|
|
2512
|
+
const bodyVars = {};
|
|
2513
|
+
|
|
2514
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2515
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2516
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2517
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2518
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2519
|
+
}
|
|
2520
|
+
});
|
|
2521
|
+
|
|
2522
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2523
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2524
|
+
const reqObj = {
|
|
2525
|
+
payload: bodyVars,
|
|
2526
|
+
uriPathVars: pathVars,
|
|
2527
|
+
uriQuery: queryParams
|
|
2528
|
+
};
|
|
2529
|
+
|
|
2530
|
+
try {
|
|
2531
|
+
// Make the call -
|
|
2532
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2533
|
+
return this.requestHandlerInst.identifyRequest('UnGroupAlarms', 'listUnGroupAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2534
|
+
// if we received an error or their is no response on the results
|
|
2535
|
+
// return an error
|
|
2536
|
+
if (irReturnError) {
|
|
2537
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2538
|
+
return callback(null, irReturnError);
|
|
2539
|
+
}
|
|
2540
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2541
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listUnGroupAlarms'], null, null, null);
|
|
2542
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2543
|
+
return callback(null, errorObj);
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2547
|
+
// return the response
|
|
2548
|
+
return callback(irReturnData, null);
|
|
2549
|
+
});
|
|
2550
|
+
} catch (ex) {
|
|
2551
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2552
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2553
|
+
return callback(null, errorObj);
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
/**
|
|
2558
|
+
* @function createUnGroupAlarms
|
|
2559
|
+
* @pronghornType method
|
|
2560
|
+
* @name createUnGroupAlarms
|
|
2561
|
+
* @summary Creates a UnGroupAlarms
|
|
2562
|
+
*
|
|
2563
|
+
* @param {object} unGroupAlarms - The UnGroupAlarms to be created
|
|
2564
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2565
|
+
* @return {object} results - An object containing the response of the action
|
|
2566
|
+
*
|
|
2567
|
+
* @route {POST} /createUnGroupAlarms
|
|
2568
|
+
* @roles admin
|
|
2569
|
+
* @task true
|
|
2570
|
+
*/
|
|
2571
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2572
|
+
createUnGroupAlarms(unGroupAlarms, callback) {
|
|
2573
|
+
const meth = 'adapter-createUnGroupAlarms';
|
|
2574
|
+
const origin = `${this.id}-${meth}`;
|
|
2575
|
+
log.trace(origin);
|
|
2576
|
+
|
|
2577
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2578
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2579
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2580
|
+
return callback(null, errorObj);
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2584
|
+
if (unGroupAlarms === undefined || unGroupAlarms === null || unGroupAlarms === '') {
|
|
2585
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['unGroupAlarms'], null, null, null);
|
|
2586
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2587
|
+
return callback(null, errorObj);
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2591
|
+
const queryParamsAvailable = {};
|
|
2592
|
+
const queryParams = {};
|
|
2593
|
+
const pathVars = [];
|
|
2594
|
+
const bodyVars = unGroupAlarms;
|
|
2595
|
+
|
|
2596
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2597
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2598
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2599
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2600
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2601
|
+
}
|
|
2602
|
+
});
|
|
2603
|
+
|
|
2604
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2605
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2606
|
+
const reqObj = {
|
|
2607
|
+
payload: bodyVars,
|
|
2608
|
+
uriPathVars: pathVars,
|
|
2609
|
+
uriQuery: queryParams
|
|
2610
|
+
};
|
|
2611
|
+
|
|
2612
|
+
try {
|
|
2613
|
+
// Make the call -
|
|
2614
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2615
|
+
return this.requestHandlerInst.identifyRequest('UnGroupAlarms', 'createUnGroupAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2616
|
+
// if we received an error or their is no response on the results
|
|
2617
|
+
// return an error
|
|
2618
|
+
if (irReturnError) {
|
|
2619
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2620
|
+
return callback(null, irReturnError);
|
|
2621
|
+
}
|
|
2622
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2623
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createUnGroupAlarms'], null, null, null);
|
|
2624
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2625
|
+
return callback(null, errorObj);
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2629
|
+
// return the response
|
|
2630
|
+
return callback(irReturnData, null);
|
|
2631
|
+
});
|
|
2632
|
+
} catch (ex) {
|
|
2633
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2634
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2635
|
+
return callback(null, errorObj);
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
/**
|
|
2640
|
+
* @function retrieveUnGroupAlarms
|
|
2641
|
+
* @pronghornType method
|
|
2642
|
+
* @name retrieveUnGroupAlarms
|
|
2643
|
+
* @summary Retrieves a UnGroupAlarms by ID
|
|
2644
|
+
*
|
|
2645
|
+
* @param {string} id - Identifier of the UnGroupAlarms
|
|
2646
|
+
* @param {string} [fields] - Comma-separated properties to provide in response
|
|
2647
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2648
|
+
* @return {object} results - An object containing the response of the action
|
|
2649
|
+
*
|
|
2650
|
+
* @route {POST} /retrieveUnGroupAlarms
|
|
2651
|
+
* @roles admin
|
|
2652
|
+
* @task true
|
|
2653
|
+
*/
|
|
2654
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2655
|
+
retrieveUnGroupAlarms(id, fields, callback) {
|
|
2656
|
+
const meth = 'adapter-retrieveUnGroupAlarms';
|
|
2657
|
+
const origin = `${this.id}-${meth}`;
|
|
2658
|
+
log.trace(origin);
|
|
2659
|
+
|
|
2660
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2661
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2662
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2663
|
+
return callback(null, errorObj);
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2667
|
+
if (id === undefined || id === null || id === '') {
|
|
2668
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
2669
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2670
|
+
return callback(null, errorObj);
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2674
|
+
const queryParamsAvailable = { fields };
|
|
2675
|
+
const queryParams = {};
|
|
2676
|
+
const pathVars = [id];
|
|
2677
|
+
const bodyVars = {};
|
|
2678
|
+
|
|
2679
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2680
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2681
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2682
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2683
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2684
|
+
}
|
|
2685
|
+
});
|
|
2686
|
+
|
|
2687
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2688
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2689
|
+
const reqObj = {
|
|
2690
|
+
payload: bodyVars,
|
|
2691
|
+
uriPathVars: pathVars,
|
|
2692
|
+
uriQuery: queryParams
|
|
2693
|
+
};
|
|
2694
|
+
|
|
2695
|
+
try {
|
|
2696
|
+
// Make the call -
|
|
2697
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2698
|
+
return this.requestHandlerInst.identifyRequest('UnGroupAlarms', 'retrieveUnGroupAlarms', reqObj, true, (irReturnData, irReturnError) => {
|
|
2699
|
+
// if we received an error or their is no response on the results
|
|
2700
|
+
// return an error
|
|
2701
|
+
if (irReturnError) {
|
|
2702
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2703
|
+
return callback(null, irReturnError);
|
|
2704
|
+
}
|
|
2705
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2706
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['retrieveUnGroupAlarms'], null, null, null);
|
|
2707
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2708
|
+
return callback(null, errorObj);
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2712
|
+
// return the response
|
|
2713
|
+
return callback(irReturnData, null);
|
|
2714
|
+
});
|
|
2715
|
+
} catch (ex) {
|
|
2716
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2717
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2718
|
+
return callback(null, errorObj);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
/**
|
|
2723
|
+
* @function registerListener
|
|
2724
|
+
* @pronghornType method
|
|
2725
|
+
* @name registerListener
|
|
2726
|
+
* @summary Register a listener
|
|
2727
|
+
*
|
|
2728
|
+
* @param {object} data - Data containing the callback endpoint to deliver the information
|
|
2729
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2730
|
+
* @return {object} results - An object containing the response of the action
|
|
2731
|
+
*
|
|
2732
|
+
* @route {POST} /registerListener
|
|
2733
|
+
* @roles admin
|
|
2734
|
+
* @task true
|
|
2735
|
+
*/
|
|
2736
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2737
|
+
registerListener(data, callback) {
|
|
2738
|
+
const meth = 'adapter-registerListener';
|
|
2739
|
+
const origin = `${this.id}-${meth}`;
|
|
2740
|
+
log.trace(origin);
|
|
2741
|
+
|
|
2742
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2743
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2744
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2745
|
+
return callback(null, errorObj);
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2749
|
+
if (data === undefined || data === null || data === '') {
|
|
2750
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
2751
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2752
|
+
return callback(null, errorObj);
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2756
|
+
const queryParamsAvailable = {};
|
|
2757
|
+
const queryParams = {};
|
|
2758
|
+
const pathVars = [];
|
|
2759
|
+
const bodyVars = data;
|
|
2760
|
+
|
|
2761
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2762
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2763
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2764
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2765
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2766
|
+
}
|
|
2767
|
+
});
|
|
2768
|
+
|
|
2769
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2770
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2771
|
+
const reqObj = {
|
|
2772
|
+
payload: bodyVars,
|
|
2773
|
+
uriPathVars: pathVars,
|
|
2774
|
+
uriQuery: queryParams
|
|
2775
|
+
};
|
|
2776
|
+
|
|
2777
|
+
try {
|
|
2778
|
+
// Make the call -
|
|
2779
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2780
|
+
return this.requestHandlerInst.identifyRequest('EventsSubscription', 'registerListener', reqObj, true, (irReturnData, irReturnError) => {
|
|
2781
|
+
// if we received an error or their is no response on the results
|
|
2782
|
+
// return an error
|
|
2783
|
+
if (irReturnError) {
|
|
2784
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2785
|
+
return callback(null, irReturnError);
|
|
2786
|
+
}
|
|
2787
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2788
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['registerListener'], null, null, null);
|
|
2789
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2790
|
+
return callback(null, errorObj);
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2794
|
+
// return the response
|
|
2795
|
+
return callback(irReturnData, null);
|
|
2796
|
+
});
|
|
2797
|
+
} catch (ex) {
|
|
2798
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2799
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2800
|
+
return callback(null, errorObj);
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
/**
|
|
2805
|
+
* @function unregisterListener
|
|
2806
|
+
* @pronghornType method
|
|
2807
|
+
* @name unregisterListener
|
|
2808
|
+
* @summary Unregister a listener
|
|
2809
|
+
*
|
|
2810
|
+
* @param {string} id - The id of the registered listener
|
|
2811
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2812
|
+
* @return {object} results - An object containing the response of the action
|
|
2813
|
+
*
|
|
2814
|
+
* @route {POST} /unregisterListener
|
|
2815
|
+
* @roles admin
|
|
2816
|
+
* @task true
|
|
2817
|
+
*/
|
|
2818
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2819
|
+
unregisterListener(id, callback) {
|
|
2820
|
+
const meth = 'adapter-unregisterListener';
|
|
2821
|
+
const origin = `${this.id}-${meth}`;
|
|
2822
|
+
log.trace(origin);
|
|
2823
|
+
|
|
2824
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2825
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2826
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2827
|
+
return callback(null, errorObj);
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2830
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2831
|
+
if (id === undefined || id === null || id === '') {
|
|
2832
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
2833
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2834
|
+
return callback(null, errorObj);
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2837
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2838
|
+
const queryParamsAvailable = {};
|
|
2839
|
+
const queryParams = {};
|
|
2840
|
+
const pathVars = [id];
|
|
2841
|
+
const bodyVars = {};
|
|
2842
|
+
|
|
2843
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2844
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2845
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2846
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2847
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2850
|
+
|
|
2851
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2852
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2853
|
+
const reqObj = {
|
|
2854
|
+
payload: bodyVars,
|
|
2855
|
+
uriPathVars: pathVars,
|
|
2856
|
+
uriQuery: queryParams
|
|
2857
|
+
};
|
|
2858
|
+
|
|
2859
|
+
try {
|
|
2860
|
+
// Make the call -
|
|
2861
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2862
|
+
return this.requestHandlerInst.identifyRequest('EventsSubscription', 'unregisterListener', reqObj, false, (irReturnData, irReturnError) => {
|
|
2863
|
+
// if we received an error or their is no response on the results
|
|
2864
|
+
// return an error
|
|
2865
|
+
if (irReturnError) {
|
|
2866
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2867
|
+
return callback(null, irReturnError);
|
|
2868
|
+
}
|
|
2869
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2870
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['unregisterListener'], null, null, null);
|
|
2871
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2872
|
+
return callback(null, errorObj);
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2876
|
+
// return the response
|
|
2877
|
+
return callback(irReturnData, null);
|
|
2878
|
+
});
|
|
2879
|
+
} catch (ex) {
|
|
2880
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2881
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2882
|
+
return callback(null, errorObj);
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
/**
|
|
2887
|
+
* @function listenToAlarmCreateEvent
|
|
2888
|
+
* @pronghornType method
|
|
2889
|
+
* @name listenToAlarmCreateEvent
|
|
2890
|
+
* @summary Client listener for entity AlarmCreateEvent
|
|
2891
|
+
*
|
|
2892
|
+
* @param {object} data - The event data
|
|
2893
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2894
|
+
* @return {object} results - An object containing the response of the action
|
|
2895
|
+
*
|
|
2896
|
+
* @route {POST} /listenToAlarmCreateEvent
|
|
2897
|
+
* @roles admin
|
|
2898
|
+
* @task true
|
|
2899
|
+
*/
|
|
2900
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2901
|
+
listenToAlarmCreateEvent(data, callback) {
|
|
2902
|
+
const meth = 'adapter-listenToAlarmCreateEvent';
|
|
2903
|
+
const origin = `${this.id}-${meth}`;
|
|
2904
|
+
log.trace(origin);
|
|
2905
|
+
|
|
2906
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2907
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2908
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2909
|
+
return callback(null, errorObj);
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2913
|
+
if (data === undefined || data === null || data === '') {
|
|
2914
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
2915
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2916
|
+
return callback(null, errorObj);
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2920
|
+
const queryParamsAvailable = {};
|
|
2921
|
+
const queryParams = {};
|
|
2922
|
+
const pathVars = [];
|
|
2923
|
+
const bodyVars = data;
|
|
2924
|
+
|
|
2925
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2926
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2927
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2928
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2929
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2930
|
+
}
|
|
2931
|
+
});
|
|
2932
|
+
|
|
2933
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2934
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2935
|
+
const reqObj = {
|
|
2936
|
+
payload: bodyVars,
|
|
2937
|
+
uriPathVars: pathVars,
|
|
2938
|
+
uriQuery: queryParams
|
|
2939
|
+
};
|
|
2940
|
+
|
|
2941
|
+
try {
|
|
2942
|
+
// Make the call -
|
|
2943
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2944
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToAlarmCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
2945
|
+
// if we received an error or their is no response on the results
|
|
2946
|
+
// return an error
|
|
2947
|
+
if (irReturnError) {
|
|
2948
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2949
|
+
return callback(null, irReturnError);
|
|
2950
|
+
}
|
|
2951
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2952
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToAlarmCreateEvent'], null, null, null);
|
|
2953
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2954
|
+
return callback(null, errorObj);
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2958
|
+
// return the response
|
|
2959
|
+
return callback(irReturnData, null);
|
|
2960
|
+
});
|
|
2961
|
+
} catch (ex) {
|
|
2962
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2963
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2964
|
+
return callback(null, errorObj);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
/**
|
|
2969
|
+
* @function listenToAlarmAttributeValueChangeEvent
|
|
2970
|
+
* @pronghornType method
|
|
2971
|
+
* @name listenToAlarmAttributeValueChangeEvent
|
|
2972
|
+
* @summary Client listener for entity AlarmAttributeValueChangeEvent
|
|
2973
|
+
*
|
|
2974
|
+
* @param {object} data - The event data
|
|
2975
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2976
|
+
* @return {object} results - An object containing the response of the action
|
|
2977
|
+
*
|
|
2978
|
+
* @route {POST} /listenToAlarmAttributeValueChangeEvent
|
|
2979
|
+
* @roles admin
|
|
2980
|
+
* @task true
|
|
2981
|
+
*/
|
|
2982
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2983
|
+
listenToAlarmAttributeValueChangeEvent(data, callback) {
|
|
2984
|
+
const meth = 'adapter-listenToAlarmAttributeValueChangeEvent';
|
|
2985
|
+
const origin = `${this.id}-${meth}`;
|
|
2986
|
+
log.trace(origin);
|
|
2987
|
+
|
|
2988
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2989
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2990
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2991
|
+
return callback(null, errorObj);
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2995
|
+
if (data === undefined || data === null || data === '') {
|
|
2996
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
2997
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2998
|
+
return callback(null, errorObj);
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3002
|
+
const queryParamsAvailable = {};
|
|
3003
|
+
const queryParams = {};
|
|
3004
|
+
const pathVars = [];
|
|
3005
|
+
const bodyVars = data;
|
|
3006
|
+
|
|
3007
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3008
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3009
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3010
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3011
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3012
|
+
}
|
|
3013
|
+
});
|
|
3014
|
+
|
|
3015
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3016
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3017
|
+
const reqObj = {
|
|
3018
|
+
payload: bodyVars,
|
|
3019
|
+
uriPathVars: pathVars,
|
|
3020
|
+
uriQuery: queryParams
|
|
3021
|
+
};
|
|
3022
|
+
|
|
3023
|
+
try {
|
|
3024
|
+
// Make the call -
|
|
3025
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3026
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToAlarmAttributeValueChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3027
|
+
// if we received an error or their is no response on the results
|
|
3028
|
+
// return an error
|
|
3029
|
+
if (irReturnError) {
|
|
3030
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3031
|
+
return callback(null, irReturnError);
|
|
3032
|
+
}
|
|
3033
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3034
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToAlarmAttributeValueChangeEvent'], null, null, null);
|
|
3035
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3036
|
+
return callback(null, errorObj);
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3040
|
+
// return the response
|
|
3041
|
+
return callback(irReturnData, null);
|
|
3042
|
+
});
|
|
3043
|
+
} catch (ex) {
|
|
3044
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3045
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3046
|
+
return callback(null, errorObj);
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
/**
|
|
3051
|
+
* @function listenToAlarmStateChangeEvent
|
|
3052
|
+
* @pronghornType method
|
|
3053
|
+
* @name listenToAlarmStateChangeEvent
|
|
3054
|
+
* @summary Client listener for entity AlarmStateChangeEvent
|
|
3055
|
+
*
|
|
3056
|
+
* @param {object} data - The event data
|
|
3057
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3058
|
+
* @return {object} results - An object containing the response of the action
|
|
3059
|
+
*
|
|
3060
|
+
* @route {POST} /listenToAlarmStateChangeEvent
|
|
3061
|
+
* @roles admin
|
|
3062
|
+
* @task true
|
|
3063
|
+
*/
|
|
3064
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3065
|
+
listenToAlarmStateChangeEvent(data, callback) {
|
|
3066
|
+
const meth = 'adapter-listenToAlarmStateChangeEvent';
|
|
3067
|
+
const origin = `${this.id}-${meth}`;
|
|
3068
|
+
log.trace(origin);
|
|
3069
|
+
|
|
3070
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3071
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3072
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3073
|
+
return callback(null, errorObj);
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3077
|
+
if (data === undefined || data === null || data === '') {
|
|
3078
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3079
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3080
|
+
return callback(null, errorObj);
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3084
|
+
const queryParamsAvailable = {};
|
|
3085
|
+
const queryParams = {};
|
|
3086
|
+
const pathVars = [];
|
|
3087
|
+
const bodyVars = data;
|
|
3088
|
+
|
|
3089
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3090
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3091
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3092
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3093
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3094
|
+
}
|
|
3095
|
+
});
|
|
3096
|
+
|
|
3097
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3098
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3099
|
+
const reqObj = {
|
|
3100
|
+
payload: bodyVars,
|
|
3101
|
+
uriPathVars: pathVars,
|
|
3102
|
+
uriQuery: queryParams
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3105
|
+
try {
|
|
3106
|
+
// Make the call -
|
|
3107
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3108
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToAlarmStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3109
|
+
// if we received an error or their is no response on the results
|
|
3110
|
+
// return an error
|
|
3111
|
+
if (irReturnError) {
|
|
3112
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3113
|
+
return callback(null, irReturnError);
|
|
3114
|
+
}
|
|
3115
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3116
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToAlarmStateChangeEvent'], null, null, null);
|
|
3117
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3118
|
+
return callback(null, errorObj);
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3122
|
+
// return the response
|
|
3123
|
+
return callback(irReturnData, null);
|
|
3124
|
+
});
|
|
3125
|
+
} catch (ex) {
|
|
3126
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3127
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3128
|
+
return callback(null, errorObj);
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
/**
|
|
3133
|
+
* @function listenToAlarmDeleteEvent
|
|
3134
|
+
* @pronghornType method
|
|
3135
|
+
* @name listenToAlarmDeleteEvent
|
|
3136
|
+
* @summary Client listener for entity AlarmDeleteEvent
|
|
3137
|
+
*
|
|
3138
|
+
* @param {object} data - The event data
|
|
3139
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3140
|
+
* @return {object} results - An object containing the response of the action
|
|
3141
|
+
*
|
|
3142
|
+
* @route {POST} /listenToAlarmDeleteEvent
|
|
3143
|
+
* @roles admin
|
|
3144
|
+
* @task true
|
|
3145
|
+
*/
|
|
3146
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3147
|
+
listenToAlarmDeleteEvent(data, callback) {
|
|
3148
|
+
const meth = 'adapter-listenToAlarmDeleteEvent';
|
|
3149
|
+
const origin = `${this.id}-${meth}`;
|
|
3150
|
+
log.trace(origin);
|
|
3151
|
+
|
|
3152
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3153
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3154
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3155
|
+
return callback(null, errorObj);
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3159
|
+
if (data === undefined || data === null || data === '') {
|
|
3160
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3161
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3162
|
+
return callback(null, errorObj);
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3166
|
+
const queryParamsAvailable = {};
|
|
3167
|
+
const queryParams = {};
|
|
3168
|
+
const pathVars = [];
|
|
3169
|
+
const bodyVars = data;
|
|
3170
|
+
|
|
3171
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3172
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3173
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3174
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3175
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3176
|
+
}
|
|
3177
|
+
});
|
|
3178
|
+
|
|
3179
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3180
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3181
|
+
const reqObj = {
|
|
3182
|
+
payload: bodyVars,
|
|
3183
|
+
uriPathVars: pathVars,
|
|
3184
|
+
uriQuery: queryParams
|
|
3185
|
+
};
|
|
3186
|
+
|
|
3187
|
+
try {
|
|
3188
|
+
// Make the call -
|
|
3189
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3190
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToAlarmDeleteEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3191
|
+
// if we received an error or their is no response on the results
|
|
3192
|
+
// return an error
|
|
3193
|
+
if (irReturnError) {
|
|
3194
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3195
|
+
return callback(null, irReturnError);
|
|
3196
|
+
}
|
|
3197
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3198
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToAlarmDeleteEvent'], null, null, null);
|
|
3199
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3200
|
+
return callback(null, errorObj);
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3204
|
+
// return the response
|
|
3205
|
+
return callback(irReturnData, null);
|
|
3206
|
+
});
|
|
3207
|
+
} catch (ex) {
|
|
3208
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3209
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3210
|
+
return callback(null, errorObj);
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
/**
|
|
3215
|
+
* @function listenToAckAlarmsCreateEvent
|
|
3216
|
+
* @pronghornType method
|
|
3217
|
+
* @name listenToAckAlarmsCreateEvent
|
|
3218
|
+
* @summary Client listener for entity AckAlarmsCreateEvent
|
|
3219
|
+
*
|
|
3220
|
+
* @param {object} data - The event data
|
|
3221
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3222
|
+
* @return {object} results - An object containing the response of the action
|
|
3223
|
+
*
|
|
3224
|
+
* @route {POST} /listenToAckAlarmsCreateEvent
|
|
3225
|
+
* @roles admin
|
|
3226
|
+
* @task true
|
|
3227
|
+
*/
|
|
3228
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3229
|
+
listenToAckAlarmsCreateEvent(data, callback) {
|
|
3230
|
+
const meth = 'adapter-listenToAckAlarmsCreateEvent';
|
|
3231
|
+
const origin = `${this.id}-${meth}`;
|
|
3232
|
+
log.trace(origin);
|
|
3233
|
+
|
|
3234
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3235
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3236
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3237
|
+
return callback(null, errorObj);
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3241
|
+
if (data === undefined || data === null || data === '') {
|
|
3242
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3243
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3244
|
+
return callback(null, errorObj);
|
|
3245
|
+
}
|
|
3246
|
+
|
|
3247
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3248
|
+
const queryParamsAvailable = {};
|
|
3249
|
+
const queryParams = {};
|
|
3250
|
+
const pathVars = [];
|
|
3251
|
+
const bodyVars = data;
|
|
3252
|
+
|
|
3253
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3254
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3255
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3256
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3257
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3258
|
+
}
|
|
3259
|
+
});
|
|
3260
|
+
|
|
3261
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3262
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3263
|
+
const reqObj = {
|
|
3264
|
+
payload: bodyVars,
|
|
3265
|
+
uriPathVars: pathVars,
|
|
3266
|
+
uriQuery: queryParams
|
|
3267
|
+
};
|
|
3268
|
+
|
|
3269
|
+
try {
|
|
3270
|
+
// Make the call -
|
|
3271
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3272
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToAckAlarmsCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3273
|
+
// if we received an error or their is no response on the results
|
|
3274
|
+
// return an error
|
|
3275
|
+
if (irReturnError) {
|
|
3276
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3277
|
+
return callback(null, irReturnError);
|
|
3278
|
+
}
|
|
3279
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3280
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToAckAlarmsCreateEvent'], null, null, null);
|
|
3281
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3282
|
+
return callback(null, errorObj);
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3286
|
+
// return the response
|
|
3287
|
+
return callback(irReturnData, null);
|
|
3288
|
+
});
|
|
3289
|
+
} catch (ex) {
|
|
3290
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3291
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3292
|
+
return callback(null, errorObj);
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3296
|
+
/**
|
|
3297
|
+
* @function listenToAckAlarmsStateChangeEvent
|
|
3298
|
+
* @pronghornType method
|
|
3299
|
+
* @name listenToAckAlarmsStateChangeEvent
|
|
3300
|
+
* @summary Client listener for entity AckAlarmsStateChangeEvent
|
|
3301
|
+
*
|
|
3302
|
+
* @param {object} data - The event data
|
|
3303
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3304
|
+
* @return {object} results - An object containing the response of the action
|
|
3305
|
+
*
|
|
3306
|
+
* @route {POST} /listenToAckAlarmsStateChangeEvent
|
|
3307
|
+
* @roles admin
|
|
3308
|
+
* @task true
|
|
3309
|
+
*/
|
|
3310
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3311
|
+
listenToAckAlarmsStateChangeEvent(data, callback) {
|
|
3312
|
+
const meth = 'adapter-listenToAckAlarmsStateChangeEvent';
|
|
3313
|
+
const origin = `${this.id}-${meth}`;
|
|
3314
|
+
log.trace(origin);
|
|
3315
|
+
|
|
3316
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3317
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3318
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3319
|
+
return callback(null, errorObj);
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3322
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3323
|
+
if (data === undefined || data === null || data === '') {
|
|
3324
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3325
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3326
|
+
return callback(null, errorObj);
|
|
3327
|
+
}
|
|
3328
|
+
|
|
3329
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3330
|
+
const queryParamsAvailable = {};
|
|
3331
|
+
const queryParams = {};
|
|
3332
|
+
const pathVars = [];
|
|
3333
|
+
const bodyVars = data;
|
|
3334
|
+
|
|
3335
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3336
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3337
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3338
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3339
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3340
|
+
}
|
|
3341
|
+
});
|
|
3342
|
+
|
|
3343
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3344
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3345
|
+
const reqObj = {
|
|
3346
|
+
payload: bodyVars,
|
|
3347
|
+
uriPathVars: pathVars,
|
|
3348
|
+
uriQuery: queryParams
|
|
3349
|
+
};
|
|
3350
|
+
|
|
3351
|
+
try {
|
|
3352
|
+
// Make the call -
|
|
3353
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3354
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToAckAlarmsStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3355
|
+
// if we received an error or their is no response on the results
|
|
3356
|
+
// return an error
|
|
3357
|
+
if (irReturnError) {
|
|
3358
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3359
|
+
return callback(null, irReturnError);
|
|
3360
|
+
}
|
|
3361
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3362
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToAckAlarmsStateChangeEvent'], null, null, null);
|
|
3363
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3364
|
+
return callback(null, errorObj);
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3368
|
+
// return the response
|
|
3369
|
+
return callback(irReturnData, null);
|
|
3370
|
+
});
|
|
3371
|
+
} catch (ex) {
|
|
3372
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3373
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3374
|
+
return callback(null, errorObj);
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
/**
|
|
3379
|
+
* @function listenToUnAckAlarmsCreateEvent
|
|
3380
|
+
* @pronghornType method
|
|
3381
|
+
* @name listenToUnAckAlarmsCreateEvent
|
|
3382
|
+
* @summary Client listener for entity UnAckAlarmsCreateEvent
|
|
3383
|
+
*
|
|
3384
|
+
* @param {object} data - The event data
|
|
3385
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3386
|
+
* @return {object} results - An object containing the response of the action
|
|
3387
|
+
*
|
|
3388
|
+
* @route {POST} /listenToUnAckAlarmsCreateEvent
|
|
3389
|
+
* @roles admin
|
|
3390
|
+
* @task true
|
|
3391
|
+
*/
|
|
3392
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3393
|
+
listenToUnAckAlarmsCreateEvent(data, callback) {
|
|
3394
|
+
const meth = 'adapter-listenToUnAckAlarmsCreateEvent';
|
|
3395
|
+
const origin = `${this.id}-${meth}`;
|
|
3396
|
+
log.trace(origin);
|
|
3397
|
+
|
|
3398
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3399
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3400
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3401
|
+
return callback(null, errorObj);
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3405
|
+
if (data === undefined || data === null || data === '') {
|
|
3406
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3407
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3408
|
+
return callback(null, errorObj);
|
|
3409
|
+
}
|
|
3410
|
+
|
|
3411
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3412
|
+
const queryParamsAvailable = {};
|
|
3413
|
+
const queryParams = {};
|
|
3414
|
+
const pathVars = [];
|
|
3415
|
+
const bodyVars = data;
|
|
3416
|
+
|
|
3417
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3418
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3419
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3420
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3421
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3422
|
+
}
|
|
3423
|
+
});
|
|
3424
|
+
|
|
3425
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3426
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3427
|
+
const reqObj = {
|
|
3428
|
+
payload: bodyVars,
|
|
3429
|
+
uriPathVars: pathVars,
|
|
3430
|
+
uriQuery: queryParams
|
|
3431
|
+
};
|
|
3432
|
+
|
|
3433
|
+
try {
|
|
3434
|
+
// Make the call -
|
|
3435
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3436
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToUnAckAlarmsCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3437
|
+
// if we received an error or their is no response on the results
|
|
3438
|
+
// return an error
|
|
3439
|
+
if (irReturnError) {
|
|
3440
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3441
|
+
return callback(null, irReturnError);
|
|
3442
|
+
}
|
|
3443
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3444
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToUnAckAlarmsCreateEvent'], null, null, null);
|
|
3445
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3446
|
+
return callback(null, errorObj);
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3450
|
+
// return the response
|
|
3451
|
+
return callback(irReturnData, null);
|
|
3452
|
+
});
|
|
3453
|
+
} catch (ex) {
|
|
3454
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3455
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3456
|
+
return callback(null, errorObj);
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
/**
|
|
3461
|
+
* @function listenToUnAckAlarmsStateChangeEvent
|
|
3462
|
+
* @pronghornType method
|
|
3463
|
+
* @name listenToUnAckAlarmsStateChangeEvent
|
|
3464
|
+
* @summary Client listener for entity UnAckAlarmsStateChangeEvent
|
|
3465
|
+
*
|
|
3466
|
+
* @param {object} data - The event data
|
|
3467
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3468
|
+
* @return {object} results - An object containing the response of the action
|
|
3469
|
+
*
|
|
3470
|
+
* @route {POST} /listenToUnAckAlarmsStateChangeEvent
|
|
3471
|
+
* @roles admin
|
|
3472
|
+
* @task true
|
|
3473
|
+
*/
|
|
3474
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3475
|
+
listenToUnAckAlarmsStateChangeEvent(data, callback) {
|
|
3476
|
+
const meth = 'adapter-listenToUnAckAlarmsStateChangeEvent';
|
|
3477
|
+
const origin = `${this.id}-${meth}`;
|
|
3478
|
+
log.trace(origin);
|
|
3479
|
+
|
|
3480
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3481
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3482
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3483
|
+
return callback(null, errorObj);
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3487
|
+
if (data === undefined || data === null || data === '') {
|
|
3488
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3489
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3490
|
+
return callback(null, errorObj);
|
|
3491
|
+
}
|
|
3492
|
+
|
|
3493
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3494
|
+
const queryParamsAvailable = {};
|
|
3495
|
+
const queryParams = {};
|
|
3496
|
+
const pathVars = [];
|
|
3497
|
+
const bodyVars = data;
|
|
3498
|
+
|
|
3499
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3500
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3501
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3502
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3503
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3504
|
+
}
|
|
3505
|
+
});
|
|
3506
|
+
|
|
3507
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3508
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3509
|
+
const reqObj = {
|
|
3510
|
+
payload: bodyVars,
|
|
3511
|
+
uriPathVars: pathVars,
|
|
3512
|
+
uriQuery: queryParams
|
|
3513
|
+
};
|
|
3514
|
+
|
|
3515
|
+
try {
|
|
3516
|
+
// Make the call -
|
|
3517
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3518
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToUnAckAlarmsStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3519
|
+
// if we received an error or their is no response on the results
|
|
3520
|
+
// return an error
|
|
3521
|
+
if (irReturnError) {
|
|
3522
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3523
|
+
return callback(null, irReturnError);
|
|
3524
|
+
}
|
|
3525
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3526
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToUnAckAlarmsStateChangeEvent'], null, null, null);
|
|
3527
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3528
|
+
return callback(null, errorObj);
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3531
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3532
|
+
// return the response
|
|
3533
|
+
return callback(irReturnData, null);
|
|
3534
|
+
});
|
|
3535
|
+
} catch (ex) {
|
|
3536
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3537
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3538
|
+
return callback(null, errorObj);
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
/**
|
|
3543
|
+
* @function listenToClearAlarmsCreateEvent
|
|
3544
|
+
* @pronghornType method
|
|
3545
|
+
* @name listenToClearAlarmsCreateEvent
|
|
3546
|
+
* @summary Client listener for entity ClearAlarmsCreateEvent
|
|
3547
|
+
*
|
|
3548
|
+
* @param {object} data - The event data
|
|
3549
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3550
|
+
* @return {object} results - An object containing the response of the action
|
|
3551
|
+
*
|
|
3552
|
+
* @route {POST} /listenToClearAlarmsCreateEvent
|
|
3553
|
+
* @roles admin
|
|
3554
|
+
* @task true
|
|
3555
|
+
*/
|
|
3556
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3557
|
+
listenToClearAlarmsCreateEvent(data, callback) {
|
|
3558
|
+
const meth = 'adapter-listenToClearAlarmsCreateEvent';
|
|
3559
|
+
const origin = `${this.id}-${meth}`;
|
|
3560
|
+
log.trace(origin);
|
|
3561
|
+
|
|
3562
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3563
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3564
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3565
|
+
return callback(null, errorObj);
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3569
|
+
if (data === undefined || data === null || data === '') {
|
|
3570
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3571
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3572
|
+
return callback(null, errorObj);
|
|
3573
|
+
}
|
|
3574
|
+
|
|
3575
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3576
|
+
const queryParamsAvailable = {};
|
|
3577
|
+
const queryParams = {};
|
|
3578
|
+
const pathVars = [];
|
|
3579
|
+
const bodyVars = data;
|
|
3580
|
+
|
|
3581
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3582
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3583
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3584
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3585
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3586
|
+
}
|
|
3587
|
+
});
|
|
3588
|
+
|
|
3589
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3590
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3591
|
+
const reqObj = {
|
|
3592
|
+
payload: bodyVars,
|
|
3593
|
+
uriPathVars: pathVars,
|
|
3594
|
+
uriQuery: queryParams
|
|
3595
|
+
};
|
|
3596
|
+
|
|
3597
|
+
try {
|
|
3598
|
+
// Make the call -
|
|
3599
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3600
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToClearAlarmsCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3601
|
+
// if we received an error or their is no response on the results
|
|
3602
|
+
// return an error
|
|
3603
|
+
if (irReturnError) {
|
|
3604
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3605
|
+
return callback(null, irReturnError);
|
|
3606
|
+
}
|
|
3607
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3608
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToClearAlarmsCreateEvent'], null, null, null);
|
|
3609
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3610
|
+
return callback(null, errorObj);
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3614
|
+
// return the response
|
|
3615
|
+
return callback(irReturnData, null);
|
|
3616
|
+
});
|
|
3617
|
+
} catch (ex) {
|
|
3618
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3619
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3620
|
+
return callback(null, errorObj);
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
/**
|
|
3625
|
+
* @function listenToClearAlarmsStateChangeEvent
|
|
3626
|
+
* @pronghornType method
|
|
3627
|
+
* @name listenToClearAlarmsStateChangeEvent
|
|
3628
|
+
* @summary Client listener for entity ClearAlarmsStateChangeEvent
|
|
3629
|
+
*
|
|
3630
|
+
* @param {object} data - The event data
|
|
3631
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3632
|
+
* @return {object} results - An object containing the response of the action
|
|
3633
|
+
*
|
|
3634
|
+
* @route {POST} /listenToClearAlarmsStateChangeEvent
|
|
3635
|
+
* @roles admin
|
|
3636
|
+
* @task true
|
|
3637
|
+
*/
|
|
3638
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3639
|
+
listenToClearAlarmsStateChangeEvent(data, callback) {
|
|
3640
|
+
const meth = 'adapter-listenToClearAlarmsStateChangeEvent';
|
|
3641
|
+
const origin = `${this.id}-${meth}`;
|
|
3642
|
+
log.trace(origin);
|
|
3643
|
+
|
|
3644
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3645
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3646
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3647
|
+
return callback(null, errorObj);
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3651
|
+
if (data === undefined || data === null || data === '') {
|
|
3652
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3653
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3654
|
+
return callback(null, errorObj);
|
|
3655
|
+
}
|
|
3656
|
+
|
|
3657
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3658
|
+
const queryParamsAvailable = {};
|
|
3659
|
+
const queryParams = {};
|
|
3660
|
+
const pathVars = [];
|
|
3661
|
+
const bodyVars = data;
|
|
3662
|
+
|
|
3663
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3664
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3665
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3666
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3667
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3668
|
+
}
|
|
3669
|
+
});
|
|
3670
|
+
|
|
3671
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3672
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3673
|
+
const reqObj = {
|
|
3674
|
+
payload: bodyVars,
|
|
3675
|
+
uriPathVars: pathVars,
|
|
3676
|
+
uriQuery: queryParams
|
|
3677
|
+
};
|
|
3678
|
+
|
|
3679
|
+
try {
|
|
3680
|
+
// Make the call -
|
|
3681
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3682
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToClearAlarmsStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3683
|
+
// if we received an error or their is no response on the results
|
|
3684
|
+
// return an error
|
|
3685
|
+
if (irReturnError) {
|
|
3686
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3687
|
+
return callback(null, irReturnError);
|
|
3688
|
+
}
|
|
3689
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3690
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToClearAlarmsStateChangeEvent'], null, null, null);
|
|
3691
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3692
|
+
return callback(null, errorObj);
|
|
3693
|
+
}
|
|
3694
|
+
|
|
3695
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3696
|
+
// return the response
|
|
3697
|
+
return callback(irReturnData, null);
|
|
3698
|
+
});
|
|
3699
|
+
} catch (ex) {
|
|
3700
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3701
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3702
|
+
return callback(null, errorObj);
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
/**
|
|
3707
|
+
* @function listenToCommentAlarmsCreateEvent
|
|
3708
|
+
* @pronghornType method
|
|
3709
|
+
* @name listenToCommentAlarmsCreateEvent
|
|
3710
|
+
* @summary Client listener for entity CommentAlarmsCreateEvent
|
|
3711
|
+
*
|
|
3712
|
+
* @param {object} data - The event data
|
|
3713
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3714
|
+
* @return {object} results - An object containing the response of the action
|
|
3715
|
+
*
|
|
3716
|
+
* @route {POST} /listenToCommentAlarmsCreateEvent
|
|
3717
|
+
* @roles admin
|
|
3718
|
+
* @task true
|
|
3719
|
+
*/
|
|
3720
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3721
|
+
listenToCommentAlarmsCreateEvent(data, callback) {
|
|
3722
|
+
const meth = 'adapter-listenToCommentAlarmsCreateEvent';
|
|
3723
|
+
const origin = `${this.id}-${meth}`;
|
|
3724
|
+
log.trace(origin);
|
|
3725
|
+
|
|
3726
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3727
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3728
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3729
|
+
return callback(null, errorObj);
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3732
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3733
|
+
if (data === undefined || data === null || data === '') {
|
|
3734
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3735
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3736
|
+
return callback(null, errorObj);
|
|
3737
|
+
}
|
|
3738
|
+
|
|
3739
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3740
|
+
const queryParamsAvailable = {};
|
|
3741
|
+
const queryParams = {};
|
|
3742
|
+
const pathVars = [];
|
|
3743
|
+
const bodyVars = data;
|
|
3744
|
+
|
|
3745
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3746
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3747
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3748
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3749
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3750
|
+
}
|
|
3751
|
+
});
|
|
3752
|
+
|
|
3753
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3754
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3755
|
+
const reqObj = {
|
|
3756
|
+
payload: bodyVars,
|
|
3757
|
+
uriPathVars: pathVars,
|
|
3758
|
+
uriQuery: queryParams
|
|
3759
|
+
};
|
|
3760
|
+
|
|
3761
|
+
try {
|
|
3762
|
+
// Make the call -
|
|
3763
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3764
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToCommentAlarmsCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3765
|
+
// if we received an error or their is no response on the results
|
|
3766
|
+
// return an error
|
|
3767
|
+
if (irReturnError) {
|
|
3768
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3769
|
+
return callback(null, irReturnError);
|
|
3770
|
+
}
|
|
3771
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3772
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToCommentAlarmsCreateEvent'], null, null, null);
|
|
3773
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3774
|
+
return callback(null, errorObj);
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3778
|
+
// return the response
|
|
3779
|
+
return callback(irReturnData, null);
|
|
3780
|
+
});
|
|
3781
|
+
} catch (ex) {
|
|
3782
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3783
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3784
|
+
return callback(null, errorObj);
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
/**
|
|
3789
|
+
* @function listenToCommentAlarmsStateChangeEvent
|
|
3790
|
+
* @pronghornType method
|
|
3791
|
+
* @name listenToCommentAlarmsStateChangeEvent
|
|
3792
|
+
* @summary Client listener for entity CommentAlarmsStateChangeEvent
|
|
3793
|
+
*
|
|
3794
|
+
* @param {object} data - The event data
|
|
3795
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3796
|
+
* @return {object} results - An object containing the response of the action
|
|
3797
|
+
*
|
|
3798
|
+
* @route {POST} /listenToCommentAlarmsStateChangeEvent
|
|
3799
|
+
* @roles admin
|
|
3800
|
+
* @task true
|
|
3801
|
+
*/
|
|
3802
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3803
|
+
listenToCommentAlarmsStateChangeEvent(data, callback) {
|
|
3804
|
+
const meth = 'adapter-listenToCommentAlarmsStateChangeEvent';
|
|
3805
|
+
const origin = `${this.id}-${meth}`;
|
|
3806
|
+
log.trace(origin);
|
|
3807
|
+
|
|
3808
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3809
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3810
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3811
|
+
return callback(null, errorObj);
|
|
3812
|
+
}
|
|
3813
|
+
|
|
3814
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3815
|
+
if (data === undefined || data === null || data === '') {
|
|
3816
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3817
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3818
|
+
return callback(null, errorObj);
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3822
|
+
const queryParamsAvailable = {};
|
|
3823
|
+
const queryParams = {};
|
|
3824
|
+
const pathVars = [];
|
|
3825
|
+
const bodyVars = data;
|
|
3826
|
+
|
|
3827
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3828
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3829
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3830
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3831
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3832
|
+
}
|
|
3833
|
+
});
|
|
3834
|
+
|
|
3835
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3836
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3837
|
+
const reqObj = {
|
|
3838
|
+
payload: bodyVars,
|
|
3839
|
+
uriPathVars: pathVars,
|
|
3840
|
+
uriQuery: queryParams
|
|
3841
|
+
};
|
|
3842
|
+
|
|
3843
|
+
try {
|
|
3844
|
+
// Make the call -
|
|
3845
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3846
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToCommentAlarmsStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3847
|
+
// if we received an error or their is no response on the results
|
|
3848
|
+
// return an error
|
|
3849
|
+
if (irReturnError) {
|
|
3850
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3851
|
+
return callback(null, irReturnError);
|
|
3852
|
+
}
|
|
3853
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3854
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToCommentAlarmsStateChangeEvent'], null, null, null);
|
|
3855
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3856
|
+
return callback(null, errorObj);
|
|
3857
|
+
}
|
|
3858
|
+
|
|
3859
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3860
|
+
// return the response
|
|
3861
|
+
return callback(irReturnData, null);
|
|
3862
|
+
});
|
|
3863
|
+
} catch (ex) {
|
|
3864
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3865
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3866
|
+
return callback(null, errorObj);
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
/**
|
|
3871
|
+
* @function listenToGroupAlarmsCreateEvent
|
|
3872
|
+
* @pronghornType method
|
|
3873
|
+
* @name listenToGroupAlarmsCreateEvent
|
|
3874
|
+
* @summary Client listener for entity GroupAlarmsCreateEvent
|
|
3875
|
+
*
|
|
3876
|
+
* @param {object} data - The event data
|
|
3877
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3878
|
+
* @return {object} results - An object containing the response of the action
|
|
3879
|
+
*
|
|
3880
|
+
* @route {POST} /listenToGroupAlarmsCreateEvent
|
|
3881
|
+
* @roles admin
|
|
3882
|
+
* @task true
|
|
3883
|
+
*/
|
|
3884
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3885
|
+
listenToGroupAlarmsCreateEvent(data, callback) {
|
|
3886
|
+
const meth = 'adapter-listenToGroupAlarmsCreateEvent';
|
|
3887
|
+
const origin = `${this.id}-${meth}`;
|
|
3888
|
+
log.trace(origin);
|
|
3889
|
+
|
|
3890
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3891
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3892
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3893
|
+
return callback(null, errorObj);
|
|
3894
|
+
}
|
|
3895
|
+
|
|
3896
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3897
|
+
if (data === undefined || data === null || data === '') {
|
|
3898
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3899
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3900
|
+
return callback(null, errorObj);
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3904
|
+
const queryParamsAvailable = {};
|
|
3905
|
+
const queryParams = {};
|
|
3906
|
+
const pathVars = [];
|
|
3907
|
+
const bodyVars = data;
|
|
3908
|
+
|
|
3909
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3910
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3911
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3912
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3913
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3914
|
+
}
|
|
3915
|
+
});
|
|
3916
|
+
|
|
3917
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3918
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3919
|
+
const reqObj = {
|
|
3920
|
+
payload: bodyVars,
|
|
3921
|
+
uriPathVars: pathVars,
|
|
3922
|
+
uriQuery: queryParams
|
|
3923
|
+
};
|
|
3924
|
+
|
|
3925
|
+
try {
|
|
3926
|
+
// Make the call -
|
|
3927
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3928
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToGroupAlarmsCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
3929
|
+
// if we received an error or their is no response on the results
|
|
3930
|
+
// return an error
|
|
3931
|
+
if (irReturnError) {
|
|
3932
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3933
|
+
return callback(null, irReturnError);
|
|
3934
|
+
}
|
|
3935
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3936
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToGroupAlarmsCreateEvent'], null, null, null);
|
|
3937
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3938
|
+
return callback(null, errorObj);
|
|
3939
|
+
}
|
|
3940
|
+
|
|
3941
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3942
|
+
// return the response
|
|
3943
|
+
return callback(irReturnData, null);
|
|
3944
|
+
});
|
|
3945
|
+
} catch (ex) {
|
|
3946
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3947
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3948
|
+
return callback(null, errorObj);
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
|
|
3952
|
+
/**
|
|
3953
|
+
* @function listenToGroupAlarmsStateChangeEvent
|
|
3954
|
+
* @pronghornType method
|
|
3955
|
+
* @name listenToGroupAlarmsStateChangeEvent
|
|
3956
|
+
* @summary Client listener for entity GroupAlarmsStateChangeEvent
|
|
3957
|
+
*
|
|
3958
|
+
* @param {object} data - The event data
|
|
3959
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3960
|
+
* @return {object} results - An object containing the response of the action
|
|
3961
|
+
*
|
|
3962
|
+
* @route {POST} /listenToGroupAlarmsStateChangeEvent
|
|
3963
|
+
* @roles admin
|
|
3964
|
+
* @task true
|
|
3965
|
+
*/
|
|
3966
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3967
|
+
listenToGroupAlarmsStateChangeEvent(data, callback) {
|
|
3968
|
+
const meth = 'adapter-listenToGroupAlarmsStateChangeEvent';
|
|
3969
|
+
const origin = `${this.id}-${meth}`;
|
|
3970
|
+
log.trace(origin);
|
|
3971
|
+
|
|
3972
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3973
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3974
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3975
|
+
return callback(null, errorObj);
|
|
3976
|
+
}
|
|
3977
|
+
|
|
3978
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3979
|
+
if (data === undefined || data === null || data === '') {
|
|
3980
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
3981
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3982
|
+
return callback(null, errorObj);
|
|
3983
|
+
}
|
|
3984
|
+
|
|
3985
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3986
|
+
const queryParamsAvailable = {};
|
|
3987
|
+
const queryParams = {};
|
|
3988
|
+
const pathVars = [];
|
|
3989
|
+
const bodyVars = data;
|
|
3990
|
+
|
|
3991
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3992
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3993
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3994
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3995
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3996
|
+
}
|
|
3997
|
+
});
|
|
3998
|
+
|
|
3999
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4000
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4001
|
+
const reqObj = {
|
|
4002
|
+
payload: bodyVars,
|
|
4003
|
+
uriPathVars: pathVars,
|
|
4004
|
+
uriQuery: queryParams
|
|
4005
|
+
};
|
|
4006
|
+
|
|
4007
|
+
try {
|
|
4008
|
+
// Make the call -
|
|
4009
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4010
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToGroupAlarmsStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
4011
|
+
// if we received an error or their is no response on the results
|
|
4012
|
+
// return an error
|
|
4013
|
+
if (irReturnError) {
|
|
4014
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4015
|
+
return callback(null, irReturnError);
|
|
4016
|
+
}
|
|
4017
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4018
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToGroupAlarmsStateChangeEvent'], null, null, null);
|
|
4019
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4020
|
+
return callback(null, errorObj);
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4024
|
+
// return the response
|
|
4025
|
+
return callback(irReturnData, null);
|
|
4026
|
+
});
|
|
4027
|
+
} catch (ex) {
|
|
4028
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4029
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4030
|
+
return callback(null, errorObj);
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
/**
|
|
4035
|
+
* @function listenToUnGroupAlarmsCreateEvent
|
|
4036
|
+
* @pronghornType method
|
|
4037
|
+
* @name listenToUnGroupAlarmsCreateEvent
|
|
4038
|
+
* @summary Client listener for entity UnGroupAlarmsCreateEvent
|
|
4039
|
+
*
|
|
4040
|
+
* @param {object} data - The event data
|
|
4041
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4042
|
+
* @return {object} results - An object containing the response of the action
|
|
4043
|
+
*
|
|
4044
|
+
* @route {POST} /listenToUnGroupAlarmsCreateEvent
|
|
4045
|
+
* @roles admin
|
|
4046
|
+
* @task true
|
|
4047
|
+
*/
|
|
4048
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4049
|
+
listenToUnGroupAlarmsCreateEvent(data, callback) {
|
|
4050
|
+
const meth = 'adapter-listenToUnGroupAlarmsCreateEvent';
|
|
4051
|
+
const origin = `${this.id}-${meth}`;
|
|
4052
|
+
log.trace(origin);
|
|
4053
|
+
|
|
4054
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4055
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4056
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4057
|
+
return callback(null, errorObj);
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4061
|
+
if (data === undefined || data === null || data === '') {
|
|
4062
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
4063
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4064
|
+
return callback(null, errorObj);
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4068
|
+
const queryParamsAvailable = {};
|
|
4069
|
+
const queryParams = {};
|
|
4070
|
+
const pathVars = [];
|
|
4071
|
+
const bodyVars = data;
|
|
4072
|
+
|
|
4073
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4074
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4075
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4076
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4077
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4078
|
+
}
|
|
4079
|
+
});
|
|
4080
|
+
|
|
4081
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4082
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4083
|
+
const reqObj = {
|
|
4084
|
+
payload: bodyVars,
|
|
4085
|
+
uriPathVars: pathVars,
|
|
4086
|
+
uriQuery: queryParams
|
|
4087
|
+
};
|
|
4088
|
+
|
|
4089
|
+
try {
|
|
4090
|
+
// Make the call -
|
|
4091
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4092
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToUnGroupAlarmsCreateEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
4093
|
+
// if we received an error or their is no response on the results
|
|
4094
|
+
// return an error
|
|
4095
|
+
if (irReturnError) {
|
|
4096
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4097
|
+
return callback(null, irReturnError);
|
|
4098
|
+
}
|
|
4099
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4100
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToUnGroupAlarmsCreateEvent'], null, null, null);
|
|
4101
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4102
|
+
return callback(null, errorObj);
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4106
|
+
// return the response
|
|
4107
|
+
return callback(irReturnData, null);
|
|
4108
|
+
});
|
|
4109
|
+
} catch (ex) {
|
|
4110
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4111
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4112
|
+
return callback(null, errorObj);
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
/**
|
|
4117
|
+
* @function listenToUnGroupAlarmsStateChangeEvent
|
|
4118
|
+
* @pronghornType method
|
|
4119
|
+
* @name listenToUnGroupAlarmsStateChangeEvent
|
|
4120
|
+
* @summary Client listener for entity UnGroupAlarmsStateChangeEvent
|
|
4121
|
+
*
|
|
4122
|
+
* @param {object} data - The event data
|
|
4123
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4124
|
+
* @return {object} results - An object containing the response of the action
|
|
4125
|
+
*
|
|
4126
|
+
* @route {POST} /listenToUnGroupAlarmsStateChangeEvent
|
|
4127
|
+
* @roles admin
|
|
4128
|
+
* @task true
|
|
4129
|
+
*/
|
|
4130
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4131
|
+
listenToUnGroupAlarmsStateChangeEvent(data, callback) {
|
|
4132
|
+
const meth = 'adapter-listenToUnGroupAlarmsStateChangeEvent';
|
|
4133
|
+
const origin = `${this.id}-${meth}`;
|
|
4134
|
+
log.trace(origin);
|
|
4135
|
+
|
|
4136
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4137
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4138
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4139
|
+
return callback(null, errorObj);
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4143
|
+
if (data === undefined || data === null || data === '') {
|
|
4144
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['data'], null, null, null);
|
|
4145
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4146
|
+
return callback(null, errorObj);
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4150
|
+
const queryParamsAvailable = {};
|
|
4151
|
+
const queryParams = {};
|
|
4152
|
+
const pathVars = [];
|
|
4153
|
+
const bodyVars = data;
|
|
4154
|
+
|
|
4155
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4156
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4157
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4158
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4159
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4160
|
+
}
|
|
4161
|
+
});
|
|
4162
|
+
|
|
4163
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4164
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4165
|
+
const reqObj = {
|
|
4166
|
+
payload: bodyVars,
|
|
4167
|
+
uriPathVars: pathVars,
|
|
4168
|
+
uriQuery: queryParams
|
|
4169
|
+
};
|
|
4170
|
+
|
|
4171
|
+
try {
|
|
4172
|
+
// Make the call -
|
|
4173
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4174
|
+
return this.requestHandlerInst.identifyRequest('NotificationListenersClientSide', 'listenToUnGroupAlarmsStateChangeEvent', reqObj, true, (irReturnData, irReturnError) => {
|
|
4175
|
+
// if we received an error or their is no response on the results
|
|
4176
|
+
// return an error
|
|
4177
|
+
if (irReturnError) {
|
|
4178
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4179
|
+
return callback(null, irReturnError);
|
|
4180
|
+
}
|
|
4181
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4182
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listenToUnGroupAlarmsStateChangeEvent'], null, null, null);
|
|
4183
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4184
|
+
return callback(null, errorObj);
|
|
4185
|
+
}
|
|
4186
|
+
|
|
4187
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4188
|
+
// return the response
|
|
4189
|
+
return callback(irReturnData, null);
|
|
4190
|
+
});
|
|
4191
|
+
} catch (ex) {
|
|
4192
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4193
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4194
|
+
return callback(null, errorObj);
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
module.exports = Tmf642AlarmManagement;
|