type Bitbucket = {
username: string;
password: string;
};
/**
* List user permissions in a workspace
* Returns the list of members in a workspace
and their permission levels.
*/
export async function main(
auth: Bitbucket,
workspace: string,
q: string | undefined
) {
const url = new URL(
`https://api.bitbucket.org/2.0/workspaces/${workspace}/permissions`
);
for (const [k, v] of [["q", q]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 375 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* List user permissions in a workspace
* Returns the list of members in a workspace
and their permission levels.
*/
export async function main(
auth: Bitbucket,
workspace: string,
q: string | undefined
) {
const url = new URL(
`https://api.bitbucket.org/2.0/workspaces/${workspace}/permissions`
);
for (const [k, v] of [["q", q]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 935 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* List user permissions in a workspace
* Returns the list of members in a workspace
and their permission levels.
Permission can be:
* `owner`
* `collaborator`
* `member`
**The `collaborator` role is being removed from the Bitbucket Cloud API. For more information,
see the [deprecation announcement](/cloud/bitbucket/deprecation-notice-collaborator-role/).**
**When you move your administration from Bitbucket Cloud to admin.atlassian.com, the following fields on
`workspace_membership` will no longer be present: `last_accessed` and `added_on`. See the
[deprecation announcement](/cloud/bitbucket/announcement-breaking-change-workspace-membership/).**
Results may be further [filtered](/cloud/bitbucket/rest/intro/#filtering) by
permission by adding the following query string parameters:
* `q=permission="owner"`
*/
export async function main(
auth: Bitbucket,
workspace: string,
q: string | undefined
) {
const url = new URL(
`https://api.bitbucket.org/2.0/workspaces/${workspace}/permissions`
);
for (const [k, v] of [["q", q]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 935 days ago