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