feat: fetch workspaces and projects in BitbucketRepoPicker; add support for access tokens to BitbucketCloudClient
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
@@ -69,6 +69,22 @@ export class BitbucketCloudClient {
|
||||
);
|
||||
}
|
||||
|
||||
listProjectsByWorkspace(
|
||||
workspace: string,
|
||||
options?: FilterAndSortOptions & PartialResponseOptions,
|
||||
): WithPagination<Models.PaginatedProjects, Models.Project> {
|
||||
const workspaceEnc = encodeURIComponent(workspace);
|
||||
|
||||
return new WithPagination(
|
||||
paginationOptions =>
|
||||
this.createUrl(`/workspaces/${workspaceEnc}/projects`, {
|
||||
...paginationOptions,
|
||||
...options,
|
||||
}),
|
||||
url => this.getTypeMapped(url),
|
||||
);
|
||||
}
|
||||
|
||||
private createUrl(endpoint: string, options?: RequestOptions): URL {
|
||||
const request = new URL(this.config.apiBaseUrl + endpoint);
|
||||
for (const key in options) {
|
||||
@@ -115,6 +131,9 @@ export class BitbucketCloudClient {
|
||||
headers.Authorization = `Basic ${buffer.toString('base64')}`;
|
||||
}
|
||||
|
||||
if (this.config.accessToken)
|
||||
headers.Authorization = `Bearer ${this.config.accessToken}`;
|
||||
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,17 @@ export namespace Models {
|
||||
values?: Set<Repository>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A paginated list of projects.
|
||||
* @public
|
||||
*/
|
||||
export interface PaginatedProjects extends Paginated<Project> {
|
||||
/**
|
||||
* The values of the current page.
|
||||
*/
|
||||
values?: Set<Project>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object describing a user's role on resources like commits or pull requests.
|
||||
* @public
|
||||
|
||||
Reference in New Issue
Block a user