Edits history of script submission #14637 for ' Get organization details (clickhouse)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickhouse = {
      username: string;
      password: string;
      host: string;
    };
    /**
     * Get organization details
     * Returns details of a single organization. In order to get the details, the auth key must belong to the organization.
     */
    export async function main(auth: Clickhouse, organizationId: string) {
      const url = new URL(
        `https://api.clickhouse.cloud/v1/organizations/${organizationId}/prometheus`
      );
    
      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.text();
    }
    

    Submitted by hugo697 235 days ago