feat(tokens): add a metrics gen command to create Warp 10 read tokens - #1128
Open
miton18 wants to merge 1 commit into
Open
feat(tokens): add a metrics gen command to create Warp 10 read tokens#1128miton18 wants to merge 1 commit into
miton18 wants to merge 1 commit into
Conversation
|
🔎 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-metrics-gen-tokenYou can also run it from your local repository: ./scripts/preview.js update feat-metrics-gen-token
This preview will be deleted once this PR is closed. |
`clever tokens metrics gen` prompts for an organisation, the platform
applications to read and a lifespan, then mints the token through
POST /v4/stats/organisations/{ownerId}/tokens/read. Each prompt is skipped
when the matching option is given, so the command stays scriptable.
The application list drives the prompt only, never validation: which ones an
owner may ask for is a server-side allow-list, and the API error already names
what it accepts.
miton18
force-pushed
the
feat/metrics-gen-token
branch
from
August 26, 2026 07:48
5fe2ff7 to
a15b113
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
clever tokens metrics gen, which mints a Warp 10 READ token throughPOST /v4/stats/organisations/{ownerId}/tokens/read.Why
Getting a Warp 10 token today means either the Console's Metrics tab — which only ever hands out one fixed scope — or a hand-rolled
clever curlwith a JSON body most people have to be told about. Neither lets you ask for, say, FS Bucket storage metrics, which is what prompted this.Design notes
Prompts are skipped when the option is given.
--org,--appsand--ttleach bypass their prompt, so the command is scriptable and CI-safe. Without a TTY the existingassertInteractiveTerminalguard fires with the option to use, rather than the silentexit(1)a raw Inquirer EOF would produce.The application list is not validation. Which applications an owner may request is a server-side allow-list that varies per deployment, so
PLATFORM_APPLICATIONSdrives the checkbox and nothing else —--appsis passed through untouched. A stale list here would otherwise reject an application the platform has since opened up, and the API's own error already names what it accepts:since: nullon both definitions, perscripts/resolve-since.js— the release resolves it.Two things worth a reviewer's eye:
/v2/summary: it appears inorganisationswith the same id asuser. A bare[user, ...organisations](the shapemodels/addon.jsuses, where it only costs a wasted loop iteration) renders a visible duplicate in a picker, so the choices are deduplicated on first occurrence — which also keeps the personal space at the top.superRefineon the input schema rather than only in thetransform.promptTextOptionvalidates against the unwrapped input schema, so this is what makes a typo re-ask instead of throwing the prompt away.iso8601Durationstays the single source of truth for the grammar and its message is forwarded verbatim, which is whyPT0Ssays something useful:src/parsers.jsNew
iso8601Duration: same grammar asdurationInSecondsminus the bare number of seconds (ambiguous here), but returns a duration instead of a count, soP5Dis sent asP5Drather than432000and the API echoes back something the user recognises.parseSimpleDurationnow shares the short-unit conversion with it — same behaviour, one copy.Open question for the reviewer
clever tokens' own description still reads "Manage API tokens to query Clever Cloud API from https://api-bridge.clever-cloud.com". That stays true of the bare command, which lists API tokens, but the group now also holds Warp 10 metrics tokens. I left the string alone rather than reword a released command's help as a side effect of this PR — say the word and I'll broaden it.Verification
npm run validateclean (eslint, prettier, tsc, docs:check).Run against the production API, not mocked:
-t 5d→ token expiring exactly 5 days later, so the short form normalises correctly-t 2h→ 2 hours--orgby name resolves throughOrganisation.getId--apps ''and--apps ' metrics , '→ the first errors client-side, the second yields['metrics']--org→This command requires an interactive terminal. Use --org <org-id|org-name> to skip this prompt.No unit tests: the repo has no test suite for commands, so this follows the existing convention.
Note
The branch is still named
feat/metrics-gen-token, from the first naming of this command (clever metrics gen-token). GitHub can't retarget a PR's head branch, so it stays — the commit and the command are the ones that matter.Follow-up
The FS Bucket storage metric this unblocks is documented in CleverCloud/documentation#998.