//native
type Fly = {
token: string;
};
/**
* Extend Volume
* Extend a volume's size within an app using the details provided in the request body.
*/
export async function main(
auth: Fly,
app_name: string,
volume_id: string,
body: { size_gb?: number },
) {
const url = new URL(
`https://api.machines.dev/v1/apps/${app_name}/volumes/${volume_id}/extend`,
);
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