2019-04-25 09:06:44 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2020-11-19 13:34:28 +01:00
|
|
|
"errors"
|
2020-06-22 17:49:13 +02:00
|
|
|
|
2021-01-15 14:43:20 +01:00
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
2019-04-25 09:06:44 +02:00
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
|
|
|
)
|
|
|
|
|
|
2021-01-15 14:43:20 +01:00
|
|
|
func (hs *HTTPServer) AdminProvisioningReloadDashboards(c *models.ReqContext) response.Response {
|
2021-10-05 13:26:24 +02:00
|
|
|
err := hs.ProvisioningService.ProvisionDashboards(c.Req.Context())
|
2020-11-19 13:34:28 +01:00
|
|
|
if err != nil && !errors.Is(err, context.Canceled) {
|
2021-01-15 14:43:20 +01:00
|
|
|
return response.Error(500, "", err)
|
2019-04-25 09:06:44 +02:00
|
|
|
}
|
2021-01-15 14:43:20 +01:00
|
|
|
return response.Success("Dashboards config reloaded")
|
2019-04-25 09:06:44 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-15 14:43:20 +01:00
|
|
|
func (hs *HTTPServer) AdminProvisioningReloadDatasources(c *models.ReqContext) response.Response {
|
2021-10-18 16:06:19 +01:00
|
|
|
err := hs.ProvisioningService.ProvisionDatasources(c.Req.Context())
|
2019-04-25 09:06:44 +02:00
|
|
|
if err != nil {
|
2021-01-15 14:43:20 +01:00
|
|
|
return response.Error(500, "", err)
|
2019-04-25 09:06:44 +02:00
|
|
|
}
|
2021-01-15 14:43:20 +01:00
|
|
|
return response.Success("Datasources config reloaded")
|
2019-04-25 09:06:44 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-15 14:43:20 +01:00
|
|
|
func (hs *HTTPServer) AdminProvisioningReloadPlugins(c *models.ReqContext) response.Response {
|
2021-12-02 18:08:59 +01:00
|
|
|
err := hs.ProvisioningService.ProvisionPlugins(c.Req.Context())
|
2020-06-22 17:49:13 +02:00
|
|
|
if err != nil {
|
2021-01-15 14:43:20 +01:00
|
|
|
return response.Error(500, "Failed to reload plugins config", err)
|
2020-06-22 17:49:13 +02:00
|
|
|
}
|
2021-01-15 14:43:20 +01:00
|
|
|
return response.Success("Plugins config reloaded")
|
2020-06-22 17:49:13 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-15 14:43:20 +01:00
|
|
|
func (hs *HTTPServer) AdminProvisioningReloadNotifications(c *models.ReqContext) response.Response {
|
2021-11-03 11:31:56 +01:00
|
|
|
err := hs.ProvisioningService.ProvisionNotifications(c.Req.Context())
|
2019-04-25 09:06:44 +02:00
|
|
|
if err != nil {
|
2021-01-15 14:43:20 +01:00
|
|
|
return response.Error(500, "", err)
|
2019-04-25 09:06:44 +02:00
|
|
|
}
|
2021-01-15 14:43:20 +01:00
|
|
|
return response.Success("Notifications config reloaded")
|
2019-04-25 09:06:44 +02:00
|
|
|
}
|