@itentialopensource/adapter-nokia_altiplano 0.4.0 → 0.5.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/CHANGELOG.md +8 -0
- package/ENHANCE.md +6 -6
- package/PROPERTIES.md +9 -3
- package/README.md +112 -542
- package/SUMMARY.md +4 -4
- package/TROUBLESHOOT.md +1 -1
- package/adapter.js +677 -344
- package/adapterBase.js +548 -283
- package/entities/Entity/action.json +70 -0
- package/entities/Entity/schema.json +21 -0
- package/error.json +6 -0
- package/package.json +3 -3
- package/pronghorn.json +328 -113
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +350 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/updateReport1651493162166.json +114 -0
- package/test/integration/adapterTestIntegration.js +76 -0
- package/test/unit/adapterBaseTestUnit.js +22 -24
- package/test/unit/adapterTestUnit.js +246 -51
- package/utils/tbUtils.js +20 -7
package/adapter.js
CHANGED
|
@@ -80,10 +80,10 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* @
|
|
83
|
+
* @iapGetAdapterWorkflowFunctions
|
|
84
84
|
*/
|
|
85
|
-
|
|
86
|
-
let myIgnore = ['hasEntities', 'hasDevices'];
|
|
85
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
86
|
+
let myIgnore = ['hasEntities', 'hasDevices', 'iapMakeBrokerCall'];
|
|
87
87
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
88
88
|
myIgnore = inIgnore;
|
|
89
89
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -94,15 +94,15 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
94
94
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
95
95
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
96
96
|
|
|
97
|
-
return super.
|
|
97
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
101
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
102
102
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
103
103
|
* file system.
|
|
104
104
|
*
|
|
105
|
-
* @function
|
|
105
|
+
* @function iapUpdateAdapterConfiguration
|
|
106
106
|
* @param {string} configFile - the name of the file being updated (required)
|
|
107
107
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
108
108
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
@@ -110,36 +110,36 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
110
110
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
111
111
|
* @param {Callback} callback - The results of the call
|
|
112
112
|
*/
|
|
113
|
-
|
|
114
|
-
const origin = `${this.id}-adapter-
|
|
113
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
114
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterConfiguration`;
|
|
115
115
|
log.trace(origin);
|
|
116
|
-
super.
|
|
116
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* See if the API path provided is found in this adapter
|
|
121
121
|
*
|
|
122
|
-
* @function
|
|
122
|
+
* @function iapFindAdapterPath
|
|
123
123
|
* @param {string} apiPath - the api path to check on
|
|
124
124
|
* @param {Callback} callback - The results of the call
|
|
125
125
|
*/
|
|
126
|
-
|
|
127
|
-
const origin = `${this.id}-adapter-
|
|
126
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
127
|
+
const origin = `${this.id}-adapter-iapFindAdapterPath`;
|
|
128
128
|
log.trace(origin);
|
|
129
|
-
super.
|
|
129
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* @summary Suspends adapter
|
|
134
134
|
*
|
|
135
|
-
* @function
|
|
135
|
+
* @function iapSuspendAdapter
|
|
136
136
|
* @param {Callback} callback - callback function
|
|
137
137
|
*/
|
|
138
|
-
|
|
139
|
-
const origin = `${this.id}-adapter-
|
|
138
|
+
iapSuspendAdapter(mode, callback) {
|
|
139
|
+
const origin = `${this.id}-adapter-iapSuspendAdapter`;
|
|
140
140
|
log.trace(origin);
|
|
141
141
|
try {
|
|
142
|
-
return super.
|
|
142
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
143
143
|
} catch (error) {
|
|
144
144
|
log.error(`${origin}: ${error}`);
|
|
145
145
|
return callback(null, error);
|
|
@@ -149,14 +149,14 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
149
149
|
/**
|
|
150
150
|
* @summary Unsuspends adapter
|
|
151
151
|
*
|
|
152
|
-
* @function
|
|
152
|
+
* @function iapUnsuspendAdapter
|
|
153
153
|
* @param {Callback} callback - callback function
|
|
154
154
|
*/
|
|
155
|
-
|
|
156
|
-
const origin = `${this.id}-adapter-
|
|
155
|
+
iapUnsuspendAdapter(callback) {
|
|
156
|
+
const origin = `${this.id}-adapter-iapUnsuspendAdapter`;
|
|
157
157
|
log.trace(origin);
|
|
158
158
|
try {
|
|
159
|
-
return super.
|
|
159
|
+
return super.iapUnsuspendAdapter(callback);
|
|
160
160
|
} catch (error) {
|
|
161
161
|
log.error(`${origin}: ${error}`);
|
|
162
162
|
return callback(null, error);
|
|
@@ -166,29 +166,29 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
166
166
|
/**
|
|
167
167
|
* @summary Get the Adaoter Queue
|
|
168
168
|
*
|
|
169
|
-
* @function
|
|
169
|
+
* @function iapGetAdapterQueue
|
|
170
170
|
* @param {Callback} callback - callback function
|
|
171
171
|
*/
|
|
172
|
-
|
|
173
|
-
const origin = `${this.id}-adapter-
|
|
172
|
+
iapGetAdapterQueue(callback) {
|
|
173
|
+
const origin = `${this.id}-adapter-iapGetAdapterQueue`;
|
|
174
174
|
log.trace(origin);
|
|
175
|
-
return super.
|
|
175
|
+
return super.iapGetAdapterQueue(callback);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* @summary Runs troubleshoot scripts for adapter
|
|
180
180
|
*
|
|
181
|
-
* @function
|
|
181
|
+
* @function iapTroubleshootAdapter
|
|
182
182
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
183
183
|
*
|
|
184
184
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
185
185
|
* @param {Callback} callback - The results of the call
|
|
186
186
|
*/
|
|
187
|
-
|
|
188
|
-
const origin = `${this.id}-adapter-
|
|
187
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
188
|
+
const origin = `${this.id}-adapter-iapTroubleshootAdapter`;
|
|
189
189
|
log.trace(origin);
|
|
190
190
|
try {
|
|
191
|
-
return super.
|
|
191
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
192
192
|
} catch (error) {
|
|
193
193
|
log.error(`${origin}: ${error}`);
|
|
194
194
|
return callback(null, error);
|
|
@@ -198,15 +198,15 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
198
198
|
/**
|
|
199
199
|
* @summary runs healthcheck script for adapter
|
|
200
200
|
*
|
|
201
|
-
* @function
|
|
201
|
+
* @function iapRunAdapterHealthcheck
|
|
202
202
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
203
203
|
* @param {Callback} callback - callback function
|
|
204
204
|
*/
|
|
205
|
-
|
|
206
|
-
const origin = `${this.id}-adapter-
|
|
205
|
+
iapRunAdapterHealthcheck(callback) {
|
|
206
|
+
const origin = `${this.id}-adapter-iapRunAdapterHealthcheck`;
|
|
207
207
|
log.trace(origin);
|
|
208
208
|
try {
|
|
209
|
-
return super.
|
|
209
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
210
210
|
} catch (error) {
|
|
211
211
|
log.error(`${origin}: ${error}`);
|
|
212
212
|
return callback(null, error);
|
|
@@ -216,14 +216,14 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
216
216
|
/**
|
|
217
217
|
* @summary runs connectivity check script for adapter
|
|
218
218
|
*
|
|
219
|
-
* @function
|
|
219
|
+
* @function iapRunAdapterConnectivity
|
|
220
220
|
* @param {Callback} callback - callback function
|
|
221
221
|
*/
|
|
222
|
-
|
|
223
|
-
const origin = `${this.id}-adapter-
|
|
222
|
+
iapRunAdapterConnectivity(callback) {
|
|
223
|
+
const origin = `${this.id}-adapter-iapRunAdapterConnectivity`;
|
|
224
224
|
log.trace(origin);
|
|
225
225
|
try {
|
|
226
|
-
return super.
|
|
226
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
227
227
|
} catch (error) {
|
|
228
228
|
log.error(`${origin}: ${error}`);
|
|
229
229
|
return callback(null, error);
|
|
@@ -233,14 +233,14 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
233
233
|
/**
|
|
234
234
|
* @summary runs basicGet script for adapter
|
|
235
235
|
*
|
|
236
|
-
* @function
|
|
236
|
+
* @function iapRunAdapterBasicGet
|
|
237
237
|
* @param {Callback} callback - callback function
|
|
238
238
|
*/
|
|
239
|
-
|
|
240
|
-
const origin = `${this.id}-adapter-
|
|
239
|
+
iapRunAdapterBasicGet(callback) {
|
|
240
|
+
const origin = `${this.id}-adapter-iapRunAdapterBasicGet`;
|
|
241
241
|
log.trace(origin);
|
|
242
242
|
try {
|
|
243
|
-
return super.
|
|
243
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
244
244
|
} catch (error) {
|
|
245
245
|
log.error(`${origin}: ${error}`);
|
|
246
246
|
return callback(null, error);
|
|
@@ -250,45 +250,46 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
250
250
|
/**
|
|
251
251
|
* @summary moves entites into Mongo DB
|
|
252
252
|
*
|
|
253
|
-
* @function
|
|
253
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
254
254
|
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
255
255
|
* or the error
|
|
256
256
|
*/
|
|
257
|
-
|
|
258
|
-
const origin = `${this.id}-adapter-
|
|
257
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
258
|
+
const origin = `${this.id}-adapter-iapMoveAdapterEntitiesToDB`;
|
|
259
259
|
log.trace(origin);
|
|
260
260
|
try {
|
|
261
|
-
return super.
|
|
261
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
262
262
|
} catch (err) {
|
|
263
263
|
log.error(`${origin}: ${err}`);
|
|
264
264
|
return callback(null, err);
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
/* BROKER CALLS */
|
|
268
269
|
/**
|
|
269
270
|
* @summary Determines if this adapter supports the specific entity
|
|
270
271
|
*
|
|
271
|
-
* @function
|
|
272
|
+
* @function iapHasAdapterEntity
|
|
272
273
|
* @param {String} entityType - the entity type to check for
|
|
273
274
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
274
275
|
*
|
|
275
276
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
276
277
|
* desired capability or an error
|
|
277
278
|
*/
|
|
278
|
-
|
|
279
|
-
const origin = `${this.id}-adapter-
|
|
279
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
280
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
280
281
|
log.trace(origin);
|
|
281
282
|
|
|
282
283
|
// Make the call -
|
|
283
|
-
//
|
|
284
|
-
return this.
|
|
284
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
285
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
285
286
|
}
|
|
286
287
|
|
|
287
288
|
/**
|
|
288
289
|
* @summary Provides a way for the adapter to tell north bound integrations
|
|
289
290
|
* whether the adapter supports type, action and specific entity
|
|
290
291
|
*
|
|
291
|
-
* @function
|
|
292
|
+
* @function iapVerifyAdapterCapability
|
|
292
293
|
* @param {String} entityType - the entity type to check for
|
|
293
294
|
* @param {String} actionType - the action type to check for
|
|
294
295
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
@@ -296,15 +297,15 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
296
297
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
297
298
|
* desired capability or an error
|
|
298
299
|
*/
|
|
299
|
-
|
|
300
|
-
const meth = 'adapterBase-
|
|
300
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
301
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
|
301
302
|
const origin = `${this.id}-${meth}`;
|
|
302
303
|
log.trace(origin);
|
|
303
304
|
|
|
304
305
|
// if caching
|
|
305
306
|
if (this.caching) {
|
|
306
|
-
// Make the call -
|
|
307
|
-
return this.requestHandlerInst.
|
|
307
|
+
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
308
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
|
308
309
|
if (error) {
|
|
309
310
|
return callback(null, error);
|
|
310
311
|
}
|
|
@@ -322,7 +323,7 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
322
323
|
}
|
|
323
324
|
|
|
324
325
|
// need to check the cache again since it has been updated
|
|
325
|
-
return this.requestHandlerInst.
|
|
326
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
326
327
|
if (verror) {
|
|
327
328
|
return callback(null, verror);
|
|
328
329
|
}
|
|
@@ -355,7 +356,7 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
355
356
|
// if no entity id
|
|
356
357
|
if (!entityId) {
|
|
357
358
|
// need to check the cache again since it has been updated
|
|
358
|
-
return this.requestHandlerInst.
|
|
359
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
359
360
|
if (verror) {
|
|
360
361
|
return callback(null, verror);
|
|
361
362
|
}
|
|
@@ -376,7 +377,7 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
376
377
|
}
|
|
377
378
|
|
|
378
379
|
// need to check the cache again since it has been updated
|
|
379
|
-
return this.requestHandlerInst.
|
|
380
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
380
381
|
if (verror) {
|
|
381
382
|
return callback(null, verror);
|
|
382
383
|
}
|
|
@@ -417,11 +418,11 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
417
418
|
/**
|
|
418
419
|
* @summary Updates the cache for all entities by call the get All entity method
|
|
419
420
|
*
|
|
420
|
-
* @function
|
|
421
|
+
* @function iapUpdateAdapterEntityCache
|
|
421
422
|
*
|
|
422
423
|
*/
|
|
423
|
-
|
|
424
|
-
const origin = `${this.id}-adapter-
|
|
424
|
+
iapUpdateAdapterEntityCache() {
|
|
425
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
|
425
426
|
log.trace(origin);
|
|
426
427
|
|
|
427
428
|
if (this.caching) {
|
|
@@ -434,117 +435,6 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
437
|
|
|
437
|
-
/**
|
|
438
|
-
* Makes the requested generic call
|
|
439
|
-
*
|
|
440
|
-
* @function genericAdapterRequest
|
|
441
|
-
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
442
|
-
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
443
|
-
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
444
|
-
* Can be a stringified Object.
|
|
445
|
-
* @param {Object} requestBody - the body to add to the request (optional).
|
|
446
|
-
* Can be a stringified Object.
|
|
447
|
-
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
448
|
-
* Can be a stringified Object.
|
|
449
|
-
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
450
|
-
* or the error
|
|
451
|
-
*/
|
|
452
|
-
genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
453
|
-
const meth = 'adapter-genericAdapterRequest';
|
|
454
|
-
const origin = `${this.id}-${meth}`;
|
|
455
|
-
log.trace(origin);
|
|
456
|
-
|
|
457
|
-
if (this.suspended && this.suspendMode === 'error') {
|
|
458
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
459
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
460
|
-
return callback(null, errorObj);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
464
|
-
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
465
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
466
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
467
|
-
return callback(null, errorObj);
|
|
468
|
-
}
|
|
469
|
-
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
470
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
471
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
472
|
-
return callback(null, errorObj);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
476
|
-
// remove any leading / and split the uripath into path variables
|
|
477
|
-
let myPath = uriPath;
|
|
478
|
-
while (myPath.indexOf('/') === 0) {
|
|
479
|
-
myPath = myPath.substring(1);
|
|
480
|
-
}
|
|
481
|
-
const pathVars = myPath.split('/');
|
|
482
|
-
const queryParamsAvailable = queryData;
|
|
483
|
-
const queryParams = {};
|
|
484
|
-
const bodyVars = requestBody;
|
|
485
|
-
|
|
486
|
-
// loop in template. long callback arg name to avoid identifier conflicts
|
|
487
|
-
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
488
|
-
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
489
|
-
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
490
|
-
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
495
|
-
const reqObj = {
|
|
496
|
-
payload: bodyVars,
|
|
497
|
-
uriPathVars: pathVars,
|
|
498
|
-
uriQuery: queryParams,
|
|
499
|
-
uriOptions: {}
|
|
500
|
-
};
|
|
501
|
-
// add headers if provided
|
|
502
|
-
if (addlHeaders) {
|
|
503
|
-
reqObj.addlHeaders = addlHeaders;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
// determine the call and return flag
|
|
507
|
-
let action = 'getGenerics';
|
|
508
|
-
let returnF = true;
|
|
509
|
-
if (restMethod.toUpperCase() === 'POST') {
|
|
510
|
-
action = 'createGeneric';
|
|
511
|
-
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
512
|
-
action = 'updateGeneric';
|
|
513
|
-
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
514
|
-
action = 'patchGeneric';
|
|
515
|
-
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
516
|
-
action = 'deleteGeneric';
|
|
517
|
-
returnF = false;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
try {
|
|
521
|
-
// Make the call -
|
|
522
|
-
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
523
|
-
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
524
|
-
// if we received an error or their is no response on the results
|
|
525
|
-
// return an error
|
|
526
|
-
if (irReturnError) {
|
|
527
|
-
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
528
|
-
return callback(null, irReturnError);
|
|
529
|
-
}
|
|
530
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
531
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
532
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
533
|
-
return callback(null, errorObj);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
537
|
-
// return the response
|
|
538
|
-
return callback(irReturnData, null);
|
|
539
|
-
});
|
|
540
|
-
} catch (ex) {
|
|
541
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
542
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
543
|
-
return callback(null, errorObj);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/* BROKER CALLS */
|
|
548
438
|
/**
|
|
549
439
|
* @summary Determines if this adapter supports any in a list of entities
|
|
550
440
|
*
|
|
@@ -620,8 +510,9 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
620
510
|
const origin = `${this.id}-${meth}`;
|
|
621
511
|
log.trace(origin);
|
|
622
512
|
|
|
623
|
-
|
|
624
|
-
|
|
513
|
+
// make sure we are set up for device broker getDevice
|
|
514
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getDevice || this.allProps.devicebroker.getDevice.length === 0 || !this.allProps.devicebroker.getDevice[0].path) {
|
|
515
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevice.path'], null, null, null);
|
|
625
516
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
626
517
|
return callback(null, errorObj);
|
|
627
518
|
}
|
|
@@ -651,32 +542,33 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
651
542
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
652
543
|
return callback(null, errorObj);
|
|
653
544
|
}
|
|
654
|
-
// get the uuid from the device
|
|
655
|
-
const { uuid } = devs.list[0];
|
|
656
545
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
546
|
+
const callPromises = [];
|
|
547
|
+
for (let i = 0; i < this.allProps.devicebroker.getDevice.length; i += 1) {
|
|
548
|
+
// Perform component calls here.
|
|
549
|
+
callPromises.push(
|
|
550
|
+
new Promise((resolve, reject) => {
|
|
551
|
+
this.iapMakeBrokerCall('getDevice', this.allProps.devicebroker.getDevice[i], devs.list[0], null, (callRet, callErr) => {
|
|
552
|
+
// return an error
|
|
553
|
+
if (callErr) {
|
|
554
|
+
reject(callErr);
|
|
555
|
+
} else {
|
|
556
|
+
// return the data
|
|
557
|
+
resolve(callRet);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
})
|
|
561
|
+
);
|
|
562
|
+
}
|
|
670
563
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
return callback(thisDevice);
|
|
564
|
+
// return an array of repsonses
|
|
565
|
+
return Promise.all(callPromises).then((results) => {
|
|
566
|
+
let myResult = {};
|
|
567
|
+
results.forEach((result) => {
|
|
568
|
+
myResult = { ...myResult, ...result };
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
return callback(myResult, null);
|
|
680
572
|
});
|
|
681
573
|
});
|
|
682
574
|
} catch (ex) {
|
|
@@ -700,6 +592,13 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
700
592
|
const origin = `${this.id}-${meth}`;
|
|
701
593
|
log.trace(origin);
|
|
702
594
|
|
|
595
|
+
// make sure we are set up for device broker getDevicesFiltered
|
|
596
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getDevicesFiltered || this.allProps.devicebroker.getDevicesFiltered.length === 0 || !this.allProps.devicebroker.getDevicesFiltered[0].path) {
|
|
597
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevicesFiltered.path'], null, null, null);
|
|
598
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
599
|
+
return callback(null, errorObj);
|
|
600
|
+
}
|
|
601
|
+
|
|
703
602
|
// verify the required fields have been provided
|
|
704
603
|
if (options === undefined || options === null || options === '' || options.length === 0) {
|
|
705
604
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['options'], null, null, null);
|
|
@@ -708,115 +607,64 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
708
607
|
}
|
|
709
608
|
log.debug(`Device Filter Options: ${JSON.stringify(options)}`);
|
|
710
609
|
|
|
711
|
-
// TODO - get pagination working
|
|
712
|
-
// const nextToken = options.start;
|
|
713
|
-
// const maxResults = options.limit;
|
|
714
|
-
|
|
715
|
-
// set up the filter of Device Names
|
|
716
|
-
let filterName = [];
|
|
717
|
-
if (options && options.filter && options.filter.name) {
|
|
718
|
-
// when this hack is removed, remove the lint ignore above
|
|
719
|
-
if (Array.isArray(options.filter.name)) {
|
|
720
|
-
// eslint-disable-next-line prefer-destructuring
|
|
721
|
-
filterName = options.filter.name;
|
|
722
|
-
} else {
|
|
723
|
-
filterName = [options.filter.name];
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
// TODO - get sort and order working
|
|
728
|
-
/*
|
|
729
|
-
if (options && options.sort) {
|
|
730
|
-
reqObj.uriOptions.sort = JSON.stringify(options.sort);
|
|
731
|
-
}
|
|
732
|
-
if (options && options.order) {
|
|
733
|
-
reqObj.uriOptions.order = options.order;
|
|
734
|
-
}
|
|
735
|
-
*/
|
|
736
610
|
try {
|
|
737
|
-
//
|
|
738
|
-
//
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
if (
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
611
|
+
// TODO - get pagination working
|
|
612
|
+
// const nextToken = options.start;
|
|
613
|
+
// const maxResults = options.limit;
|
|
614
|
+
|
|
615
|
+
// set up the filter of Device Names
|
|
616
|
+
let filterName = [];
|
|
617
|
+
if (options && options.filter && options.filter.name) {
|
|
618
|
+
// when this hack is removed, remove the lint ignore above
|
|
619
|
+
if (Array.isArray(options.filter.name)) {
|
|
620
|
+
// eslint-disable-next-line prefer-destructuring
|
|
621
|
+
filterName = options.filter.name;
|
|
622
|
+
} else {
|
|
623
|
+
filterName = [options.filter.name];
|
|
749
624
|
}
|
|
625
|
+
}
|
|
750
626
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
if (thisDevice.name.indexOf(filterName[f]) >= 0) {
|
|
773
|
-
found = true;
|
|
774
|
-
break;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
// matching device
|
|
778
|
-
if (found) {
|
|
779
|
-
myDevices.push(thisDevice);
|
|
627
|
+
// TODO - get sort and order working
|
|
628
|
+
/*
|
|
629
|
+
if (options && options.sort) {
|
|
630
|
+
reqObj.uriOptions.sort = JSON.stringify(options.sort);
|
|
631
|
+
}
|
|
632
|
+
if (options && options.order) {
|
|
633
|
+
reqObj.uriOptions.order = options.order;
|
|
634
|
+
}
|
|
635
|
+
*/
|
|
636
|
+
const callPromises = [];
|
|
637
|
+
for (let i = 0; i < this.allProps.devicebroker.getDevicesFiltered.length; i += 1) {
|
|
638
|
+
// Perform component calls here.
|
|
639
|
+
callPromises.push(
|
|
640
|
+
new Promise((resolve, reject) => {
|
|
641
|
+
this.iapMakeBrokerCall('getDevicesFiltered', this.allProps.devicebroker.getDevicesFiltered[i], null, filterName, (callRet, callErr) => {
|
|
642
|
+
// return an error
|
|
643
|
+
if (callErr) {
|
|
644
|
+
reject(callErr);
|
|
645
|
+
} else {
|
|
646
|
+
// return the data
|
|
647
|
+
resolve(callRet);
|
|
780
648
|
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
thisDevice.ipaddress = thisDevice.systemIP;
|
|
795
|
-
|
|
796
|
-
// if there is no filter - return the device
|
|
797
|
-
if (filterName.length === 0) {
|
|
798
|
-
log.debug(`${origin}: Found #1 device.`);
|
|
799
|
-
log.debug(`Device: ${JSON.stringify(thisDevice)}`);
|
|
800
|
-
return callback({ total: 1, list: [thisDevice] });
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
// if there is a filter need to check for matching device
|
|
804
|
-
let found = false;
|
|
805
|
-
for (let f = 0; f < filterName.length; f += 1) {
|
|
806
|
-
if (thisDevice.name.indexOf(filterName[f]) >= 0) {
|
|
807
|
-
found = true;
|
|
808
|
-
break;
|
|
649
|
+
});
|
|
650
|
+
})
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// return an array of repsonses
|
|
655
|
+
return Promise.all(callPromises).then((results) => {
|
|
656
|
+
let myResult = [];
|
|
657
|
+
results.forEach((result) => {
|
|
658
|
+
if (Array.isArray(result)) {
|
|
659
|
+
myResult = [...myResult, ...result];
|
|
660
|
+
} else if (Object.keys(result).length > 0) {
|
|
661
|
+
myResult.push(result);
|
|
809
662
|
}
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
return callback({ total: 1, list: [thisDevice] });
|
|
816
|
-
}
|
|
817
|
-
// not a matching device
|
|
818
|
-
log.debug(`${origin}: No matching device found.`);
|
|
819
|
-
return callback({ total: 0, list: [] });
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
log.debug(`${origin}: Found #${myResult.length} devices.`);
|
|
666
|
+
log.debug(`Devices: ${JSON.stringify(myResult)}`);
|
|
667
|
+
return callback({ total: myResult.length, list: myResult });
|
|
820
668
|
});
|
|
821
669
|
} catch (ex) {
|
|
822
670
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
@@ -839,6 +687,13 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
839
687
|
const origin = `${this.id}-${meth}`;
|
|
840
688
|
log.trace(origin);
|
|
841
689
|
|
|
690
|
+
// make sure we are set up for device broker isAlive
|
|
691
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.isAlive || this.allProps.devicebroker.isAlive.length === 0 || !this.allProps.devicebroker.isAlive[0].path) {
|
|
692
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.isAlive.path'], null, null, null);
|
|
693
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
694
|
+
return callback(null, errorObj);
|
|
695
|
+
}
|
|
696
|
+
|
|
842
697
|
// verify the required fields have been provided
|
|
843
698
|
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
844
699
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
@@ -864,26 +719,37 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
864
719
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
865
720
|
return callback(null, errorObj);
|
|
866
721
|
}
|
|
867
|
-
// get the uuid from the device
|
|
868
|
-
const { uuid } = devs.list[0];
|
|
869
722
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
723
|
+
const callPromises = [];
|
|
724
|
+
for (let i = 0; i < this.allProps.devicebroker.isAlive.length; i += 1) {
|
|
725
|
+
// Perform component calls here.
|
|
726
|
+
callPromises.push(
|
|
727
|
+
new Promise((resolve, reject) => {
|
|
728
|
+
this.iapMakeBrokerCall('isAlive', this.allProps.devicebroker.isAlive[i], devs.list[0], null, (callRet, callErr) => {
|
|
729
|
+
// return an error
|
|
730
|
+
if (callErr) {
|
|
731
|
+
reject(callErr);
|
|
732
|
+
} else {
|
|
733
|
+
// return the data
|
|
734
|
+
resolve(callRet);
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
})
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
// return an array of repsonses
|
|
742
|
+
return Promise.all(callPromises).then((results) => {
|
|
743
|
+
let myResult = {};
|
|
744
|
+
results.forEach((result) => {
|
|
745
|
+
myResult = { ...myResult, ...result };
|
|
746
|
+
});
|
|
884
747
|
|
|
885
|
-
|
|
886
|
-
|
|
748
|
+
let response = true;
|
|
749
|
+
if (myResult.isAlive !== null && myResult.isAlive !== undefined && myResult.isAlive === false) {
|
|
750
|
+
response = false;
|
|
751
|
+
}
|
|
752
|
+
return callback(response);
|
|
887
753
|
});
|
|
888
754
|
});
|
|
889
755
|
} catch (ex) {
|
|
@@ -908,6 +774,13 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
908
774
|
const origin = `${this.id}-${meth}`;
|
|
909
775
|
log.trace(origin);
|
|
910
776
|
|
|
777
|
+
// make sure we are set up for device broker getConfig
|
|
778
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getConfig || this.allProps.devicebroker.getConfig.length === 0 || !this.allProps.devicebroker.getConfig[0].path) {
|
|
779
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getConfig.path'], null, null, null);
|
|
780
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
781
|
+
return callback(null, errorObj);
|
|
782
|
+
}
|
|
783
|
+
|
|
911
784
|
// verify the required fields have been provided
|
|
912
785
|
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
913
786
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
@@ -933,23 +806,37 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
933
806
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
934
807
|
return callback(null, errorObj);
|
|
935
808
|
}
|
|
936
|
-
// get the uuid from the device
|
|
937
|
-
const { uuid } = devs.list[0];
|
|
938
809
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
810
|
+
const callPromises = [];
|
|
811
|
+
for (let i = 0; i < this.allProps.devicebroker.getConfig.length; i += 1) {
|
|
812
|
+
// Perform component calls here.
|
|
813
|
+
callPromises.push(
|
|
814
|
+
new Promise((resolve, reject) => {
|
|
815
|
+
this.iapMakeBrokerCall('getConfig', this.allProps.devicebroker.getConfig[i], devs.list[0], null, (callRet, callErr) => {
|
|
816
|
+
// return an error
|
|
817
|
+
if (callErr) {
|
|
818
|
+
reject(callErr);
|
|
819
|
+
} else {
|
|
820
|
+
// return the data
|
|
821
|
+
resolve(callRet);
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
})
|
|
825
|
+
);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// return an array of repsonses
|
|
829
|
+
return Promise.all(callPromises).then((results) => {
|
|
830
|
+
let myResult = {};
|
|
831
|
+
results.forEach((result) => {
|
|
832
|
+
myResult = { ...myResult, ...result };
|
|
833
|
+
});
|
|
947
834
|
|
|
948
835
|
// return the result
|
|
949
836
|
const newResponse = {
|
|
950
|
-
response: JSON.stringify(
|
|
837
|
+
response: JSON.stringify(myResult, null, 2)
|
|
951
838
|
};
|
|
952
|
-
return callback(newResponse);
|
|
839
|
+
return callback(newResponse, null);
|
|
953
840
|
});
|
|
954
841
|
});
|
|
955
842
|
} catch (ex) {
|
|
@@ -962,30 +849,164 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
962
849
|
/**
|
|
963
850
|
* @summary Gets the device count from the system
|
|
964
851
|
*
|
|
965
|
-
* @function
|
|
852
|
+
* @function iapGetDeviceCount
|
|
966
853
|
*
|
|
967
854
|
* @param {getCallback} callback - callback function to return the result
|
|
968
855
|
* (count) or the error
|
|
969
856
|
*/
|
|
970
|
-
|
|
971
|
-
const meth = 'adapter-
|
|
857
|
+
iapGetDeviceCount(callback) {
|
|
858
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
972
859
|
const origin = `${this.id}-${meth}`;
|
|
973
860
|
log.trace(origin);
|
|
974
861
|
|
|
862
|
+
// make sure we are set up for device broker getCount
|
|
863
|
+
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getCount || this.allProps.devicebroker.getCount.length === 0 || !this.allProps.devicebroker.getCount[0].path) {
|
|
864
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getCount.path'], null, null, null);
|
|
865
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
866
|
+
return callback(null, errorObj);
|
|
867
|
+
}
|
|
868
|
+
|
|
975
869
|
// verify the required fields have been provided
|
|
976
870
|
|
|
977
871
|
try {
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
872
|
+
const callPromises = [];
|
|
873
|
+
for (let i = 0; i < this.allProps.devicebroker.getCount.length; i += 1) {
|
|
874
|
+
// Perform component calls here.
|
|
875
|
+
callPromises.push(
|
|
876
|
+
new Promise((resolve, reject) => {
|
|
877
|
+
this.iapMakeBrokerCall('getCount', this.allProps.devicebroker.getCount[i], null, null, (callRet, callErr) => {
|
|
878
|
+
// return an error
|
|
879
|
+
if (callErr) {
|
|
880
|
+
reject(callErr);
|
|
881
|
+
} else {
|
|
882
|
+
// return the data
|
|
883
|
+
resolve(callRet);
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
})
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
// return an array of repsonses
|
|
891
|
+
return Promise.all(callPromises).then((results) => {
|
|
892
|
+
let myResult = {};
|
|
893
|
+
results.forEach((result) => {
|
|
894
|
+
myResult = { ...myResult, ...result };
|
|
895
|
+
});
|
|
896
|
+
|
|
897
|
+
// return the result
|
|
898
|
+
return callback({ count: myResult.length });
|
|
899
|
+
});
|
|
900
|
+
} catch (ex) {
|
|
901
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
902
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
903
|
+
return callback(null, errorObj);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
908
|
+
/**
|
|
909
|
+
* Makes the requested generic call
|
|
910
|
+
*
|
|
911
|
+
* @function genericAdapterRequest
|
|
912
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
913
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
914
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
915
|
+
* Can be a stringified Object.
|
|
916
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
917
|
+
* Can be a stringified Object.
|
|
918
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
919
|
+
* Can be a stringified Object.
|
|
920
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
921
|
+
* or the error
|
|
922
|
+
*/
|
|
923
|
+
genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
924
|
+
const meth = 'adapter-genericAdapterRequest';
|
|
925
|
+
const origin = `${this.id}-${meth}`;
|
|
926
|
+
log.trace(origin);
|
|
927
|
+
|
|
928
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
929
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
930
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
931
|
+
return callback(null, errorObj);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
935
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
936
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
937
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
938
|
+
return callback(null, errorObj);
|
|
939
|
+
}
|
|
940
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
941
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
942
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
943
|
+
return callback(null, errorObj);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
947
|
+
// remove any leading / and split the uripath into path variables
|
|
948
|
+
let myPath = uriPath;
|
|
949
|
+
while (myPath.indexOf('/') === 0) {
|
|
950
|
+
myPath = myPath.substring(1);
|
|
951
|
+
}
|
|
952
|
+
const pathVars = myPath.split('/');
|
|
953
|
+
const queryParamsAvailable = queryData;
|
|
954
|
+
const queryParams = {};
|
|
955
|
+
const bodyVars = requestBody;
|
|
956
|
+
|
|
957
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
958
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
959
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
960
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
961
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
966
|
+
const reqObj = {
|
|
967
|
+
payload: bodyVars,
|
|
968
|
+
uriPathVars: pathVars,
|
|
969
|
+
uriQuery: queryParams,
|
|
970
|
+
uriOptions: {}
|
|
971
|
+
};
|
|
972
|
+
// add headers if provided
|
|
973
|
+
if (addlHeaders) {
|
|
974
|
+
reqObj.addlHeaders = addlHeaders;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// determine the call and return flag
|
|
978
|
+
let action = 'getGenerics';
|
|
979
|
+
let returnF = true;
|
|
980
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
981
|
+
action = 'createGeneric';
|
|
982
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
983
|
+
action = 'updateGeneric';
|
|
984
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
985
|
+
action = 'patchGeneric';
|
|
986
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
987
|
+
action = 'deleteGeneric';
|
|
988
|
+
returnF = false;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
try {
|
|
992
|
+
// Make the call -
|
|
993
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
994
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
995
|
+
// if we received an error or their is no response on the results
|
|
996
|
+
// return an error
|
|
997
|
+
if (irReturnError) {
|
|
998
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
999
|
+
return callback(null, irReturnError);
|
|
1000
|
+
}
|
|
1001
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1002
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
1003
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1004
|
+
return callback(null, errorObj);
|
|
985
1005
|
}
|
|
986
1006
|
|
|
987
|
-
|
|
988
|
-
return
|
|
1007
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1008
|
+
// return the response
|
|
1009
|
+
return callback(irReturnData, null);
|
|
989
1010
|
});
|
|
990
1011
|
} catch (ex) {
|
|
991
1012
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
@@ -2773,6 +2794,318 @@ class NokiaAltiplano extends AdapterBaseCl {
|
|
|
2773
2794
|
return callback(null, errorObj);
|
|
2774
2795
|
}
|
|
2775
2796
|
}
|
|
2797
|
+
|
|
2798
|
+
/**
|
|
2799
|
+
* @function getEntityOntView
|
|
2800
|
+
* @pronghornType method
|
|
2801
|
+
* @name getEntityOntView
|
|
2802
|
+
* @summary Get ONT Network View
|
|
2803
|
+
*
|
|
2804
|
+
* @param {string} isamVer - the ISAM Version
|
|
2805
|
+
* @param {string} shelfName - the Shelf Name
|
|
2806
|
+
* @param {string} demark - the Demark
|
|
2807
|
+
* @param {boolean} child - is this a child (default false)
|
|
2808
|
+
* @param {boolean} one - should there be only one (default true)
|
|
2809
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2810
|
+
* @return {object} results - An object containing the response of the action
|
|
2811
|
+
*
|
|
2812
|
+
* @route {POST} /getEntityOntView
|
|
2813
|
+
* @roles admin
|
|
2814
|
+
* @task true
|
|
2815
|
+
*/
|
|
2816
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2817
|
+
getEntityOntView(isamVer, shelfName, demark, child, one, callback) {
|
|
2818
|
+
const meth = 'adapter-getEntityOntView';
|
|
2819
|
+
const origin = `${this.id}-${meth}`;
|
|
2820
|
+
log.trace(origin);
|
|
2821
|
+
|
|
2822
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2823
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2824
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2825
|
+
return callback(null, errorObj);
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2829
|
+
if (isamVer === undefined || isamVer === null || isamVer === '') {
|
|
2830
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['isamVer'], null, null, null);
|
|
2831
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2832
|
+
return callback(null, errorObj);
|
|
2833
|
+
}
|
|
2834
|
+
if (shelfName === undefined || shelfName === null || shelfName === '') {
|
|
2835
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['shelfName'], null, null, null);
|
|
2836
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2837
|
+
return callback(null, errorObj);
|
|
2838
|
+
}
|
|
2839
|
+
if (demark === undefined || demark === null || demark === '') {
|
|
2840
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['demark'], null, null, null);
|
|
2841
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2842
|
+
return callback(null, errorObj);
|
|
2843
|
+
}
|
|
2844
|
+
let isChild = false;
|
|
2845
|
+
if (child !== null && child !== undefined && child === true) {
|
|
2846
|
+
isChild = true;
|
|
2847
|
+
}
|
|
2848
|
+
let isOne = true;
|
|
2849
|
+
if (one !== null && one !== undefined && one === false) {
|
|
2850
|
+
isOne = false;
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2854
|
+
const queryParamsAvailable = { isChild, isOne };
|
|
2855
|
+
const queryParams = {};
|
|
2856
|
+
const pathVars = [isamVer, shelfName, demark];
|
|
2857
|
+
const bodyVars = {};
|
|
2858
|
+
|
|
2859
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2860
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2861
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2862
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2863
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2864
|
+
}
|
|
2865
|
+
});
|
|
2866
|
+
|
|
2867
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2868
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2869
|
+
const reqObj = {
|
|
2870
|
+
payload: bodyVars,
|
|
2871
|
+
uriPathVars: pathVars,
|
|
2872
|
+
uriQuery: queryParams
|
|
2873
|
+
};
|
|
2874
|
+
|
|
2875
|
+
try {
|
|
2876
|
+
// Make the call -
|
|
2877
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2878
|
+
return this.requestHandlerInst.identifyRequest('Entity', 'getEntityOntView', reqObj, true, (irReturnData, irReturnError) => {
|
|
2879
|
+
// if we received an error or their is no response on the results
|
|
2880
|
+
// return an error
|
|
2881
|
+
if (irReturnError) {
|
|
2882
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2883
|
+
return callback(null, irReturnError);
|
|
2884
|
+
}
|
|
2885
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2886
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getEntityOntView'], null, null, null);
|
|
2887
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2888
|
+
return callback(null, errorObj);
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2892
|
+
// return the response
|
|
2893
|
+
return callback(irReturnData, null);
|
|
2894
|
+
});
|
|
2895
|
+
} catch (ex) {
|
|
2896
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2897
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2898
|
+
return callback(null, errorObj);
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
/**
|
|
2903
|
+
* @function getEntityOntPort
|
|
2904
|
+
* @pronghornType method
|
|
2905
|
+
* @name getEntityOntPort
|
|
2906
|
+
* @summary Get ONT Port
|
|
2907
|
+
*
|
|
2908
|
+
* @param {string} isamVer - the ISAM Version
|
|
2909
|
+
* @param {string} shelfName - the Shelf Name
|
|
2910
|
+
* @param {string} demark - the Demark
|
|
2911
|
+
* @param {boolean} child - is this a child (default false)
|
|
2912
|
+
* @param {boolean} one - should there be only one (default true)
|
|
2913
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2914
|
+
* @return {object} results - An object containing the response of the action
|
|
2915
|
+
*
|
|
2916
|
+
* @route {POST} /getEntityOntPort
|
|
2917
|
+
* @roles admin
|
|
2918
|
+
* @task true
|
|
2919
|
+
*/
|
|
2920
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2921
|
+
getEntityOntPort(isamVer, shelfName, demark, child, one, callback) {
|
|
2922
|
+
const meth = 'adapter-getEntityOntPort';
|
|
2923
|
+
const origin = `${this.id}-${meth}`;
|
|
2924
|
+
log.trace(origin);
|
|
2925
|
+
|
|
2926
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2927
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2928
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2929
|
+
return callback(null, errorObj);
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2933
|
+
if (isamVer === undefined || isamVer === null || isamVer === '') {
|
|
2934
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['isamVer'], null, null, null);
|
|
2935
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2936
|
+
return callback(null, errorObj);
|
|
2937
|
+
}
|
|
2938
|
+
if (shelfName === undefined || shelfName === null || shelfName === '') {
|
|
2939
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['shelfName'], null, null, null);
|
|
2940
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2941
|
+
return callback(null, errorObj);
|
|
2942
|
+
}
|
|
2943
|
+
if (demark === undefined || demark === null || demark === '') {
|
|
2944
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['demark'], null, null, null);
|
|
2945
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2946
|
+
return callback(null, errorObj);
|
|
2947
|
+
}
|
|
2948
|
+
let isChild = false;
|
|
2949
|
+
if (child !== null && child !== undefined && child === true) {
|
|
2950
|
+
isChild = true;
|
|
2951
|
+
}
|
|
2952
|
+
let isOne = true;
|
|
2953
|
+
if (one !== null && one !== undefined && one === false) {
|
|
2954
|
+
isOne = false;
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2958
|
+
const queryParamsAvailable = { isChild, isOne };
|
|
2959
|
+
const queryParams = {};
|
|
2960
|
+
const pathVars = [isamVer, shelfName, demark];
|
|
2961
|
+
const bodyVars = {};
|
|
2962
|
+
|
|
2963
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2964
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2965
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2966
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2967
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2968
|
+
}
|
|
2969
|
+
});
|
|
2970
|
+
|
|
2971
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2972
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2973
|
+
const reqObj = {
|
|
2974
|
+
payload: bodyVars,
|
|
2975
|
+
uriPathVars: pathVars,
|
|
2976
|
+
uriQuery: queryParams
|
|
2977
|
+
};
|
|
2978
|
+
|
|
2979
|
+
try {
|
|
2980
|
+
// Make the call -
|
|
2981
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2982
|
+
return this.requestHandlerInst.identifyRequest('Entity', 'getEntityOntPort', reqObj, true, (irReturnData, irReturnError) => {
|
|
2983
|
+
// if we received an error or their is no response on the results
|
|
2984
|
+
// return an error
|
|
2985
|
+
if (irReturnError) {
|
|
2986
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2987
|
+
return callback(null, irReturnError);
|
|
2988
|
+
}
|
|
2989
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2990
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getEntityOntPort'], null, null, null);
|
|
2991
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2992
|
+
return callback(null, errorObj);
|
|
2993
|
+
}
|
|
2994
|
+
|
|
2995
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2996
|
+
// return the response
|
|
2997
|
+
return callback(irReturnData, null);
|
|
2998
|
+
});
|
|
2999
|
+
} catch (ex) {
|
|
3000
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3001
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3002
|
+
return callback(null, errorObj);
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
/**
|
|
3007
|
+
* @function getEntityOntVlanAssociation
|
|
3008
|
+
* @pronghornType method
|
|
3009
|
+
* @name getEntityOntVlanAssociation
|
|
3010
|
+
* @summary Get ONT Vlan Association
|
|
3011
|
+
*
|
|
3012
|
+
* @param {string} isamVer - the ISAM Version
|
|
3013
|
+
* @param {string} shelfName - the Shelf Name
|
|
3014
|
+
* @param {string} vlanAssociation - the VLAN Association
|
|
3015
|
+
* @param {boolean} child - is this a child (default false)
|
|
3016
|
+
* @param {boolean} one - should there be only one (default true)
|
|
3017
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3018
|
+
* @return {object} results - An object containing the response of the action
|
|
3019
|
+
*
|
|
3020
|
+
* @route {POST} /getEntityOntVlanAssociation
|
|
3021
|
+
* @roles admin
|
|
3022
|
+
* @task true
|
|
3023
|
+
*/
|
|
3024
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3025
|
+
getEntityOntVlanAssociation(isamVer, shelfName, vlanAssociation, child, one, callback) {
|
|
3026
|
+
const meth = 'adapter-getEntityOntVlanAssociation';
|
|
3027
|
+
const origin = `${this.id}-${meth}`;
|
|
3028
|
+
log.trace(origin);
|
|
3029
|
+
|
|
3030
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3031
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3032
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3033
|
+
return callback(null, errorObj);
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3037
|
+
if (isamVer === undefined || isamVer === null || isamVer === '') {
|
|
3038
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['isamVer'], null, null, null);
|
|
3039
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3040
|
+
return callback(null, errorObj);
|
|
3041
|
+
}
|
|
3042
|
+
if (shelfName === undefined || shelfName === null || shelfName === '') {
|
|
3043
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['shelfName'], null, null, null);
|
|
3044
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3045
|
+
return callback(null, errorObj);
|
|
3046
|
+
}
|
|
3047
|
+
if (vlanAssociation === undefined || vlanAssociation === null || vlanAssociation === '') {
|
|
3048
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vlanAssociation'], null, null, null);
|
|
3049
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3050
|
+
return callback(null, errorObj);
|
|
3051
|
+
}
|
|
3052
|
+
let isChild = false;
|
|
3053
|
+
if (child !== null && child !== undefined && child === true) {
|
|
3054
|
+
isChild = true;
|
|
3055
|
+
}
|
|
3056
|
+
let isOne = true;
|
|
3057
|
+
if (one !== null && one !== undefined && one === false) {
|
|
3058
|
+
isOne = false;
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3062
|
+
const queryParamsAvailable = { isChild, isOne };
|
|
3063
|
+
const queryParams = {};
|
|
3064
|
+
const pathVars = [isamVer, shelfName, vlanAssociation];
|
|
3065
|
+
const bodyVars = {};
|
|
3066
|
+
|
|
3067
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3068
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3069
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3070
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3071
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3072
|
+
}
|
|
3073
|
+
});
|
|
3074
|
+
|
|
3075
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3076
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3077
|
+
const reqObj = {
|
|
3078
|
+
payload: bodyVars,
|
|
3079
|
+
uriPathVars: pathVars,
|
|
3080
|
+
uriQuery: queryParams
|
|
3081
|
+
};
|
|
3082
|
+
|
|
3083
|
+
try {
|
|
3084
|
+
// Make the call -
|
|
3085
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3086
|
+
return this.requestHandlerInst.identifyRequest('Entity', 'getEntityOntVlanAssociation', reqObj, true, (irReturnData, irReturnError) => {
|
|
3087
|
+
// if we received an error or their is no response on the results
|
|
3088
|
+
// return an error
|
|
3089
|
+
if (irReturnError) {
|
|
3090
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3091
|
+
return callback(null, irReturnError);
|
|
3092
|
+
}
|
|
3093
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3094
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getEntityOntVlanAssociation'], null, null, null);
|
|
3095
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3096
|
+
return callback(null, errorObj);
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3100
|
+
// return the response
|
|
3101
|
+
return callback(irReturnData, null);
|
|
3102
|
+
});
|
|
3103
|
+
} catch (ex) {
|
|
3104
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3105
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3106
|
+
return callback(null, errorObj);
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
2776
3109
|
}
|
|
2777
3110
|
|
|
2778
3111
|
module.exports = NokiaAltiplano;
|