//native
type Fly = {
token: string;
};
/**
* Suspend Machine
* Suspend a specific Machine within an app. The next start operation will attempt (but is not guaranteed) to resume the Machine from a snapshot taken at suspension time, rather than performing a cold boot.
*/
export async function main(auth: Fly, app_name: string, machine_id: string) {
const url = new URL(
`https://api.machines.dev/v1/apps/${app_name}/machines/${machine_id}/suspend`,
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago