//native
type Fly = {
token: string;
};
/**
* Get Placements
* Simulates placing the specified number of machines into regions, depending on available capacity and limits.
*/
export async function main(
auth: Fly,
body: {
compute?: {
cpu_kind?: string;
cpus?: number;
gpu_kind?: string;
gpus?: number;
host_dedication_id?: string;
kernel_args?: string[];
memory_mb?: number;
};
count?: number;
org_slug: string;
region?: string;
volume_name?: string;
volume_size_bytes?: number;
weights?: {};
},
) {
const url = new URL(`https://api.machines.dev/v1/platform/placements`);
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