grafana/pkg/services/ngalert/api/util.go
Sofia Papagiannaki 68b05b8aaa
AlertingNG: Unified alerting API mock (#32040)
* AlertingNG: Alertmanager mock API

* AlertingNG: Remove permissions API routes

* Add example POST payloads

* Prometheus and testing mock API
2021-03-17 12:47:03 +02:00

30 lines
481 B
Go

package api
import (
"fmt"
"regexp"
"github.com/go-openapi/strfmt"
)
var searchRegex = regexp.MustCompile(`\{(\w+)\}`)
func toMacaronPath(path string) string {
return string(searchRegex.ReplaceAllFunc([]byte(path), func(s []byte) []byte {
m := string(s[1 : len(s)-1])
return []byte(fmt.Sprintf(":%s", m))
}))
}
func timePtr(t strfmt.DateTime) *strfmt.DateTime {
return &t
}
func stringPtr(s string) *string {
return &s
}
func boolPtr(b bool) *bool {
return &b
}