Skip to content

Update API M247 #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 75 additions & 3 deletions api/AlertApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export interface IAlertApi extends basem.ClientApiBase {
updateAlert(stateUpdate: AlertInterfaces.AlertStateUpdate, project: string, alertId: number, repository: string): Promise<AlertInterfaces.Alert>;
getAlertInstances(project: string, alertId: number, repository: string, ref?: string): Promise<AlertInterfaces.AlertAnalysisInstance[]>;
updateAlertsMetadata(alertsMetadata: AlertInterfaces.AlertMetadata[], project: string, repository: string): Promise<AlertInterfaces.AlertMetadataChange[]>;
uploadSarif(customHeaders: any, contentStream: NodeJS.ReadableStream, project: string, repository: string): Promise<number>;
uploadSarif(customHeaders: any, contentStream: NodeJS.ReadableStream, project: string, repository: string, notificationFlag?: String): Promise<number>;
getBranches(project: string, repository: string, alertType: AlertInterfaces.AlertType, continuationToken?: string, branchNameContains?: string, top?: number, includePullRequestBranches?: boolean): Promise<AlertInterfaces.Branch[]>;
getUxFilters(project: string, repository: string, alertType: AlertInterfaces.AlertType): Promise<AlertInterfaces.UxFilters>;
getSarif(sarifId: number): Promise<AlertInterfaces.SarifUploadStatus>;
}
Expand Down Expand Up @@ -258,7 +259,7 @@ export class AlertApi extends basem.ClientApiBase implements IAlertApi {
}

/**
* Get instances of an alert.
* Get instances of an alert on a branch specified with @ref. If @ref is not provided, return instances of an alert on default branch(if the alert exist in default branch) or latest affected branch.
*
* @param {string} project - Project ID or project name
* @param {number} alertId - ID of alert to retrieve
Expand Down Expand Up @@ -363,12 +364,14 @@ export class AlertApi extends basem.ClientApiBase implements IAlertApi {
* @param {NodeJS.ReadableStream} contentStream - Content to upload
* @param {string} project - Project ID or project name
* @param {string} repository - The name or ID of a repository
* @param {String} notificationFlag - Header to signal that this is a progress notification
*/
public async uploadSarif(
customHeaders: any,
contentStream: NodeJS.ReadableStream,
project: string,
repository: string
repository: string,
notificationFlag?: String
): Promise<number> {

return new Promise<number>(async (resolve, reject) => {
Expand All @@ -379,6 +382,7 @@ export class AlertApi extends basem.ClientApiBase implements IAlertApi {

customHeaders = customHeaders || {};
customHeaders["Content-Type"] = "application/octet-stream";
customHeaders["X-AdvSec-NotificationSarif"] = "notificationFlag";

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
Expand Down Expand Up @@ -408,6 +412,73 @@ export class AlertApi extends basem.ClientApiBase implements IAlertApi {
});
}

/**
* Returns the branches for which analysis results were submitted.
*
* @param {string} project - Project ID or project name
* @param {string} repository
* @param {AlertInterfaces.AlertType} alertType - The type of alert: Dependency Scanning (1), Secret (2), Code QL (3), etc.
* @param {string} continuationToken - A string variable that represents the branch name and is used to fetch branches that follow it in alphabetical order.
* @param {string} branchNameContains - A string variable used to fetch branches that contain this string anywhere in the branch name, case insensitive.
* @param {number} top - An int variable used to return the top k branches that satisfy the search criteria.
* @param {boolean} includePullRequestBranches - A bool variable indicating whether or not to include pull request branches.
*/
public async getBranches(
project: string,
repository: string,
alertType: AlertInterfaces.AlertType,
continuationToken?: string,
branchNameContains?: string,
top?: number,
includePullRequestBranches?: boolean
): Promise<AlertInterfaces.Branch[]> {
if (alertType == null) {
throw new TypeError('alertType can not be null or undefined');
}

return new Promise<AlertInterfaces.Branch[]>(async (resolve, reject) => {
let routeValues: any = {
action: "Branches",
project: project,
repository: repository
};

let queryValues: any = {
alertType: alertType,
continuationToken: continuationToken,
branchNameContains: branchNameContains,
top: top,
includePullRequestBranches: includePullRequestBranches,
};

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.1",
"Alert",
"8f90675b-f794-434d-8f2c-cfae0a11c02a",
routeValues,
queryValues);

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

let res: restm.IRestResponse<AlertInterfaces.Branch[]>;
res = await this.rest.get<AlertInterfaces.Branch[]>(url, options);

let ret = this.formatResponse(res.result,
AlertInterfaces.TypeInfo.Branch,
true);

resolve(ret);

}
catch (err) {
reject(err);
}
});
}

/**
* @param {string} project - Project ID or project name
* @param {string} repository
Expand All @@ -424,6 +495,7 @@ export class AlertApi extends basem.ClientApiBase implements IAlertApi {

return new Promise<AlertInterfaces.UxFilters>(async (resolve, reject) => {
let routeValues: any = {
action: "Default",
project: project,
repository: repository
};
Expand Down
2 changes: 1 addition & 1 deletion api/BuildApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4618,7 +4618,7 @@ export class BuildApi extends basem.ClientApiBase implements IBuildApi {

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.2",
"7.2-preview.3",
"build",
"8baac422-4c6e-4de5-8532-db96d92acffa",
routeValues,
Expand Down
14 changes: 7 additions & 7 deletions api/ExtensionManagementApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ export class ExtensionManagementApi extends basem.ClientApiBase implements IExte

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.1",
"7.2-preview.2",
"ExtensionManagement",
"92755d3d-9a8a-42b3-8a4d-87359fe5aa93",
routeValues,
Expand Down Expand Up @@ -674,7 +674,7 @@ export class ExtensionManagementApi extends basem.ClientApiBase implements IExte

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.1",
"7.2-preview.2",
"ExtensionManagement",
"046c980f-1345-4ce2-bf85-b46d10ff4cfd",
routeValues);
Expand Down Expand Up @@ -727,7 +727,7 @@ export class ExtensionManagementApi extends basem.ClientApiBase implements IExte

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.1",
"7.2-preview.2",
"ExtensionManagement",
"275424d0-c844-4fe2-bda6-04933a1357d8",
routeValues,
Expand Down Expand Up @@ -768,7 +768,7 @@ export class ExtensionManagementApi extends basem.ClientApiBase implements IExte

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.1",
"7.2-preview.2",
"ExtensionManagement",
"275424d0-c844-4fe2-bda6-04933a1357d8",
routeValues);
Expand Down Expand Up @@ -818,7 +818,7 @@ export class ExtensionManagementApi extends basem.ClientApiBase implements IExte

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.1",
"7.2-preview.2",
"ExtensionManagement",
"fb0da285-f23e-4b56-8b53-3ef5f9f6de66",
routeValues,
Expand Down Expand Up @@ -866,7 +866,7 @@ export class ExtensionManagementApi extends basem.ClientApiBase implements IExte

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.1",
"7.2-preview.2",
"ExtensionManagement",
"fb0da285-f23e-4b56-8b53-3ef5f9f6de66",
routeValues);
Expand Down Expand Up @@ -919,7 +919,7 @@ export class ExtensionManagementApi extends basem.ClientApiBase implements IExte

try {
let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData(
"7.2-preview.1",
"7.2-preview.2",
"ExtensionManagement",
"fb0da285-f23e-4b56-8b53-3ef5f9f6de66",
routeValues,
Expand Down
Loading