@itentialopensource/adapter-phpipam 2.0.4 → 2.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 +757 -0
- package/CHANGELOG.md +49 -23
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +3 -148
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +239 -507
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +390 -271
- package/adapterBase.js +855 -409
- package/changelogs/changelog.md +102 -0
- package/entities/.generic/action.json +110 -5
- package/entities/.generic/schema.json +6 -1
- package/entities/.system/schemaTokenReq.json +0 -4
- package/error.json +12 -0
- package/metadata.json +49 -0
- package/package.json +28 -22
- package/pronghorn.json +674 -71
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +842 -6
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +4152 -0
- package/report/adapter-openapi.yaml +3011 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653302326761.json +120 -0
- package/report/updateReport1691508486949.json +120 -0
- package/report/updateReport1692202972871.json +120 -0
- package/report/updateReport1694466392520.json +120 -0
- package/report/updateReport1698421952447.json +120 -0
- package/sampleProperties.json +156 -3
- package/test/integration/adapterTestBasicGet.js +4 -6
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +164 -110
- package/test/unit/adapterBaseTestUnit.js +393 -310
- package/test/unit/adapterTestUnit.js +926 -172
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +1 -1
- package/utils/basicGet.js +1 -14
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +179 -0
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +14 -16
- package/utils/packModificationScript.js +2 -2
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +5 -0
- package/utils/removeHooks.js +20 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +129 -53
- package/utils/tbUtils.js +152 -35
- package/utils/testRunner.js +17 -17
- package/utils/troubleshootingAdapter.js +10 -31
- package/workflows/README.md +0 -3
package/adapter.js
CHANGED
|
@@ -80,10 +80,15 @@ class Phpipam extends AdapterBaseCl {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* @
|
|
83
|
+
* @iapGetAdapterWorkflowFunctions
|
|
84
84
|
*/
|
|
85
|
-
|
|
86
|
-
let myIgnore = [
|
|
85
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
86
|
+
let myIgnore = [
|
|
87
|
+
'healthCheck',
|
|
88
|
+
'iapGetAdapterWorkflowFunctions',
|
|
89
|
+
'hasEntities',
|
|
90
|
+
'getAuthorization'
|
|
91
|
+
];
|
|
87
92
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
88
93
|
myIgnore = inIgnore;
|
|
89
94
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -94,52 +99,44 @@ class Phpipam extends AdapterBaseCl {
|
|
|
94
99
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
95
100
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
96
101
|
|
|
97
|
-
return super.
|
|
102
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
/**
|
|
101
|
-
*
|
|
106
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
102
107
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
103
108
|
* file system.
|
|
104
109
|
*
|
|
105
|
-
* @function
|
|
110
|
+
* @function iapUpdateAdapterConfiguration
|
|
106
111
|
* @param {string} configFile - the name of the file being updated (required)
|
|
107
112
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
108
113
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
109
114
|
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
110
115
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
116
|
+
* @param {boolean} replace - true to replace entire mock data, false to merge/append
|
|
111
117
|
* @param {Callback} callback - The results of the call
|
|
112
118
|
*/
|
|
113
|
-
|
|
114
|
-
const
|
|
119
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
|
|
120
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
121
|
+
const origin = `${this.id}-${meth}`;
|
|
115
122
|
log.trace(origin);
|
|
116
|
-
super.updateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
117
|
-
}
|
|
118
123
|
|
|
119
|
-
|
|
120
|
-
* See if the API path provided is found in this adapter
|
|
121
|
-
*
|
|
122
|
-
* @function findPath
|
|
123
|
-
* @param {string} apiPath - the api path to check on
|
|
124
|
-
* @param {Callback} callback - The results of the call
|
|
125
|
-
*/
|
|
126
|
-
findPath(apiPath, callback) {
|
|
127
|
-
const origin = `${this.id}-adapter-findPath`;
|
|
128
|
-
log.trace(origin);
|
|
129
|
-
super.findPath(apiPath, callback);
|
|
124
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
|
|
130
125
|
}
|
|
131
126
|
|
|
132
127
|
/**
|
|
133
128
|
* @summary Suspends adapter
|
|
134
129
|
*
|
|
135
|
-
* @function
|
|
130
|
+
* @function iapSuspendAdapter
|
|
136
131
|
* @param {Callback} callback - callback function
|
|
137
132
|
*/
|
|
138
|
-
|
|
139
|
-
const
|
|
133
|
+
iapSuspendAdapter(mode, callback) {
|
|
134
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
135
|
+
const origin = `${this.id}-${meth}`;
|
|
140
136
|
log.trace(origin);
|
|
137
|
+
|
|
141
138
|
try {
|
|
142
|
-
return super.
|
|
139
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
143
140
|
} catch (error) {
|
|
144
141
|
log.error(`${origin}: ${error}`);
|
|
145
142
|
return callback(null, error);
|
|
@@ -149,14 +146,16 @@ class Phpipam extends AdapterBaseCl {
|
|
|
149
146
|
/**
|
|
150
147
|
* @summary Unsuspends adapter
|
|
151
148
|
*
|
|
152
|
-
* @function
|
|
149
|
+
* @function iapUnsuspendAdapter
|
|
153
150
|
* @param {Callback} callback - callback function
|
|
154
151
|
*/
|
|
155
|
-
|
|
156
|
-
const
|
|
152
|
+
iapUnsuspendAdapter(callback) {
|
|
153
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
154
|
+
const origin = `${this.id}-${meth}`;
|
|
157
155
|
log.trace(origin);
|
|
156
|
+
|
|
158
157
|
try {
|
|
159
|
-
return super.
|
|
158
|
+
return super.iapUnsuspendAdapter(callback);
|
|
160
159
|
} catch (error) {
|
|
161
160
|
log.error(`${origin}: ${error}`);
|
|
162
161
|
return callback(null, error);
|
|
@@ -164,31 +163,51 @@ class Phpipam extends AdapterBaseCl {
|
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
/**
|
|
167
|
-
* @summary Get the
|
|
166
|
+
* @summary Get the Adapter Queue
|
|
168
167
|
*
|
|
169
|
-
* @function
|
|
168
|
+
* @function iapGetAdapterQueue
|
|
170
169
|
* @param {Callback} callback - callback function
|
|
171
170
|
*/
|
|
172
|
-
|
|
173
|
-
const
|
|
171
|
+
iapGetAdapterQueue(callback) {
|
|
172
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
173
|
+
const origin = `${this.id}-${meth}`;
|
|
174
174
|
log.trace(origin);
|
|
175
|
-
|
|
175
|
+
|
|
176
|
+
return super.iapGetAdapterQueue(callback);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* SCRIPT CALLS */
|
|
180
|
+
/**
|
|
181
|
+
* See if the API path provided is found in this adapter
|
|
182
|
+
*
|
|
183
|
+
* @function iapFindAdapterPath
|
|
184
|
+
* @param {string} apiPath - the api path to check on
|
|
185
|
+
* @param {Callback} callback - The results of the call
|
|
186
|
+
*/
|
|
187
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
188
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
189
|
+
const origin = `${this.id}-${meth}`;
|
|
190
|
+
log.trace(origin);
|
|
191
|
+
|
|
192
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
176
193
|
}
|
|
177
194
|
|
|
178
195
|
/**
|
|
179
196
|
* @summary Runs troubleshoot scripts for adapter
|
|
180
197
|
*
|
|
181
|
-
* @function
|
|
198
|
+
* @function iapTroubleshootAdapter
|
|
182
199
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
183
200
|
*
|
|
184
201
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
185
202
|
* @param {Callback} callback - The results of the call
|
|
186
203
|
*/
|
|
187
|
-
|
|
188
|
-
const
|
|
204
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
205
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
206
|
+
const origin = `${this.id}-${meth}`;
|
|
189
207
|
log.trace(origin);
|
|
208
|
+
|
|
190
209
|
try {
|
|
191
|
-
return super.
|
|
210
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
192
211
|
} catch (error) {
|
|
193
212
|
log.error(`${origin}: ${error}`);
|
|
194
213
|
return callback(null, error);
|
|
@@ -198,15 +217,17 @@ class Phpipam extends AdapterBaseCl {
|
|
|
198
217
|
/**
|
|
199
218
|
* @summary runs healthcheck script for adapter
|
|
200
219
|
*
|
|
201
|
-
* @function
|
|
220
|
+
* @function iapRunAdapterHealthcheck
|
|
202
221
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
203
222
|
* @param {Callback} callback - callback function
|
|
204
223
|
*/
|
|
205
|
-
|
|
206
|
-
const
|
|
224
|
+
iapRunAdapterHealthcheck(callback) {
|
|
225
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
226
|
+
const origin = `${this.id}-${meth}`;
|
|
207
227
|
log.trace(origin);
|
|
228
|
+
|
|
208
229
|
try {
|
|
209
|
-
return super.
|
|
230
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
210
231
|
} catch (error) {
|
|
211
232
|
log.error(`${origin}: ${error}`);
|
|
212
233
|
return callback(null, error);
|
|
@@ -216,14 +237,16 @@ class Phpipam extends AdapterBaseCl {
|
|
|
216
237
|
/**
|
|
217
238
|
* @summary runs connectivity check script for adapter
|
|
218
239
|
*
|
|
219
|
-
* @function
|
|
240
|
+
* @function iapRunAdapterConnectivity
|
|
220
241
|
* @param {Callback} callback - callback function
|
|
221
242
|
*/
|
|
222
|
-
|
|
223
|
-
const
|
|
243
|
+
iapRunAdapterConnectivity(callback) {
|
|
244
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
245
|
+
const origin = `${this.id}-${meth}`;
|
|
224
246
|
log.trace(origin);
|
|
247
|
+
|
|
225
248
|
try {
|
|
226
|
-
return super.
|
|
249
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
227
250
|
} catch (error) {
|
|
228
251
|
log.error(`${origin}: ${error}`);
|
|
229
252
|
return callback(null, error);
|
|
@@ -233,14 +256,16 @@ class Phpipam extends AdapterBaseCl {
|
|
|
233
256
|
/**
|
|
234
257
|
* @summary runs basicGet script for adapter
|
|
235
258
|
*
|
|
236
|
-
* @function
|
|
259
|
+
* @function iapRunAdapterBasicGet
|
|
237
260
|
* @param {Callback} callback - callback function
|
|
238
261
|
*/
|
|
239
|
-
|
|
240
|
-
const
|
|
262
|
+
iapRunAdapterBasicGet(callback) {
|
|
263
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
264
|
+
const origin = `${this.id}-${meth}`;
|
|
241
265
|
log.trace(origin);
|
|
266
|
+
|
|
242
267
|
try {
|
|
243
|
-
return super.
|
|
268
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
244
269
|
} catch (error) {
|
|
245
270
|
log.error(`${origin}: ${error}`);
|
|
246
271
|
return callback(null, error);
|
|
@@ -248,171 +273,275 @@ class Phpipam extends AdapterBaseCl {
|
|
|
248
273
|
}
|
|
249
274
|
|
|
250
275
|
/**
|
|
251
|
-
* @summary
|
|
276
|
+
* @summary moves entites into Mongo DB
|
|
252
277
|
*
|
|
253
|
-
* @function
|
|
254
|
-
* @param {
|
|
255
|
-
*
|
|
278
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
279
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
280
|
+
* or the error
|
|
281
|
+
*/
|
|
282
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
283
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
284
|
+
const origin = `${this.id}-${meth}`;
|
|
285
|
+
log.trace(origin);
|
|
286
|
+
|
|
287
|
+
try {
|
|
288
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
289
|
+
} catch (err) {
|
|
290
|
+
log.error(`${origin}: ${err}`);
|
|
291
|
+
return callback(null, err);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @summary Deactivate adapter tasks
|
|
297
|
+
*
|
|
298
|
+
* @function iapDeactivateTasks
|
|
256
299
|
*
|
|
257
|
-
* @param {
|
|
258
|
-
*
|
|
300
|
+
* @param {Array} tasks - List of tasks to deactivate
|
|
301
|
+
* @param {Callback} callback
|
|
259
302
|
*/
|
|
260
|
-
|
|
261
|
-
const
|
|
303
|
+
iapDeactivateTasks(tasks, callback) {
|
|
304
|
+
const meth = 'adapter-iapDeactivateTasks';
|
|
305
|
+
const origin = `${this.id}-${meth}`;
|
|
262
306
|
log.trace(origin);
|
|
263
307
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
308
|
+
try {
|
|
309
|
+
return super.iapDeactivateTasks(tasks, callback);
|
|
310
|
+
} catch (err) {
|
|
311
|
+
log.error(`${origin}: ${err}`);
|
|
312
|
+
return callback(null, err);
|
|
313
|
+
}
|
|
267
314
|
}
|
|
268
315
|
|
|
269
316
|
/**
|
|
270
|
-
* @summary
|
|
271
|
-
*
|
|
317
|
+
* @summary Activate adapter tasks that have previously been deactivated
|
|
318
|
+
*
|
|
319
|
+
* @function iapActivateTasks
|
|
320
|
+
*
|
|
321
|
+
* @param {Array} tasks - List of tasks to activate
|
|
322
|
+
* @param {Callback} callback
|
|
323
|
+
*/
|
|
324
|
+
iapActivateTasks(tasks, callback) {
|
|
325
|
+
const meth = 'adapter-iapActivateTasks';
|
|
326
|
+
const origin = `${this.id}-${meth}`;
|
|
327
|
+
log.trace(origin);
|
|
328
|
+
|
|
329
|
+
try {
|
|
330
|
+
return super.iapActivateTasks(tasks, callback);
|
|
331
|
+
} catch (err) {
|
|
332
|
+
log.error(`${origin}: ${err}`);
|
|
333
|
+
return callback(null, err);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/* CACHE CALLS */
|
|
338
|
+
/**
|
|
339
|
+
* @summary Populate the cache for the given entities
|
|
340
|
+
*
|
|
341
|
+
* @function iapPopulateEntityCache
|
|
342
|
+
* @param {String/Array of Strings} entityType - the entity type(s) to populate
|
|
343
|
+
* @param {Callback} callback - whether the cache was updated or not for each entity type
|
|
272
344
|
*
|
|
273
|
-
* @
|
|
345
|
+
* @returns status of the populate
|
|
346
|
+
*/
|
|
347
|
+
iapPopulateEntityCache(entityTypes, callback) {
|
|
348
|
+
const meth = 'adapter-iapPopulateEntityCache';
|
|
349
|
+
const origin = `${this.id}-${meth}`;
|
|
350
|
+
log.trace(origin);
|
|
351
|
+
|
|
352
|
+
try {
|
|
353
|
+
return super.iapPopulateEntityCache(entityTypes, callback);
|
|
354
|
+
} catch (err) {
|
|
355
|
+
log.error(`${origin}: ${err}`);
|
|
356
|
+
return callback(null, err);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @summary Retrieves data from cache for specified entity type
|
|
362
|
+
*
|
|
363
|
+
* @function iapRetrieveEntitiesCache
|
|
364
|
+
* @param {String} entityType - entity of which to retrieve
|
|
365
|
+
* @param {Object} options - settings of which data to return and how to return it
|
|
366
|
+
* @param {Callback} callback - the data if it was retrieved
|
|
367
|
+
*/
|
|
368
|
+
iapRetrieveEntitiesCache(entityType, options, callback) {
|
|
369
|
+
const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
|
|
370
|
+
const origin = `${this.id}-${meth}`;
|
|
371
|
+
log.trace(origin);
|
|
372
|
+
|
|
373
|
+
try {
|
|
374
|
+
return super.iapRetrieveEntitiesCache(entityType, options, callback);
|
|
375
|
+
} catch (err) {
|
|
376
|
+
log.error(`${origin}: ${err}`);
|
|
377
|
+
return callback(null, err);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/* BROKER CALLS */
|
|
382
|
+
/**
|
|
383
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
384
|
+
*
|
|
385
|
+
* @function hasEntities
|
|
274
386
|
* @param {String} entityType - the entity type to check for
|
|
275
|
-
* @param {
|
|
276
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
387
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
277
388
|
*
|
|
278
|
-
* @param {Callback} callback -
|
|
279
|
-
*
|
|
389
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
390
|
+
* value is true or false
|
|
280
391
|
*/
|
|
281
|
-
|
|
282
|
-
const meth = '
|
|
392
|
+
hasEntities(entityType, entityList, callback) {
|
|
393
|
+
const meth = 'adapter-hasEntities';
|
|
283
394
|
const origin = `${this.id}-${meth}`;
|
|
284
395
|
log.trace(origin);
|
|
285
396
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return callback(null, error);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// if the cache needs to be updated, update and try again
|
|
295
|
-
if (results && results[0] === 'needupdate') {
|
|
296
|
-
switch (entityType) {
|
|
297
|
-
case 'template_entity': {
|
|
298
|
-
// if the cache is invalid, update the cache
|
|
299
|
-
return this.getEntities(null, null, null, null, (data, err) => {
|
|
300
|
-
if (err) {
|
|
301
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
302
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
303
|
-
return callback(null, errorObj);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// need to check the cache again since it has been updated
|
|
307
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
308
|
-
if (verror) {
|
|
309
|
-
return callback(null, verror);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return this.capabilityResults(vcapable, callback);
|
|
313
|
-
});
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
default: {
|
|
317
|
-
// unsupported entity type
|
|
318
|
-
const result = [false];
|
|
319
|
-
|
|
320
|
-
// put false in array for all entities
|
|
321
|
-
if (Array.isArray(entityId)) {
|
|
322
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
323
|
-
result.push(false);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return callback(result);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// return the results
|
|
333
|
-
return this.capabilityResults(results, callback);
|
|
334
|
-
});
|
|
397
|
+
try {
|
|
398
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
399
|
+
} catch (err) {
|
|
400
|
+
log.error(`${origin}: ${err}`);
|
|
401
|
+
return callback(null, err);
|
|
335
402
|
}
|
|
403
|
+
}
|
|
336
404
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
405
|
+
/**
|
|
406
|
+
* @summary Get Appliance that match the deviceName
|
|
407
|
+
*
|
|
408
|
+
* @function getDevice
|
|
409
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
410
|
+
*
|
|
411
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
412
|
+
* (appliance) or the error
|
|
413
|
+
*/
|
|
414
|
+
getDevice(deviceName, callback) {
|
|
415
|
+
const meth = 'adapter-getDevice';
|
|
416
|
+
const origin = `${this.id}-${meth}`;
|
|
417
|
+
log.trace(origin);
|
|
344
418
|
|
|
345
|
-
|
|
346
|
-
|
|
419
|
+
try {
|
|
420
|
+
return super.getDevice(deviceName, callback);
|
|
421
|
+
} catch (err) {
|
|
422
|
+
log.error(`${origin}: ${err}`);
|
|
423
|
+
return callback(null, err);
|
|
347
424
|
}
|
|
425
|
+
}
|
|
348
426
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if (verror) {
|
|
363
|
-
return callback(null, verror);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// is the entity in the list?
|
|
367
|
-
const isEntity = this.entityInList(entityId, data.response, callback);
|
|
368
|
-
const res = [];
|
|
369
|
-
|
|
370
|
-
// not found
|
|
371
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
372
|
-
if (vcapable) {
|
|
373
|
-
res.push(isEntity[i]);
|
|
374
|
-
} else {
|
|
375
|
-
res.push(false);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
return callback(res);
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
default: {
|
|
384
|
-
// unsupported entity type
|
|
385
|
-
const result = [false];
|
|
427
|
+
/**
|
|
428
|
+
* @summary Get Appliances that match the filter
|
|
429
|
+
*
|
|
430
|
+
* @function getDevicesFiltered
|
|
431
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
432
|
+
*
|
|
433
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
434
|
+
* (appliances) or the error
|
|
435
|
+
*/
|
|
436
|
+
getDevicesFiltered(options, callback) {
|
|
437
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
438
|
+
const origin = `${this.id}-${meth}`;
|
|
439
|
+
log.trace(origin);
|
|
386
440
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
441
|
+
try {
|
|
442
|
+
return super.getDevicesFiltered(options, callback);
|
|
443
|
+
} catch (err) {
|
|
444
|
+
log.error(`${origin}: ${err}`);
|
|
445
|
+
return callback(null, err);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
393
448
|
|
|
394
|
-
|
|
395
|
-
|
|
449
|
+
/**
|
|
450
|
+
* @summary Gets the status for the provided appliance
|
|
451
|
+
*
|
|
452
|
+
* @function isAlive
|
|
453
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
454
|
+
*
|
|
455
|
+
* @param {configCallback} callback - callback function to return the result
|
|
456
|
+
* (appliance isAlive) or the error
|
|
457
|
+
*/
|
|
458
|
+
isAlive(deviceName, callback) {
|
|
459
|
+
const meth = 'adapter-isAlive';
|
|
460
|
+
const origin = `${this.id}-${meth}`;
|
|
461
|
+
log.trace(origin);
|
|
462
|
+
|
|
463
|
+
try {
|
|
464
|
+
return super.isAlive(deviceName, callback);
|
|
465
|
+
} catch (err) {
|
|
466
|
+
log.error(`${origin}: ${err}`);
|
|
467
|
+
return callback(null, err);
|
|
396
468
|
}
|
|
397
469
|
}
|
|
398
470
|
|
|
399
471
|
/**
|
|
400
|
-
* @summary
|
|
472
|
+
* @summary Gets a config for the provided Appliance
|
|
401
473
|
*
|
|
402
|
-
* @function
|
|
474
|
+
* @function getConfig
|
|
475
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
476
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
403
477
|
*
|
|
478
|
+
* @param {configCallback} callback - callback function to return the result
|
|
479
|
+
* (appliance config) or the error
|
|
404
480
|
*/
|
|
405
|
-
|
|
406
|
-
const
|
|
481
|
+
getConfig(deviceName, format, callback) {
|
|
482
|
+
const meth = 'adapter-getConfig';
|
|
483
|
+
const origin = `${this.id}-${meth}`;
|
|
407
484
|
log.trace(origin);
|
|
408
485
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
486
|
+
try {
|
|
487
|
+
return super.getConfig(deviceName, format, callback);
|
|
488
|
+
} catch (err) {
|
|
489
|
+
log.error(`${origin}: ${err}`);
|
|
490
|
+
return callback(null, err);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* @summary Gets the device count from the system
|
|
496
|
+
*
|
|
497
|
+
* @function iapGetDeviceCount
|
|
498
|
+
*
|
|
499
|
+
* @param {getCallback} callback - callback function to return the result
|
|
500
|
+
* (count) or the error
|
|
501
|
+
*/
|
|
502
|
+
iapGetDeviceCount(callback) {
|
|
503
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
504
|
+
const origin = `${this.id}-${meth}`;
|
|
505
|
+
log.trace(origin);
|
|
506
|
+
|
|
507
|
+
try {
|
|
508
|
+
return super.iapGetDeviceCount(callback);
|
|
509
|
+
} catch (err) {
|
|
510
|
+
log.error(`${origin}: ${err}`);
|
|
511
|
+
return callback(null, err);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
516
|
+
/**
|
|
517
|
+
* Makes the requested generic call
|
|
518
|
+
*
|
|
519
|
+
* @function iapExpandedGenericAdapterRequest
|
|
520
|
+
* @param {Object} metadata - metadata for the call (optional).
|
|
521
|
+
* Can be a stringified Object.
|
|
522
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
|
|
523
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
|
|
524
|
+
* @param {Object} pathVars - the parameters to be put within the url path (optional).
|
|
525
|
+
* Can be a stringified Object.
|
|
526
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
527
|
+
* Can be a stringified Object.
|
|
528
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
529
|
+
* Can be a stringified Object.
|
|
530
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
531
|
+
* Can be a stringified Object.
|
|
532
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
533
|
+
* or the error
|
|
534
|
+
*/
|
|
535
|
+
iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
|
|
536
|
+
const meth = 'adapter-iapExpandedGenericAdapterRequest';
|
|
537
|
+
const origin = `${this.id}-${meth}`;
|
|
538
|
+
log.trace(origin);
|
|
539
|
+
|
|
540
|
+
try {
|
|
541
|
+
return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
|
|
542
|
+
} catch (err) {
|
|
543
|
+
log.error(`${origin}: ${err}`);
|
|
544
|
+
return callback(null, err);
|
|
416
545
|
}
|
|
417
546
|
}
|
|
418
547
|
|
|
@@ -436,94 +565,84 @@ class Phpipam extends AdapterBaseCl {
|
|
|
436
565
|
const origin = `${this.id}-${meth}`;
|
|
437
566
|
log.trace(origin);
|
|
438
567
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
568
|
+
try {
|
|
569
|
+
return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
570
|
+
} catch (err) {
|
|
571
|
+
log.error(`${origin}: ${err}`);
|
|
572
|
+
return callback(null, err);
|
|
443
573
|
}
|
|
574
|
+
}
|
|
444
575
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
576
|
+
/**
|
|
577
|
+
* Makes the requested generic call with no base path or version
|
|
578
|
+
*
|
|
579
|
+
* @function genericAdapterRequestNoBasePath
|
|
580
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
581
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
582
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
583
|
+
* Can be a stringified Object.
|
|
584
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
585
|
+
* Can be a stringified Object.
|
|
586
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
587
|
+
* Can be a stringified Object.
|
|
588
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
589
|
+
* or the error
|
|
590
|
+
*/
|
|
591
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
592
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
593
|
+
const origin = `${this.id}-${meth}`;
|
|
594
|
+
log.trace(origin);
|
|
456
595
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
596
|
+
try {
|
|
597
|
+
return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
598
|
+
} catch (err) {
|
|
599
|
+
log.error(`${origin}: ${err}`);
|
|
600
|
+
return callback(null, err);
|
|
462
601
|
}
|
|
463
|
-
|
|
464
|
-
const queryParamsAvailable = queryData;
|
|
465
|
-
const queryParams = {};
|
|
466
|
-
const bodyVars = requestBody;
|
|
602
|
+
}
|
|
467
603
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
604
|
+
/* INVENTORY CALLS */
|
|
605
|
+
/**
|
|
606
|
+
* @summary run the adapter lint script to return the results.
|
|
607
|
+
*
|
|
608
|
+
* @function iapRunAdapterLint
|
|
609
|
+
* @param {Callback} callback - callback function
|
|
610
|
+
*/
|
|
611
|
+
iapRunAdapterLint(callback) {
|
|
612
|
+
const meth = 'adapter-iapRunAdapterLint';
|
|
613
|
+
const origin = `${this.id}-${meth}`;
|
|
614
|
+
log.trace(origin);
|
|
475
615
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
payload: bodyVars,
|
|
479
|
-
uriPathVars: pathVars,
|
|
480
|
-
uriQuery: queryParams,
|
|
481
|
-
uriOptions: {}
|
|
482
|
-
};
|
|
483
|
-
// add headers if provided
|
|
484
|
-
if (addlHeaders) {
|
|
485
|
-
reqObj.addlHeaders = addlHeaders;
|
|
486
|
-
}
|
|
616
|
+
return super.iapRunAdapterLint(callback);
|
|
617
|
+
}
|
|
487
618
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
returnF = false;
|
|
500
|
-
}
|
|
619
|
+
/**
|
|
620
|
+
* @summary run the adapter test scripts (baseunit and unit) to return the results.
|
|
621
|
+
* can not run integration as there can be implications with that.
|
|
622
|
+
*
|
|
623
|
+
* @function iapRunAdapterTests
|
|
624
|
+
* @param {Callback} callback - callback function
|
|
625
|
+
*/
|
|
626
|
+
iapRunAdapterTests(callback) {
|
|
627
|
+
const meth = 'adapter-iapRunAdapterTests';
|
|
628
|
+
const origin = `${this.id}-${meth}`;
|
|
629
|
+
log.trace(origin);
|
|
501
630
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
505
|
-
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
506
|
-
// if we received an error or their is no response on the results
|
|
507
|
-
// return an error
|
|
508
|
-
if (irReturnError) {
|
|
509
|
-
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
510
|
-
return callback(null, irReturnError);
|
|
511
|
-
}
|
|
512
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
513
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
514
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
515
|
-
return callback(null, errorObj);
|
|
516
|
-
}
|
|
631
|
+
return super.iapRunAdapterTests(callback);
|
|
632
|
+
}
|
|
517
633
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
634
|
+
/**
|
|
635
|
+
* @summary provide inventory information abbout the adapter
|
|
636
|
+
*
|
|
637
|
+
* @function iapGetAdapterInventory
|
|
638
|
+
* @param {Callback} callback - callback function
|
|
639
|
+
*/
|
|
640
|
+
iapGetAdapterInventory(callback) {
|
|
641
|
+
const meth = 'adapter-iapGetAdapterInventory';
|
|
642
|
+
const origin = `${this.id}-${meth}`;
|
|
643
|
+
log.trace(origin);
|
|
644
|
+
|
|
645
|
+
return super.iapGetAdapterInventory(callback);
|
|
527
646
|
}
|
|
528
647
|
|
|
529
648
|
/**
|
|
@@ -5683,13 +5802,13 @@ class Phpipam extends AdapterBaseCl {
|
|
|
5683
5802
|
/**
|
|
5684
5803
|
* @summary Returns all devices
|
|
5685
5804
|
*
|
|
5686
|
-
* @function
|
|
5805
|
+
* @function getPhpDevices
|
|
5687
5806
|
* @param {object} globals - global params (optional)
|
|
5688
5807
|
* @param {getCallback} callback - a callback function to return the result
|
|
5689
5808
|
*/
|
|
5690
5809
|
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
5691
|
-
|
|
5692
|
-
const meth = 'adapter-
|
|
5810
|
+
getPhpDevices(globals, callback) {
|
|
5811
|
+
const meth = 'adapter-getPhpDevices';
|
|
5693
5812
|
const origin = `${this.id}-${meth}`;
|
|
5694
5813
|
log.trace(origin);
|
|
5695
5814
|
|
|
@@ -5737,7 +5856,7 @@ class Phpipam extends AdapterBaseCl {
|
|
|
5737
5856
|
return callback(null, irReturnError);
|
|
5738
5857
|
}
|
|
5739
5858
|
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
5740
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['
|
|
5859
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPhpDevices'], null, null, null);
|
|
5741
5860
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
5742
5861
|
return callback(null, errorObj);
|
|
5743
5862
|
}
|
|
@@ -5896,14 +6015,14 @@ class Phpipam extends AdapterBaseCl {
|
|
|
5896
6015
|
/**
|
|
5897
6016
|
* @summary Returns specific device
|
|
5898
6017
|
*
|
|
5899
|
-
* @function
|
|
6018
|
+
* @function getPhpDevice
|
|
5900
6019
|
* @param {string} id - Device identifier
|
|
5901
6020
|
* @param {object} globals - global params (optional)
|
|
5902
6021
|
* @param {getCallback} callback - a callback function to return the result
|
|
5903
6022
|
*/
|
|
5904
6023
|
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
5905
|
-
|
|
5906
|
-
const meth = 'adapter-
|
|
6024
|
+
getPhpDevice(id, globals, callback) {
|
|
6025
|
+
const meth = 'adapter-getPhpDevice';
|
|
5907
6026
|
const origin = `${this.id}-${meth}`;
|
|
5908
6027
|
log.trace(origin);
|
|
5909
6028
|
|
|
@@ -5956,7 +6075,7 @@ class Phpipam extends AdapterBaseCl {
|
|
|
5956
6075
|
return callback(null, irReturnError);
|
|
5957
6076
|
}
|
|
5958
6077
|
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
5959
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['
|
|
6078
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPhpDevice'], null, null, null);
|
|
5960
6079
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
5961
6080
|
return callback(null, errorObj);
|
|
5962
6081
|
}
|