Documentation ¶
Index ¶
- func ColumnPermutations(results []*Result) map[string][]string
- func Handler(server *api.ApiServer, w http.ResponseWriter, r *http.Request)
- func Register(mux *http.ServeMux, apiServer *api.ApiServer)
- func StandardCounters(ctx context.Context, q *awsu.Queries, resp *ApiResponse)
- func StandardDates(response *ApiResponse, start time.Time, end time.Time, rangeEnd time.Time, ...)
- type ApiResponse
- type CountValues
- type Counters
- type PossibleResults
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColumnPermutations ¶
ColumnPermutations uses the result set to create a list of columns and all of their possible values This is normally used to create table headers and the like
func Register ¶
Register sets the local context and database paths to the values passed and then attaches the local handles to the url patterns supported by aws_costs api
func StandardCounters ¶
func StandardCounters(ctx context.Context, q *awsu.Queries, resp *ApiResponse)
StandardCounters adds the standard counter data
Types ¶
type ApiResponse ¶
type ApiResponse struct { *response.Response Counters *Counters `json:"counters,omitempty"` Columns map[string][]string `json:"columns,omitempty"` ColumnOrdering []string `json:"column_ordering,omitempty"` QueryFilters map[string]interface{} `json:"query_filters,omitempty"` Result []*Result `json:"result"` }
ApiResponse is the response object used and returned by the aws_costs api handler Based on response.Response struct as a common ground and then add additional fields to the struct that are used for this api
type CountValues ¶
type CountValues struct {
Count int `json:"count"`
}
CountValues tracks a single counter value This is normally used to track the total of the data sets
type Counters ¶
type Counters struct { Totals *CountValues `json:"totals"` This *CountValues `json:"current"` }
Counters captures multiple count values, in general we return the Total (so everyhing in the database) version and `This` - which is based on the current query result
type PossibleResults ¶
type PossibleResults interface { awsu.UptimePerMonthRow | awsu.UptimePerMonthUnitRow | awsu.UptimePerMonthFilterByUnitRow | awsu.UptimePerDayRow | awsu.UptimePerDayUnitRow | awsu.UptimePerDayFilterByUnitRow }
PossibleResults is used to constrain the type of the value on the Common func and simply is interface for all the know result types
type Result ¶
type Result struct { Avgerage interface{} `json:"avgerage,omitempty"` Interval interface{} `json:"interval,omitempty"` Unit string `json:"unit,omitempty"` }
Result is used instead of the variable versions encapsulated by PossibleResults in the ApiResponse struct This is to simplify the parsing on both the api and the consumer in front To be effective, any empty field is omited in the json Converted using `Common` func
func Common ¶
func Common[T PossibleResults](results []T) (common []*Result)
Common func converts from the known aws cost structs to the common result type via json marshaling