//native
type Digitalocean = {
token: string;
};
/**
* Delete Trigger
* Deletes the given trigger.
To delete trigger, send a DELETE request to `/v2/functions/namespaces/$NAMESPACE_ID/triggers/$TRIGGER_NAME`.
A successful deletion returns a 204 response.
*/
export async function main(
auth: Digitalocean,
namespace_id: string,
trigger_name: string,
) {
const url = new URL(
`https://api.digitalocean.com/v2/functions/namespaces/${namespace_id}/triggers/${trigger_name}`,
);
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