Alerting: Pass yaml as a query param in export request (#62751)
* Set YAML as default value for exporting alert rules * use YAML format for rule list export Co-authored-by: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> * lint * Add new format query param to swagger+docs * Fix broken test --------- Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com> Co-authored-by: Matt Jacobson <matthew.jacobson@grafana.com>
This commit is contained in:
co-authored by
Gilles De Mey
Matt Jacobson
parent
99a16d27c1
commit
753c84f825
@@ -428,12 +428,22 @@ func determineProvenance(ctx *contextmodel.ReqContext) alerting_models.Provenanc
|
||||
}
|
||||
|
||||
func exportResponse(c *contextmodel.ReqContext, body any) response.Response {
|
||||
format := "json"
|
||||
var format = "yaml"
|
||||
|
||||
acceptHeader := c.Req.Header.Get("Accept")
|
||||
if strings.Contains(acceptHeader, "yaml") && !strings.Contains(acceptHeader, "json") {
|
||||
if strings.Contains(acceptHeader, "yaml") {
|
||||
format = "yaml"
|
||||
}
|
||||
|
||||
if strings.Contains(acceptHeader, "json") {
|
||||
format = "json"
|
||||
}
|
||||
|
||||
queryFormat := c.Query("format")
|
||||
if queryFormat == "yaml" || queryFormat == "json" {
|
||||
format = queryFormat
|
||||
}
|
||||
|
||||
download := c.QueryBoolWithDefault("download", false)
|
||||
if download {
|
||||
r := response.JSONDownload
|
||||
|
||||
Reference in New Issue
Block a user