billing

package
v0.28.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package billing is the obot-billing subscription of a billed Obot Cloud environment. Client asks obot-billing itself. Provider provides the entitlements the subscription grants, and the restriction for staying over them, from the Subscription the leader stores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestSync

func RequestSync(ctx context.Context, c kclient.Client) error

RequestSync asks the leader to sync the Subscription with billing now, by setting SubscriptionSyncAnnotation. A sync that's already pending covers the request, so it isn't written again. Without a Subscription, which only a billed environment has, it returns a not-found error.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client calls billing's API for Obot with the environment's billing key.

func NewClient

func NewClient(url, key string) *Client

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, returnURL string) (types.BillingSession, error)

CreateSession opens the billing pages for an owner and returns a one-time link to them. Billing sends the owner back to returnURL when they're done.

func (*Client) FetchSubscription

func (c *Client) FetchSubscription(ctx context.Context) (types.Subscription, error)

FetchSubscription reads the environment's subscription, entitlements included. It refuses an answer with a negative limit, which nothing could enforce.

type Error

type Error struct {
	Status  int    `json:"-"`
	Message string `json:"message"`
}

Error is an error response from billing. Message is safe to show to owners.

func (*Error) Error

func (e *Error) Error() string

type Provider

type Provider struct {
	// Client asks obot-billing itself.
	Client *Client
	// contains filtered or unexported fields
}

Provider provides a billed environment's entitlements, in place of its license.

func NewProvider

func NewProvider(client *Client, cache, storage kclient.Reader) *Provider

NewProvider returns the provider for the environment that client's billing key belongs to. Requests read the Subscription all the time, so it's read from the cache, which follows the leader's writes within moments. Startup reads it before the cache starts, and those reads go to storage.

func (*Provider) Entitlements

func (p *Provider) Entitlements(ctx context.Context) (types.Entitlements, error)

Entitlements are what the subscription grants.

func (*Provider) Restricted

func (p *Provider) Restricted(ctx context.Context) (bool, error)

Restricted reports whether only admins and owners can use the environment. It's restricted once usage has been over the limits for the grace period, or once billing hasn't answered for the grace period past the end of the period it last answered with.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL