//native
type Clickhouse = {
username: string;
password: string;
host: string;
};
/**
* Update service basic details
* Updates basic service details like service name or IP access list.
*/
export async function main(
auth: Clickhouse,
organizationId: string,
serviceId: string,
body: {
name?: string;
ipAccessList?: {
add?: { source?: string; description?: string }[];
remove?: { source?: string; description?: string }[];
};
privateEndpointIds?: { add?: string[]; remove?: string[] };
releaseChannel?: "default" | "fast";
}
) {
const url = new URL(
`https://api.clickhouse.cloud/v1/organizations/${organizationId}/services/${serviceId}`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 141 days ago