0

Update a PostgreSQL Managed Database

by
Published Oct 17, 2025

Make changes to an existing PostgreSQL Managed Database.

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Update a PostgreSQL Managed Database
7
 * Make changes to an existing PostgreSQL Managed Database.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  instanceId: string,
13
  body: {
14
    allow_list?: string[];
15
    label?: string;
16
    type?: string;
17
    updates?: {
18
      day_of_week?: number;
19
      duration?: number;
20
      frequency?: "weekly";
21
      hour_of_day?: number;
22
      pending?: {
23
        deadline?: string;
24
        description?: string;
25
        planned_for?: string;
26
      }[];
27
    };
28
    version?: string;
29
  },
30
) {
31
  const url = new URL(
32
    `https://api.linode.com/${apiVersion}/databases/postgresql/instances/${instanceId}`,
33
  );
34

35
  const response = await fetch(url, {
36
    method: "PUT",
37
    headers: {
38
      "Content-Type": "application/json",
39
      Authorization: "Bearer " + auth.token,
40
    },
41
    body: JSON.stringify(body),
42
  });
43
  if (!response.ok) {
44
    const text = await response.text();
45
    throw new Error(`${response.status} ${text}`);
46
  }
47
  return await response.json();
48
}
49