0

List Logsinks for a Database Cluster

by
Published Dec 20, 2024

To list logsinks for a database cluster, send a GET request to `/v2/databases/$DATABASE_ID/logsink`.

Script digitalocean Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Digitalocean = {
3
  token: string;
4
};
5
/**
6
 * List Logsinks for a Database Cluster
7

8
 * To list logsinks for a database cluster, send a GET request to
9
`/v2/databases/$DATABASE_ID/logsink`.
10

11
 */
12
export async function main(auth: Digitalocean, database_cluster_uuid: string) {
13
  const url = new URL(
14
    `https://api.digitalocean.com/v2/databases/${database_cluster_uuid}/logsink`,
15
  );
16

17
  const response = await fetch(url, {
18
    method: "GET",
19
    headers: {
20
      Authorization: "Bearer " + auth.token,
21
    },
22
    body: undefined,
23
  });
24
  if (!response.ok) {
25
    const text = await response.text();
26
    throw new Error(`${response.status} ${text}`);
27
  }
28
  return await response.json();
29
}
30