sqlcgen

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdjustmentRecord

type AdjustmentRecord struct {
	ID             pgtype.UUID
	RunID          pgtype.UUID
	ProjectID      string
	RelationID     pgtype.UUID
	RelationType   string
	RelationTarget string
	Beneficiary    pgtype.Text
	Type           string
	Scope          string
	Rate           pgtype.Numeric
	Base           pgtype.Numeric
	Amount         pgtype.Numeric
	Currency       string
}

type BillingPeriod

type BillingPeriod struct {
	PeriodFrom     pgtype.Timestamptz
	PeriodTo       pgtype.Timestamptz
	Status         string
	FinalizedRunID pgtype.UUID
	FinalizedAt    pgtype.Timestamptz
}

type CorrectionDelta

type CorrectionDelta struct {
	ID            pgtype.UUID
	RunID         pgtype.UUID
	CorrectsRunID pgtype.UUID
	Cloud         string
	Platform      string
	ResourceType  string
	ResourceID    string
	ProjectID     string
	Dimension     string
	OldAmount     pgtype.Numeric
	NewAmount     pgtype.Numeric
	Delta         pgtype.Numeric
	Currency      string
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetPricingModelRow

type GetPricingModelRow struct {
	Version    string
	ValidFrom  pgtype.Timestamptz
	Currency   string
	ImportedAt pgtype.Timestamptz
	Document   []byte
}

type GetStatementParams

type GetStatementParams struct {
	RunID     pgtype.UUID
	ProjectID string
}

type GetStatementRow

type GetStatementRow struct {
	Document []byte
	Total    pgtype.Numeric
	Currency string
}

type LatestRunWithResourceParams

type LatestRunWithResourceParams struct {
	Cloud        string
	ResourceType string
	ResourceID   string
}

type ListCorrectionDeltasRow

type ListCorrectionDeltasRow struct {
	Cloud        string
	Platform     string
	ResourceType string
	ResourceID   string
	ProjectID    string
	Dimension    string
	OldAmount    pgtype.Numeric
	NewAmount    pgtype.Numeric
	Delta        pgtype.Numeric
	Currency     string
}

type ListPricingModelsRow

type ListPricingModelsRow struct {
	Version    string
	ValidFrom  pgtype.Timestamptz
	Currency   string
	ImportedAt pgtype.Timestamptz
}

type ListResourceSegmentsParams

type ListResourceSegmentsParams struct {
	RunID        pgtype.UUID
	Cloud        string
	ResourceType string
	ResourceID   string
}

type ListResourceSegmentsRow

type ListResourceSegmentsRow struct {
	State     string
	FromTs    pgtype.Timestamptz
	ToTs      pgtype.Timestamptz
	Seconds   int64
	Usage     []byte
	Dimension string
	Amount    pgtype.Numeric
	Currency  string
}

type ListRunTotalsForPeriodRow

type ListRunTotalsForPeriodRow struct {
	RunID      pgtype.UUID
	Currency   string
	Statements int64
	Total      pgtype.Numeric
}

type ListRunsSettlingForRow

type ListRunsSettlingForRow struct {
	ID         pgtype.UUID
	PeriodFrom pgtype.Timestamptz
	Kind       string
	Status     string
}

type ListStatementsForProjectRow

type ListStatementsForProjectRow struct {
	RunID      pgtype.UUID
	PeriodFrom pgtype.Timestamptz
	Kind       string
	Status     string
	Total      pgtype.Numeric
	Currency   string
}

type ListStatementsRow

type ListStatementsRow struct {
	ProjectID string
	Total     pgtype.Numeric
	Currency  string
}

type PricingModel

type PricingModel struct {
	Version    string
	ValidFrom  pgtype.Timestamptz
	Currency   string
	Document   []byte
	ImportedAt pgtype.Timestamptz
}

type ProjectStatement

type ProjectStatement struct {
	ID        pgtype.UUID
	RunID     pgtype.UUID
	ProjectID string
	Document  []byte
	Total     pgtype.Numeric
	Currency  string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) GetPeriod

func (q *Queries) GetPeriod(ctx context.Context, periodFrom pgtype.Timestamptz) (BillingPeriod, error)

The head of a period page: one month, where it stands, and which run closed it.

func (*Queries) GetPricingModel

func (q *Queries) GetPricingModel(ctx context.Context, version string) (GetPricingModelRow, error)

One pricing version with the catalog document the pricing page renders.

func (*Queries) GetRun

func (q *Queries) GetRun(ctx context.Context, id pgtype.UUID) (Run, error)

The header of a run page: the eleven columns a run carries.

func (*Queries) GetStatement

func (q *Queries) GetStatement(ctx context.Context, arg GetStatementParams) (GetStatementRow, error)

The statement page: the stored document and the total it sums to.

func (*Queries) LatestRunWithResource

func (q *Queries) LatestRunWithResource(ctx context.Context, arg LatestRunWithResourceParams) (pgtype.UUID, error)

The run a resource page defaults to: the newest run that metered that resource at all.

func (*Queries) ListCorrectionDeltas

func (q *Queries) ListCorrectionDeltas(ctx context.Context, runID pgtype.UUID) ([]ListCorrectionDeltasRow, error)

The delta table of a correction run page: what the correction moved, per key.

func (*Queries) ListPeriods

func (q *Queries) ListPeriods(ctx context.Context) ([]BillingPeriod, error)

The period list of the overview page: what months exist, where each one stands, and which run closed the finalized ones.

func (*Queries) ListPricingModels

func (q *Queries) ListPricingModels(ctx context.Context) ([]ListPricingModelsRow, error)

The pricing page's version list, the version in force last first.

func (*Queries) ListResourceSegments

func (q *Queries) ListResourceSegments(ctx context.Context, arg ListResourceSegmentsParams) ([]ListResourceSegmentsRow, error)

The timeline of a resource page: every metered segment of one run with the amounts it was rated at.

func (*Queries) ListRunTotalsForPeriod

func (q *Queries) ListRunTotalsForPeriod(ctx context.Context, periodFrom pgtype.Timestamptz) ([]ListRunTotalsForPeriodRow, error)

The totals of a period page: per run of one month and currency, how many statements the run wrote and what they add up to.

func (*Queries) ListRuns

func (q *Queries) ListRuns(ctx context.Context, limit int32) ([]Run, error)

The run list of the overview page, newest first and bounded by the caller.

func (*Queries) ListRunsForPeriod

func (q *Queries) ListRunsForPeriod(ctx context.Context, periodFrom pgtype.Timestamptz) ([]Run, error)

The run table of a period page: every run of one month in the order the runs started, so a correction stands under the run it corrects.

func (*Queries) ListRunsSettlingFor

func (q *Queries) ListRunsSettlingFor(ctx context.Context, beneficiary pgtype.Text) ([]ListRunsSettlingForRow, error)

The runs a partner's settlement is read from: every run that stands of every period that ever settled a kickback for the partner. A period is read whole, rather than only the runs holding a record for the partner, because a correction that takes a kickback away holds no record of it and is what the settlement of that period then hangs on.

func (*Queries) ListStatements

func (q *Queries) ListStatements(ctx context.Context, runID pgtype.UUID) ([]ListStatementsRow, error)

The statement table of a run page, largest total first. The project key breaks a tie between two equal totals, so the page renders one order.

func (*Queries) ListStatementsForProject

func (q *Queries) ListStatementsForProject(ctx context.Context, projectID string) ([]ListStatementsForProjectRow, error)

The history of one project across runs, oldest month first.

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RatedRecord

type RatedRecord struct {
	ID            pgtype.UUID
	RunID         pgtype.UUID
	UsageRecordID pgtype.UUID
	Dimension     string
	Amount        pgtype.Numeric
	Currency      string
}

type Run

type Run struct {
	ID             pgtype.UUID
	PeriodFrom     pgtype.Timestamptz
	PeriodTo       pgtype.Timestamptz
	Kind           string
	CorrectsRunID  pgtype.UUID
	PricingVersion pgtype.Text
	Status         string
	Clouds         []string
	Stats          []byte
	StartedAt      pgtype.Timestamptz
	CompletedAt    pgtype.Timestamptz
}

type UsageRecord

type UsageRecord struct {
	ID           pgtype.UUID
	RunID        pgtype.UUID
	Cloud        string
	Platform     string
	ResourceType string
	ResourceID   string
	ProjectID    string
	State        string
	FromTs       pgtype.Timestamptz
	ToTs         pgtype.Timestamptz
	Seconds      int64
	Usage        []byte
}

Jump to

Keyboard shortcuts

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