@itentialopensource/adapter-apic 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -0
- package/.eslintrc.js +12 -12
- package/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +46 -20
- 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 +244 -392
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +691 -42
- package/adapterBase.js +1331 -50
- package/entities/.generic/action.json +214 -0
- package/entities/.generic/schema.json +28 -0
- package/error.json +12 -0
- package/package.json +47 -23
- package/pronghorn.json +677 -28
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +505 -11
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1593819602461.json +95 -0
- package/report/updateReport1614354810622.json +95 -0
- package/report/updateReport1653418391508.json +120 -0
- package/sampleProperties.json +111 -7
- package/test/integration/adapterTestBasicGet.js +85 -0
- package/test/integration/adapterTestConnectivity.js +93 -0
- package/test/integration/adapterTestIntegration.js +40 -103
- package/test/unit/adapterBaseTestUnit.js +949 -0
- package/test/unit/adapterTestUnit.js +653 -114
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +9 -14
- package/utils/basicGet.js +50 -0
- package/utils/checkMigrate.js +63 -0
- package/utils/entitiesToDB.js +179 -0
- package/utils/findPath.js +74 -0
- package/utils/modify.js +154 -0
- package/utils/packModificationScript.js +1 -1
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +4 -1
- package/utils/removeHooks.js +20 -0
- package/utils/tbScript.js +184 -0
- package/utils/tbUtils.js +469 -0
- package/utils/testRunner.js +16 -16
- package/utils/troubleshootingAdapter.js +190 -0
- package/gl-code-quality-report.json +0 -1
package/adapter.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/* @copyright Itential, LLC 2018 */
|
|
2
2
|
|
|
3
|
+
/* eslint import/no-dynamic-require: warn */
|
|
4
|
+
/* eslint object-curly-newline: warn */
|
|
5
|
+
|
|
3
6
|
// Set globals
|
|
4
7
|
/* global log */
|
|
5
|
-
/* eslint import/no-dynamic-require: warn */
|
|
6
8
|
|
|
7
9
|
/* Required libraries. */
|
|
8
10
|
const path = require('path');
|
|
9
|
-
// const xmldom = require('xmldom');
|
|
10
11
|
|
|
11
12
|
/* Fetch in the other needed components for the this Adaptor */
|
|
12
13
|
const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
|
|
13
14
|
|
|
14
|
-
|
|
15
15
|
/**
|
|
16
16
|
* This is the adapter/interface into Apic
|
|
17
17
|
*/
|
|
@@ -19,71 +19,305 @@ const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
|
|
|
19
19
|
/* GENERAL ADAPTER FUNCTIONS */
|
|
20
20
|
class Apic extends AdapterBaseCl {
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Apic Adapter
|
|
23
23
|
* @constructor
|
|
24
|
+
*/
|
|
25
|
+
/* Working on changing the way we do Emit methods due to size and time constrainsts
|
|
24
26
|
constructor(prongid, properties) {
|
|
25
27
|
// Instantiate the AdapterBase super class
|
|
26
28
|
super(prongid, properties);
|
|
27
29
|
|
|
30
|
+
const restFunctionNames = this.getWorkflowFunctions();
|
|
31
|
+
|
|
32
|
+
// Dynamically bind emit functions
|
|
33
|
+
for (let i = 0; i < restFunctionNames.length; i += 1) {
|
|
34
|
+
// Bind function to have name fnNameEmit for fnName
|
|
35
|
+
const version = restFunctionNames[i].match(/__v[0-9]+/);
|
|
36
|
+
const baseFnName = restFunctionNames[i].replace(/__v[0-9]+/, '');
|
|
37
|
+
const fnNameEmit = version ? `${baseFnName}Emit${version}` : `${baseFnName}Emit`;
|
|
38
|
+
this[fnNameEmit] = function (...args) {
|
|
39
|
+
// extract the callback
|
|
40
|
+
const callback = args[args.length - 1];
|
|
41
|
+
// slice the callback from args so we can insert our own
|
|
42
|
+
const functionArgs = args.slice(0, args.length - 1);
|
|
43
|
+
// create a random name for the listener
|
|
44
|
+
const eventName = `${restFunctionNames[i]}:${Math.random().toString(36)}`;
|
|
45
|
+
// tell the calling class to start listening
|
|
46
|
+
callback({ event: eventName, status: 'received' });
|
|
47
|
+
// store parent for use of this context later
|
|
48
|
+
const parent = this;
|
|
49
|
+
// store emission function
|
|
50
|
+
const func = function (val, err) {
|
|
51
|
+
parent.removeListener(eventName, func);
|
|
52
|
+
parent.emit(eventName, val, err);
|
|
53
|
+
};
|
|
54
|
+
// Use apply to call the function in a specific context
|
|
55
|
+
this[restFunctionNames[i]].apply(this, functionArgs.concat([func])); // eslint-disable-line prefer-spread
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
28
59
|
// Uncomment if you have things to add to the constructor like using your own properties.
|
|
29
60
|
// Otherwise the constructor in the adapterBase will be used.
|
|
30
61
|
// Capture my own properties - they need to be defined in propertiesSchema.json
|
|
31
|
-
if (this.allProps && this.allProps.myownproperty) {
|
|
32
|
-
|
|
33
|
-
}
|
|
62
|
+
// if (this.allProps && this.allProps.myownproperty) {
|
|
63
|
+
// mypropvariable = this.allProps.myownproperty;
|
|
64
|
+
// }
|
|
34
65
|
}
|
|
35
66
|
*/
|
|
36
67
|
|
|
37
|
-
|
|
38
68
|
/**
|
|
39
69
|
* @callback healthCallback
|
|
40
|
-
* @param {Object}
|
|
70
|
+
* @param {Object} reqObj - the request to send into the healthcheck
|
|
71
|
+
* @param {Callback} callback - The results of the call
|
|
41
72
|
*/
|
|
73
|
+
healthCheck(reqObj, callback) {
|
|
74
|
+
// you can modify what is passed into the healthcheck by changing things in the newReq
|
|
75
|
+
let newReq = null;
|
|
76
|
+
if (reqObj) {
|
|
77
|
+
newReq = Object.assign(...reqObj);
|
|
78
|
+
}
|
|
79
|
+
super.healthCheck(newReq, callback);
|
|
80
|
+
}
|
|
81
|
+
|
|
42
82
|
/**
|
|
43
|
-
* @
|
|
44
|
-
* @param {Object} result - the result of the get request (entity/ies)
|
|
45
|
-
* @param {String} error - any error that occurred
|
|
83
|
+
* @iapGetAdapterWorkflowFunctions
|
|
46
84
|
*/
|
|
85
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
86
|
+
let myIgnore = [
|
|
87
|
+
'healthCheck',
|
|
88
|
+
'iapGetAdapterWorkflowFunctions',
|
|
89
|
+
'iapHasAdapterEntity',
|
|
90
|
+
'iapVerifyAdapterCapability',
|
|
91
|
+
'iapUpdateAdapterEntityCache',
|
|
92
|
+
'hasEntities',
|
|
93
|
+
'getAuthorization'
|
|
94
|
+
];
|
|
95
|
+
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
96
|
+
myIgnore = inIgnore;
|
|
97
|
+
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
98
|
+
myIgnore = [inIgnore];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// The generic adapter functions should already be ignored (e.g. healthCheck)
|
|
102
|
+
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
103
|
+
// myIgnore.push('myMethodNotInWorkflow');
|
|
104
|
+
|
|
105
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
106
|
+
}
|
|
107
|
+
|
|
47
108
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
109
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
110
|
+
* allows customers to make changes to adapter configuration without having to be on the
|
|
111
|
+
* file system.
|
|
112
|
+
*
|
|
113
|
+
* @function iapUpdateAdapterConfiguration
|
|
114
|
+
* @param {string} configFile - the name of the file being updated (required)
|
|
115
|
+
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
116
|
+
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
117
|
+
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
118
|
+
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
119
|
+
* @param {Callback} callback - The results of the call
|
|
51
120
|
*/
|
|
121
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
122
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
123
|
+
const origin = `${this.id}-${meth}`;
|
|
124
|
+
log.trace(origin);
|
|
125
|
+
|
|
126
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
127
|
+
}
|
|
128
|
+
|
|
52
129
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @
|
|
130
|
+
* See if the API path provided is found in this adapter
|
|
131
|
+
*
|
|
132
|
+
* @function iapFindAdapterPath
|
|
133
|
+
* @param {string} apiPath - the api path to check on
|
|
134
|
+
* @param {Callback} callback - The results of the call
|
|
56
135
|
*/
|
|
136
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
137
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
138
|
+
const origin = `${this.id}-${meth}`;
|
|
139
|
+
log.trace(origin);
|
|
140
|
+
|
|
141
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
142
|
+
}
|
|
143
|
+
|
|
57
144
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
145
|
+
* @summary Suspends adapter
|
|
146
|
+
*
|
|
147
|
+
* @function iapSuspendAdapter
|
|
148
|
+
* @param {Callback} callback - callback function
|
|
149
|
+
*/
|
|
150
|
+
iapSuspendAdapter(mode, callback) {
|
|
151
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
152
|
+
const origin = `${this.id}-${meth}`;
|
|
153
|
+
log.trace(origin);
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
log.error(`${origin}: ${error}`);
|
|
159
|
+
return callback(null, error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @summary Unsuspends adapter
|
|
165
|
+
*
|
|
166
|
+
* @function iapUnsuspendAdapter
|
|
167
|
+
* @param {Callback} callback - callback function
|
|
168
|
+
*/
|
|
169
|
+
iapUnsuspendAdapter(callback) {
|
|
170
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
171
|
+
const origin = `${this.id}-${meth}`;
|
|
172
|
+
log.trace(origin);
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
return super.iapUnsuspendAdapter(callback);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
log.error(`${origin}: ${error}`);
|
|
178
|
+
return callback(null, error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @summary Get the Adaoter Queue
|
|
184
|
+
*
|
|
185
|
+
* @function iapGetAdapterQueue
|
|
186
|
+
* @param {Callback} callback - callback function
|
|
187
|
+
*/
|
|
188
|
+
iapGetAdapterQueue(callback) {
|
|
189
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
190
|
+
const origin = `${this.id}-${meth}`;
|
|
191
|
+
log.trace(origin);
|
|
192
|
+
|
|
193
|
+
return super.iapGetAdapterQueue(callback);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @summary Runs troubleshoot scripts for adapter
|
|
198
|
+
*
|
|
199
|
+
* @function iapTroubleshootAdapter
|
|
200
|
+
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
201
|
+
*
|
|
202
|
+
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
203
|
+
* @param {Callback} callback - The results of the call
|
|
204
|
+
*/
|
|
205
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
206
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
207
|
+
const origin = `${this.id}-${meth}`;
|
|
208
|
+
log.trace(origin);
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
log.error(`${origin}: ${error}`);
|
|
214
|
+
return callback(null, error);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @summary runs healthcheck script for adapter
|
|
220
|
+
*
|
|
221
|
+
* @function iapRunAdapterHealthcheck
|
|
222
|
+
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
223
|
+
* @param {Callback} callback - callback function
|
|
224
|
+
*/
|
|
225
|
+
iapRunAdapterHealthcheck(callback) {
|
|
226
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
227
|
+
const origin = `${this.id}-${meth}`;
|
|
228
|
+
log.trace(origin);
|
|
229
|
+
|
|
230
|
+
try {
|
|
231
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
log.error(`${origin}: ${error}`);
|
|
234
|
+
return callback(null, error);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @summary runs connectivity check script for adapter
|
|
240
|
+
*
|
|
241
|
+
* @function iapRunAdapterConnectivity
|
|
242
|
+
* @param {Callback} callback - callback function
|
|
243
|
+
*/
|
|
244
|
+
iapRunAdapterConnectivity(callback) {
|
|
245
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
246
|
+
const origin = `${this.id}-${meth}`;
|
|
247
|
+
log.trace(origin);
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
log.error(`${origin}: ${error}`);
|
|
253
|
+
return callback(null, error);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @summary runs basicGet script for adapter
|
|
259
|
+
*
|
|
260
|
+
* @function iapRunAdapterBasicGet
|
|
261
|
+
* @param {Callback} callback - callback function
|
|
262
|
+
*/
|
|
263
|
+
iapRunAdapterBasicGet(callback) {
|
|
264
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
265
|
+
const origin = `${this.id}-${meth}`;
|
|
266
|
+
log.trace(origin);
|
|
267
|
+
|
|
268
|
+
try {
|
|
269
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
270
|
+
} catch (error) {
|
|
271
|
+
log.error(`${origin}: ${error}`);
|
|
272
|
+
return callback(null, error);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @summary moves entites into Mongo DB
|
|
278
|
+
*
|
|
279
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
280
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
281
|
+
* or the error
|
|
61
282
|
*/
|
|
283
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
284
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
285
|
+
const origin = `${this.id}-${meth}`;
|
|
286
|
+
log.trace(origin);
|
|
287
|
+
|
|
288
|
+
try {
|
|
289
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
290
|
+
} catch (err) {
|
|
291
|
+
log.error(`${origin}: ${err}`);
|
|
292
|
+
return callback(null, err);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
62
295
|
|
|
296
|
+
/* BROKER CALLS */
|
|
63
297
|
/**
|
|
64
298
|
* @summary Determines if this adapter supports the specific entity
|
|
65
299
|
*
|
|
66
|
-
* @function
|
|
300
|
+
* @function iapHasAdapterEntity
|
|
67
301
|
* @param {String} entityType - the entity type to check for
|
|
68
302
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
69
303
|
*
|
|
70
304
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
71
305
|
* desired capability or an error
|
|
72
306
|
*/
|
|
73
|
-
|
|
74
|
-
const origin = `${this.id}-adapter-
|
|
307
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
308
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
75
309
|
log.trace(origin);
|
|
76
310
|
|
|
77
311
|
// Make the call -
|
|
78
|
-
//
|
|
79
|
-
return this.
|
|
312
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
313
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
80
314
|
}
|
|
81
315
|
|
|
82
316
|
/**
|
|
83
317
|
* @summary Provides a way for the adapter to tell north bound integrations
|
|
84
318
|
* whether the adapter supports type, action and specific entity
|
|
85
319
|
*
|
|
86
|
-
* @function
|
|
320
|
+
* @function iapVerifyAdapterCapability
|
|
87
321
|
* @param {String} entityType - the entity type to check for
|
|
88
322
|
* @param {String} actionType - the action type to check for
|
|
89
323
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
@@ -91,15 +325,15 @@ class Apic extends AdapterBaseCl {
|
|
|
91
325
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
92
326
|
* desired capability or an error
|
|
93
327
|
*/
|
|
94
|
-
|
|
95
|
-
const meth = 'adapterBase-
|
|
328
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
329
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
|
96
330
|
const origin = `${this.id}-${meth}`;
|
|
97
331
|
log.trace(origin);
|
|
98
332
|
|
|
99
333
|
// if caching
|
|
100
334
|
if (this.caching) {
|
|
101
|
-
// Make the call -
|
|
102
|
-
return this.requestHandlerInst.
|
|
335
|
+
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
336
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
|
103
337
|
if (error) {
|
|
104
338
|
return callback(null, error);
|
|
105
339
|
}
|
|
@@ -117,7 +351,7 @@ class Apic extends AdapterBaseCl {
|
|
|
117
351
|
}
|
|
118
352
|
|
|
119
353
|
// need to check the cache again since it has been updated
|
|
120
|
-
return this.requestHandlerInst.
|
|
354
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
121
355
|
if (verror) {
|
|
122
356
|
return callback(null, verror);
|
|
123
357
|
}
|
|
@@ -150,7 +384,7 @@ class Apic extends AdapterBaseCl {
|
|
|
150
384
|
// if no entity id
|
|
151
385
|
if (!entityId) {
|
|
152
386
|
// need to check the cache again since it has been updated
|
|
153
|
-
return this.requestHandlerInst.
|
|
387
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
154
388
|
if (verror) {
|
|
155
389
|
return callback(null, verror);
|
|
156
390
|
}
|
|
@@ -171,7 +405,7 @@ class Apic extends AdapterBaseCl {
|
|
|
171
405
|
}
|
|
172
406
|
|
|
173
407
|
// need to check the cache again since it has been updated
|
|
174
|
-
return this.requestHandlerInst.
|
|
408
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
175
409
|
if (verror) {
|
|
176
410
|
return callback(null, verror);
|
|
177
411
|
}
|
|
@@ -212,11 +446,11 @@ class Apic extends AdapterBaseCl {
|
|
|
212
446
|
/**
|
|
213
447
|
* @summary Updates the cache for all entities by call the get All entity method
|
|
214
448
|
*
|
|
215
|
-
* @function
|
|
449
|
+
* @function iapUpdateAdapterEntityCache
|
|
216
450
|
*
|
|
217
451
|
*/
|
|
218
|
-
|
|
219
|
-
const origin = `${this.id}-adapter-
|
|
452
|
+
iapUpdateAdapterEntityCache() {
|
|
453
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
|
220
454
|
log.trace(origin);
|
|
221
455
|
|
|
222
456
|
if (this.caching) {
|
|
@@ -229,6 +463,385 @@ class Apic extends AdapterBaseCl {
|
|
|
229
463
|
}
|
|
230
464
|
}
|
|
231
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 */
|
|
600
|
+
/**
|
|
601
|
+
* Makes the requested generic call
|
|
602
|
+
*
|
|
603
|
+
* @function genericAdapterRequest
|
|
604
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
605
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
606
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
607
|
+
* Can be a stringified Object.
|
|
608
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
609
|
+
* Can be a stringified Object.
|
|
610
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
611
|
+
* Can be a stringified Object.
|
|
612
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
613
|
+
* or the error
|
|
614
|
+
*/
|
|
615
|
+
genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
616
|
+
const meth = 'adapter-genericAdapterRequest';
|
|
617
|
+
const origin = `${this.id}-${meth}`;
|
|
618
|
+
log.trace(origin);
|
|
619
|
+
|
|
620
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
621
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
622
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
623
|
+
return callback(null, errorObj);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
627
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
628
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
629
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
630
|
+
return callback(null, errorObj);
|
|
631
|
+
}
|
|
632
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
633
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
634
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
635
|
+
return callback(null, errorObj);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
639
|
+
// remove any leading / and split the uripath into path variables
|
|
640
|
+
let myPath = uriPath;
|
|
641
|
+
while (myPath.indexOf('/') === 0) {
|
|
642
|
+
myPath = myPath.substring(1);
|
|
643
|
+
}
|
|
644
|
+
const pathVars = myPath.split('/');
|
|
645
|
+
const queryParamsAvailable = queryData;
|
|
646
|
+
const queryParams = {};
|
|
647
|
+
const bodyVars = requestBody;
|
|
648
|
+
|
|
649
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
650
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
651
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
652
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
653
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
658
|
+
const reqObj = {
|
|
659
|
+
payload: bodyVars,
|
|
660
|
+
uriPathVars: pathVars,
|
|
661
|
+
uriQuery: queryParams,
|
|
662
|
+
uriOptions: {}
|
|
663
|
+
};
|
|
664
|
+
// add headers if provided
|
|
665
|
+
if (addlHeaders) {
|
|
666
|
+
reqObj.addlHeaders = addlHeaders;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// determine the call and return flag
|
|
670
|
+
let action = 'getGenerics';
|
|
671
|
+
let returnF = true;
|
|
672
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
673
|
+
action = 'createGeneric';
|
|
674
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
675
|
+
action = 'updateGeneric';
|
|
676
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
677
|
+
action = 'patchGeneric';
|
|
678
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
679
|
+
action = 'deleteGeneric';
|
|
680
|
+
returnF = false;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
try {
|
|
684
|
+
// Make the call -
|
|
685
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
686
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
687
|
+
// if we received an error or their is no response on the results
|
|
688
|
+
// return an error
|
|
689
|
+
if (irReturnError) {
|
|
690
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
691
|
+
return callback(null, irReturnError);
|
|
692
|
+
}
|
|
693
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
694
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
695
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
696
|
+
return callback(null, errorObj);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
700
|
+
// return the response
|
|
701
|
+
return callback(irReturnData, null);
|
|
702
|
+
});
|
|
703
|
+
} catch (ex) {
|
|
704
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
705
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
706
|
+
return callback(null, errorObj);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
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
|
+
|
|
820
|
+
/**
|
|
821
|
+
* @callback healthCallback
|
|
822
|
+
* @param {object} result - the result of the get request (contains an id and a status)
|
|
823
|
+
*/
|
|
824
|
+
/**
|
|
825
|
+
* @callback getCallback
|
|
826
|
+
* @param {object} result - the result of the get request (entity/ies)
|
|
827
|
+
* @param {string} error - any error that occurred
|
|
828
|
+
*/
|
|
829
|
+
/**
|
|
830
|
+
* @callback createCallback
|
|
831
|
+
* @param {object} item - the newly created entity
|
|
832
|
+
* @param {string} error - any error that occurred
|
|
833
|
+
*/
|
|
834
|
+
/**
|
|
835
|
+
* @callback updateCallback
|
|
836
|
+
* @param {string} status - the status of the update action
|
|
837
|
+
* @param {string} error - any error that occurred
|
|
838
|
+
*/
|
|
839
|
+
/**
|
|
840
|
+
* @callback deleteCallback
|
|
841
|
+
* @param {string} status - the status of the delete action
|
|
842
|
+
* @param {string} error - any error that occurred
|
|
843
|
+
*/
|
|
844
|
+
|
|
232
845
|
/* START ACTION FUNCTIONS */
|
|
233
846
|
/**
|
|
234
847
|
* @summary Creates a tenant
|
|
@@ -236,7 +849,7 @@ class Apic extends AdapterBaseCl {
|
|
|
236
849
|
*
|
|
237
850
|
* @function createTenant
|
|
238
851
|
* @param {string} tenantName - Name of the tenant(optional)
|
|
239
|
-
* @param {
|
|
852
|
+
* @param {object} attributes - Attributes for the tenant (optional)
|
|
240
853
|
* @param {getCallback} callback - a callback function to return the result
|
|
241
854
|
*/
|
|
242
855
|
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
@@ -245,6 +858,12 @@ class Apic extends AdapterBaseCl {
|
|
|
245
858
|
const origin = `${this.id}-${meth}`;
|
|
246
859
|
log.trace(origin);
|
|
247
860
|
|
|
861
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
862
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
863
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
864
|
+
return callback(null, errorObj);
|
|
865
|
+
}
|
|
866
|
+
|
|
248
867
|
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
249
868
|
if (tenantName === undefined || tenantName === null || tenantName === '') {
|
|
250
869
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantName'], null, null, null);
|
|
@@ -298,7 +917,7 @@ class Apic extends AdapterBaseCl {
|
|
|
298
917
|
*
|
|
299
918
|
* @function createBridgeDomain
|
|
300
919
|
* @param {string} tenantName - Name of the tenant(optional)
|
|
301
|
-
* @param {
|
|
920
|
+
* @param {object} attributes - Attributes for the tenant (optional)
|
|
302
921
|
* @param {getCallback} callback - a callback function to return the result
|
|
303
922
|
*/
|
|
304
923
|
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
@@ -307,6 +926,12 @@ class Apic extends AdapterBaseCl {
|
|
|
307
926
|
const origin = `${this.id}-${meth}`;
|
|
308
927
|
log.trace(origin);
|
|
309
928
|
|
|
929
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
930
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
931
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
932
|
+
return callback(null, errorObj);
|
|
933
|
+
}
|
|
934
|
+
|
|
310
935
|
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
311
936
|
if (tenantName === undefined || tenantName === null || tenantName === '') {
|
|
312
937
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantName'], null, null, null);
|
|
@@ -360,7 +985,7 @@ class Apic extends AdapterBaseCl {
|
|
|
360
985
|
*
|
|
361
986
|
* @function createApplicationProfile
|
|
362
987
|
* @param {string} tenantName - Name of the tenant(optional)
|
|
363
|
-
* @param {
|
|
988
|
+
* @param {object} attributes - Attributes for the tenant (optional)
|
|
364
989
|
* @param {getCallback} callback - a callback function to return the result
|
|
365
990
|
*/
|
|
366
991
|
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
@@ -369,6 +994,12 @@ class Apic extends AdapterBaseCl {
|
|
|
369
994
|
const origin = `${this.id}-${meth}`;
|
|
370
995
|
log.trace(origin);
|
|
371
996
|
|
|
997
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
998
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
999
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1000
|
+
return callback(null, errorObj);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
372
1003
|
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
373
1004
|
if (tenantName === undefined || tenantName === null || tenantName === '') {
|
|
374
1005
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantName'], null, null, null);
|
|
@@ -423,7 +1054,7 @@ class Apic extends AdapterBaseCl {
|
|
|
423
1054
|
* @function createEPG
|
|
424
1055
|
* @param {string} tenantName - Name of the tenant(optional)
|
|
425
1056
|
* @param {string} applicationProfile - Name of the tenant(optional)
|
|
426
|
-
* @param {
|
|
1057
|
+
* @param {object} attributes - Attributes for the tenant (optional)
|
|
427
1058
|
* @param {getCallback} callback - a callback function to return the result
|
|
428
1059
|
*/
|
|
429
1060
|
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
@@ -432,6 +1063,12 @@ class Apic extends AdapterBaseCl {
|
|
|
432
1063
|
const origin = `${this.id}-${meth}`;
|
|
433
1064
|
log.trace(origin);
|
|
434
1065
|
|
|
1066
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1067
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1068
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1069
|
+
return callback(null, errorObj);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
435
1072
|
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
436
1073
|
if (tenantName === undefined || tenantName === null || tenantName === '') {
|
|
437
1074
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantName'], null, null, null);
|
|
@@ -493,7 +1130,7 @@ class Apic extends AdapterBaseCl {
|
|
|
493
1130
|
* @param {string} tenantName - Name of the tenant(optional)
|
|
494
1131
|
* @param {string} applicationProfile - Name of the tenant(optional)
|
|
495
1132
|
* @param {string} epgName - Name of the tenant(optional)
|
|
496
|
-
* @param {
|
|
1133
|
+
* @param {object} attributes - Attributes for the tenant (optional)
|
|
497
1134
|
* @param {getCallback} callback - a callback function to return the result
|
|
498
1135
|
*/
|
|
499
1136
|
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
@@ -502,6 +1139,12 @@ class Apic extends AdapterBaseCl {
|
|
|
502
1139
|
const origin = `${this.id}-${meth}`;
|
|
503
1140
|
log.trace(origin);
|
|
504
1141
|
|
|
1142
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1143
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1144
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1145
|
+
return callback(null, errorObj);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
505
1148
|
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
506
1149
|
if (tenantName === undefined || tenantName === null || tenantName === '') {
|
|
507
1150
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantName'], null, null, null);
|
|
@@ -575,6 +1218,12 @@ class Apic extends AdapterBaseCl {
|
|
|
575
1218
|
const origin = `${this.id}-${meth}`;
|
|
576
1219
|
log.trace(origin);
|
|
577
1220
|
|
|
1221
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1222
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1223
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1224
|
+
return callback(null, errorObj);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
578
1227
|
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
579
1228
|
if (tenantName === undefined || tenantName === null || tenantName === '') {
|
|
580
1229
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['tenantName'], null, null, null);
|