@itentialopensource/adapter-netbrain 1.0.3 → 1.1.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/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +48 -28
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +225 -511
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +349 -57
- package/adapterBase.js +1021 -245
- package/entities/.generic/action.json +110 -5
- package/entities/.generic/schema.json +6 -1
- package/error.json +12 -0
- package/package.json +18 -11
- package/pronghorn.json +642 -378
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +436 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653178689558.json +120 -0
- package/sampleProperties.json +94 -2
- package/test/integration/adapterTestBasicGet.js +1 -1
- package/test/integration/adapterTestIntegration.js +28 -104
- package/test/unit/adapterBaseTestUnit.js +34 -26
- package/test/unit/adapterTestUnit.js +640 -114
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/basicGet.js +1 -14
- package/utils/entitiesToDB.js +179 -0
- package/utils/modify.js +1 -1
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +3 -0
- package/utils/removeHooks.js +20 -0
- package/utils/tbScript.js +43 -22
- package/utils/tbUtils.js +126 -29
- package/utils/testRunner.js +16 -16
- package/utils/troubleshootingAdapter.js +2 -26
package/SUMMARY.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
This adapter is used to integrate the Itential Automation Platform (IAP) with the Netbrain System. The API that was used to build the adapter for Netbrain is usually available in the report directory of this adapter. The adapter utilizes the Netbrain API to provide the integrations that are deemed pertinent to IAP. The ReadMe file is intended to provide information on this adapter it is generated from various other Markdown files.
|
|
4
|
+
|
|
5
|
+
>**Note**: It is possible that some integrations will be supported through the Netbrain adapter while other integrations will not. If you need additional API calls, you can use the Update capabilities provided by the Adapter Builder or request Itential to add them if the Adapter is an Itential opensourced adapter.
|
|
6
|
+
|
|
7
|
+
Itential provides information on all of its product adapters in the Customer Knowledge Base. Information in the <a href="https://itential.atlassian.net/servicedesk/customer/portals" target="_blank">Customer Knowledge Base</a> is consistently maintained and goes through documentation reviews. As a result, it should be the first place to go for information.
|
|
8
|
+
|
|
9
|
+
For opensourced and custom built adapters, the ReadMe is a starting point to understand what you have built, provide the information for you to be able to update the adapter, and assist you with deploying the adapter into IAP.
|
package/SYSTEMINFO.md
ADDED
package/TROUBLESHOOT.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
## Troubleshoot
|
|
2
|
+
|
|
3
|
+
Run `npm run troubleshoot` to start the interactive troubleshooting process. The command allows you to verify and update connection, authentication as well as healthcheck configuration. After that it will test these properties by sending HTTP request to the endpoint. If the tests pass, it will persist these changes into IAP.
|
|
4
|
+
|
|
5
|
+
You also have the option to run individual commands to perform specific test:
|
|
6
|
+
|
|
7
|
+
- `npm run healthcheck` will perform a healthcheck request of with current setting.
|
|
8
|
+
- `npm run basicget` will perform some non-parameter GET request with current setting.
|
|
9
|
+
- `npm run connectivity` will perform networking diagnostics of the adatper endpoint.
|
|
10
|
+
|
|
11
|
+
### Connectivity Issues
|
|
12
|
+
|
|
13
|
+
1. You can run the adapter troubleshooting script which will check connectivity, run the healthcheck and run basic get calls.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run troubleshoot
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Verify the adapter properties are set up correctly.
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
3. Verify there is connectivity between the Itential Platform Server and Netbrain Server.
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
ping the ip address of Netbrain server
|
|
29
|
+
try telnet to the ip address port of Netbrain
|
|
30
|
+
execute a curl command to the other system
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
4. Verify the credentials provided for Netbrain.
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
login to Netbrain using the provided credentials
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
5. Verify the API of the call utilized for Netbrain Healthcheck.
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Functional Issues
|
|
46
|
+
|
|
47
|
+
Adapter logs are located in `/var/log/pronghorn`. In older releases of the Itential Platform, there is a `pronghorn.log` file which contains logs for all of the Itential Platform. In newer versions, adapters can be configured to log into their own files.
|
package/adapter.js
CHANGED
|
@@ -82,10 +82,19 @@ class Netbrain extends AdapterBaseCl {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* @
|
|
85
|
+
* @iapGetAdapterWorkflowFunctions
|
|
86
86
|
*/
|
|
87
|
-
|
|
88
|
-
let myIgnore = [
|
|
87
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
88
|
+
let myIgnore = [
|
|
89
|
+
'healthCheck',
|
|
90
|
+
'iapGetAdapterWorkflowFunctions',
|
|
91
|
+
'iapHasAdapterEntity',
|
|
92
|
+
'iapVerifyAdapterCapability',
|
|
93
|
+
'iapUpdateAdapterEntityCache',
|
|
94
|
+
'hasEntities',
|
|
95
|
+
'getAuthorization',
|
|
96
|
+
'processRequest'
|
|
97
|
+
];
|
|
89
98
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
90
99
|
myIgnore = inIgnore;
|
|
91
100
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -96,15 +105,15 @@ class Netbrain extends AdapterBaseCl {
|
|
|
96
105
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
97
106
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
98
107
|
|
|
99
|
-
return super.
|
|
108
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
100
109
|
}
|
|
101
110
|
|
|
102
111
|
/**
|
|
103
|
-
*
|
|
112
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
104
113
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
105
114
|
* file system.
|
|
106
115
|
*
|
|
107
|
-
* @function
|
|
116
|
+
* @function iapUpdateAdapterConfiguration
|
|
108
117
|
* @param {string} configFile - the name of the file being updated (required)
|
|
109
118
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
110
119
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
@@ -112,36 +121,42 @@ class Netbrain extends AdapterBaseCl {
|
|
|
112
121
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
113
122
|
* @param {Callback} callback - The results of the call
|
|
114
123
|
*/
|
|
115
|
-
|
|
116
|
-
const
|
|
124
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
125
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
126
|
+
const origin = `${this.id}-${meth}`;
|
|
117
127
|
log.trace(origin);
|
|
118
|
-
|
|
128
|
+
|
|
129
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
/**
|
|
122
133
|
* See if the API path provided is found in this adapter
|
|
123
134
|
*
|
|
124
|
-
* @function
|
|
135
|
+
* @function iapFindAdapterPath
|
|
125
136
|
* @param {string} apiPath - the api path to check on
|
|
126
137
|
* @param {Callback} callback - The results of the call
|
|
127
138
|
*/
|
|
128
|
-
|
|
129
|
-
const
|
|
139
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
140
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
141
|
+
const origin = `${this.id}-${meth}`;
|
|
130
142
|
log.trace(origin);
|
|
131
|
-
|
|
143
|
+
|
|
144
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
132
145
|
}
|
|
133
146
|
|
|
134
147
|
/**
|
|
135
148
|
* @summary Suspends adapter
|
|
136
149
|
*
|
|
137
|
-
* @function
|
|
150
|
+
* @function iapSuspendAdapter
|
|
138
151
|
* @param {Callback} callback - callback function
|
|
139
152
|
*/
|
|
140
|
-
|
|
141
|
-
const
|
|
153
|
+
iapSuspendAdapter(mode, callback) {
|
|
154
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
155
|
+
const origin = `${this.id}-${meth}`;
|
|
142
156
|
log.trace(origin);
|
|
157
|
+
|
|
143
158
|
try {
|
|
144
|
-
return super.
|
|
159
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
145
160
|
} catch (error) {
|
|
146
161
|
log.error(`${origin}: ${error}`);
|
|
147
162
|
return callback(null, error);
|
|
@@ -151,14 +166,16 @@ class Netbrain extends AdapterBaseCl {
|
|
|
151
166
|
/**
|
|
152
167
|
* @summary Unsuspends adapter
|
|
153
168
|
*
|
|
154
|
-
* @function
|
|
169
|
+
* @function iapUnsuspendAdapter
|
|
155
170
|
* @param {Callback} callback - callback function
|
|
156
171
|
*/
|
|
157
|
-
|
|
158
|
-
const
|
|
172
|
+
iapUnsuspendAdapter(callback) {
|
|
173
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
174
|
+
const origin = `${this.id}-${meth}`;
|
|
159
175
|
log.trace(origin);
|
|
176
|
+
|
|
160
177
|
try {
|
|
161
|
-
return super.
|
|
178
|
+
return super.iapUnsuspendAdapter(callback);
|
|
162
179
|
} catch (error) {
|
|
163
180
|
log.error(`${origin}: ${error}`);
|
|
164
181
|
return callback(null, error);
|
|
@@ -168,29 +185,33 @@ class Netbrain extends AdapterBaseCl {
|
|
|
168
185
|
/**
|
|
169
186
|
* @summary Get the Adaoter Queue
|
|
170
187
|
*
|
|
171
|
-
* @function
|
|
188
|
+
* @function iapGetAdapterQueue
|
|
172
189
|
* @param {Callback} callback - callback function
|
|
173
190
|
*/
|
|
174
|
-
|
|
175
|
-
const
|
|
191
|
+
iapGetAdapterQueue(callback) {
|
|
192
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
193
|
+
const origin = `${this.id}-${meth}`;
|
|
176
194
|
log.trace(origin);
|
|
177
|
-
|
|
195
|
+
|
|
196
|
+
return super.iapGetAdapterQueue(callback);
|
|
178
197
|
}
|
|
179
198
|
|
|
180
199
|
/**
|
|
181
200
|
* @summary Runs troubleshoot scripts for adapter
|
|
182
201
|
*
|
|
183
|
-
* @function
|
|
202
|
+
* @function iapTroubleshootAdapter
|
|
184
203
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
185
204
|
*
|
|
186
205
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
187
206
|
* @param {Callback} callback - The results of the call
|
|
188
207
|
*/
|
|
189
|
-
|
|
190
|
-
const
|
|
208
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
209
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
210
|
+
const origin = `${this.id}-${meth}`;
|
|
191
211
|
log.trace(origin);
|
|
212
|
+
|
|
192
213
|
try {
|
|
193
|
-
return super.
|
|
214
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
194
215
|
} catch (error) {
|
|
195
216
|
log.error(`${origin}: ${error}`);
|
|
196
217
|
return callback(null, error);
|
|
@@ -200,15 +221,17 @@ class Netbrain extends AdapterBaseCl {
|
|
|
200
221
|
/**
|
|
201
222
|
* @summary runs healthcheck script for adapter
|
|
202
223
|
*
|
|
203
|
-
* @function
|
|
224
|
+
* @function iapRunAdapterHealthcheck
|
|
204
225
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
205
226
|
* @param {Callback} callback - callback function
|
|
206
227
|
*/
|
|
207
|
-
|
|
208
|
-
const
|
|
228
|
+
iapRunAdapterHealthcheck(callback) {
|
|
229
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
230
|
+
const origin = `${this.id}-${meth}`;
|
|
209
231
|
log.trace(origin);
|
|
232
|
+
|
|
210
233
|
try {
|
|
211
|
-
return super.
|
|
234
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
212
235
|
} catch (error) {
|
|
213
236
|
log.error(`${origin}: ${error}`);
|
|
214
237
|
return callback(null, error);
|
|
@@ -218,14 +241,16 @@ class Netbrain extends AdapterBaseCl {
|
|
|
218
241
|
/**
|
|
219
242
|
* @summary runs connectivity check script for adapter
|
|
220
243
|
*
|
|
221
|
-
* @function
|
|
244
|
+
* @function iapRunAdapterConnectivity
|
|
222
245
|
* @param {Callback} callback - callback function
|
|
223
246
|
*/
|
|
224
|
-
|
|
225
|
-
const
|
|
247
|
+
iapRunAdapterConnectivity(callback) {
|
|
248
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
249
|
+
const origin = `${this.id}-${meth}`;
|
|
226
250
|
log.trace(origin);
|
|
251
|
+
|
|
227
252
|
try {
|
|
228
|
-
return super.
|
|
253
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
229
254
|
} catch (error) {
|
|
230
255
|
log.error(`${origin}: ${error}`);
|
|
231
256
|
return callback(null, error);
|
|
@@ -235,44 +260,67 @@ class Netbrain extends AdapterBaseCl {
|
|
|
235
260
|
/**
|
|
236
261
|
* @summary runs basicGet script for adapter
|
|
237
262
|
*
|
|
238
|
-
* @function
|
|
263
|
+
* @function iapRunAdapterBasicGet
|
|
239
264
|
* @param {Callback} callback - callback function
|
|
240
265
|
*/
|
|
241
|
-
|
|
242
|
-
const
|
|
266
|
+
iapRunAdapterBasicGet(callback) {
|
|
267
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
268
|
+
const origin = `${this.id}-${meth}`;
|
|
243
269
|
log.trace(origin);
|
|
270
|
+
|
|
244
271
|
try {
|
|
245
|
-
return super.
|
|
272
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
246
273
|
} catch (error) {
|
|
247
274
|
log.error(`${origin}: ${error}`);
|
|
248
275
|
return callback(null, error);
|
|
249
276
|
}
|
|
250
277
|
}
|
|
251
278
|
|
|
279
|
+
/**
|
|
280
|
+
* @summary moves entites into Mongo DB
|
|
281
|
+
*
|
|
282
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
283
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
284
|
+
* or the error
|
|
285
|
+
*/
|
|
286
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
287
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
288
|
+
const origin = `${this.id}-${meth}`;
|
|
289
|
+
log.trace(origin);
|
|
290
|
+
|
|
291
|
+
try {
|
|
292
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
293
|
+
} catch (err) {
|
|
294
|
+
log.error(`${origin}: ${err}`);
|
|
295
|
+
return callback(null, err);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/* BROKER CALLS */
|
|
252
300
|
/**
|
|
253
301
|
* @summary Determines if this adapter supports the specific entity
|
|
254
302
|
*
|
|
255
|
-
* @function
|
|
303
|
+
* @function iapHasAdapterEntity
|
|
256
304
|
* @param {String} entityType - the entity type to check for
|
|
257
305
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
258
306
|
*
|
|
259
307
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
260
308
|
* desired capability or an error
|
|
261
309
|
*/
|
|
262
|
-
|
|
263
|
-
const origin = `${this.id}-adapter-
|
|
310
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
311
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
264
312
|
log.trace(origin);
|
|
265
313
|
|
|
266
314
|
// Make the call -
|
|
267
|
-
//
|
|
268
|
-
return this.
|
|
315
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
316
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
269
317
|
}
|
|
270
318
|
|
|
271
319
|
/**
|
|
272
320
|
* @summary Provides a way for the adapter to tell north bound integrations
|
|
273
321
|
* whether the adapter supports type, action and specific entity
|
|
274
322
|
*
|
|
275
|
-
* @function
|
|
323
|
+
* @function iapVerifyAdapterCapability
|
|
276
324
|
* @param {String} entityType - the entity type to check for
|
|
277
325
|
* @param {String} actionType - the action type to check for
|
|
278
326
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
@@ -280,15 +328,15 @@ class Netbrain extends AdapterBaseCl {
|
|
|
280
328
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
281
329
|
* desired capability or an error
|
|
282
330
|
*/
|
|
283
|
-
|
|
284
|
-
const meth = 'adapterBase-
|
|
331
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
332
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
|
285
333
|
const origin = `${this.id}-${meth}`;
|
|
286
334
|
log.trace(origin);
|
|
287
335
|
|
|
288
336
|
// if caching
|
|
289
337
|
if (this.caching) {
|
|
290
|
-
// Make the call -
|
|
291
|
-
return this.requestHandlerInst.
|
|
338
|
+
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
339
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
|
292
340
|
if (error) {
|
|
293
341
|
return callback(null, error);
|
|
294
342
|
}
|
|
@@ -306,7 +354,7 @@ class Netbrain extends AdapterBaseCl {
|
|
|
306
354
|
}
|
|
307
355
|
|
|
308
356
|
// need to check the cache again since it has been updated
|
|
309
|
-
return this.requestHandlerInst.
|
|
357
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
310
358
|
if (verror) {
|
|
311
359
|
return callback(null, verror);
|
|
312
360
|
}
|
|
@@ -339,7 +387,7 @@ class Netbrain extends AdapterBaseCl {
|
|
|
339
387
|
// if no entity id
|
|
340
388
|
if (!entityId) {
|
|
341
389
|
// need to check the cache again since it has been updated
|
|
342
|
-
return this.requestHandlerInst.
|
|
390
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
343
391
|
if (verror) {
|
|
344
392
|
return callback(null, verror);
|
|
345
393
|
}
|
|
@@ -360,7 +408,7 @@ class Netbrain extends AdapterBaseCl {
|
|
|
360
408
|
}
|
|
361
409
|
|
|
362
410
|
// need to check the cache again since it has been updated
|
|
363
|
-
return this.requestHandlerInst.
|
|
411
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
364
412
|
if (verror) {
|
|
365
413
|
return callback(null, verror);
|
|
366
414
|
}
|
|
@@ -401,11 +449,11 @@ class Netbrain extends AdapterBaseCl {
|
|
|
401
449
|
/**
|
|
402
450
|
* @summary Updates the cache for all entities by call the get All entity method
|
|
403
451
|
*
|
|
404
|
-
* @function
|
|
452
|
+
* @function iapUpdateAdapterEntityCache
|
|
405
453
|
*
|
|
406
454
|
*/
|
|
407
|
-
|
|
408
|
-
const origin = `${this.id}-adapter-
|
|
455
|
+
iapUpdateAdapterEntityCache() {
|
|
456
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
|
409
457
|
log.trace(origin);
|
|
410
458
|
|
|
411
459
|
if (this.caching) {
|
|
@@ -418,6 +466,140 @@ class Netbrain extends AdapterBaseCl {
|
|
|
418
466
|
}
|
|
419
467
|
}
|
|
420
468
|
|
|
469
|
+
/**
|
|
470
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
471
|
+
*
|
|
472
|
+
* @function hasEntities
|
|
473
|
+
* @param {String} entityType - the entity type to check for
|
|
474
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
475
|
+
*
|
|
476
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
477
|
+
* value is true or false
|
|
478
|
+
*/
|
|
479
|
+
hasEntities(entityType, entityList, callback) {
|
|
480
|
+
const meth = 'adapter-hasEntities';
|
|
481
|
+
const origin = `${this.id}-${meth}`;
|
|
482
|
+
log.trace(origin);
|
|
483
|
+
|
|
484
|
+
try {
|
|
485
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
486
|
+
} catch (err) {
|
|
487
|
+
log.error(`${origin}: ${err}`);
|
|
488
|
+
return callback(null, err);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @summary Get Appliance that match the deviceName
|
|
494
|
+
*
|
|
495
|
+
* @function getDevice
|
|
496
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
497
|
+
*
|
|
498
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
499
|
+
* (appliance) or the error
|
|
500
|
+
*/
|
|
501
|
+
getDevice(deviceName, callback) {
|
|
502
|
+
const meth = 'adapter-getDevice';
|
|
503
|
+
const origin = `${this.id}-${meth}`;
|
|
504
|
+
log.trace(origin);
|
|
505
|
+
|
|
506
|
+
try {
|
|
507
|
+
return super.getDevice(deviceName, callback);
|
|
508
|
+
} catch (err) {
|
|
509
|
+
log.error(`${origin}: ${err}`);
|
|
510
|
+
return callback(null, err);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* @summary Get Appliances that match the filter
|
|
516
|
+
*
|
|
517
|
+
* @function getDevicesFiltered
|
|
518
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
519
|
+
*
|
|
520
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
521
|
+
* (appliances) or the error
|
|
522
|
+
*/
|
|
523
|
+
getDevicesFiltered(options, callback) {
|
|
524
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
525
|
+
const origin = `${this.id}-${meth}`;
|
|
526
|
+
log.trace(origin);
|
|
527
|
+
|
|
528
|
+
try {
|
|
529
|
+
return super.getDevicesFiltered(options, callback);
|
|
530
|
+
} catch (err) {
|
|
531
|
+
log.error(`${origin}: ${err}`);
|
|
532
|
+
return callback(null, err);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* @summary Gets the status for the provided appliance
|
|
538
|
+
*
|
|
539
|
+
* @function isAlive
|
|
540
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
541
|
+
*
|
|
542
|
+
* @param {configCallback} callback - callback function to return the result
|
|
543
|
+
* (appliance isAlive) or the error
|
|
544
|
+
*/
|
|
545
|
+
isAlive(deviceName, callback) {
|
|
546
|
+
const meth = 'adapter-isAlive';
|
|
547
|
+
const origin = `${this.id}-${meth}`;
|
|
548
|
+
log.trace(origin);
|
|
549
|
+
|
|
550
|
+
try {
|
|
551
|
+
return super.isAlive(deviceName, callback);
|
|
552
|
+
} catch (err) {
|
|
553
|
+
log.error(`${origin}: ${err}`);
|
|
554
|
+
return callback(null, err);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* @summary Gets a config for the provided Appliance
|
|
560
|
+
*
|
|
561
|
+
* @function getConfig
|
|
562
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
563
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
564
|
+
*
|
|
565
|
+
* @param {configCallback} callback - callback function to return the result
|
|
566
|
+
* (appliance config) or the error
|
|
567
|
+
*/
|
|
568
|
+
getConfig(deviceName, format, callback) {
|
|
569
|
+
const meth = 'adapter-getConfig';
|
|
570
|
+
const origin = `${this.id}-${meth}`;
|
|
571
|
+
log.trace(origin);
|
|
572
|
+
|
|
573
|
+
try {
|
|
574
|
+
return super.getConfig(deviceName, format, callback);
|
|
575
|
+
} catch (err) {
|
|
576
|
+
log.error(`${origin}: ${err}`);
|
|
577
|
+
return callback(null, err);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* @summary Gets the device count from the system
|
|
583
|
+
*
|
|
584
|
+
* @function iapGetDeviceCount
|
|
585
|
+
*
|
|
586
|
+
* @param {getCallback} callback - callback function to return the result
|
|
587
|
+
* (count) or the error
|
|
588
|
+
*/
|
|
589
|
+
iapGetDeviceCount(callback) {
|
|
590
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
591
|
+
const origin = `${this.id}-${meth}`;
|
|
592
|
+
log.trace(origin);
|
|
593
|
+
|
|
594
|
+
try {
|
|
595
|
+
return super.iapGetDeviceCount(callback);
|
|
596
|
+
} catch (err) {
|
|
597
|
+
log.error(`${origin}: ${err}`);
|
|
598
|
+
return callback(null, err);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
421
603
|
/**
|
|
422
604
|
* Makes the requested generic call
|
|
423
605
|
*
|
|
@@ -528,6 +710,116 @@ class Netbrain extends AdapterBaseCl {
|
|
|
528
710
|
}
|
|
529
711
|
}
|
|
530
712
|
|
|
713
|
+
/**
|
|
714
|
+
* Makes the requested generic call with no base path or version
|
|
715
|
+
*
|
|
716
|
+
* @function genericAdapterRequestNoBasePath
|
|
717
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
718
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
719
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
720
|
+
* Can be a stringified Object.
|
|
721
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
722
|
+
* Can be a stringified Object.
|
|
723
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
724
|
+
* Can be a stringified Object.
|
|
725
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
726
|
+
* or the error
|
|
727
|
+
*/
|
|
728
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
729
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
730
|
+
const origin = `${this.id}-${meth}`;
|
|
731
|
+
log.trace(origin);
|
|
732
|
+
|
|
733
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
734
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
735
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
736
|
+
return callback(null, errorObj);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
740
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
741
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
742
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
743
|
+
return callback(null, errorObj);
|
|
744
|
+
}
|
|
745
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
746
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
747
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
748
|
+
return callback(null, errorObj);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
752
|
+
// remove any leading / and split the uripath into path variables
|
|
753
|
+
let myPath = uriPath;
|
|
754
|
+
while (myPath.indexOf('/') === 0) {
|
|
755
|
+
myPath = myPath.substring(1);
|
|
756
|
+
}
|
|
757
|
+
const pathVars = myPath.split('/');
|
|
758
|
+
const queryParamsAvailable = queryData;
|
|
759
|
+
const queryParams = {};
|
|
760
|
+
const bodyVars = requestBody;
|
|
761
|
+
|
|
762
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
763
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
764
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
765
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
766
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
771
|
+
const reqObj = {
|
|
772
|
+
payload: bodyVars,
|
|
773
|
+
uriPathVars: pathVars,
|
|
774
|
+
uriQuery: queryParams,
|
|
775
|
+
uriOptions: {}
|
|
776
|
+
};
|
|
777
|
+
// add headers if provided
|
|
778
|
+
if (addlHeaders) {
|
|
779
|
+
reqObj.addlHeaders = addlHeaders;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// determine the call and return flag
|
|
783
|
+
let action = 'getGenericsNoBase';
|
|
784
|
+
let returnF = true;
|
|
785
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
786
|
+
action = 'createGenericNoBase';
|
|
787
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
788
|
+
action = 'updateGenericNoBase';
|
|
789
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
790
|
+
action = 'patchGenericNoBase';
|
|
791
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
792
|
+
action = 'deleteGenericNoBase';
|
|
793
|
+
returnF = false;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
try {
|
|
797
|
+
// Make the call -
|
|
798
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
799
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
800
|
+
// if we received an error or their is no response on the results
|
|
801
|
+
// return an error
|
|
802
|
+
if (irReturnError) {
|
|
803
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
804
|
+
return callback(null, irReturnError);
|
|
805
|
+
}
|
|
806
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
807
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
|
808
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
809
|
+
return callback(null, errorObj);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
813
|
+
// return the response
|
|
814
|
+
return callback(irReturnData, null);
|
|
815
|
+
});
|
|
816
|
+
} catch (ex) {
|
|
817
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
818
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
819
|
+
return callback(null, errorObj);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
531
823
|
/**
|
|
532
824
|
* @callback healthCallback
|
|
533
825
|
* @param {Object} result - the result of the get request (contains an id and a status)
|