0

Update service basic details

by
Published Oct 17, 2025

Updates basic service details like service name or IP access list.

Script clickhouse Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Clickhouse = {
3
  username: string;
4
  password: string;
5
  host: string;
6
};
7
/**
8
 * Update service basic details
9
 * Updates basic service details like service name or IP access list.
10
 */
11
export async function main(
12
  auth: Clickhouse,
13
  organizationId: string,
14
  serviceId: string,
15
  body: {
16
    name?: string;
17
    ipAccessList?: {
18
      add?: { source?: string; description?: string }[];
19
      remove?: { source?: string; description?: string }[];
20
    };
21
    privateEndpointIds?: { add?: string[]; remove?: string[] };
22
    releaseChannel?: "default" | "fast";
23
  }
24
) {
25
  const url = new URL(
26
    `https://api.clickhouse.cloud/v1/organizations/${organizationId}/services/${serviceId}`
27
  );
28

29
  const response = await fetch(url, {
30
    method: "PATCH",
31
    headers: {
32
      "Content-Type": "application/json",
33
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
34
    },
35
    body: JSON.stringify(body),
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43