grafana/pkg/services/ngalert/api/api_permissions_base.go
Sofia Papagiannaki fe628c6282
AlertingNG: base API implementation (#31824)
* AlertingNG: base API implementation

* Pass the interface instead of the base impl

* Ruler mock draft (WIP)

* Update alerting-api dependency

* Improve mock implementation
2021-03-11 21:28:00 +02:00

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)
}