billingexport

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	Tags             map[string]string
	Service          string
	Region           string
	UsageType        string
	Account          string
	AvailabilityZone string
	InstanceType     string
	Operation        string
	ChargeType       string
	PurchaseType     string
	ProductFamily    string
	UsageTypeGroup   string
	ResourceID       string
	Blended          float64
	Unblended        float64
	Usage            float64
}

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

func (CostLine) ChargeCategory

func (l CostLine) ChargeCategory() string

ChargeCategory maps the ledger charge type onto a FOCUS ChargeCategory value.

func (CostLine) Key

func (l CostLine) Key() string

Key identifies the dimensions a monthly roll-up merges lines on.

func (CostLine) LineItemType

func (l CostLine) LineItemType() string

LineItemType maps the ledger charge type onto a CUR lineItem/LineItemType value.

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