//native
type Linode = {
token: string;
};
/**
* Update a Linode
* Updates a Linode that you have permission to `read_write`.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
linodeId: string,
body: {
alerts?: {
cpu?: number;
io?: number;
network_in?: number;
network_out?: number;
transfer_quota?: number;
};
backups?: {
available?: false | true;
enabled?: false | true;
last_successful?: string;
schedule?: {
day?:
| "Scheduling"
| "Sunday"
| "Monday"
| "Tuesday"
| "Wednesday"
| "Thursday"
| "Friday"
| "Saturday";
window?:
| "Scheduling"
| "W0"
| "W2"
| "W4"
| "W6"
| "W8"
| "W10"
| "W12"
| "W14"
| "W16"
| "W18"
| "W20"
| "W22";
};
};
capabilities?: string[];
created?: string;
disk_encryption?: string;
group?: string;
has_user_data?: false | true;
host_uuid?: string;
hypervisor?: "kvm";
id?: number;
image?: string;
ipv4?: string[];
ipv6?: string;
label?: string;
lke_cluster_id?: number;
placement_group?: {
id?: number;
label?: string;
placement_group_policy?: "strict" | "flexible";
placement_group_type?: "anti_affinity:local";
};
region?: string;
specs?: {
disk?: number;
gpus?: number;
memory?: number;
transfer?: number;
vcpus?: number;
};
status?:
| "running"
| "offline"
| "booting"
| "busy"
| "rebooting"
| "shutting_down"
| "provisioning"
| "deleting"
| "migrating"
| "rebuilding"
| "cloning"
| "restoring"
| "stopped"
| "billing_suspension";
tags?: string[];
type?: string;
updated?: string;
watchdog_enabled?: false | true;
},
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/linode/instances/${linodeId}`,
);
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