Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteBillRepositoryById(brId int, tx *sql.Tx) error
- func ReadBills(ctx context.Context, aa taws.AwsAccount, br BillRepository, oli OnLineItem, ...) (time.Time, error)
- func UpdateBillRepository(br BillRepository, tx *sql.Tx) error
- func UpdateBillRepositoryWithoutContext(br BillRepository, db models.XODB) error
- func UpdateReport(ctx context.Context, aa aws.AwsAccount, br BillRepository) (latestManifest time.Time, err error)
- type AwsAccountWithBillRepositoriesWithPending
- type AwsAccountWithBillRepositoriesWithStatus
- type BillKey
- type BillRepository
- func CreateBillRepository(aa aws.AwsAccount, br BillRepository, tx *sql.Tx) (BillRepository, error)
- func GetAwsBillRepositoriesWithDueUpdate(tx *sql.Tx) ([]BillRepository, error)
- func GetBillRepositoriesForAwsAccount(aa aws.AwsAccount, tx *sql.Tx) ([]BillRepository, error)
- func GetBillRepositoryForAwsAccountById(aa aws.AwsAccount, brId int, tx *sql.Tx) (BillRepository, error)
- func UpdateBillRepositorySafe(dbBr *models.AwsBillRepository, br BillRepository, tx *sql.Tx) (BillRepository, error)
- type BillRepositoryWithPending
- type BillRepositoryWithStatus
- type LineItem
- type LineItemTags
- type ManifestPredicate
- type OnLineItem
- type ReportUpdateConclusion
- type Status
Constants ¶
const ( // MaxCheckedKeysByRepository is the amount of keys inspected before we give // up. If users have a massive bucket where their bills are stored alongside // other keys, we don't to spend too much time reading the metadata of all // keys. This means that it is the responsibility of the user to put their // bills in a place where there isn't much of anything else. MaxCheckedKeysByRepository = 10000 ReadBillsStsSessionName = "read-bills" )
const IndexPrefixLineItem = "lineitems"
const TemplateLineItem = `` /* 1723-byte string literal not displayed */
const TemplateNameLineItem = "lineitems"
const TypeLineItem = "lineitem"
Variables ¶
var (
ErrUnsupportedCompression = errors.New("unsupported compression")
)
Functions ¶
func ReadBills ¶
func ReadBills(ctx context.Context, aa taws.AwsAccount, br BillRepository, oli OnLineItem, mp ManifestPredicate) (time.Time, error)
ReadBills reads all LineItems from new bills in a BillRepository, and runs `oli` for each one.
func UpdateBillRepository ¶
func UpdateBillRepository(br BillRepository, tx *sql.Tx) error
UpdateBillRepository updates a BillRepository in the database. No checks are performed.
func UpdateBillRepositoryWithoutContext ¶
func UpdateBillRepositoryWithoutContext(br BillRepository, db models.XODB) error
UpdateBillRepositoryWithoutContext updates a BillRepository in the database. No checks are performed.
func UpdateReport ¶
func UpdateReport(ctx context.Context, aa aws.AwsAccount, br BillRepository) (latestManifest time.Time, err error)
UpdateReport updates the elasticsearch database with new data from usage and cost reports.
Types ¶
type AwsAccountWithBillRepositoriesWithPending ¶
type AwsAccountWithBillRepositoriesWithPending struct {
aws.AwsAccount
BillRepositories []BillRepositoryWithPending `json:"billRepositories"`
SubAccounts []AwsAccountWithBillRepositoriesWithPending `json:"subAccounts,omitempty"`
}
AwsAccountWithBillRepositoriesWithPending represents a client's AWS account with its bill repositories.
func WrapAwsAccountsWithBillRepositories ¶
func WrapAwsAccountsWithBillRepositories(awsAccounts []aws.AwsAccount, tx *sql.Tx) (awsAccountsWithBillRepositories []AwsAccountWithBillRepositoriesWithPending, err error)
WrapAwsAccountsWithBillRepositories wraps AwsAccounts with BillRepositories. Value returned contains all sub accounts.
type AwsAccountWithBillRepositoriesWithStatus ¶
type AwsAccountWithBillRepositoriesWithStatus struct {
aws.AwsAccount
BillRepositories []BillRepositoryWithStatus `json:"billRepositories"`
SubAccounts []AwsAccountWithBillRepositoriesWithStatus `json:"subAccounts,omitempty"`
}
AwsAccountWithBillRepositoriesWithStatus represents a client's AWS account with its bill repositories.
func WrapAwsAccountsWithBillRepositoriesWithPendingWithStatus ¶
func WrapAwsAccountsWithBillRepositoriesWithPendingWithStatus(awsAccountsWithBillRepositories []AwsAccountWithBillRepositoriesWithPending, tx *sql.Tx) []AwsAccountWithBillRepositoriesWithStatus
WrapAwsAccountsWithBillRepositoriesWithPendingWithStatus wraps AwsAccountWithBillRepositoriesWithPending with a status.
type BillRepository ¶
type BillRepository struct {
Id int `json:"id"`
AwsAccountId int `json:"awsAccountId"`
Bucket string `json:"bucket"`
Prefix string `json:"prefix"`
Error string `json:"error"`
LastImportedManifest time.Time `json:"lastImportedManifest"`
NextUpdate time.Time `json:"nextUpdate"`
}
BillRepository is a location where the server may look for bill objects.
func CreateBillRepository ¶
func CreateBillRepository(aa aws.AwsAccount, br BillRepository, tx *sql.Tx) (BillRepository, error)
CreateBillRepository creates a BillRepository for an AwsAccount. It does not perform checks on the repository.
func GetAwsBillRepositoriesWithDueUpdate ¶
func GetAwsBillRepositoriesWithDueUpdate(tx *sql.Tx) ([]BillRepository, error)
GetAwsBillRepositoriesWithDueUpdate gets all bill repositories in need of an update.
func GetBillRepositoriesForAwsAccount ¶
func GetBillRepositoriesForAwsAccount(aa aws.AwsAccount, tx *sql.Tx) ([]BillRepository, error)
GetBillRepositoriesForAwsAccount retrieves from the database all the BillRepositories for an AwsAccount.
func GetBillRepositoryForAwsAccountById ¶
func GetBillRepositoryForAwsAccountById(aa aws.AwsAccount, brId int, tx *sql.Tx) (BillRepository, error)
GetBillRepositoryForAwsAccountById gets a BillRepository by its ID, ensuring it belongs to the provided AwsAccount.
func UpdateBillRepositorySafe ¶
func UpdateBillRepositorySafe(dbBr *models.AwsBillRepository, br BillRepository, tx *sql.Tx) (BillRepository, error)
UpdateBillRepository updates a BillRepository in the database
type BillRepositoryWithPending ¶
type BillRepositoryWithPending struct {
BillRepository
NextPending bool `json:"nextPending"`
}
BillRepositoryWithPending is a BillRepository wrapped with NextPending
func GetBillRepositoryWithPendingForAwsAccount ¶
func GetBillRepositoryWithPendingForAwsAccount(tx *sql.Tx, awsAccountId int) ([]BillRepositoryWithPending, error)
GetBillRepositoryWithPendingForAwsAccount gets a BillRepositoryWithPending by Aws Account id
type BillRepositoryWithStatus ¶
type BillRepositoryWithStatus struct {
BillRepositoryWithPending
Status Status `json:"status"`
}
BillRepositoryWithStatus is a BillRepository wrapped with Status
func WrapBillRepositoriesWithPendingWithStatus ¶
func WrapBillRepositoriesWithPendingWithStatus(tx *sql.Tx, billRepositoryWithPending BillRepositoryWithPending) (BillRepositoryWithStatus, error)
WrapBillRepositoriesWithPendingWithStatus wraps BillRepositoryWithPending with a status.
type LineItem ¶
type LineItem struct {
BillRepositoryId int `csv:"-" json:"billRepositoryId"`
LineItemId string `csv:"identity/LineItemId" json:"lineItemId"`
TimeInterval string `csv:"identity/TimeInterval" json:"-"`
InvoiceId string `csv:"bill/InvoiceId" json:"invoiceId"`
BillingPeriodStart string `csv:"bill/BillingPeriodStartDate" json:"-"`
BillingPeriodEnd string `csv:"bill/BillingPeriodEndDate" json:"-"`
UsageAccountId string `csv:"lineItem/UsageAccountId" json:"usageAccountId"`
LineItemType string `csv:"lineItem/LineItemType" json:"lineItemType"`
UsageStartDate string `csv:"lineItem/UsageStartDate" json:"usageStartDate"`
UsageEndDate string `csv:"lineItem/UsageEndDate" json:"usageEndDate""`
ProductCode string `csv:"lineItem/ProductCode" json:"productCode"`
UsageType string `csv:"lineItem/UsageType" json:"usageType"`
Operation string `csv:"lineItem/Operation" json:"operation"`
AvailabilityZone string `csv:"lineItem/AvailabilityZone" json:"availabilityZone"`
Region string `csv:"product/region" json:"region"`
ResourceId string `csv:"lineItem/ResourceId" json:"resourceId"`
UsageAmount string `csv:"lineItem/UsageAmount" json:"usageAmount"`
ServiceCode string `csv:"product/servicecode" json:"serviceCode"`
CurrencyCode string `csv:"lineItem/CurrencyCode" json:"currencyCode"`
UnblendedCost string `csv:"lineItem/UnblendedCost" json:"unblendedCost"`
TaxType string `csv:"lineItem/TaxType" json:"taxType"`
Any map[string]string `csv:",any" json:"-"`
Tags []LineItemTags `csv:"-" json:"tags,omitempty"`
}
type LineItemTags ¶
type ManifestPredicate ¶
type OnLineItem ¶
type ReportUpdateConclusion ¶
type ReportUpdateConclusion struct {
BillRepository BillRepository
LastImportedManifest time.Time
Error error
}
ReportUpdateConclusion represents the results of a bill ingestion job.
func UpdateDueReports ¶
UpdateDueReports finds all BillRepositories in need of an update and updates them.