feat: Created getDashboardPullRequests and getAllTeams methods in AzureDevOpsClient.
Signed-off-by: Marley Powell <Marley.Powell@exclaimer.com>
This commit is contained in:
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
DashboardPullRequest,
|
||||
RepoBuild,
|
||||
RepoBuildOptions,
|
||||
Team,
|
||||
} from '@backstage/plugin-azure-devops-common';
|
||||
|
||||
import { createApiRef } from '@backstage/core-plugin-api';
|
||||
@@ -33,4 +35,10 @@ export interface AzureDevOpsApi {
|
||||
repoName: string,
|
||||
options?: RepoBuildOptions,
|
||||
): Promise<{ items: RepoBuild[] }>;
|
||||
|
||||
getDashboardPullRequests(
|
||||
projectName: string,
|
||||
): Promise<DashboardPullRequest[]>;
|
||||
|
||||
getAllTeams(): Promise<Team[]>;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
|
||||
import {
|
||||
DashboardPullRequest,
|
||||
RepoBuild,
|
||||
RepoBuildOptions,
|
||||
Team,
|
||||
} from '@backstage/plugin-azure-devops-common';
|
||||
import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
|
||||
|
||||
import { AzureDevOpsApi } from './AzureDevOpsApi';
|
||||
import { ResponseError } from '@backstage/errors';
|
||||
@@ -27,7 +29,7 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
|
||||
private readonly discoveryApi: DiscoveryApi;
|
||||
private readonly identityApi: IdentityApi;
|
||||
|
||||
constructor(options: {
|
||||
public constructor(options: {
|
||||
discoveryApi: DiscoveryApi;
|
||||
identityApi: IdentityApi;
|
||||
}) {
|
||||
@@ -35,7 +37,7 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
|
||||
this.identityApi = options.identityApi;
|
||||
}
|
||||
|
||||
async getRepoBuilds(
|
||||
public async getRepoBuilds(
|
||||
projectName: string,
|
||||
repoName: string,
|
||||
options?: RepoBuildOptions,
|
||||
@@ -46,6 +48,18 @@ export class AzureDevOpsClient implements AzureDevOpsApi {
|
||||
return { items };
|
||||
}
|
||||
|
||||
public getDashboardPullRequests(
|
||||
projectName: string,
|
||||
): Promise<DashboardPullRequest[]> {
|
||||
return this.get<DashboardPullRequest[]>(
|
||||
`dashboard-pull-requests/${projectName}?top=100`,
|
||||
);
|
||||
}
|
||||
|
||||
public getAllTeams(): Promise<Team[]> {
|
||||
return this.get<Team[]>('all-teams');
|
||||
}
|
||||
|
||||
private async get<T>(path: string): Promise<T> {
|
||||
const baseUrl = `${await this.discoveryApi.getBaseUrl('azure-devops')}/`;
|
||||
const url = new URL(path, baseUrl);
|
||||
|
||||
Reference in New Issue
Block a user