//native
type Grist = {
apiKey: string;
host: string;
};
/**
* Change who has access to workspace
*
*/
export async function main(
auth: Grist,
workspaceId: string,
body: {
delta: { maxInheritedRole?: "owners" | "editors" | "viewers"; users?: {} };
},
) {
const url = new URL(
`https://${auth.host}/api/workspaces/${workspaceId}/access`,
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago