@itentialopensource/adapter-azure_devops 0.1.1

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.
Files changed (68) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +18 -0
  3. package/.jshintrc +3 -0
  4. package/CHANGELOG.md +9 -0
  5. package/CODE_OF_CONDUCT.md +48 -0
  6. package/CONTRIBUTING.md +158 -0
  7. package/LICENSE +201 -0
  8. package/README.md +687 -0
  9. package/adapter.js +1606 -0
  10. package/adapterBase.js +1028 -0
  11. package/entities/.generic/action.json +109 -0
  12. package/entities/.generic/schema.json +23 -0
  13. package/entities/.system/action.json +50 -0
  14. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  15. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  16. package/entities/.system/schema.json +19 -0
  17. package/entities/.system/schemaTokenReq.json +53 -0
  18. package/entities/.system/schemaTokenResp.json +53 -0
  19. package/entities/Artifacts/action.json +25 -0
  20. package/entities/Artifacts/mockdatafiles/artifactsGet-default.json +5 -0
  21. package/entities/Artifacts/schema.json +41 -0
  22. package/entities/Logs/action.json +46 -0
  23. package/entities/Logs/mockdatafiles/logsGet-default.json +11 -0
  24. package/entities/Logs/mockdatafiles/logsList-default.json +119 -0
  25. package/entities/Logs/schema.json +42 -0
  26. package/entities/Pipelines/action.json +66 -0
  27. package/entities/Pipelines/mockdatafiles/pipelinesCreate-default.json +6 -0
  28. package/entities/Pipelines/mockdatafiles/pipelinesGet-default.json +6 -0
  29. package/entities/Pipelines/mockdatafiles/pipelinesList-default.json +26 -0
  30. package/entities/Pipelines/schema.json +43 -0
  31. package/entities/Preview/action.json +24 -0
  32. package/entities/Preview/mockdatafiles/previewPreview-default.json +3 -0
  33. package/entities/Preview/schema.json +30 -0
  34. package/entities/Runs/action.json +66 -0
  35. package/entities/Runs/mockdatafiles/runsGet-default.json +4 -0
  36. package/entities/Runs/mockdatafiles/runsList-default.json +18 -0
  37. package/entities/Runs/mockdatafiles/runsRunPipeline-default.json +4 -0
  38. package/entities/Runs/schema.json +32 -0
  39. package/error.json +184 -0
  40. package/package.json +85 -0
  41. package/pronghorn.json +2488 -0
  42. package/propertiesSchema.json +840 -0
  43. package/refs?service=git-upload-pack +0 -0
  44. package/report/ado.json +1382 -0
  45. package/report/creationReport.json +228 -0
  46. package/report/updateReport1639421539710.json +95 -0
  47. package/sampleProperties.json +106 -0
  48. package/test/integration/adapterTestBasicGet.js +85 -0
  49. package/test/integration/adapterTestConnectivity.js +93 -0
  50. package/test/integration/adapterTestIntegration.js +751 -0
  51. package/test/unit/adapterBaseTestUnit.js +944 -0
  52. package/test/unit/adapterTestUnit.js +2192 -0
  53. package/utils/addAuth.js +94 -0
  54. package/utils/artifactize.js +146 -0
  55. package/utils/basicGet.js +50 -0
  56. package/utils/checkMigrate.js +63 -0
  57. package/utils/entitiesToDB.js +224 -0
  58. package/utils/findPath.js +74 -0
  59. package/utils/modify.js +154 -0
  60. package/utils/packModificationScript.js +35 -0
  61. package/utils/pre-commit.sh +27 -0
  62. package/utils/removeHooks.js +20 -0
  63. package/utils/setup.js +33 -0
  64. package/utils/tbScript.js +169 -0
  65. package/utils/tbUtils.js +445 -0
  66. package/utils/testRunner.js +298 -0
  67. package/utils/troubleshootingAdapter.js +190 -0
  68. package/workflows/README.md +3 -0
package/adapter.js ADDED
@@ -0,0 +1,1606 @@
1
+ /* @copyright Itential, LLC 2019 (pre-modifications) */
2
+
3
+ /* eslint import/no-dynamic-require: warn */
4
+ /* eslint object-curly-newline: warn */
5
+
6
+ // Set globals
7
+ /* global log */
8
+
9
+ /* Required libraries. */
10
+ const path = require('path');
11
+
12
+ /* Fetch in the other needed components for the this Adaptor */
13
+ const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
14
+
15
+ /**
16
+ * This is the adapter/interface into Azure_devops
17
+ */
18
+
19
+ /* GENERAL ADAPTER FUNCTIONS */
20
+ class AzureDevops extends AdapterBaseCl {
21
+ /**
22
+ * AzureDevops Adapter
23
+ * @constructor
24
+ */
25
+ /* Working on changing the way we do Emit methods due to size and time constrainsts
26
+ constructor(prongid, properties) {
27
+ // Instantiate the AdapterBase super class
28
+ super(prongid, properties);
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
+
59
+ // Uncomment if you have things to add to the constructor like using your own properties.
60
+ // Otherwise the constructor in the adapterBase will be used.
61
+ // Capture my own properties - they need to be defined in propertiesSchema.json
62
+ // if (this.allProps && this.allProps.myownproperty) {
63
+ // mypropvariable = this.allProps.myownproperty;
64
+ // }
65
+ }
66
+ */
67
+
68
+ /**
69
+ * @callback healthCallback
70
+ * @param {Object} reqObj - the request to send into the healthcheck
71
+ * @param {Callback} callback - The results of the call
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
+
82
+ /**
83
+ * @getWorkflowFunctions
84
+ */
85
+ getWorkflowFunctions(inIgnore) {
86
+ let myIgnore = [];
87
+ if (!inIgnore && Array.isArray(inIgnore)) {
88
+ myIgnore = inIgnore;
89
+ } else if (!inIgnore && typeof inIgnore === 'string') {
90
+ myIgnore = [inIgnore];
91
+ }
92
+
93
+ // The generic adapter functions should already be ignored (e.g. healthCheck)
94
+ // you can add specific methods that you do not want to be workflow functions to ignore like below
95
+ // myIgnore.push('myMethodNotInWorkflow');
96
+
97
+ return super.getWorkflowFunctions(myIgnore);
98
+ }
99
+
100
+ /**
101
+ * updateAdapterConfiguration is used to update any of the adapter configuration files. This
102
+ * allows customers to make changes to adapter configuration without having to be on the
103
+ * file system.
104
+ *
105
+ * @function updateAdapterConfiguration
106
+ * @param {string} configFile - the name of the file being updated (required)
107
+ * @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
108
+ * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
109
+ * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
110
+ * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
111
+ * @param {Callback} callback - The results of the call
112
+ */
113
+ updateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
114
+ const origin = `${this.id}-adapter-updateAdapterConfiguration`;
115
+ log.trace(origin);
116
+ super.updateAdapterConfiguration(configFile, changes, entity, type, action, callback);
117
+ }
118
+
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);
130
+ }
131
+
132
+ /**
133
+ * @summary Suspends adapter
134
+ *
135
+ * @function suspend
136
+ * @param {Callback} callback - callback function
137
+ */
138
+ suspend(mode, callback) {
139
+ const origin = `${this.id}-adapter-suspend`;
140
+ log.trace(origin);
141
+ try {
142
+ return super.suspend(mode, callback);
143
+ } catch (error) {
144
+ log.error(`${origin}: ${error}`);
145
+ return callback(null, error);
146
+ }
147
+ }
148
+
149
+ /**
150
+ * @summary Unsuspends adapter
151
+ *
152
+ * @function unsuspend
153
+ * @param {Callback} callback - callback function
154
+ */
155
+ unsuspend(callback) {
156
+ const origin = `${this.id}-adapter-unsuspend`;
157
+ log.trace(origin);
158
+ try {
159
+ return super.unsuspend(callback);
160
+ } catch (error) {
161
+ log.error(`${origin}: ${error}`);
162
+ return callback(null, error);
163
+ }
164
+ }
165
+
166
+ /**
167
+ * @summary Get the Adaoter Queue
168
+ *
169
+ * @function getQueue
170
+ * @param {Callback} callback - callback function
171
+ */
172
+ getQueue(callback) {
173
+ const origin = `${this.id}-adapter-getQueue`;
174
+ log.trace(origin);
175
+ return super.getQueue(callback);
176
+ }
177
+
178
+ /**
179
+ * @summary Runs troubleshoot scripts for adapter
180
+ *
181
+ * @function troubleshoot
182
+ * @param {Object} props - the connection, healthcheck and authentication properties
183
+ *
184
+ * @param {boolean} persistFlag - whether the adapter properties should be updated
185
+ * @param {Callback} callback - The results of the call
186
+ */
187
+ troubleshoot(props, persistFlag, callback) {
188
+ const origin = `${this.id}-adapter-troubleshoot`;
189
+ log.trace(origin);
190
+ try {
191
+ return super.troubleshoot(props, persistFlag, this, callback);
192
+ } catch (error) {
193
+ log.error(`${origin}: ${error}`);
194
+ return callback(null, error);
195
+ }
196
+ }
197
+
198
+ /**
199
+ * @summary runs healthcheck script for adapter
200
+ *
201
+ * @function runHealthcheck
202
+ * @param {Adapter} adapter - adapter instance to troubleshoot
203
+ * @param {Callback} callback - callback function
204
+ */
205
+ runHealthcheck(callback) {
206
+ const origin = `${this.id}-adapter-runHealthcheck`;
207
+ log.trace(origin);
208
+ try {
209
+ return super.runHealthcheck(this, callback);
210
+ } catch (error) {
211
+ log.error(`${origin}: ${error}`);
212
+ return callback(null, error);
213
+ }
214
+ }
215
+
216
+ /**
217
+ * @summary runs connectivity check script for adapter
218
+ *
219
+ * @function runConnectivity
220
+ * @param {Callback} callback - callback function
221
+ */
222
+ runConnectivity(callback) {
223
+ const origin = `${this.id}-adapter-runConnectivity`;
224
+ log.trace(origin);
225
+ try {
226
+ return super.runConnectivity(callback);
227
+ } catch (error) {
228
+ log.error(`${origin}: ${error}`);
229
+ return callback(null, error);
230
+ }
231
+ }
232
+
233
+ /**
234
+ * @summary runs basicGet script for adapter
235
+ *
236
+ * @function runBasicGet
237
+ * @param {Callback} callback - callback function
238
+ */
239
+ runBasicGet(callback) {
240
+ const origin = `${this.id}-adapter-runBasicGet`;
241
+ log.trace(origin);
242
+ try {
243
+ return super.runBasicGet(callback);
244
+ } catch (error) {
245
+ log.error(`${origin}: ${error}`);
246
+ return callback(null, error);
247
+ }
248
+ }
249
+
250
+ /**
251
+ * @summary Determines if this adapter supports the specific entity
252
+ *
253
+ * @function hasEntity
254
+ * @param {String} entityType - the entity type to check for
255
+ * @param {String/Array} entityId - the specific entity we are looking for
256
+ *
257
+ * @param {Callback} callback - An array of whether the adapter can has the
258
+ * desired capability or an error
259
+ */
260
+ hasEntity(entityType, entityId, callback) {
261
+ const origin = `${this.id}-adapter-hasEntity`;
262
+ log.trace(origin);
263
+
264
+ // Make the call -
265
+ // verifyCapability(entityType, actionType, entityId, callback)
266
+ return this.verifyCapability(entityType, null, entityId, callback);
267
+ }
268
+
269
+ /**
270
+ * @summary Provides a way for the adapter to tell north bound integrations
271
+ * whether the adapter supports type, action and specific entity
272
+ *
273
+ * @function verifyCapability
274
+ * @param {String} entityType - the entity type to check for
275
+ * @param {String} actionType - the action type to check for
276
+ * @param {String/Array} entityId - the specific entity we are looking for
277
+ *
278
+ * @param {Callback} callback - An array of whether the adapter can has the
279
+ * desired capability or an error
280
+ */
281
+ verifyCapability(entityType, actionType, entityId, callback) {
282
+ const meth = 'adapterBase-verifyCapability';
283
+ const origin = `${this.id}-${meth}`;
284
+ log.trace(origin);
285
+
286
+ // if caching
287
+ if (this.caching) {
288
+ // Make the call - verifyCapability(entityType, actionType, entityId, callback)
289
+ return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (results, error) => {
290
+ if (error) {
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
+ });
335
+ }
336
+
337
+ // if no entity id
338
+ if (!entityId) {
339
+ // need to check the cache again since it has been updated
340
+ return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
341
+ if (verror) {
342
+ return callback(null, verror);
343
+ }
344
+
345
+ return this.capabilityResults(vcapable, callback);
346
+ });
347
+ }
348
+
349
+ // if not caching
350
+ switch (entityType) {
351
+ case 'template_entity': {
352
+ // need to get the entities to check
353
+ return this.getEntities(null, null, null, null, (data, err) => {
354
+ if (err) {
355
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
356
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
357
+ return callback(null, errorObj);
358
+ }
359
+
360
+ // need to check the cache again since it has been updated
361
+ return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
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];
386
+
387
+ // put false in array for all entities
388
+ if (Array.isArray(entityId)) {
389
+ for (let e = 1; e < entityId.length; e += 1) {
390
+ result.push(false);
391
+ }
392
+ }
393
+
394
+ return callback(result);
395
+ }
396
+ }
397
+ }
398
+
399
+ /**
400
+ * @summary Updates the cache for all entities by call the get All entity method
401
+ *
402
+ * @function updateEntityCache
403
+ *
404
+ */
405
+ updateEntityCache() {
406
+ const origin = `${this.id}-adapter-updateEntityCache`;
407
+ log.trace(origin);
408
+
409
+ if (this.caching) {
410
+ // if the cache is invalid, update the cache
411
+ this.getEntities(null, null, null, null, (data, err) => {
412
+ if (err) {
413
+ log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
414
+ }
415
+ });
416
+ }
417
+ }
418
+
419
+ /**
420
+ * Makes the requested generic call
421
+ *
422
+ * @function genericAdapterRequest
423
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
424
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
425
+ * @param {Object} queryData - the parameters to be put on the url (optional).
426
+ * Can be a stringified Object.
427
+ * @param {Object} requestBody - the body to add to the request (optional).
428
+ * Can be a stringified Object.
429
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
430
+ * Can be a stringified Object.
431
+ * @param {getCallback} callback - a callback function to return the result (Generics)
432
+ * or the error
433
+ */
434
+ genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
435
+ const meth = 'adapter-genericAdapterRequest';
436
+ const origin = `${this.id}-${meth}`;
437
+ log.trace(origin);
438
+
439
+ if (this.suspended && this.suspendMode === 'error') {
440
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
441
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
442
+ return callback(null, errorObj);
443
+ }
444
+
445
+ /* HERE IS WHERE YOU VALIDATE DATA */
446
+ if (uriPath === undefined || uriPath === null || uriPath === '') {
447
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
448
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
449
+ return callback(null, errorObj);
450
+ }
451
+ if (restMethod === undefined || restMethod === null || restMethod === '') {
452
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
453
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
454
+ return callback(null, errorObj);
455
+ }
456
+
457
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
458
+ // remove any leading / and split the uripath into path variables
459
+ let myPath = uriPath;
460
+ while (myPath.indexOf('/') === 0) {
461
+ myPath = myPath.substring(1);
462
+ }
463
+ const pathVars = myPath.split('/');
464
+ const queryParamsAvailable = queryData;
465
+ const queryParams = {};
466
+ const bodyVars = requestBody;
467
+
468
+ // loop in template. long callback arg name to avoid identifier conflicts
469
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
470
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
471
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
472
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
473
+ }
474
+ });
475
+
476
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
477
+ const reqObj = {
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
+ }
487
+
488
+ // determine the call and return flag
489
+ let action = 'getGenerics';
490
+ let returnF = true;
491
+ if (restMethod.toUpperCase() === 'POST') {
492
+ action = 'createGeneric';
493
+ } else if (restMethod.toUpperCase() === 'PUT') {
494
+ action = 'updateGeneric';
495
+ } else if (restMethod.toUpperCase() === 'PATCH') {
496
+ action = 'patchGeneric';
497
+ } else if (restMethod.toUpperCase() === 'DELETE') {
498
+ action = 'deleteGeneric';
499
+ returnF = false;
500
+ }
501
+
502
+ try {
503
+ // Make the call -
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
+ }
517
+
518
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
519
+ // return the response
520
+ return callback(irReturnData, null);
521
+ });
522
+ } catch (ex) {
523
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
524
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
525
+ return callback(null, errorObj);
526
+ }
527
+ }
528
+
529
+ /**
530
+ * @callback healthCallback
531
+ * @param {Object} result - the result of the get request (contains an id and a status)
532
+ */
533
+ /**
534
+ * @callback getCallback
535
+ * @param {Object} result - the result of the get request (entity/ies)
536
+ * @param {String} error - any error that occurred
537
+ */
538
+ /**
539
+ * @callback createCallback
540
+ * @param {Object} item - the newly created entity
541
+ * @param {String} error - any error that occurred
542
+ */
543
+ /**
544
+ * @callback updateCallback
545
+ * @param {String} status - the status of the update action
546
+ * @param {String} error - any error that occurred
547
+ */
548
+ /**
549
+ * @callback deleteCallback
550
+ * @param {String} status - the status of the delete action
551
+ * @param {String} error - any error that occurred
552
+ */
553
+
554
+ /**
555
+ * @function pipelinesCreate
556
+ * @pronghornType method
557
+ * @name pipelinesCreate
558
+ * @summary Create a pipeline.
559
+ *
560
+ * @param {string} organization - The name of the Azure DevOps organization.
561
+ * @param {object} body - Input parameters.
562
+ * @param {string} project - Project ID or project name
563
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
564
+ * @param {getCallback} callback - a callback function to return the result
565
+ * @return {object} results - An object containing the response of the action
566
+ *
567
+ * @route {POST} /pipelinesCreate
568
+ * @roles admin
569
+ * @task true
570
+ */
571
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
572
+ pipelinesCreate(organization, body, project, apiVersion, callback) {
573
+ const meth = 'adapter-pipelinesCreate';
574
+ const origin = `${this.id}-${meth}`;
575
+ log.trace(origin);
576
+
577
+ if (this.suspended && this.suspendMode === 'error') {
578
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
579
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
580
+ return callback(null, errorObj);
581
+ }
582
+
583
+ /* HERE IS WHERE YOU VALIDATE DATA */
584
+ if (organization === undefined || organization === null || organization === '') {
585
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
586
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
587
+ return callback(null, errorObj);
588
+ }
589
+ if (body === undefined || body === null || body === '') {
590
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
591
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
592
+ return callback(null, errorObj);
593
+ }
594
+ if (project === undefined || project === null || project === '') {
595
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
596
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
597
+ return callback(null, errorObj);
598
+ }
599
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
600
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
601
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
602
+ return callback(null, errorObj);
603
+ }
604
+
605
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
606
+ const queryParamsAvailable = { apiVersion };
607
+ const queryParams = {};
608
+ const pathVars = [organization, project];
609
+ const bodyVars = body;
610
+
611
+ // loop in template. long callback arg name to avoid identifier conflicts
612
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
613
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
614
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
615
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
616
+ }
617
+ });
618
+
619
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
620
+ // see adapter code documentation for more information on the request object's fields
621
+ const reqObj = {
622
+ payload: bodyVars,
623
+ uriPathVars: pathVars,
624
+ uriQuery: queryParams
625
+ };
626
+
627
+ try {
628
+ // Make the call -
629
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
630
+ return this.requestHandlerInst.identifyRequest('Pipelines', 'pipelinesCreate', reqObj, true, (irReturnData, irReturnError) => {
631
+ // if we received an error or their is no response on the results
632
+ // return an error
633
+ if (irReturnError) {
634
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
635
+ return callback(null, irReturnError);
636
+ }
637
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
638
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['pipelinesCreate'], null, null, null);
639
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
640
+ return callback(null, errorObj);
641
+ }
642
+
643
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
644
+ // return the response
645
+ return callback(irReturnData, null);
646
+ });
647
+ } catch (ex) {
648
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
649
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
650
+ return callback(null, errorObj);
651
+ }
652
+ }
653
+
654
+ /**
655
+ * @function pipelinesList
656
+ * @pronghornType method
657
+ * @name pipelinesList
658
+ * @summary Get a list of pipelines.
659
+ *
660
+ * @param {string} organization - The name of the Azure DevOps organization.
661
+ * @param {string} project - Project ID or project name
662
+ * @param {string} [orderBy] - A sort expression. Defaults to &#34;name asc&#34;
663
+ * @param {number} [top] - The maximum number of pipelines to return
664
+ * @param {string} [continuationToken] - A continuation token from a previous request, to retrieve the next page of results
665
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
666
+ * @param {getCallback} callback - a callback function to return the result
667
+ * @return {object} results - An object containing the response of the action
668
+ *
669
+ * @route {POST} /pipelinesList
670
+ * @roles admin
671
+ * @task true
672
+ */
673
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
674
+ pipelinesList(organization, project, orderBy, top, continuationToken, apiVersion, callback) {
675
+ const meth = 'adapter-pipelinesList';
676
+ const origin = `${this.id}-${meth}`;
677
+ log.trace(origin);
678
+
679
+ if (this.suspended && this.suspendMode === 'error') {
680
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
681
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
682
+ return callback(null, errorObj);
683
+ }
684
+
685
+ /* HERE IS WHERE YOU VALIDATE DATA */
686
+ if (organization === undefined || organization === null || organization === '') {
687
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
688
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
689
+ return callback(null, errorObj);
690
+ }
691
+ if (project === undefined || project === null || project === '') {
692
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
693
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
694
+ return callback(null, errorObj);
695
+ }
696
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
697
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
698
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
699
+ return callback(null, errorObj);
700
+ }
701
+
702
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
703
+ const queryParamsAvailable = { orderBy, top, continuationToken, apiVersion };
704
+ const queryParams = {};
705
+ const pathVars = [organization, project];
706
+ const bodyVars = {};
707
+
708
+ // loop in template. long callback arg name to avoid identifier conflicts
709
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
710
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
711
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
712
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
713
+ }
714
+ });
715
+
716
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
717
+ // see adapter code documentation for more information on the request object's fields
718
+ const reqObj = {
719
+ payload: bodyVars,
720
+ uriPathVars: pathVars,
721
+ uriQuery: queryParams
722
+ };
723
+
724
+ try {
725
+ // Make the call -
726
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
727
+ return this.requestHandlerInst.identifyRequest('Pipelines', 'pipelinesList', reqObj, true, (irReturnData, irReturnError) => {
728
+ // if we received an error or their is no response on the results
729
+ // return an error
730
+ if (irReturnError) {
731
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
732
+ return callback(null, irReturnError);
733
+ }
734
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
735
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['pipelinesList'], null, null, null);
736
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
737
+ return callback(null, errorObj);
738
+ }
739
+
740
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
741
+ // return the response
742
+ return callback(irReturnData, null);
743
+ });
744
+ } catch (ex) {
745
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
746
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
747
+ return callback(null, errorObj);
748
+ }
749
+ }
750
+
751
+ /**
752
+ * @function pipelinesGet
753
+ * @pronghornType method
754
+ * @name pipelinesGet
755
+ * @summary Gets a pipeline, optionally at the specified version
756
+ *
757
+ * @param {string} organization - The name of the Azure DevOps organization.
758
+ * @param {string} project - Project ID or project name
759
+ * @param {number} pipelineId - The pipeline ID
760
+ * @param {number} [pipelineVersion] - The pipeline version
761
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
762
+ * @param {getCallback} callback - a callback function to return the result
763
+ * @return {object} results - An object containing the response of the action
764
+ *
765
+ * @route {POST} /pipelinesGet
766
+ * @roles admin
767
+ * @task true
768
+ */
769
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
770
+ pipelinesGet(organization, project, pipelineId, pipelineVersion, apiVersion, callback) {
771
+ const meth = 'adapter-pipelinesGet';
772
+ const origin = `${this.id}-${meth}`;
773
+ log.trace(origin);
774
+
775
+ if (this.suspended && this.suspendMode === 'error') {
776
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
777
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
778
+ return callback(null, errorObj);
779
+ }
780
+
781
+ /* HERE IS WHERE YOU VALIDATE DATA */
782
+ if (organization === undefined || organization === null || organization === '') {
783
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
784
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
785
+ return callback(null, errorObj);
786
+ }
787
+ if (project === undefined || project === null || project === '') {
788
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
789
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
790
+ return callback(null, errorObj);
791
+ }
792
+ if (pipelineId === undefined || pipelineId === null || pipelineId === '') {
793
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pipelineId'], null, null, null);
794
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
795
+ return callback(null, errorObj);
796
+ }
797
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
798
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
799
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
800
+ return callback(null, errorObj);
801
+ }
802
+
803
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
804
+ const queryParamsAvailable = { pipelineVersion, apiVersion };
805
+ const queryParams = {};
806
+ const pathVars = [organization, project, pipelineId];
807
+ const bodyVars = {};
808
+
809
+ // loop in template. long callback arg name to avoid identifier conflicts
810
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
811
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
812
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
813
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
814
+ }
815
+ });
816
+
817
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
818
+ // see adapter code documentation for more information on the request object's fields
819
+ const reqObj = {
820
+ payload: bodyVars,
821
+ uriPathVars: pathVars,
822
+ uriQuery: queryParams
823
+ };
824
+
825
+ try {
826
+ // Make the call -
827
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
828
+ return this.requestHandlerInst.identifyRequest('Pipelines', 'pipelinesGet', reqObj, true, (irReturnData, irReturnError) => {
829
+ // if we received an error or their is no response on the results
830
+ // return an error
831
+ if (irReturnError) {
832
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
833
+ return callback(null, irReturnError);
834
+ }
835
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
836
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['pipelinesGet'], null, null, null);
837
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
838
+ return callback(null, errorObj);
839
+ }
840
+
841
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
842
+ // return the response
843
+ return callback(irReturnData, null);
844
+ });
845
+ } catch (ex) {
846
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
847
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
848
+ return callback(null, errorObj);
849
+ }
850
+ }
851
+
852
+ /**
853
+ * @function previewPreview
854
+ * @pronghornType method
855
+ * @name previewPreview
856
+ * @summary Queues a dry run of the pipeline and returns an object containing the final yaml.
857
+ *
858
+ * @param {string} organization - The name of the Azure DevOps organization.
859
+ * @param {object} body - Optional additional parameters for this run.
860
+ * @param {string} project - Project ID or project name
861
+ * @param {number} pipelineId - The pipeline ID.
862
+ * @param {number} [pipelineVersion] - The pipeline version.
863
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
864
+ * @param {getCallback} callback - a callback function to return the result
865
+ * @return {object} results - An object containing the response of the action
866
+ *
867
+ * @route {POST} /previewPreview
868
+ * @roles admin
869
+ * @task true
870
+ */
871
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
872
+ previewPreview(organization, body, project, pipelineId, pipelineVersion, apiVersion, callback) {
873
+ const meth = 'adapter-previewPreview';
874
+ const origin = `${this.id}-${meth}`;
875
+ log.trace(origin);
876
+
877
+ if (this.suspended && this.suspendMode === 'error') {
878
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
879
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
880
+ return callback(null, errorObj);
881
+ }
882
+
883
+ /* HERE IS WHERE YOU VALIDATE DATA */
884
+ if (organization === undefined || organization === null || organization === '') {
885
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
886
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
887
+ return callback(null, errorObj);
888
+ }
889
+ if (body === undefined || body === null || body === '') {
890
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
891
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
892
+ return callback(null, errorObj);
893
+ }
894
+ if (project === undefined || project === null || project === '') {
895
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
896
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
897
+ return callback(null, errorObj);
898
+ }
899
+ if (pipelineId === undefined || pipelineId === null || pipelineId === '') {
900
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pipelineId'], null, null, null);
901
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
902
+ return callback(null, errorObj);
903
+ }
904
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
905
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
906
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
907
+ return callback(null, errorObj);
908
+ }
909
+
910
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
911
+ const queryParamsAvailable = { pipelineVersion, apiVersion };
912
+ const queryParams = {};
913
+ const pathVars = [organization, project, pipelineId];
914
+ const bodyVars = body;
915
+
916
+ // loop in template. long callback arg name to avoid identifier conflicts
917
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
918
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
919
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
920
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
921
+ }
922
+ });
923
+
924
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
925
+ // see adapter code documentation for more information on the request object's fields
926
+ const reqObj = {
927
+ payload: bodyVars,
928
+ uriPathVars: pathVars,
929
+ uriQuery: queryParams
930
+ };
931
+
932
+ try {
933
+ // Make the call -
934
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
935
+ return this.requestHandlerInst.identifyRequest('Preview', 'previewPreview', reqObj, true, (irReturnData, irReturnError) => {
936
+ // if we received an error or their is no response on the results
937
+ // return an error
938
+ if (irReturnError) {
939
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
940
+ return callback(null, irReturnError);
941
+ }
942
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
943
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['previewPreview'], null, null, null);
944
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
945
+ return callback(null, errorObj);
946
+ }
947
+
948
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
949
+ // return the response
950
+ return callback(irReturnData, null);
951
+ });
952
+ } catch (ex) {
953
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
954
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
955
+ return callback(null, errorObj);
956
+ }
957
+ }
958
+
959
+ /**
960
+ * @function runsList
961
+ * @pronghornType method
962
+ * @name runsList
963
+ * @summary Gets top 10000 runs for a particular pipeline.
964
+ *
965
+ * @param {string} organization - The name of the Azure DevOps organization.
966
+ * @param {string} project - Project ID or project name
967
+ * @param {number} pipelineId - The pipeline id
968
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
969
+ * @param {getCallback} callback - a callback function to return the result
970
+ * @return {object} results - An object containing the response of the action
971
+ *
972
+ * @route {POST} /runsList
973
+ * @roles admin
974
+ * @task true
975
+ */
976
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
977
+ runsList(organization, project, pipelineId, apiVersion, callback) {
978
+ const meth = 'adapter-runsList';
979
+ const origin = `${this.id}-${meth}`;
980
+ log.trace(origin);
981
+
982
+ if (this.suspended && this.suspendMode === 'error') {
983
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
984
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
985
+ return callback(null, errorObj);
986
+ }
987
+
988
+ /* HERE IS WHERE YOU VALIDATE DATA */
989
+ if (organization === undefined || organization === null || organization === '') {
990
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
991
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
992
+ return callback(null, errorObj);
993
+ }
994
+ if (project === undefined || project === null || project === '') {
995
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
996
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
997
+ return callback(null, errorObj);
998
+ }
999
+ if (pipelineId === undefined || pipelineId === null || pipelineId === '') {
1000
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pipelineId'], null, null, null);
1001
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1002
+ return callback(null, errorObj);
1003
+ }
1004
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
1005
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
1006
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1007
+ return callback(null, errorObj);
1008
+ }
1009
+
1010
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1011
+ const queryParamsAvailable = { apiVersion };
1012
+ const queryParams = {};
1013
+ const pathVars = [organization, project, pipelineId];
1014
+ const bodyVars = {};
1015
+
1016
+ // loop in template. long callback arg name to avoid identifier conflicts
1017
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1018
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1019
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1020
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1021
+ }
1022
+ });
1023
+
1024
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1025
+ // see adapter code documentation for more information on the request object's fields
1026
+ const reqObj = {
1027
+ payload: bodyVars,
1028
+ uriPathVars: pathVars,
1029
+ uriQuery: queryParams
1030
+ };
1031
+
1032
+ try {
1033
+ // Make the call -
1034
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1035
+ return this.requestHandlerInst.identifyRequest('Runs', 'runsList', reqObj, true, (irReturnData, irReturnError) => {
1036
+ // if we received an error or their is no response on the results
1037
+ // return an error
1038
+ if (irReturnError) {
1039
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1040
+ return callback(null, irReturnError);
1041
+ }
1042
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1043
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['runsList'], null, null, null);
1044
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1045
+ return callback(null, errorObj);
1046
+ }
1047
+
1048
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1049
+ // return the response
1050
+ return callback(irReturnData, null);
1051
+ });
1052
+ } catch (ex) {
1053
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1054
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1055
+ return callback(null, errorObj);
1056
+ }
1057
+ }
1058
+
1059
+ /**
1060
+ * @function runsRunPipeline
1061
+ * @pronghornType method
1062
+ * @name runsRunPipeline
1063
+ * @summary Runs a pipeline.
1064
+ *
1065
+ * @param {string} organization - The name of the Azure DevOps organization.
1066
+ * @param {object} body - Optional additional parameters for this run.
1067
+ * @param {string} project - Project ID or project name
1068
+ * @param {number} pipelineId - The pipeline ID.
1069
+ * @param {number} [pipelineVersion] - The pipeline version.
1070
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
1071
+ * @param {getCallback} callback - a callback function to return the result
1072
+ * @return {object} results - An object containing the response of the action
1073
+ *
1074
+ * @route {POST} /runsRunPipeline
1075
+ * @roles admin
1076
+ * @task true
1077
+ */
1078
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1079
+ runsRunPipeline(organization, body, project, pipelineId, pipelineVersion, apiVersion, callback) {
1080
+ const meth = 'adapter-runsRunPipeline';
1081
+ const origin = `${this.id}-${meth}`;
1082
+ log.trace(origin);
1083
+
1084
+ if (this.suspended && this.suspendMode === 'error') {
1085
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1086
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1087
+ return callback(null, errorObj);
1088
+ }
1089
+
1090
+ /* HERE IS WHERE YOU VALIDATE DATA */
1091
+ if (organization === undefined || organization === null || organization === '') {
1092
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
1093
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1094
+ return callback(null, errorObj);
1095
+ }
1096
+ if (body === undefined || body === null || body === '') {
1097
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1098
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1099
+ return callback(null, errorObj);
1100
+ }
1101
+ if (project === undefined || project === null || project === '') {
1102
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
1103
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1104
+ return callback(null, errorObj);
1105
+ }
1106
+ if (pipelineId === undefined || pipelineId === null || pipelineId === '') {
1107
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pipelineId'], null, null, null);
1108
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1109
+ return callback(null, errorObj);
1110
+ }
1111
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
1112
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
1113
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1114
+ return callback(null, errorObj);
1115
+ }
1116
+
1117
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1118
+ const queryParamsAvailable = { pipelineVersion, apiVersion };
1119
+ const queryParams = {};
1120
+ const pathVars = [organization, project, pipelineId];
1121
+ const bodyVars = body;
1122
+
1123
+ // loop in template. long callback arg name to avoid identifier conflicts
1124
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1125
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1126
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1127
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1128
+ }
1129
+ });
1130
+
1131
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1132
+ // see adapter code documentation for more information on the request object's fields
1133
+ const reqObj = {
1134
+ payload: bodyVars,
1135
+ uriPathVars: pathVars,
1136
+ uriQuery: queryParams
1137
+ };
1138
+
1139
+ try {
1140
+ // Make the call -
1141
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1142
+ return this.requestHandlerInst.identifyRequest('Runs', 'runsRunPipeline', reqObj, true, (irReturnData, irReturnError) => {
1143
+ // if we received an error or their is no response on the results
1144
+ // return an error
1145
+ if (irReturnError) {
1146
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1147
+ return callback(null, irReturnError);
1148
+ }
1149
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1150
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['runsRunPipeline'], null, null, null);
1151
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1152
+ return callback(null, errorObj);
1153
+ }
1154
+
1155
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1156
+ // return the response
1157
+ return callback(irReturnData, null);
1158
+ });
1159
+ } catch (ex) {
1160
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1161
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1162
+ return callback(null, errorObj);
1163
+ }
1164
+ }
1165
+
1166
+ /**
1167
+ * @function runsGet
1168
+ * @pronghornType method
1169
+ * @name runsGet
1170
+ * @summary Gets a run for a particular pipeline.
1171
+ *
1172
+ * @param {string} organization - The name of the Azure DevOps organization.
1173
+ * @param {string} project - Project ID or project name
1174
+ * @param {number} pipelineId - The pipeline id
1175
+ * @param {number} runId - The run id
1176
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
1177
+ * @param {getCallback} callback - a callback function to return the result
1178
+ * @return {object} results - An object containing the response of the action
1179
+ *
1180
+ * @route {POST} /runsGet
1181
+ * @roles admin
1182
+ * @task true
1183
+ */
1184
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1185
+ runsGet(organization, project, pipelineId, runId, apiVersion, callback) {
1186
+ const meth = 'adapter-runsGet';
1187
+ const origin = `${this.id}-${meth}`;
1188
+ log.trace(origin);
1189
+
1190
+ if (this.suspended && this.suspendMode === 'error') {
1191
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1192
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1193
+ return callback(null, errorObj);
1194
+ }
1195
+
1196
+ /* HERE IS WHERE YOU VALIDATE DATA */
1197
+ if (organization === undefined || organization === null || organization === '') {
1198
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
1199
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1200
+ return callback(null, errorObj);
1201
+ }
1202
+ if (project === undefined || project === null || project === '') {
1203
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
1204
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1205
+ return callback(null, errorObj);
1206
+ }
1207
+ if (pipelineId === undefined || pipelineId === null || pipelineId === '') {
1208
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pipelineId'], null, null, null);
1209
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1210
+ return callback(null, errorObj);
1211
+ }
1212
+ if (runId === undefined || runId === null || runId === '') {
1213
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['runId'], null, null, null);
1214
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1215
+ return callback(null, errorObj);
1216
+ }
1217
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
1218
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
1219
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1220
+ return callback(null, errorObj);
1221
+ }
1222
+
1223
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1224
+ const queryParamsAvailable = { apiVersion };
1225
+ const queryParams = {};
1226
+ const pathVars = [organization, project, pipelineId, runId];
1227
+ const bodyVars = {};
1228
+
1229
+ // loop in template. long callback arg name to avoid identifier conflicts
1230
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1231
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1232
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1233
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1234
+ }
1235
+ });
1236
+
1237
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1238
+ // see adapter code documentation for more information on the request object's fields
1239
+ const reqObj = {
1240
+ payload: bodyVars,
1241
+ uriPathVars: pathVars,
1242
+ uriQuery: queryParams
1243
+ };
1244
+
1245
+ try {
1246
+ // Make the call -
1247
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1248
+ return this.requestHandlerInst.identifyRequest('Runs', 'runsGet', reqObj, true, (irReturnData, irReturnError) => {
1249
+ // if we received an error or their is no response on the results
1250
+ // return an error
1251
+ if (irReturnError) {
1252
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1253
+ return callback(null, irReturnError);
1254
+ }
1255
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1256
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['runsGet'], null, null, null);
1257
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1258
+ return callback(null, errorObj);
1259
+ }
1260
+
1261
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1262
+ // return the response
1263
+ return callback(irReturnData, null);
1264
+ });
1265
+ } catch (ex) {
1266
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1267
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1268
+ return callback(null, errorObj);
1269
+ }
1270
+ }
1271
+
1272
+ /**
1273
+ * @function artifactsGet
1274
+ * @pronghornType method
1275
+ * @name artifactsGet
1276
+ * @summary Get a specific artifact from a pipeline run
1277
+ *
1278
+ * @param {string} organization - The name of the Azure DevOps organization.
1279
+ * @param {string} project - Project ID or project name
1280
+ * @param {number} pipelineId - ID of the pipeline.
1281
+ * @param {number} runId - ID of the run of that pipeline.
1282
+ * @param {string} artifactName - Name of the artifact.
1283
+ * @param {string} [expand] - Expand options. Default is None.
1284
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
1285
+ * @param {getCallback} callback - a callback function to return the result
1286
+ * @return {object} results - An object containing the response of the action
1287
+ *
1288
+ * @route {POST} /artifactsGet
1289
+ * @roles admin
1290
+ * @task true
1291
+ */
1292
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1293
+ artifactsGet(organization, project, pipelineId, runId, artifactName, expand = 'none', apiVersion, callback) {
1294
+ const meth = 'adapter-artifactsGet';
1295
+ const origin = `${this.id}-${meth}`;
1296
+ log.trace(origin);
1297
+
1298
+ if (this.suspended && this.suspendMode === 'error') {
1299
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1300
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1301
+ return callback(null, errorObj);
1302
+ }
1303
+
1304
+ /* HERE IS WHERE YOU VALIDATE DATA */
1305
+ if (organization === undefined || organization === null || organization === '') {
1306
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
1307
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1308
+ return callback(null, errorObj);
1309
+ }
1310
+ if (project === undefined || project === null || project === '') {
1311
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
1312
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1313
+ return callback(null, errorObj);
1314
+ }
1315
+ if (pipelineId === undefined || pipelineId === null || pipelineId === '') {
1316
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pipelineId'], null, null, null);
1317
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1318
+ return callback(null, errorObj);
1319
+ }
1320
+ if (runId === undefined || runId === null || runId === '') {
1321
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['runId'], null, null, null);
1322
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1323
+ return callback(null, errorObj);
1324
+ }
1325
+ if (artifactName === undefined || artifactName === null || artifactName === '') {
1326
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['artifactName'], null, null, null);
1327
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1328
+ return callback(null, errorObj);
1329
+ }
1330
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
1331
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
1332
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1333
+ return callback(null, errorObj);
1334
+ }
1335
+
1336
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1337
+ const queryParamsAvailable = { artifactName, expand, apiVersion };
1338
+ const queryParams = {};
1339
+ const pathVars = [organization, project, pipelineId, runId];
1340
+ const bodyVars = {};
1341
+
1342
+ // loop in template. long callback arg name to avoid identifier conflicts
1343
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1344
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1345
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1346
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1347
+ }
1348
+ });
1349
+
1350
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1351
+ // see adapter code documentation for more information on the request object's fields
1352
+ const reqObj = {
1353
+ payload: bodyVars,
1354
+ uriPathVars: pathVars,
1355
+ uriQuery: queryParams
1356
+ };
1357
+
1358
+ try {
1359
+ // Make the call -
1360
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1361
+ return this.requestHandlerInst.identifyRequest('Artifacts', 'artifactsGet', reqObj, true, (irReturnData, irReturnError) => {
1362
+ // if we received an error or their is no response on the results
1363
+ // return an error
1364
+ if (irReturnError) {
1365
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1366
+ return callback(null, irReturnError);
1367
+ }
1368
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1369
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['artifactsGet'], null, null, null);
1370
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1371
+ return callback(null, errorObj);
1372
+ }
1373
+
1374
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1375
+ // return the response
1376
+ return callback(irReturnData, null);
1377
+ });
1378
+ } catch (ex) {
1379
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1380
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1381
+ return callback(null, errorObj);
1382
+ }
1383
+ }
1384
+
1385
+ /**
1386
+ * @function logsList
1387
+ * @pronghornType method
1388
+ * @name logsList
1389
+ * @summary Get a list of logs from a pipeline run.
1390
+ *
1391
+ * @param {string} organization - The name of the Azure DevOps organization.
1392
+ * @param {string} project - Project ID or project name
1393
+ * @param {number} pipelineId - ID of the pipeline.
1394
+ * @param {number} runId - ID of the run of that pipeline.
1395
+ * @param {string} [expand] - Expand options. Default is None.
1396
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
1397
+ * @param {getCallback} callback - a callback function to return the result
1398
+ * @return {object} results - An object containing the response of the action
1399
+ *
1400
+ * @route {POST} /logsList
1401
+ * @roles admin
1402
+ * @task true
1403
+ */
1404
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1405
+ logsList(organization, project, pipelineId, runId, expand = 'none', apiVersion, callback) {
1406
+ const meth = 'adapter-logsList';
1407
+ const origin = `${this.id}-${meth}`;
1408
+ log.trace(origin);
1409
+
1410
+ if (this.suspended && this.suspendMode === 'error') {
1411
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1412
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1413
+ return callback(null, errorObj);
1414
+ }
1415
+
1416
+ /* HERE IS WHERE YOU VALIDATE DATA */
1417
+ if (organization === undefined || organization === null || organization === '') {
1418
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
1419
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1420
+ return callback(null, errorObj);
1421
+ }
1422
+ if (project === undefined || project === null || project === '') {
1423
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
1424
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1425
+ return callback(null, errorObj);
1426
+ }
1427
+ if (pipelineId === undefined || pipelineId === null || pipelineId === '') {
1428
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pipelineId'], null, null, null);
1429
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1430
+ return callback(null, errorObj);
1431
+ }
1432
+ if (runId === undefined || runId === null || runId === '') {
1433
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['runId'], null, null, null);
1434
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1435
+ return callback(null, errorObj);
1436
+ }
1437
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
1438
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
1439
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1440
+ return callback(null, errorObj);
1441
+ }
1442
+
1443
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1444
+ const queryParamsAvailable = { expand, apiVersion };
1445
+ const queryParams = {};
1446
+ const pathVars = [organization, project, pipelineId, runId];
1447
+ const bodyVars = {};
1448
+
1449
+ // loop in template. long callback arg name to avoid identifier conflicts
1450
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1451
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1452
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1453
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1454
+ }
1455
+ });
1456
+
1457
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1458
+ // see adapter code documentation for more information on the request object's fields
1459
+ const reqObj = {
1460
+ payload: bodyVars,
1461
+ uriPathVars: pathVars,
1462
+ uriQuery: queryParams
1463
+ };
1464
+
1465
+ try {
1466
+ // Make the call -
1467
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1468
+ return this.requestHandlerInst.identifyRequest('Logs', 'logsList', reqObj, true, (irReturnData, irReturnError) => {
1469
+ // if we received an error or their is no response on the results
1470
+ // return an error
1471
+ if (irReturnError) {
1472
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1473
+ return callback(null, irReturnError);
1474
+ }
1475
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1476
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['logsList'], null, null, null);
1477
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1478
+ return callback(null, errorObj);
1479
+ }
1480
+
1481
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1482
+ // return the response
1483
+ return callback(irReturnData, null);
1484
+ });
1485
+ } catch (ex) {
1486
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1487
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1488
+ return callback(null, errorObj);
1489
+ }
1490
+ }
1491
+
1492
+ /**
1493
+ * @function logsGet
1494
+ * @pronghornType method
1495
+ * @name logsGet
1496
+ * @summary Get a specific log from a pipeline run
1497
+ *
1498
+ * @param {string} organization - The name of the Azure DevOps organization.
1499
+ * @param {string} project - Project ID or project name
1500
+ * @param {number} pipelineId - ID of the pipeline.
1501
+ * @param {number} runId - ID of the run of that pipeline.
1502
+ * @param {number} logId - ID of the log.
1503
+ * @param {string} [expand] - Expand options. Default is None.
1504
+ * @param {string} apiVersion - Version of the API to use. This should be set to &#39;6.1-preview.1&#39; to use this version of the api.
1505
+ * @param {getCallback} callback - a callback function to return the result
1506
+ * @return {object} results - An object containing the response of the action
1507
+ *
1508
+ * @route {POST} /logsGet
1509
+ * @roles admin
1510
+ * @task true
1511
+ */
1512
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1513
+ logsGet(organization, project, pipelineId, runId, logId, expand = 'none', apiVersion, callback) {
1514
+ const meth = 'adapter-logsGet';
1515
+ const origin = `${this.id}-${meth}`;
1516
+ log.trace(origin);
1517
+
1518
+ if (this.suspended && this.suspendMode === 'error') {
1519
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1520
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1521
+ return callback(null, errorObj);
1522
+ }
1523
+
1524
+ /* HERE IS WHERE YOU VALIDATE DATA */
1525
+ if (organization === undefined || organization === null || organization === '') {
1526
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['organization'], null, null, null);
1527
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1528
+ return callback(null, errorObj);
1529
+ }
1530
+ if (project === undefined || project === null || project === '') {
1531
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['project'], null, null, null);
1532
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1533
+ return callback(null, errorObj);
1534
+ }
1535
+ if (pipelineId === undefined || pipelineId === null || pipelineId === '') {
1536
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pipelineId'], null, null, null);
1537
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1538
+ return callback(null, errorObj);
1539
+ }
1540
+ if (runId === undefined || runId === null || runId === '') {
1541
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['runId'], null, null, null);
1542
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1543
+ return callback(null, errorObj);
1544
+ }
1545
+ if (logId === undefined || logId === null || logId === '') {
1546
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['logId'], null, null, null);
1547
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1548
+ return callback(null, errorObj);
1549
+ }
1550
+ if (apiVersion === undefined || apiVersion === null || apiVersion === '') {
1551
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiVersion'], null, null, null);
1552
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1553
+ return callback(null, errorObj);
1554
+ }
1555
+
1556
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1557
+ const queryParamsAvailable = { expand, apiVersion };
1558
+ const queryParams = {};
1559
+ const pathVars = [organization, project, pipelineId, runId, logId];
1560
+ const bodyVars = {};
1561
+
1562
+ // loop in template. long callback arg name to avoid identifier conflicts
1563
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1564
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1565
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1566
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1567
+ }
1568
+ });
1569
+
1570
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1571
+ // see adapter code documentation for more information on the request object's fields
1572
+ const reqObj = {
1573
+ payload: bodyVars,
1574
+ uriPathVars: pathVars,
1575
+ uriQuery: queryParams
1576
+ };
1577
+
1578
+ try {
1579
+ // Make the call -
1580
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1581
+ return this.requestHandlerInst.identifyRequest('Logs', 'logsGet', reqObj, true, (irReturnData, irReturnError) => {
1582
+ // if we received an error or their is no response on the results
1583
+ // return an error
1584
+ if (irReturnError) {
1585
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1586
+ return callback(null, irReturnError);
1587
+ }
1588
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1589
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['logsGet'], null, null, null);
1590
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1591
+ return callback(null, errorObj);
1592
+ }
1593
+
1594
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1595
+ // return the response
1596
+ return callback(irReturnData, null);
1597
+ });
1598
+ } catch (ex) {
1599
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1600
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1601
+ return callback(null, errorObj);
1602
+ }
1603
+ }
1604
+ }
1605
+
1606
+ module.exports = AzureDevops;