Skip to content

feat(drain): filter the drain list by recipient type - #1113

Open
KannarFr wants to merge 1 commit into
feat/option-groupsfrom
feat/drain-filter-by-type
Open

feat(drain): filter the drain list by recipient type#1113
KannarFr wants to merge 1 commit into
feat/option-groupsfrom
feat/drain-filter-by-type

Conversation

@KannarFr

@KannarFr KannarFr commented Aug 3, 2026

Copy link
Copy Markdown
Member

Follow-up to #1112, independent of it (branched from master, no shared files beyond the generated docs).

clever drain listed every drain of a resource with no way to narrow it down. This adds --type:

clever drain --type elasticsearch
clever drain --type datadog -F json

The option reuses DRAIN_TYPE_CLI_CODES, so it is validated at parse time, shell-completed, and stays in sync with whatever drain create accepts — including new types as they ship.

Why the filter is client side

The endpoint the CLI calls, GET /v4/drains/organisations/{ownerId}/resources/{resourceId}/drains, only takes status, executionStatus and executionStatusNotIn. recipientType exists, but on the admin GET /v4/drains endpoint, which isn't reachable from here. The response is bounded by the drains of a single resource and never paginates, so filtering after the call can't miss anything. If recipientType is ever added to the resource-scoped endpoint, moving the filter server-side is a one-line change in src/clever-client/drains.js.

The filter applies to both output formats, and the empty-list message names the type when one is set, so an empty result reads as an empty filter rather than a resource with no drains at all.

Checks

npm run validate passes. Verified by hand that an unknown --type is rejected at parse time with the list of valid values, and that shell completion offers the drain types after --type.

Not included, still open if you want it: the multi-drain table shows ID / Status / Execution status / URL but no Type column, so an unfiltered list still doesn't tell you what to filter on.

@KannarFr
KannarFr requested a review from a team as a code owner August 3, 2026 12:52
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

🔎 A preview has been automatically published!

If you created the alias to the preview script, you can run this command to download and install this preview:

clever-preview update feat-drain-filter-by-type

You can also run it from your local repository:

./scripts/preview.js update feat-drain-filter-by-type
OS SHA256 checksum
🐧 linux b5dbbd56e416e4d4b7072f8cd73d6be320d32cb40bccd03dafafd5b76286e016
🍏 macos 5cd0e314484fee03590240686cc56d1548ef4b3844f03bed1ccb8b538df26692

This preview will be deleted once this PR is closed.

Adds `clever drain --type <drain-type>` so a resource with several drains
can be narrowed to one recipient type, in both human and JSON output:

    clever drain --type elasticsearch
    clever drain --type datadog -F json

The option reuses DRAIN_TYPE_CLI_CODES, so it validates at parse time, is
shell-completed, and stays in sync with the types `drain create` accepts.

Filtering happens client side: the resource scoped endpoint the CLI calls
(`GET /v4/drains/organisations/{ownerId}/resources/{resourceId}/drains`)
only takes status and executionStatus query parameters. `recipientType`
exists on the admin `GET /v4/drains` endpoint, which is not reachable here.
The response is bounded by the drains of a single resource and never
paginates, so there is nothing to miss by filtering after the call.

The empty-list message names the type when one is set, so an empty result
reads as an empty filter rather than a resource with no drains at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KcPGoR5eyRZtYWhCFvyqvs
@KannarFr
KannarFr force-pushed the feat/drain-filter-by-type branch from 7da7a0e to b95d575 Compare August 3, 2026 13:11
@KannarFr
KannarFr changed the base branch from master to feat/option-groups August 3, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant