//native
type Clickhouse = {
username: string;
password: string;
host: string;
};
/**
* Create an invitation
* Creates organization invitation.
*/
export async function main(
auth: Clickhouse,
organizationId: string,
body: {
email?: string;
role?: "admin" | "developer" | "org_member" | "billing";
}
) {
const url = new URL(
`https://api.clickhouse.cloud/v1/organizations/${organizationId}/invitations`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
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 141 days ago