Get backup details
One script reply has been approved by the moderators Verified

Returns a single backup info.

Created by hugo697 141 days ago
Submitted by hugo697 Bun
Verified 141 days ago
1
//native
2
type Clickhouse = {
3
  username: string;
4
  password: string;
5
  host: string;
6
};
7
/**
8
 * Get backup details
9
 * Returns a single backup info.
10
 */
11
export async function main(
12
  auth: Clickhouse,
13
  organizationId: string,
14
  serviceId: string,
15
  backupId: string
16
) {
17
  const url = new URL(
18
    `https://api.clickhouse.cloud/v1/organizations/${organizationId}/services/${serviceId}/backups/${backupId}`
19
  );
20

21
  const response = await fetch(url, {
22
    method: "GET",
23
    headers: {
24
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
25
    },
26
    body: undefined,
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34