Skip to content

Commit 1351c2c

Browse files
[Azure DevOps Node API] Add support of the pipelines API (#590)
* M236 API updates - Add new endpoints * M236 API updates - Fix types * M236 API updates - Add pipelines api sample * M236 API updates - Formating * M236 API updates - Remove legacy method
1 parent 00d544f commit 1351c2c

25 files changed

+2471
-247
lines changed

api/AlertApi.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface IAlertApi extends basem.ClientApiBase {
2323
getAlertSarif(project: string, alertId: number, repository: string, ref?: string, expand?: AlertInterfaces.ExpandOption): Promise<string>;
2424
updateAlert(stateUpdate: AlertInterfaces.AlertStateUpdate, project: string, alertId: number, repository: string): Promise<AlertInterfaces.Alert>;
2525
getAlertInstances(project: string, alertId: number, repository: string, ref?: string): Promise<AlertInterfaces.AlertAnalysisInstance[]>;
26+
updateAlertsMetadata(alertsMetadata: AlertInterfaces.AlertMetadata[], project: string, repository: string): Promise<AlertInterfaces.AlertMetadataChange[]>;
2627
uploadSarif(customHeaders: any, contentStream: NodeJS.ReadableStream, project: string, repository: string): Promise<number>;
2728
getUxFilters(project: string, repository: string, alertType: AlertInterfaces.AlertType): Promise<AlertInterfaces.UxFilters>;
2829
getSarif(sarifId: number): Promise<AlertInterfaces.SarifUploadStatus>;
@@ -310,6 +311,52 @@ export class AlertApi extends basem.ClientApiBase implements IAlertApi {
310311
});
311312
}
312313

314+
/**
315+
* Update alert metadata associations.
316+
*
317+
* @param {AlertInterfaces.AlertMetadata[]} alertsMetadata - A list of metadata to associate with alerts.
318+
* @param {string} project - Project ID or project name
319+
* @param {string} repository - The name or ID of the repository.
320+
*/
321+
public async updateAlertsMetadata(
322+
alertsMetadata: AlertInterfaces.AlertMetadata[],
323+
project: string,
324+
repository: string
325+
): Promise<AlertInterfaces.AlertMetadataChange[]> {
326+
327+
return new Promise<AlertInterfaces.AlertMetadataChange[]>(async (resolve, reject) => {
328+
let routeValues: any = {
329+
project: project,
330+
repository: repository
331+
};
332+
333+
try {
334+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
335+
"7.2-preview.1",
336+
"Alert",
337+
"65de4b84-7519-4ae8-8623-175f79b49b80",
338+
routeValues);
339+
340+
let url: string = verData.requestUrl!;
341+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
342+
verData.apiVersion);
343+
344+
let res: restm.IRestResponse<AlertInterfaces.AlertMetadataChange[]>;
345+
res = await this.rest.update<AlertInterfaces.AlertMetadataChange[]>(url, alertsMetadata, options);
346+
347+
let ret = this.formatResponse(res.result,
348+
AlertInterfaces.TypeInfo.AlertMetadataChange,
349+
true);
350+
351+
resolve(ret);
352+
353+
}
354+
catch (err) {
355+
reject(err);
356+
}
357+
});
358+
}
359+
313360
/**
314361
* Upload a Sarif containing security alerts
315362
*

api/CIXApi.ts

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
/*
2+
* ---------------------------------------------------------
3+
* Copyright(C) Microsoft Corporation. All rights reserved.
4+
* ---------------------------------------------------------
5+
*
6+
* ---------------------------------------------------------
7+
* Generated file, DO NOT EDIT
8+
* ---------------------------------------------------------
9+
*/
10+
11+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
12+
13+
import * as restm from 'typed-rest-client/RestClient';
14+
import vsom = require('./VsoClient');
15+
import basem = require('./ClientApiBases');
16+
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
17+
import CIXInterfaces = require("./interfaces/CIXInterfaces");
18+
import OperationsInterfaces = require("./interfaces/common/OperationsInterfaces");
19+
20+
export interface ICixApi extends basem.ClientApiBase {
21+
getConfigurations(project: string, repositoryType?: string, repositoryId?: string, branch?: string, serviceConnectionId?: string): Promise<CIXInterfaces.ConfigurationFile[]>;
22+
createProjectConnection(createConnectionInputs: CIXInterfaces.CreatePipelineConnectionInputs, project: string): Promise<CIXInterfaces.PipelineConnection>;
23+
getDetectedBuildFrameworks(project: string, repositoryType?: string, repositoryId?: string, branch?: string, detectionType?: CIXInterfaces.BuildFrameworkDetectionType, serviceConnectionId?: string): Promise<CIXInterfaces.DetectedBuildFramework[]>;
24+
createResources(creationParameters: { [key: string] : CIXInterfaces.ResourceCreationParameter; }, project: string): Promise<CIXInterfaces.CreatedResources>;
25+
}
26+
27+
export class CixApi extends basem.ClientApiBase implements ICixApi {
28+
constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], options?: VsoBaseInterfaces.IRequestOptions) {
29+
super(baseUrl, handlers, 'node-Pipelines-api', options);
30+
}
31+
32+
/**
33+
* Gets a list of existing configuration files for the given repository.
34+
*
35+
* @param {string} project - Project ID or project name
36+
* @param {string} repositoryType - The type of the repository such as GitHub, TfsGit (i.e. Azure Repos), Bitbucket, etc.
37+
* @param {string} repositoryId - The vendor-specific identifier or the name of the repository, e.g. Microsoft/vscode (GitHub) or e9d82045-ddba-4e01-a63d-2ab9f040af62 (Azure Repos)
38+
* @param {string} branch - The repository branch where to look for the configuration file.
39+
* @param {string} serviceConnectionId - If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TfsGit (i.e. Azure Repos).
40+
*/
41+
public async getConfigurations(
42+
project: string,
43+
repositoryType?: string,
44+
repositoryId?: string,
45+
branch?: string,
46+
serviceConnectionId?: string
47+
): Promise<CIXInterfaces.ConfigurationFile[]> {
48+
49+
return new Promise<CIXInterfaces.ConfigurationFile[]>(async (resolve, reject) => {
50+
let routeValues: any = {
51+
project: project
52+
};
53+
54+
let queryValues: any = {
55+
repositoryType: repositoryType,
56+
repositoryId: repositoryId,
57+
branch: branch,
58+
serviceConnectionId: serviceConnectionId,
59+
};
60+
61+
try {
62+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
63+
"7.2-preview.1",
64+
"pipelines",
65+
"8fc87684-9ebc-4c37-ab92-f4ac4a58cb3a",
66+
routeValues,
67+
queryValues);
68+
69+
let url: string = verData.requestUrl!;
70+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
71+
verData.apiVersion);
72+
73+
let res: restm.IRestResponse<CIXInterfaces.ConfigurationFile[]>;
74+
res = await this.rest.get<CIXInterfaces.ConfigurationFile[]>(url, options);
75+
76+
let ret = this.formatResponse(res.result,
77+
null,
78+
true);
79+
80+
resolve(ret);
81+
82+
}
83+
catch (err) {
84+
reject(err);
85+
}
86+
});
87+
}
88+
89+
/**
90+
* Creates a new Pipeline connection between the provider installation and the specified project. Returns the PipelineConnection object created.
91+
*
92+
* @param {CIXInterfaces.CreatePipelineConnectionInputs} createConnectionInputs
93+
* @param {string} project
94+
*/
95+
public async createProjectConnection(
96+
createConnectionInputs: CIXInterfaces.CreatePipelineConnectionInputs,
97+
project: string
98+
): Promise<CIXInterfaces.PipelineConnection> {
99+
if (project == null) {
100+
throw new TypeError('project can not be null or undefined');
101+
}
102+
103+
return new Promise<CIXInterfaces.PipelineConnection>(async (resolve, reject) => {
104+
let routeValues: any = {
105+
};
106+
107+
let queryValues: any = {
108+
project: project,
109+
};
110+
111+
try {
112+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
113+
"7.2-preview.1",
114+
"pipelines",
115+
"00df4879-9216-45d5-b38d-4a487b626b2c",
116+
routeValues,
117+
queryValues);
118+
119+
let url: string = verData.requestUrl!;
120+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
121+
verData.apiVersion);
122+
123+
let res: restm.IRestResponse<CIXInterfaces.PipelineConnection>;
124+
res = await this.rest.create<CIXInterfaces.PipelineConnection>(url, createConnectionInputs, options);
125+
126+
let ret = this.formatResponse(res.result,
127+
null,
128+
false);
129+
130+
resolve(ret);
131+
132+
}
133+
catch (err) {
134+
reject(err);
135+
}
136+
});
137+
}
138+
139+
/**
140+
* Returns a list of build frameworks that best match the given repository based on its contents.
141+
*
142+
* @param {string} project - Project ID or project name
143+
* @param {string} repositoryType - The type of the repository such as GitHub, TfsGit (i.e. Azure Repos), Bitbucket, etc.
144+
* @param {string} repositoryId - The vendor-specific identifier or the name of the repository, e.g. Microsoft/vscode (GitHub) or e9d82045-ddba-4e01-a63d-2ab9f040af62 (Azure Repos)
145+
* @param {string} branch - The repository branch to detect build frameworks for.
146+
* @param {CIXInterfaces.BuildFrameworkDetectionType} detectionType
147+
* @param {string} serviceConnectionId - If specified, the ID of the service endpoint to query. Can only be omitted for providers that do not use service endpoints, e.g. TfsGit (i.e. Azure Repos).
148+
*/
149+
public async getDetectedBuildFrameworks(
150+
project: string,
151+
repositoryType?: string,
152+
repositoryId?: string,
153+
branch?: string,
154+
detectionType?: CIXInterfaces.BuildFrameworkDetectionType,
155+
serviceConnectionId?: string
156+
): Promise<CIXInterfaces.DetectedBuildFramework[]> {
157+
158+
return new Promise<CIXInterfaces.DetectedBuildFramework[]>(async (resolve, reject) => {
159+
let routeValues: any = {
160+
project: project
161+
};
162+
163+
let queryValues: any = {
164+
repositoryType: repositoryType,
165+
repositoryId: repositoryId,
166+
branch: branch,
167+
detectionType: detectionType,
168+
serviceConnectionId: serviceConnectionId,
169+
};
170+
171+
try {
172+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
173+
"7.2-preview.1",
174+
"pipelines",
175+
"29a30bab-9efb-4652-bf1b-9269baca0980",
176+
routeValues,
177+
queryValues);
178+
179+
let url: string = verData.requestUrl!;
180+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
181+
verData.apiVersion);
182+
183+
let res: restm.IRestResponse<CIXInterfaces.DetectedBuildFramework[]>;
184+
res = await this.rest.get<CIXInterfaces.DetectedBuildFramework[]>(url, options);
185+
186+
let ret = this.formatResponse(res.result,
187+
null,
188+
true);
189+
190+
resolve(ret);
191+
192+
}
193+
catch (err) {
194+
reject(err);
195+
}
196+
});
197+
}
198+
199+
/**
200+
* @param {{ [key: string] : CIXInterfaces.ResourceCreationParameter; }} creationParameters
201+
* @param {string} project - Project ID or project name
202+
*/
203+
public async createResources(
204+
creationParameters: { [key: string] : CIXInterfaces.ResourceCreationParameter; },
205+
project: string
206+
): Promise<CIXInterfaces.CreatedResources> {
207+
208+
return new Promise<CIXInterfaces.CreatedResources>(async (resolve, reject) => {
209+
let routeValues: any = {
210+
project: project
211+
};
212+
213+
try {
214+
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
215+
"7.2-preview.1",
216+
"pipelines",
217+
"43201899-7690-4870-9c79-ab69605f21ed",
218+
routeValues);
219+
220+
let url: string = verData.requestUrl!;
221+
let options: restm.IRequestOptions = this.createRequestOptions('application/json',
222+
verData.apiVersion);
223+
224+
let res: restm.IRestResponse<CIXInterfaces.CreatedResources>;
225+
res = await this.rest.create<CIXInterfaces.CreatedResources>(url, creationParameters, options);
226+
227+
let ret = this.formatResponse(res.result,
228+
null,
229+
false);
230+
231+
resolve(ret);
232+
233+
}
234+
catch (err) {
235+
reject(err);
236+
}
237+
});
238+
}
239+
240+
}

api/GitApi.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export interface IGitApi extends basem.ClientApiBase {
163163
getRevertForRefName(project: string, repositoryId: string, refName: string): Promise<GitInterfaces.GitRevert>;
164164
createCommitStatus(gitCommitStatusToCreate: GitInterfaces.GitStatus, commitId: string, repositoryId: string, project?: string): Promise<GitInterfaces.GitStatus>;
165165
getStatuses(commitId: string, repositoryId: string, project?: string, top?: number, skip?: number, latestOnly?: boolean): Promise<GitInterfaces.GitStatus[]>;
166-
getSuggestions(repositoryId: string, project?: string): Promise<GitInterfaces.GitSuggestion[]>;
166+
getSuggestions(repositoryId: string, project?: string, preferCompareBranch?: boolean): Promise<GitInterfaces.GitSuggestion[]>;
167167
getTree(repositoryId: string, sha1: string, project?: string, projectId?: string, recursive?: boolean, fileName?: string): Promise<GitInterfaces.GitTreeRef>;
168168
getTreeZip(repositoryId: string, sha1: string, project?: string, projectId?: string, recursive?: boolean, fileName?: string): Promise<NodeJS.ReadableStream>;
169169
}
@@ -7670,10 +7670,12 @@ export class GitApi extends basem.ClientApiBase implements IGitApi {
76707670
*
76717671
* @param {string} repositoryId - ID of the git repository.
76727672
* @param {string} project - Project ID or project name
7673+
* @param {boolean} preferCompareBranch - If true, prefer the compare branch over the default branch as target branch for pull requests.
76737674
*/
76747675
public async getSuggestions(
76757676
repositoryId: string,
7676-
project?: string
7677+
project?: string,
7678+
preferCompareBranch?: boolean
76777679
): Promise<GitInterfaces.GitSuggestion[]> {
76787680

76797681
return new Promise<GitInterfaces.GitSuggestion[]>(async (resolve, reject) => {
@@ -7682,12 +7684,17 @@ export class GitApi extends basem.ClientApiBase implements IGitApi {
76827684
repositoryId: repositoryId
76837685
};
76847686

7687+
let queryValues: any = {
7688+
preferCompareBranch: preferCompareBranch,
7689+
};
7690+
76857691
try {
76867692
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
76877693
"7.2-preview.1",
76887694
"git",
76897695
"9393b4fb-4445-4919-972b-9ad16f442d83",
7690-
routeValues);
7696+
routeValues,
7697+
queryValues);
76917698

76927699
let url: string = verData.requestUrl!;
76937700
let options: restm.IRequestOptions = this.createRequestOptions('application/json',

0 commit comments

Comments
 (0)