0

Retrieve Existing Connection Pool (PostgreSQL)

by
Published Dec 20, 2024

To show information about an existing connection pool for a PostgreSQL database cluster, send a GET request to `/v2/databases/$DATABASE_ID/pools/$POOL_NAME`. The response will be a JSON object with a `pool` 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
 * Retrieve Existing Connection Pool (PostgreSQL)
7
 * To show information about an existing connection pool for a PostgreSQL database cluster, send a GET request to `/v2/databases/$DATABASE_ID/pools/$POOL_NAME`.
8
The response will be a JSON object with a `pool` key.
9
 */
10
export async function main(
11
  auth: Digitalocean,
12
  database_cluster_uuid: string,
13
  pool_name: string,
14
) {
15
  const url = new URL(
16
    `https://api.digitalocean.com/v2/databases/${database_cluster_uuid}/pools/${pool_name}`,
17
  );
18

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