billingexport

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package billingexport holds the cost-line source, S3 sink and file encoders shared by the Cost and Usage Reports and Billing and Cost Management Data Exports emulators.

Index

Constants

View Source
const (
	TypeString = "string"
	TypeDouble = "double"
)

Column types understood by Encode.

View Source
const (
	FormatCSV     = "csv"
	FormatParquet = "parquet"

	CompressNone = "none"
	CompressGzip = "gzip"
	CompressZip  = "zip"
)

Output file formats and compressions.

Variables

This section is empty.

Functions

func BucketExists

func BucketExists(ctx context.Context, store ObjectStore, bucket string) bool

BucketExists reports whether bucket is present in store.

func Encode

func Encode(t *Table, format, compression, baseName string) ([]byte, string, error)

Encode renders t as format with compression and returns the body and the file extension. Parquet is always internally compressed (snappy) and ignores compression.

func ProductCode

func ProductCode(service string) string

ProductCode maps a Cost Explorer service name to its billing product code.

func Put

func Put(ctx context.Context, store ObjectStore, bucket, key string, body []byte, contentType string) error

Put writes body to bucket/key.

func SnakeCase

func SnakeCase(s string) string

SnakeCase converts "lineItem/UsageAccountId" style names to "line_item_usage_account_id".

Types

type Column

type Column struct {
	Name string
	Type string
}

Column is one output column.

type CostLine

type CostLine struct {
	Day       time.Time
	Service   string
	Region    string
	UsageType string
	Account   string
	Blended   float64
	Unblended float64
	Usage     float64
}

CostLine is one day of cost for a service/region/usage-type/account combination.

type CostSource

type CostSource interface {
	CostLines(start, end time.Time) []CostLine
}

CostSource yields the daily cost lines with start <= Day < end.

type ObjectStore

type ObjectStore interface {
	PutObject(ctx context.Context, in *sdk_s3.PutObjectInput) (*sdk_s3.PutObjectOutput, error)
	HeadBucket(ctx context.Context, in *sdk_s3.HeadBucketInput) (*sdk_s3.HeadBucketOutput, error)
}

ObjectStore is the S3 surface report delivery writes to.

type Table

type Table struct {
	Columns []Column
	Rows    [][]any
}

Table is a header plus rows; a cell is a string, float64 or nil.

Jump to

Keyboard shortcuts

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