grafana/pkg/tsdb/cloudwatch/models/request/dimension_values_request.go
Erik Sundell 017da781cf
Cloudwatch: Refactor dimension values resource request (#57346)
* refactor dimension values backend

* fix test file name
2022-10-24 15:04:25 +02:00

38 lines
822 B
Go

package request
import (
"net/url"
)
type DimensionValuesRequest struct {
*ResourceRequest
Namespace string
MetricName string
DimensionKey string
DimensionFilter []*Dimension
}
func GetDimensionValuesRequest(parameters url.Values) (*DimensionValuesRequest, error) {
resourceRequest, err := getResourceRequest(parameters)
if err != nil {
return nil, err
}
request := &DimensionValuesRequest{
ResourceRequest: resourceRequest,
Namespace: parameters.Get("namespace"),
MetricName: parameters.Get("metricName"),
DimensionKey: parameters.Get("dimensionKey"),
DimensionFilter: []*Dimension{},
}
dimensions, err := parseDimensionFilter(parameters.Get("dimensionFilters"))
if err != nil {
return nil, err
}
request.DimensionFilter = dimensions
return request, nil
}