//native
type Digitalocean = {
token: string;
};
/**
* Retry a Droplet Destroy with Associated Resources Request
* If the status of a request to destroy a Droplet with its associated resources
reported any errors, it can be retried by sending a POST request to the
`/v2/droplets/$DROPLET_ID/destroy_with_associated_resources/retry` endpoint.
Only one destroy can be active at a time per Droplet. If a retry is issued
while another destroy is in progress for the Droplet a 409 status code will
be returned. A successful response will include a 202 response code and no
content.
*/
export async function main(auth: Digitalocean, droplet_id: string) {
const url = new URL(
`https://api.digitalocean.com/v2/droplets/${droplet_id}/destroy_with_associated_resources/retry`,
);
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.json();
}
Submitted by hugo697 536 days ago