//native
/**
* Update User
* Update a user's fields with patch semantics: only the fields in `body` change (e.g. `{"name": {"givenName": "Jane"}, "orgUnitPath": "/Sales", "suspended": false}`). Repeated fields like `phones` or `emails` are replaced as a whole.
*/
export async function main(
auth: RT.Gworkspace,
user_key: string,
body: { [key: string]: any },
) {
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(body),
},
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 1 hour ago