2021-06-15 17:14:02 +01:00
|
|
|
package notifier
|
|
|
|
|
|
|
|
|
|
import (
|
2023-01-13 12:54:38 -04:00
|
|
|
"encoding/json"
|
|
|
|
|
|
2021-06-15 17:14:02 +01:00
|
|
|
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
|
|
|
|
)
|
|
|
|
|
|
2023-01-13 12:54:38 -04:00
|
|
|
// TODO: We no longer do apimodels at this layer, move it to the API.
|
2023-09-06 07:59:29 -03:00
|
|
|
func (am *alertmanager) GetStatus() apimodels.GettableStatus {
|
2024-03-04 13:12:49 -05:00
|
|
|
config := &apimodels.PostableUserConfig{}
|
|
|
|
|
status := am.Base.GetStatus() // TODO: This should return a GettableStatus, for now it returns PostableUserConfig.
|
2023-01-13 12:54:38 -04:00
|
|
|
if status == nil {
|
2024-03-04 13:12:49 -05:00
|
|
|
return *apimodels.NewGettableStatus(&config.AlertmanagerConfig)
|
2023-01-13 12:54:38 -04:00
|
|
|
}
|
2021-06-15 17:14:02 +01:00
|
|
|
|
2023-01-13 12:54:38 -04:00
|
|
|
if err := json.Unmarshal(status, config); err != nil {
|
2023-09-04 18:46:34 +02:00
|
|
|
am.logger.Error("Unable to unmarshall alertmanager config", "Err", err)
|
2021-06-15 17:14:02 +01:00
|
|
|
}
|
2023-01-13 12:54:38 -04:00
|
|
|
|
2024-03-04 13:12:49 -05:00
|
|
|
return *apimodels.NewGettableStatus(&config.AlertmanagerConfig)
|
2021-06-15 17:14:02 +01:00
|
|
|
}
|