Documentation
¶
Overview ¶
Package subscriptions is the fleet SUBSCRIPTION view (/v1/admin/subscriptions) — every tenant's plan subscription: customer/org, plan, status, monthly-normalized MRR, and the current-period start/renews. SuperAdmin only (core.Admit).
It reads the ONE shared warehouse (commerce.events) — the table the commerce analytics collector lands every subscription-lifecycle event in — over the SAME client (datastore.Query) the o11y/compute lenses use, with ZERO per-org fan-out: one GROUP BY resolves each subscription's LATEST lifecycle state (argMax by timestamp), so the whole fleet is one query, not N per-org commerce reads. Honest by construction: no datastore connected or the collector's table not provisioned yet → the real empty list, never a fabricated tenant. The MRR is the monthly-normalized figure the emitter already computed (cents). Optional ?org= scopes to one tenant, ?status= filters the LATEST status, ?limit= caps.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SubscriptionRow ¶
type SubscriptionRow struct {
ID string `json:"id"`
Org string `json:"org"`
Display string `json:"display"`
User string `json:"user"`
Plan string `json:"plan"`
Status string `json:"status"`
MRRCents int64 `json:"mrrCents"`
Started string `json:"started"`
Renews string `json:"renews"`
}
SubscriptionRow is one row of GET /v1/admin/subscriptions — a tenant's subscription at a glance, tagged with its owning org. MRR is USD cents; timestamps are RFC3339 strings.
type SubscriptionsIn ¶
type SubscriptionsIn struct {
// Status filters on the subscription's LATEST lifecycle status (active, trialing,
// canceled, …), matched case-insensitively.
Status string `json:"status"`
// Org filters to one tenant, matched exactly.
Org string `json:"org"`
// Limit caps the rows returned. total still reports the full match count.
Limit string `json:"limit"`
}
SubscriptionsIn is the GET /v1/admin/subscriptions filter.
type SubscriptionsOut ¶
type SubscriptionsOut struct {
Status string `json:"status"`
Msg string `json:"msg"`
Data []SubscriptionRow `json:"data"`
Total *int `json:"total,omitempty"`
}
SubscriptionsOut is the GET /v1/admin/subscriptions envelope. total is the count BEFORE limit truncates.
func Subscriptions ¶
func Subscriptions(ctx context.Context, in *SubscriptionsIn) (*SubscriptionsOut, error)
Subscriptions answers GET /v1/admin/subscriptions.
GET /v1/admin/subscriptions?org=&status=&limit=