0

Update a node

by
Published Oct 17, 2025

Updates information about a Node, a backend for this NodeBalancer's configured port.

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 node
7
 * Updates information about a Node, a backend for this NodeBalancer's configured port.
8
 */
9
export async function main(
10
  auth: Linode,
11
  apiVersion: "v4" | "v4beta",
12
  nodeBalancerId: string,
13
  configId: string,
14
  nodeId: string,
15
  body: {
16
    address?: string;
17
    config_id?: number;
18
    id?: number;
19
    label?: string;
20
    mode?: "accept" | "reject" | "drain" | "backup";
21
    nodebalancer_id?: number;
22
    status?: "unknown" | "UP" | "DOWN";
23
    weight?: number;
24
  },
25
) {
26
  const url = new URL(
27
    `https://api.linode.com/${apiVersion}/nodebalancers/${nodeBalancerId}/configs/${configId}/nodes/${nodeId}`,
28
  );
29

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