type Bitbucket = {
username: string;
password: string;
};
/**
* Update an explicit group permission for a project
* Updates the group permission, or grants a new permission if one does not already exist.
Only users with admin permission for the project may access this resource.
Due to security concerns, the JWT and OAuth authentication methods are unsupported.
This is to ensure integrations and add-ons are not allowed to change permissions.
Permissions can be:
* `admin`
* `create-repo`
* `write`
* `read`
*/
export async function main(
auth: Bitbucket,
group_slug: string,
project_key: string,
workspace: string,
body: { permission: "read" | "write" | "create-repo" | "admin" }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}/permissions-config/groups/${group_slug}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
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;
};
/**
* Update an explicit group permission for a project
* Updates the group permission, or grants a new permission if one does not already exist.
Only users with admin permission for the project may access this resource.
Due to security concerns, the JWT and OAuth authentication methods are unsupported.
This is to ensure integrations and add-ons are not allowed to change permissions.
Permissions can be:
* `admin`
* `create-repo`
* `write`
* `read`
*/
export async function main(
auth: Bitbucket,
group_slug: string,
project_key: string,
workspace: string,
body: { permission: "read" | "write" | "create-repo" | "admin" }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}/permissions-config/groups/${group_slug}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 935 days ago