Edits history of script submission #14644 for ' List of organization services (clickhouse)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clickhouse = {
      username: string;
      password: string;
      host: string;
    };
    /**
     * List of organization services
     * Returns a list of all services in the organization.
     */
    export async function main(auth: Clickhouse, organizationId: string) {
      const url = new URL(
        `https://api.clickhouse.cloud/v1/organizations/${organizationId}/services`
      );
    
      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 205 days ago