type Bitbucket = {
username: string;
password: string;
};
/**
* Update an explicit user permission for a repository
* Updates the explicit user permission for a given user and repository. The selected user must be a member of
the workspace, and cannot be the workspace owner.
Only users with admin permission for the repository may access this resource.
The only authentication method for this endpoint is via app passwords.
Permissions can be:
* `admin`
* `write`
* `read`
*/
export async function main(
auth: Bitbucket,
repo_slug: string,
selected_user_id: string,
workspace: string,
body: { permission: "read" | "write" | "admin" }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/permissions-config/users/${selected_user_id}`
);
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 86 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update an explicit user permission for a repository
* Updates the explicit user permission for a given user and repository. The selected user must be a member of
the workspace, and cannot be the workspace owner.
Only users with admin permission for the repository may access this resource.
The only authentication method for this endpoint is via app passwords.
Permissions can be:
* `admin`
* `write`
* `read`
*/
export async function main(
auth: Bitbucket,
repo_slug: string,
selected_user_id: string,
workspace: string,
body: { permission: "read" | "write" | "admin" }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/permissions-config/users/${selected_user_id}`
);
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 647 days ago