//native
type Cockroachdb = {
token: string;
};
/**
* Patch a user by supplying partial updates
* Apply a sequence of operations to modify attributes of a SCIM User resource. Supports 'add', 'remove', and 'replace' operations per RFC 7644 Section 3.5.2. Operations are applied atomically — if any operation fails, no changes are applied. The request body must include the 'schemas' field set to 'urn:ietf:params:scim:api:messages:2.0:PatchOp'.
Can be used by the following roles assigned at the organization scope:
- ORG_ADMIN
*/
export async function main(
auth: Cockroachdb,
id: string,
body: {
Operations: { op: string; path?: string; value?: unknown }[];
schemas: string[];
},
) {
const url = new URL(`https://cockroachlabs.cloud/api/scim/v2/Users/${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