Documentation
¶
Overview ¶
Package localpricing provides a local SQLite-based pricing database for offline cost estimation.
Index ¶
- func DefaultPath() string
- func Exists(path string) bool
- func Sync(opts SyncOptions) error
- type PriceEntry
- type QueryResult
- type Store
- func (s *Store) Close() error
- func (s *Store) GetMetadata(key string) (string, error)
- func (s *Store) LookupPrice(vendor, service, region string, attrFilters map[string]string, ...) (gjson.Result, error)
- func (s *Store) ProductCount() (int, error)
- func (s *Store) QueryProducts(vendor, service, region string, attributeFilters map[string]string) (*sql.Rows, error)
- func (s *Store) SetMetadata(key, value string) error
- func (s *Store) UpsertProduct(vendor, region, service, productFamily, sku, attributes, prices string) error
- type SyncOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns the default path for the local pricing database.
func Sync ¶
func Sync(opts SyncOptions) error
Sync downloads pricing data from cloud provider bulk APIs into the local store.
Types ¶
type PriceEntry ¶
type PriceEntry struct {
USD string `json:"USD"`
Unit string `json:"unit"`
Description string `json:"description,omitempty"`
}
PriceEntry represents a single price dimension.
type QueryResult ¶
type QueryResult struct {
SKU string
Attributes map[string]string
Prices []PriceEntry
}
QueryResult represents a single product price result from the local database.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store represents a local SQLite pricing database.
func (*Store) GetMetadata ¶
GetMetadata gets a metadata value by key.
func (*Store) LookupPrice ¶
func (s *Store) LookupPrice(vendor, service, region string, attrFilters map[string]string, priceUnit string) (gjson.Result, error)
LookupPrice queries the local pricing database for a product matching the given filters. Returns a gjson.Result in the same format as the remote GraphQL API response.
func (*Store) ProductCount ¶
ProductCount returns the total number of products in the database.
func (*Store) QueryProducts ¶
func (s *Store) QueryProducts(vendor, service, region string, attributeFilters map[string]string) (*sql.Rows, error)
QueryProducts queries products matching the given filters.
func (*Store) SetMetadata ¶
SetMetadata sets a metadata key-value pair.
func (*Store) UpsertProduct ¶
func (s *Store) UpsertProduct(vendor, region, service, productFamily, sku, attributes, prices string) error
UpsertProduct inserts or updates a product in the local database.