//native
/**
* Suspend or Unsuspend User
* Suspend a user (blocks sign-in and mail delivery but keeps their data), or set `suspended` to false to restore access.
*/
export async function main(
auth: RT.Gworkspace,
user_key: string,
suspended: boolean = true,
) {
const response = await fetch(
`https://admin.googleapis.com/admin/directory/v1/users/${encodeURIComponent(user_key)}`,
{
method: "PATCH",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ suspended }),
},
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 1 hour ago