//native
type Linode = {
token: string;
};
/**
* Clone a Linode
* You can clone your Linode's existing Disks or Configuration profiles to another Linode on your Account.
*/
export async function main(
auth: Linode,
apiVersion: "v4" | "v4beta",
linodeId: string,
body: {
backups_enabled?: false | true;
configs?: number[];
disks?: number[];
group?: string;
label?: string;
linode_id?: number;
metadata?: { user_data?: string };
placement_group?: { id: number };
private_ip?: false | true;
region?: string;
type?: string;
},
) {
const url = new URL(
`https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/clone`,
);
const response = await fetch(url, {
method: "POST",
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