//native
type Linode = {
token: string;
};
/**
* Update a node
* Updates information about a Node, a backend for this NodeBalancer's configured port.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
nodeBalancerId: string,
configId: string,
nodeId: string,
body: {
address?: string;
config_id?: number;
id?: number;
label?: string;
mode?: "accept" | "reject" | "drain" | "backup";
nodebalancer_id?: number;
status?: "unknown" | "UP" | "DOWN";
weight?: number;
},
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/nodebalancers/${nodeBalancerId}/configs/${configId}/nodes/${nodeId}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago