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