0

List all Events Logs

by
Published Dec 20, 2024

To list all of the cluster events, send a GET request to `/v2/databases/$DATABASE_ID/events`. The result will be a JSON object with a `events` key.

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 all Events Logs
7
 * To list all of the cluster events, send a GET request to
8
`/v2/databases/$DATABASE_ID/events`.
9

10
The result will be a JSON object with a `events` key.
11

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

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