mirror of
https://github.com/grafana/grafana.git
synced 2025-09-27 22:34:12 +08:00

* Revert "CloudWatch: Import new grafana-aws-sdk with PDC fix (#103249)" This reverts commit f2b5b4e0c0230b9cc8553b0c768582698610da00. * Revert "CloudWatch: Migrate to aws-sdk-go-v2 (#103106)" This reverts commit a65cc0df93c5568d0ba32f0171a3c2cd04997cf7. * make update-workspace
60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
package models
|
|
|
|
import (
|
|
"github.com/aws/aws-sdk-go/service/cloudwatch"
|
|
)
|
|
|
|
// queryRowResponse represents the GetMetricData response for a query row in the query editor.
|
|
type QueryRowResponse struct {
|
|
partialDataSet map[string]*cloudwatch.MetricDataResult
|
|
ErrorCodes map[string]bool
|
|
HasArithmeticError bool
|
|
ArithmeticErrorMessage string
|
|
HasPermissionError bool
|
|
PermissionErrorMessage string
|
|
Metrics []*cloudwatch.MetricDataResult
|
|
StatusCode string
|
|
}
|
|
|
|
func NewQueryRowResponse(errors map[string]bool) QueryRowResponse {
|
|
return QueryRowResponse{
|
|
partialDataSet: make(map[string]*cloudwatch.MetricDataResult),
|
|
ErrorCodes: errors,
|
|
HasArithmeticError: false,
|
|
ArithmeticErrorMessage: "",
|
|
Metrics: []*cloudwatch.MetricDataResult{},
|
|
}
|
|
}
|
|
|
|
func (q *QueryRowResponse) AddMetricDataResult(mdr *cloudwatch.MetricDataResult) {
|
|
if mdr.Label == nil {
|
|
return
|
|
}
|
|
|
|
if partialData, ok := q.partialDataSet[*mdr.Label]; ok {
|
|
partialData.Timestamps = append(partialData.Timestamps, mdr.Timestamps...)
|
|
partialData.Values = append(partialData.Values, mdr.Values...)
|
|
q.StatusCode = *mdr.StatusCode
|
|
if *mdr.StatusCode != "PartialData" {
|
|
delete(q.partialDataSet, *mdr.Label)
|
|
}
|
|
return
|
|
}
|
|
|
|
q.Metrics = append(q.Metrics, mdr)
|
|
q.StatusCode = *mdr.StatusCode
|
|
if *mdr.StatusCode == "PartialData" {
|
|
q.partialDataSet[*mdr.Label] = mdr
|
|
}
|
|
}
|
|
|
|
func (q *QueryRowResponse) AddArithmeticError(message *string) {
|
|
q.HasArithmeticError = true
|
|
q.ArithmeticErrorMessage = *message
|
|
}
|
|
|
|
func (q *QueryRowResponse) AddPermissionError(message *string) {
|
|
q.HasPermissionError = true
|
|
q.PermissionErrorMessage = *message
|
|
}
|