mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Use context in aws ListMetricsPages Use ListMetricsPagesWithContext and pass context in related sub calls
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package routes
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/url"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models"
|
|
"github.com/grafana/grafana/pkg/tsdb/cloudwatch/models/resources"
|
|
)
|
|
|
|
func DimensionValuesHandler(ctx context.Context, pluginCtx backend.PluginContext, reqCtxFactory models.RequestContextFactoryFunc, parameters url.Values) ([]byte, *models.HttpError) {
|
|
dimensionValuesRequest, err := resources.GetDimensionValuesRequest(parameters)
|
|
if err != nil {
|
|
return nil, models.NewHttpError("error in DimensionValuesHandler", http.StatusBadRequest, err)
|
|
}
|
|
|
|
service, err := newListMetricsService(ctx, pluginCtx, reqCtxFactory, dimensionValuesRequest.Region)
|
|
if err != nil {
|
|
return nil, models.NewHttpError("error in DimensionValuesHandler", http.StatusInternalServerError, err)
|
|
}
|
|
|
|
response, err := service.GetDimensionValuesByDimensionFilter(ctx, dimensionValuesRequest)
|
|
if err != nil {
|
|
return nil, models.NewHttpError("error in DimensionValuesHandler", http.StatusInternalServerError, err)
|
|
}
|
|
|
|
dimensionValuesResponse, err := json.Marshal(response)
|
|
if err != nil {
|
|
return nil, models.NewHttpError("error in DimensionValuesHandler", http.StatusInternalServerError, err)
|
|
}
|
|
|
|
return dimensionValuesResponse, nil
|
|
}
|