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