Alerting: time interval service to support addressing intervals by Base64 encoded name (#90563)

* rename to getMuteTimingByName

* add UID to api model of MuteTiming

* update GetMuteTiming to search by UID

* update UpdateMuteTiming to support search by UID

* update DeleteMuteTiming to support uid

* make sure UID is populated

* update usages

* use base64 url-safe, no padding encoding for UID
This commit is contained in:
Yuri Tseretyan
2024-07-26 16:43:40 -04:00
committed by GitHub
parent 2ab746ae76
commit 6b0d20c96a
6 changed files with 221 additions and 46 deletions
+8 -1
View File
@@ -298,7 +298,14 @@ func (srv *ProvisioningSrv) RoutePostMuteTiming(c *contextmodel.ReqContext, mt d
}
func (srv *ProvisioningSrv) RoutePutMuteTiming(c *contextmodel.ReqContext, mt definitions.MuteTimeInterval, name string) response.Response {
mt.Name = name
// if body does not specify name, assume that the path contains the name
if mt.Name == "" {
mt.Name = name
}
// if body contains a name, and it's different from the one in the path, assume the latter to be UID
if mt.Name != name {
mt.UID = name
}
mt.Provenance = determineProvenance(c)
updated, err := srv.muteTimings.UpdateMuteTiming(c.Req.Context(), mt, c.SignedInUser.GetOrgID())
if err != nil {