//native
type Clickhouse = {
username: string;
password: string;
host: string;
};
/**
* Get list of available organizations
* Returns a list with a single organization associated with the API key in the request.
*/
export async function main(auth: Clickhouse) {
const url = new URL(`https://api.clickhouse.cloud/v1/organizations`);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 182 days ago