Documentation
¶
Overview ¶
Package do reads DigitalOcean's billing API for the finance dashboard's cost side. DO is our PRIMARY venue (a large promotional credit); this client turns the customer balance + billing history into money.Cents the finance aggregator folds into gross margin and runway.
Auth is a single personal-access token, DO_API_TOKEN, sourced from a KMSSecret on the cloud env — NEVER hard-coded. When the token is unset the client is not Ready and every read reports the honest not-configured state.
SIGN CONVENTION (from DO's public OpenAPI spec): GET /v2/customers/my/balance returns decimal-dollar strings; account_balance carries the accounts-receivable sign — POSITIVE = we OWE DO, NEGATIVE = we hold CREDIT. Our promo credit shows as a negative account balance, so credit-remaining = -Account. Dollars are converted to cents once at this edge; everything downstream is money.Cents.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Balance ¶
Balance is the decoded /v2/customers/my/balance, in cents. Account carries DO's accounts-receivable sign (positive = owed to DO, negative = credit we hold).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client reads DigitalOcean billing with a personal-access token.
func NewWithBase ¶
NewWithBase builds a DO client against base (a test may point it at a stub).
func (*Client) Balance ¶
Balance fetches the customer balance, converting every dollar string to cents.
func (*Client) History ¶
History fetches recent billing history. Used only for the burn-down series; a failure is non-fatal to the caller (it renders the balance tiles with no series).
func (*Client) Volumes ¶ added in v1.801.186
Volumes lists ALL block-storage volumes across the account, following DO's page-number pagination (200/page, a hard 25-page cap so a runaway can never loop). The fleet inventory (count, capacity, monthly cost) is real; per-volume fill is NOT exposed by DO and stays absent (honest) until a filesystem source reports it.
type Entry ¶
type Entry struct {
Description string
Amount money.Cents
Date string
Kind string
InvoiceID string
}
Entry is one billing-history row (used to build the credit burn-down series).
type Volume ¶ added in v1.801.186
Volume is one DO block-storage volume: capacity + attachment + region. DO's API gives capacity and which droplets a volume is attached to, but NOT fill % — the caller enriches fill only where a filesystem source (the datastore's own system.disks) reports it, and renders an honest "—" everywhere else.