feat: add show-linking-usage support CLI command#3122
Open
Sneagan wants to merge 4 commits into
Open
Conversation
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
bat-go skus show-linking-usage, a read-only support CLI command that showshow many device linking slots are in use for a premium order.
Support asked for a way to see a subscriber's slot usage without touching anything.
The deletion flow (
reset-linking-limit) already reveals this during itsconfirmation step; this command exposes the same listing — active credential
batches via the signed
GET /v1/orders/{orderID}/credentials/batchesendpoint,where each batch is one linked device — without any mutation or confirmation
prompt. The order is identified by
--order-idor--email(subscriptionssupport API lookup, with interactive selection when several match), optionally
scoped with
--item-id.The shared logic between the two commands is extracted into helpers used by both
(
requireOrderRef,resolveOrderID,batchesURL,formatBatchTable) rather thanduplicated;
reset-linking-limit's behavior and output are unchanged.Note: the report shows slots in use only, not used-of-total — the batches
endpoint does not return the item's
max_active_batches_tlv2_creds, so aused/total display would need a small SKUs server change. Possible follow-up.
The new command's flags are deliberately not bound to viper:
reset-linking-limitalready binds the shared global keys, and
viper.BindPFlagis global, so rebindingwould clobber that command. Flags are read directly from cobra with env fallback.
Type of Change
Tested Environments
Before Requesting Review
endpoint)
Manual Test Plan
bat-go skus show-linking-usage
--skus-base-url https://
--private-key
--email subscriber@example.com
--subscriptions-base-url https://
--subscriptions-token <SUPPORT_TOKEN>
count plus a per-device table (request_id, oldest_valid_from), making no changes.
--order-id <uuid>targets an order directly without the email lookup.--item-id <uuid>scopes the listing to one order item.reset-linking-limitis unaffected: same prompts, output, and behavior as before.