mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
babfa2beac
This PR connects the new RBAC authentication service to existing alertmanager API silence endpoints.
31 lines
817 B
Go
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,
|
|
}
|
|
}
|