diff --git a/scripts/manage-webhooks.ts b/scripts/manage-webhooks.ts index 517f418..5861495 100644 --- a/scripts/manage-webhooks.ts +++ b/scripts/manage-webhooks.ts @@ -18,6 +18,10 @@ Usage: [--method POST] \\ [--token ] + deno task webhooks list + + deno task webhooks delete --id + deno task webhooks delete-all Inputs (env or flag, env preferred): @@ -150,6 +154,32 @@ const main = async () => { return; } + if (command === "list") { + const res = await fetch(`${api}/${session.did}/webhooks`, { + headers: { "Authorization": `Bearer ${session.accessJwt}` }, + }); + if (!res.ok) { + console.error(`list failed (${res.status}): ${await res.text()}`); + Deno.exit(1); + } + console.log(JSON.stringify(await res.json(), null, 2)); + return; + } + + if (command === "delete") { + const id = flags.id ?? die("--id is required for delete"); + const res = await fetch(`${api}/${session.did}/webhooks/${id}`, { + method: "DELETE", + headers: { "Authorization": `Bearer ${session.accessJwt}` }, + }); + if (!res.ok) { + console.error(`delete failed (${res.status}): ${await res.text()}`); + Deno.exit(1); + } + console.log(`[done] webhook ${id} deleted`); + return; + } + if (command === "delete-all") { const res = await fetch(`${api}/${session.did}/webhooks`, { method: "DELETE",