Returns a single key details.
1
//native
2
type Clickhouse = {
3
username: string;
4
password: string;
5
host: string;
6
};
7
/**
8
* Get key details
9
* Returns a single key details.
10
*/
11
export async function main(
12
auth: Clickhouse,
13
organizationId: string,
14
keyId: string
15
) {
16
const url = new URL(
17
`https://api.clickhouse.cloud/v1/organizations/${organizationId}/keys/${keyId}`
18
);
19
20
const response = await fetch(url, {
21
method: "GET",
22
headers: {
23
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
24
},
25
body: undefined,
26
});
27
if (!response.ok) {
28
const text = await response.text();
29
throw new Error(`${response.status} ${text}`);
30
}
31
return await response.json();
32
33