Repository navigation
feat(serverless): add usage command with the billed usage per space - #269
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
forgems
approved these changes
Nov 25, 2026
dstdfx
approved these changes
Nov 25, 2026
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.
Summary
Adds
qcloud serverless usage, which shows the billed serverless usage per space and billable item fromMeteringService.GetUsageBreakdown. Serverless spaces were added to that RPC in public API v0.234.0 (UsageBreakdownAccount.spaces), which this repo already uses, so no dependency bump is needed. Until now the CLI had no metering commands at all.Period
--month 2026-10[2026-10-01, 2026-11-01). For the current month the end is cut to now. Future months are rejected.--since/--untilYYYY-MM-DDor a duration ago, read with the sharedutil.ReadTimeRange.--untildefaults to now and is cut to now. Without--sincethe period starts on the first day of the month of--until, or the month before when--untilis exactly the first instant of a month.--monthcan't be combined with--sinceor--until.Output
SPACEshows-when the API can no longer resolve the name, for example for a deleted space.NET = AMOUNT - DISCOUNT.Totalis the net sum, with one amount per currency if there is more than one.output.Millicentsformats non-USD amounts as1,234.56 EUR.ACCOUNTcolumn appears when more than one account has space usage.--space <id>filters to one space on the client side, because the RPC has no space filter. Completion usesSpaceIDCompletion.funding.credits_drawnare removed, from--jsontoo. Both cover all of the account's usage, not only serverless, so they would be misleading underqcloud serverless. Months and accounts with no space usage left are dropped. If we want cluster usage in the CLI, I'd add a separate top-level command (for exampleqcloud usage) rather than mixing it in here.The RPC needs the
read:payment_informationpermission. The help text says so.Plumbing
qcloudapi.Client.Metering(),testutil.FakeMeteringService, registered in the test server.output.Millicents(int64, currency)next tooutput.USDMillicents.Testing
usage_test.go: text output (columns, quantity, discount, net, total, clusters and cluster-only months hidden, sorting, unknown space name), default period,--month(past and current),--since/--until,--untilonly (mid-month and first instant of a month),--space(match and no match), parent account column, mixed currencies, JSON (clusters and funding stripped), input errors with no API call, and the backend error.money_test.go:output.Millicents.make lint,make build,make testandmake docs(docs regenerated) pass. I haven't run it against the real API.🤖 Generated with Claude Code
Written with Overlord from https://overlord.qdrant.tech/r/1089/t/7445