//native
type Digitalocean = {
token: string;
};
/**
* Delete a Tag
* A tag can be deleted by sending a `DELETE` request to `/v2/tags/$TAG_NAME`. Deleting a tag also untags all the resources that have previously been tagged by the Tag
*/
export async function main(auth: Digitalocean, tag_id: string) {
const url = new URL(`https://api.digitalocean.com/v2/tags/${tag_id}`);
const response = await fetch(url, {
method: "DELETE",
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