schema

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Ref     KeyRef
	Display string
	Totals  Totals
}

type Group

type Group struct {
	Canonical string
	Ref       KeyRef
	Display   string
	Totals    Totals
}

type Item

type Item struct {
	RowID          string `json:"row_id"`
	KeyName        string `json:"key_name"`
	KeyDisplay     string `json:"key_display"`
	Source         string `json:"source"`
	Owner          Owner  `json:"owner"`
	KeyStatus      string `json:"key_status"`
	MetadataStatus string `json:"metadata_status"`
	Metrics
}

type KeyRef

type KeyRef struct {
	Hash, KeyID, WorkspaceID, UserID, TenantID string
}

KeyRef, Candidate, Resolution, Group and Metadata are internal only, never HTTP DTOs.

type Metadata

type Metadata struct {
	KeyName, Display, Source, KeyStatus, MetadataStatus string
	Owner                                               Owner
}

type Metrics

type Metrics struct {
	RequestCount        uint64   `json:"request_count"`
	SuccessCount        uint64   `json:"success_count"`
	SuccessRate         float64  `json:"success_rate"`
	InputTokens         uint64   `json:"input_tokens"`
	OutputTokens        uint64   `json:"output_tokens"`
	CachedTokens        uint64   `json:"cached_tokens"`
	CacheCreationTokens uint64   `json:"cache_creation_tokens"`
	TotalTokens         uint64   `json:"total_tokens"`
	TotalCost           string   `json:"total_cost"`
	TokenShare          *float64 `json:"token_share"`
}

type Owner

type Owner struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Query

type Query struct {
	TimeRange string
	SortBy    string
	Limit     int
}

func ParseQuery

func ParseQuery(values url.Values) (Query, error)

func (Query) Validate

func (q Query) Validate() error

type Resolution

type Resolution struct {
	Keys     map[KeyRef]string
	Warnings []string
}

type Response

type Response struct {
	State        string     `json:"state"`
	DataSource   string     `json:"data_source"`
	Window       *Window    `json:"window"`
	GeneratedAt  *time.Time `json:"generated_at"`
	Summary      *Summary   `json:"summary"`
	Items        []Item     `json:"items"`
	Unattributed *Metrics   `json:"unattributed"`
	Warnings     []string   `json:"warnings"`
}

type Summary

type Summary struct {
	KeyCount uint64 `json:"key_count"`
	Metrics
}

type Totals

type Totals struct {
	Requests, Success, Input, Output, Cached, CacheCreation uint64
	Cost                                                    decimal.Decimal
}

func (*Totals) Add

func (t *Totals) Add(other Totals)

func (Totals) Tokens

func (t Totals) Tokens() uint64

type UsageTrendsBucket added in v1.0.4

type UsageTrendsBucket struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
	UsageTrendsMetrics
}

type UsageTrendsMetrics added in v1.0.4

type UsageTrendsMetrics struct {
	Requests      uint64   `json:"requests"`
	Success       uint64   `json:"success"`
	Failure       uint64   `json:"failure"`
	Input         uint64   `json:"input_tokens"`
	Output        uint64   `json:"output_tokens"`
	Cached        uint64   `json:"cached_tokens"`
	CacheCreation uint64   `json:"cache_creation_tokens"`
	TotalTokens   uint64   `json:"total_tokens"`
	FailureRate   *float64 `json:"failure_rate"`
	AvgLatencyMs  *float64 `json:"avg_latency_ms"`
	AvgTTFTMs     *float64 `json:"avg_ttft_ms"`
}

type UsageTrendsQuery added in v1.0.4

type UsageTrendsQuery struct {
	TimeRange string
}

func ParseUsageTrendsQuery added in v1.0.4

func ParseUsageTrendsQuery(values url.Values) (UsageTrendsQuery, error)

func (UsageTrendsQuery) BucketSeconds added in v1.0.4

func (q UsageTrendsQuery) BucketSeconds(window Window) int64

func (UsageTrendsQuery) Validate added in v1.0.4

func (q UsageTrendsQuery) Validate() error

func (UsageTrendsQuery) Window added in v1.0.4

func (q UsageTrendsQuery) Window(end time.Time) Window

type UsageTrendsResponse added in v1.0.4

type UsageTrendsResponse struct {
	State         string              `json:"state"`
	DataSource    string              `json:"data_source"`
	Window        *Window             `json:"window"`
	GeneratedAt   *time.Time          `json:"generated_at"`
	BucketSeconds int64               `json:"bucket_seconds"`
	Summary       *UsageTrendsMetrics `json:"summary"`
	Buckets       []UsageTrendsBucket `json:"buckets"`
}

type UsageTrendsRow added in v1.0.4

type UsageTrendsRow struct {
	Index uint64
	UsageTrendsTotals
}

type UsageTrendsTotals added in v1.0.4

type UsageTrendsTotals struct {
	Requests, Success, Input, Output, Cached, CacheCreation uint64
	LatencySumMs, TTFTSumMs, TTFTCount                      uint64
}

UsageTrendsTotals is an internal aggregate; it never contains request identities.

func (*UsageTrendsTotals) Add added in v1.0.4

func (t *UsageTrendsTotals) Add(other UsageTrendsTotals)

func (UsageTrendsTotals) Metrics added in v1.0.4

type Window

type Window struct {
	Start    time.Time `json:"start"`
	End      time.Time `json:"end"`
	Timezone string    `json:"timezone"`
}

func ResolveWindow

func ResolveWindow(q Query, end time.Time) Window

ResolveWindow expects a validated query and preserves the server's day boundary.

Jump to

Keyboard shortcuts

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