vantageapi

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package vantageapi provides a thin wrapper around the official Vantage Go client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	RetryAfter time.Duration
	// contains filtered or unexported fields
}

APIError preserves status and retry timing without exposing the response body.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Unwrap preserves the original error for context cancellation and diagnostics.

type Client

type Client interface {
	GetCosts(ctx context.Context, params *GetCostsParams) (*CostsResponse, error)
}

Client wraps the official Vantage generated client for cost queries. The plugin owns this interface to decouple from generated code changes.

func NewClient

func NewClient(baseURL, bearerToken string) (Client, error)

NewClient creates a new Vantage API client with the given base URL and bearer token. If baseURL is empty, defaults to https://api.vantage.sh/v2.

type CostAmount

type CostAmount struct {
	Amount   string // Decimal string
	Currency string // ISO 4217 code
}

CostAmount represents an amount with currency.

type CostRow

type CostRow struct {
	AccruedAt        string      // ISO 8601: YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DD
	Amount           string      // Decimal string, never float
	Currency         string      // ISO 4217 code (USD, EUR, etc.)
	Usage            interface{} // Untyped, provider-specific
	UsageUnit        *string
	Provider         *string
	Service          *string
	AccountID        *string
	BillingAccountID *string
	Region           *string
	ResourceID       *string
	ResourceName     *string
	Tags             []string // Array of strings, format undocumented
	CostCategory     *string
	CostSubcategory  *string
	ChargeType       *string // Distinguishes tax, credit, refund lines
	Tagged           *bool
	Segment          *string
}

CostRow represents a single cost data point.

type CostSettings

type CostSettings struct {
	Amortize           *bool
	IncludeCredits     *bool
	IncludeRefunds     *bool
	IncludeDiscounts   *bool
	IncludeTax         *bool
	AggregateBy        *string
	ShowPreviousPeriod *bool
	UnAllocated        *bool
}

CostSettings represents cost query settings.

type CostsResponse

type CostsResponse struct {
	// Costs is the list of cost rows; amounts are decimal strings
	Costs []*CostRow
	// TotalCost is the sum of all costs in the period
	TotalCost *CostAmount
	// TotalUsage is usage broken down by unit
	TotalUsage []*UsageAmount
	// Links for pagination (next URL, etc.)
	Links *PaginationLinks
}

CostsResponse represents the response from GET /costs.

type GetCostsParams

type GetCostsParams struct {
	CostReportToken *string
	WorkspaceToken  *string
	Filter          *string
	StartDate       *string  // ISO 8601 format: YYYY-MM-DD
	EndDate         *string  // ISO 8601 format: YYYY-MM-DD
	DateBin         *string  // day, week, month, quarter, hour
	Groupings       []string // e.g., []string{"provider", "service", "account_id"}
	Page            *int32
	Limit           *int32
	// Settings for cost basis
	Settings *CostSettings
}

GetCostsParams represents parameters for the GET /costs operation.

type PaginationLinks struct {
	Self  *string
	First *string
	Next  *string
	Prev  *string
	Last  *string
}

PaginationLinks contains links for pagination.

type UsageAmount

type UsageAmount struct {
	Amount string // Decimal string
	Unit   string
}

UsageAmount represents usage grouped by unit.

Jump to

Keyboard shortcuts

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