4c654ddb76
* refactor metrics request * Update pkg/tsdb/cloudwatch/routes/dimension_keys_test.go Co-authored-by: Shirley <4163034+fridgepoet@users.noreply.github.com> * return metric struct value intead of pointer * make it possible to test hard coded metrics service * test all paths in route * fix broken test * fix one more broken test * add integration test Co-authored-by: Shirley <4163034+fridgepoet@users.noreply.github.com>
43 lines
776 B
Go
43 lines
776 B
Go
package request
|
|
|
|
import (
|
|
"net/url"
|
|
)
|
|
|
|
type MetricsRequestType uint32
|
|
|
|
const (
|
|
MetricsByNamespaceRequestType MetricsRequestType = iota
|
|
AllMetricsRequestType
|
|
CustomNamespaceRequestType
|
|
)
|
|
|
|
type MetricsRequest struct {
|
|
*ResourceRequest
|
|
Namespace string
|
|
}
|
|
|
|
func GetMetricsRequest(parameters url.Values) (*MetricsRequest, error) {
|
|
resourceRequest, err := getResourceRequest(parameters)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &MetricsRequest{
|
|
ResourceRequest: resourceRequest,
|
|
Namespace: parameters.Get("namespace"),
|
|
}, nil
|
|
}
|
|
|
|
func (r *MetricsRequest) Type() MetricsRequestType {
|
|
if r.Namespace == "" {
|
|
return AllMetricsRequestType
|
|
}
|
|
|
|
if isCustomNamespace(r.Namespace) {
|
|
return CustomNamespaceRequestType
|
|
}
|
|
|
|
return MetricsByNamespaceRequestType
|
|
}
|