|
| 1 | +# flyteplugins-webhooks-clickup |
| 2 | + |
| 3 | +Receive ClickUp webhooks in Flyte. |
| 4 | + |
| 5 | +```bash |
| 6 | +pip install "flyteplugins-webhooks-core[app]" flyteplugins-webhooks-clickup |
| 7 | +``` |
| 8 | + |
| 9 | +## Using it |
| 10 | + |
| 11 | +Hand `PROVIDER` to a `WebhookAppEnvironment` and register handlers with the |
| 12 | +typed constants in `events`: |
| 13 | + |
| 14 | +```python |
| 15 | +import flyte |
| 16 | +from flyteplugins.webhooks.core import DuplicateRun, WebhookAppEnvironment, idempotent_run |
| 17 | +from flyteplugins.webhooks.clickup import PROVIDER, events |
| 18 | + |
| 19 | +app_env = WebhookAppEnvironment( |
| 20 | + name="clickup-webhooks", |
| 21 | + providers=[PROVIDER], |
| 22 | + secrets=[flyte.Secret("CLICKUP_WEBHOOK_SECRET", as_env_var="CLICKUP_WEBHOOK_SECRET")], |
| 23 | +) |
| 24 | + |
| 25 | + |
| 26 | +@app_env.on_event(events.Task.STATUS_UPDATED) |
| 27 | +async def handle(event): |
| 28 | + import flyte.remote as remote |
| 29 | + |
| 30 | + task = remote.Task.get(name="my-env.my_task", auto_version="latest") |
| 31 | + try: |
| 32 | + run = await idempotent_run.aio(task, key=event.dedupe_key(), resource=event.resource_id) |
| 33 | + except DuplicateRun as exc: |
| 34 | + return {"skipped": str(exc)} |
| 35 | + return {"run": run.name} |
| 36 | + |
| 37 | + |
| 38 | +flyte.serve(app_env) |
| 39 | +``` |
| 40 | + |
| 41 | +Handlers must `await idempotent_run.aio(...)`. The blocking form stalls the |
| 42 | +app's event loop, and ClickUp times deliveries out in seconds. |
| 43 | + |
| 44 | +One app can serve several products at once — hand it more than one `PROVIDER`. |
| 45 | + |
| 46 | +## Setup |
| 47 | + |
| 48 | +1. Store the secret and mount it on the app: |
| 49 | + ```bash |
| 50 | + flyte create secret CLICKUP_WEBHOOK_SECRET --value <secret> |
| 51 | + ``` |
| 52 | +2. Point ClickUp at `<app-url>/webhook/clickup`, from |
| 53 | + Space Settings → Integrations → Webhooks (it shows the signing secret on creation). |
| 54 | + |
| 55 | +**Verification:** HMAC-SHA256 over the raw body (`X-Clickup-Signature`). |
| 56 | + |
| 57 | +The list id is at the top level on list-scoped events and on the nested task for task-scoped ones; the parser reads both. |
| 58 | + |
| 59 | +## Event constants |
| 60 | + |
| 61 | +`events` spells every event this plugin can dispatch, as `str` enums grouped by |
| 62 | +event type, so a typo fails at import rather than by silently never matching. |
| 63 | +Raw strings still work, for events the constants do not cover yet. |
| 64 | + |
| 65 | +## What this plugin does not do |
| 66 | + |
| 67 | +Call the ClickUp API. Use `httpx` — ClickUp ships no Python SDK, and its API is a handful of REST calls directly from your tasks — see |
| 68 | +`examples/external_saas_integrations`. This plugin owns only the part that is |
| 69 | +Flyte's: authenticating an inbound delivery and turning it into a run. |
0 commit comments