//native
type Digitalocean = {
token: string;
};
/**
* Destroy a Droplet and All of its Associated Resources (Dangerous)
* To destroy a Droplet along with all of its associated resources, send a DELETE
request to the `/v2/droplets/$DROPLET_ID/destroy_with_associated_resources/dangerous`
endpoint.
*/
export async function main(
auth: Digitalocean,
droplet_id: string,
X_Dangerous: string,
) {
const url = new URL(
`https://api.digitalocean.com/v2/droplets/${droplet_id}/destroy_with_associated_resources/dangerous`,
);
const response = await fetch(url, {
method: "DELETE",
headers: {
"X-Dangerous": X_Dangerous,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago