//native
type Cockroachdb = {
token: string;
};
/**
* Remove a role from a user or service account
* Remove a single role from a user or service account by providing its user_id or service_account_id.
Roles that will be removed as a result of this call must follow the CC rules for role assignment:
https://www.cockroachlabs.com/docs/cockroachcloud/authorization#which-roles-grant-the-ability-to-add-remove-and-manage-members-in-in-a-cockroachdb-cloud-organization
*/
export async function main(
auth: Cockroachdb,
user_id: string,
resource_type: "ORGANIZATION" | "CLUSTER" | "FOLDER",
resource_id: string,
role_name:
| "BILLING_COORDINATOR"
| "ORG_ADMIN"
| "ORG_MEMBER"
| "CLUSTER_ADMIN"
| "CLUSTER_OPERATOR_WRITER"
| "CLUSTER_DEVELOPER"
| "CLUSTER_CREATOR"
| "FOLDER_ADMIN"
| "FOLDER_MOVER",
) {
const url = new URL(
`https://cockroachlabs.cloud/api/v1/roles/${user_id}/${resource_type}/${resource_id}/${role_name}`,
);
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago