mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* AlertingNG: base API implementation * Pass the interface instead of the base impl * Ruler mock draft (WIP) * Update alerting-api dependency * Improve mock implementation
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
/*Package api contains base API implementation of unified alerting
|
|
*
|
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
|
*
|
|
* Need to remove unused imports.
|
|
*/
|
|
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-macaron/binding"
|
|
apimodels "github.com/grafana/alerting-api/pkg/api"
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
"github.com/grafana/grafana/pkg/api/routing"
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
type PermissionsApiService interface {
|
|
RouteGetNamespacePermissions(*models.ReqContext) response.Response
|
|
RouteSetNamespacePermissions(*models.ReqContext, apimodels.Permissions) response.Response
|
|
}
|
|
|
|
type PermissionsApiBase struct {
|
|
log log.Logger
|
|
}
|
|
|
|
func (api *API) RegisterPermissionsApiEndpoints(srv PermissionsApiService) {
|
|
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
|
group.Get(toMacaronPath("/api/v1/namespace/{Namespace}/permissions"), routing.Wrap(srv.RouteGetNamespacePermissions))
|
|
group.Post(toMacaronPath("/api/v1/namespace/{Namespace}/permissions"), binding.Bind(apimodels.Permissions{}), routing.Wrap(srv.RouteSetNamespacePermissions))
|
|
})
|
|
}
|
|
|
|
func (base PermissionsApiBase) RouteGetNamespacePermissions(c *models.ReqContext) response.Response {
|
|
namespace := c.Params(":Namespace")
|
|
base.log.Info("RouteGetNamespacePermissions: ", "Namespace", namespace)
|
|
return response.Error(http.StatusNotImplemented, "", nil)
|
|
}
|
|
|
|
func (base PermissionsApiBase) RouteSetNamespacePermissions(c *models.ReqContext, body apimodels.Permissions) response.Response {
|
|
namespace := c.Params(":Namespace")
|
|
base.log.Info("RouteSetNamespacePermissions: ", "Namespace", namespace)
|
|
base.log.Info("RouteSetNamespacePermissions: ", "body", body)
|
|
return response.Error(http.StatusNotImplemented, "", nil)
|
|
}
|