feat(billing): add billing:usage command#153
Open
Frostist wants to merge 5 commits intolaravel:mainfrom
Open
Conversation
Surfaces billing and usage data from GET /api/usage without requiring a browser. Supports period offsets (0–3), optional environment filter, --detailed breakdown (per-app, per-resource, per-addon tables), and --json for CI/scripting use.
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
Update BillingUsage to format item amounts using the `total_cents` field rather than `cost_cents`. This aligns the displayed values with the API response (which provides `total_cents`) and prevents showing incorrect/zero costs when `cost_cents` is absent.
Author
|
One aspect I found is that application names are returned as a UUID. Not a human readable name. It is possible to create a name lookup map if the user has ran: cloud application:list But what do you guys think? Could always do a background call if the user had to run: cloud billing:usage --detailed and then match the UUID's and print names instead. |
Author
Allow the BillingUsage command to continue when an environmentId is provided even if the --detailed flag is not set, and add rendering for environment usage items. The change adds an environment usage table (Identifier, Type, Profile, CPU Hours, Cost) formatted with numeric CPU hours and cents via formatCents, and only shows it when environment usage data is present.
Author
Removed note about JSON output support for billing commands.
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.




Surfaces billing and usage data from GET /api/usage. Supports period offsets (0–3), optional environment filter, --detailed breakdown (per-app, per-resource, per-addon tables), and --json for CI/scripting use.
Got this idea from the Issue at #105
Summary
cloud billing:usageto surface billing and usage data fromGET /api/usagewithout leaving the terminal--period(0–3 offsets),--environmentfilter,--detailedfor full per-app/per-resource/add-on tables, and--jsonfor CI/scriptingApr 1, 2026 – Apr 30, 2026) frommeta.available_periodsNew files
app/Client/Resources/Usage/GetUsageRequest.phpGET /api/usageapp/Client/Resources/UsageResource.phpapp/Dto/BillingUsage.phpapp/Commands/BillingUsage.phpbilling:usagecommand with summary and--detailedviewsapp/Client/Connector.phpModified files
app/Client/Connector.php— wires inusage()resource methodREADME.md— documents the new billing commandsUsage
I have tested this and it does work for me, I will include screenshots below.