grafana/pkg/services/ngalert/api/compat_silences.go
Matthew Jacobson babfa2beac
Alerting: Hook up GMA silence APIs to new authentication handler (#86625)
This PR connects the new RBAC authentication service to existing alertmanager API silence endpoints.
2024-05-03 15:32:30 -04:00

31 lines
817 B
Go

package api
import (
"github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
"github.com/grafana/grafana/pkg/services/ngalert/models"
)
// Silence-specific compat functions to convert between API and model types.
func SilenceToGettableSilence(s models.Silence) definitions.GettableSilence {
return definitions.GettableSilence(s)
}
func SilencesToGettableSilences(silences []*models.Silence) definitions.GettableSilences {
res := make(definitions.GettableSilences, 0, len(silences))
for _, sil := range silences {
apiSil := SilenceToGettableSilence(*sil)
res = append(res, &apiSil)
}
return res
}
func PostableSilenceToSilence(s definitions.PostableSilence) models.Silence {
return models.Silence{
ID: &s.ID,
Status: nil,
UpdatedAt: nil,
Silence: s.Silence,
}
}