Skip to content

Commit

Permalink
Merge pull request #7 from rhyskoedijk/feature/expand-api-version-com…
Browse files Browse the repository at this point in the history
…patibility

Lower minimum server API version to 5.0 for greater compatibility
  • Loading branch information
rhyskoedijk authored Nov 21, 2024
2 parents 9a5f2d5 + 01ba0b4 commit 94bdecf
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"category": "Azure Pipelines",
"visibility": ["Build"],
"runsOn": ["Agent"],
"minimumAgentVersion": "3.232.1",
"author": "Rhys Koedijk",
"version": {
"Major": 0,
Expand Down
3 changes: 2 additions & 1 deletion ui/sbom-report-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';

import { CommonServiceIds, getClient, IProjectPageService } from 'azure-devops-extension-api';
import { BuildRestClient, BuildServiceIds, IBuildPageDataService } from 'azure-devops-extension-api/Build';
import { BuildServiceIds, IBuildPageDataService } from 'azure-devops-extension-api/Build';
import { Spinner } from 'azure-devops-ui/Spinner';
import { ZeroData } from 'azure-devops-ui/ZeroData';

import { SpdxDocumentPage } from './components/SpdxDocumentPage';
import { ISpdx22Document } from './models/Spdx22';

import { BuildRestClient } from './utils/BuildRestClient';
import './utils/StringExtensions';

import './sbom-report-tab.scss';
Expand Down
64 changes: 64 additions & 0 deletions ui/utils/BuildRestClient.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { IVssRestClientOptions } from 'azure-devops-extension-api/Common';
import { RestClientBase } from 'azure-devops-extension-api/Common/RestClientBase';

import * as Build from 'azure-devops-extension-api/Build';

export class BuildRestClient extends RestClientBase {
constructor(options: IVssRestClientOptions) {
super(options);
}

public static readonly API_VERSION = '5.0';

/**
* Gets the list of attachments of a specific type that are associated with a build.
*
* @param project - Project ID or project name
* @param buildId - The ID of the build.
* @param type - The type of attachment.
*/
public async getAttachments(project: string, buildId: number, type: string): Promise<Build.Attachment[]> {
return this.beginRequest<Build.Attachment[]>({
apiVersion: BuildRestClient.API_VERSION,
routeTemplate: '{project}/_apis/build/builds/{buildId}/attachments/{type}',
routeValues: {
project: project,
buildId: buildId,
type: type,
},
});
}

/**
* Gets a specific attachment.
*
* @param project - Project ID or project name
* @param buildId - The ID of the build.
* @param timelineId - The ID of the timeline.
* @param recordId - The ID of the timeline record.
* @param type - The type of the attachment.
* @param name - The name of the attachment.
*/
public async getAttachment(
project: string,
buildId: number,
timelineId: string,
recordId: string,
type: string,
name: string,
): Promise<ArrayBuffer> {
return this.beginRequest<ArrayBuffer>({
apiVersion: BuildRestClient.API_VERSION,
httpResponseType: 'application/octet-stream',
routeTemplate: '{project}/_apis/build/builds/{buildId}/{timelineId}/{recordId}/attachments/{type}/{name}',
routeValues: {
project: project,
buildId: buildId,
timelineId: timelineId,
recordId: recordId,
type: type,
name: name,
},
});
}
}
1 change: 1 addition & 0 deletions vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"id": "Microsoft.VisualStudio.Services"
}
],
"demands": ["api-version/5.0"],
"categories": ["Azure Pipelines"],
"tags": [
"sbom",
Expand Down

0 comments on commit 94bdecf

Please sign in to comment.