type Bitbucket = {
username: string;
password: string;
};
/**
* Update an explicit group permission for a repository
* Updates the group permission, or grants a new permission if one does not already exist.
Only users with admin permission for the repository may access this resource.
The only authentication method supported for this endpoint is via app passwords.
Permissions can be:
* `admin`
* `write`
* `read`
*/
export async function main(
auth: Bitbucket,
group_slug: string,
repo_slug: string,
workspace: string,
body: { permission: "read" | "write" | "admin" }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/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 repository
* Updates the group permission, or grants a new permission if one does not already exist.
Only users with admin permission for the repository may access this resource.
The only authentication method supported for this endpoint is via app passwords.
Permissions can be:
* `admin`
* `write`
* `read`
*/
export async function main(
auth: Bitbucket,
group_slug: string,
repo_slug: string,
workspace: string,
body: { permission: "read" | "write" | "admin" }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/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