s3

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 31 Imported by: 8

Documentation

Index

Constants

View Source
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"
)
View Source
const IndexPrefixLineItem = "lineitems"
View Source
const TemplateLineItem = `` /* 1723-byte string literal not displayed */
View Source
const TemplateNameLineItem = "lineitems"
View Source
const TypeLineItem = "lineitem"

Variables

View Source
var (
	ErrUnsupportedCompression = errors.New("unsupported compression")
)

Functions

func DeleteBillRepositoryById

func DeleteBillRepositoryById(brId int, tx *sql.Tx) error

func ReadBills

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 BillKey

type BillKey struct {
	Region       string
	Bucket       string
	Key          string
	LastModified time.Time
}

BillKey is a key where a bill object may be found.

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"`
}

func (LineItem) EsId

func (li LineItem) EsId() string

type LineItemTags

type LineItemTags struct {
	Key string `json:"key"`
	Tag string `json:"tag"`
}

type ManifestPredicate

type ManifestPredicate func(manifest, bool) bool

type OnLineItem

type OnLineItem func(LineItem, bool)

type ReportUpdateConclusion

type ReportUpdateConclusion struct {
	BillRepository       BillRepository
	LastImportedManifest time.Time
	Error                error
}

ReportUpdateConclusion represents the results of a bill ingestion job.

func UpdateDueReports

func UpdateDueReports(ctx context.Context, tx *sql.Tx) ([]ReportUpdateConclusion, error)

UpdateDueReports finds all BillRepositories in need of an update and updates them.

type Status

type Status struct {
	Value  string `json:"value"`
	Detail string `json:"detail"`
}

Status contains a value and a human readable detail.

Jump to

Keyboard shortcuts

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