1 | |
2 | type Clickhouse = { |
3 | username: string; |
4 | password: string; |
5 | host: string; |
6 | }; |
7 | |
8 | * Create new service |
9 | * Creates a new service in the organization, and returns the current service state and a password to access the service. The service is started asynchronously. |
10 | */ |
11 | export async function main( |
12 | auth: Clickhouse, |
13 | organizationId: string, |
14 | body: { |
15 | name?: string; |
16 | provider?: "aws" | "gcp" | "azure"; |
17 | region?: |
18 | | "ap-south-1" |
19 | | "ap-southeast-1" |
20 | | "eu-central-1" |
21 | | "eu-west-1" |
22 | | "eu-west-2" |
23 | | "us-east-1" |
24 | | "us-east-2" |
25 | | "us-west-2" |
26 | | "ap-southeast-2" |
27 | | "ap-northeast-1" |
28 | | "us-east1" |
29 | | "us-central1" |
30 | | "europe-west4" |
31 | | "asia-southeast1" |
32 | | "eastus" |
33 | | "eastus2" |
34 | | "westus3" |
35 | | "germanywestcentral"; |
36 | tier?: |
37 | | "development" |
38 | | "production" |
39 | | "dedicated_high_mem" |
40 | | "dedicated_high_cpu" |
41 | | "dedicated_standard" |
42 | | "dedicated_standard_n2d_standard_4" |
43 | | "dedicated_standard_n2d_standard_8" |
44 | | "dedicated_standard_n2d_standard_32" |
45 | | "dedicated_standard_n2d_standard_128"; |
46 | ipAccessList?: { source?: string; description?: string }[]; |
47 | minTotalMemoryGb?: number; |
48 | maxTotalMemoryGb?: number; |
49 | minReplicaMemoryGb?: number; |
50 | maxReplicaMemoryGb?: number; |
51 | numReplicas?: number; |
52 | idleScaling?: false | true; |
53 | idleTimeoutMinutes?: number; |
54 | isReadonly?: false | true; |
55 | dataWarehouseId?: string; |
56 | backupId?: string; |
57 | encryptionKey?: string; |
58 | encryptionAssumedRoleIdentifier?: string; |
59 | privateEndpointIds?: string[]; |
60 | privatePreviewTermsChecked?: false | true; |
61 | releaseChannel?: "default" | "fast"; |
62 | byocId?: string; |
63 | } |
64 | ) { |
65 | const url = new URL( |
66 | `https://api.clickhouse.cloud/v1/organizations/${organizationId}/services` |
67 | ); |
68 |
|
69 | const response = await fetch(url, { |
70 | method: "POST", |
71 | headers: { |
72 | "Content-Type": "application/json", |
73 | Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`), |
74 | }, |
75 | body: JSON.stringify(body), |
76 | }); |
77 | if (!response.ok) { |
78 | const text = await response.text(); |
79 | throw new Error(`${response.status} ${text}`); |
80 | } |
81 | return await response.json(); |
82 | } |
83 |
|