//native
type Cockroachdb = {
token: string;
};
/**
* Update a service account
* To manage roles associated with a service account after creation, pass the service_account_id instead of a user_id to any [Role Management endpoint](#tag--Role-Management).
Can be used by the following roles assigned at the organization scope:
- ORG_ADMIN
*/
export async function main(
auth: Cockroachdb,
id: string,
body: { description?: string; name?: string },
) {
const url = new URL(
`https://cockroachlabs.cloud/api/v1/service-accounts/${id}`,
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
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 235 days ago