|
@@ -5,10 +5,10 @@ import (
|
|
|
|
|
|
|
|
"github.com/opencost/opencost/core/pkg/filter"
|
|
"github.com/opencost/opencost/core/pkg/filter"
|
|
|
"github.com/opencost/opencost/core/pkg/opencost"
|
|
"github.com/opencost/opencost/core/pkg/opencost"
|
|
|
- "github.com/opencost/opencost/core/pkg/util/httputil"
|
|
|
|
|
|
|
+ "github.com/opencost/opencost/core/pkg/util/mapper"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-func ParseCustomCostTotalRequest(qp httputil.QueryParams) (*CostTotalRequest, error) {
|
|
|
|
|
|
|
+func ParseCustomCostTotalRequest(qp mapper.PrimitiveMap) (*CostTotalRequest, error) {
|
|
|
windowStr := qp.Get("window", "")
|
|
windowStr := qp.Get("window", "")
|
|
|
if windowStr == "" {
|
|
if windowStr == "" {
|
|
|
return nil, fmt.Errorf("missing require window param")
|
|
return nil, fmt.Errorf("missing require window param")
|
|
@@ -28,6 +28,8 @@ func ParseCustomCostTotalRequest(qp httputil.QueryParams) (*CostTotalRequest, er
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ accumulate := opencost.ParseAccumulate(qp.Get("accumulate", "day"))
|
|
|
|
|
+
|
|
|
var filter filter.Filter
|
|
var filter filter.Filter
|
|
|
filterString := qp.Get("filter", "")
|
|
filterString := qp.Get("filter", "")
|
|
|
if filterString != "" {
|
|
if filterString != "" {
|
|
@@ -42,13 +44,14 @@ func ParseCustomCostTotalRequest(qp httputil.QueryParams) (*CostTotalRequest, er
|
|
|
Start: *window.Start(),
|
|
Start: *window.Start(),
|
|
|
End: *window.End(),
|
|
End: *window.End(),
|
|
|
AggregateBy: aggregateBy,
|
|
AggregateBy: aggregateBy,
|
|
|
|
|
+ Accumulate: accumulate,
|
|
|
Filter: filter,
|
|
Filter: filter,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return opts, nil
|
|
return opts, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func ParseCustomCostTimeseriesRequest(qp httputil.QueryParams) (*CostTimeseriesRequest, error) {
|
|
|
|
|
|
|
+func ParseCustomCostTimeseriesRequest(qp mapper.PrimitiveMap) (*CostTimeseriesRequest, error) {
|
|
|
windowStr := qp.Get("window", "")
|
|
windowStr := qp.Get("window", "")
|
|
|
if windowStr == "" {
|
|
if windowStr == "" {
|
|
|
return nil, fmt.Errorf("missing require window param")
|
|
return nil, fmt.Errorf("missing require window param")
|
|
@@ -68,7 +71,7 @@ func ParseCustomCostTimeseriesRequest(qp httputil.QueryParams) (*CostTimeseriesR
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- accumulate := opencost.ParseAccumulate(qp.Get("accumulate", ""))
|
|
|
|
|
|
|
+ accumulate := opencost.ParseAccumulate(qp.Get("accumulate", "day"))
|
|
|
|
|
|
|
|
var filter filter.Filter
|
|
var filter filter.Filter
|
|
|
filterString := qp.Get("filter", "")
|
|
filterString := qp.Get("filter", "")
|