grafana/pkg/api/admin_provisioning.go
Hugo Häggmark 3d41267fc4
Chore: Moves common and response into separate packages (#30298)
* Chore: moves common and response into separate packages

* Chore: moves common and response into separate packages

* Update pkg/api/utils/common.go

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: changes after PR comments

* Chore: move wrap to routing package

* Chore: move functions in common to response package

* Chore: move functions in common to response package

* Chore: formats imports

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-01-15 14:43:20 +01:00

42 lines
1.2 KiB
Go

package api
import (
"context"
"errors"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/models"
)
func (hs *HTTPServer) AdminProvisioningReloadDashboards(c *models.ReqContext) response.Response {
err := hs.ProvisioningService.ProvisionDashboards()
if err != nil && !errors.Is(err, context.Canceled) {
return response.Error(500, "", err)
}
return response.Success("Dashboards config reloaded")
}
func (hs *HTTPServer) AdminProvisioningReloadDatasources(c *models.ReqContext) response.Response {
err := hs.ProvisioningService.ProvisionDatasources()
if err != nil {
return response.Error(500, "", err)
}
return response.Success("Datasources config reloaded")
}
func (hs *HTTPServer) AdminProvisioningReloadPlugins(c *models.ReqContext) response.Response {
err := hs.ProvisioningService.ProvisionPlugins()
if err != nil {
return response.Error(500, "Failed to reload plugins config", err)
}
return response.Success("Plugins config reloaded")
}
func (hs *HTTPServer) AdminProvisioningReloadNotifications(c *models.ReqContext) response.Response {
err := hs.ProvisioningService.ProvisionNotifications()
if err != nil {
return response.Error(500, "", err)
}
return response.Success("Notifications config reloaded")
}