feat: (rbac) list permission api.
fix: (model/alerting) tag syntax error
This commit is contained in:
parent
a377918e9d
commit
844f091a13
|
@ -9,7 +9,7 @@ type Monitor struct {
|
|||
Schedule Schedule `json:"schedule" elastic_mapping:"schedule:{type:object}"`
|
||||
SchemaVersion int `json:"schema_version" elastic_mapping:"schema_version:{type:integer}"`
|
||||
Triggers []Trigger `json:"triggers" elastic_mapping:"triggers:{type:nested}"`
|
||||
Type string `json:"type" elastic_mapping:"type:{type:keyword}`
|
||||
Type string `json:"type" elastic_mapping:"type:{type:keyword}"`
|
||||
}
|
||||
|
||||
type MonitorInput struct {
|
||||
|
@ -31,13 +31,11 @@ type Period struct {
|
|||
Unit string `json:"unit" elastic_mapping:"unit:{type:keyword}"`
|
||||
}
|
||||
|
||||
|
||||
type Schedule struct {
|
||||
Cron *Cron `json:"cron,omitempty" elastic_mapping:"cron:{type:object}"`
|
||||
Period *Period `json:"period,omitempty" elastic_mapping:"period:{type:object}"`
|
||||
}
|
||||
|
||||
|
||||
type Throttle struct {
|
||||
Unit string `json:"unit" elastic_mapping:"unit:{type:keyword}"`
|
||||
Value int `json:"value" elastic_mapping:"value:{type:integer}"`
|
||||
|
|
|
@ -30,6 +30,7 @@ func ListElasticsearchPermisson() (permisson ElasticsearchPermisson, err error)
|
|||
|
||||
permisson = ElasticsearchPermisson{
|
||||
ClusterPrivileges: CategoryApi["list"],
|
||||
IndexPrivileges: CategoryApi["indices"],
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package rbac
|
||||
|
||||
import (
|
||||
log "github.com/cihub/seelog"
|
||||
"github.com/pkg/errors"
|
||||
"infini.sh/console/plugin/api/rbac/biz"
|
||||
httprouter "infini.sh/framework/core/api/router"
|
||||
"net/http"
|
||||
)
|
||||
|
@ -17,6 +20,26 @@ type Response struct {
|
|||
}
|
||||
|
||||
func (h Permisson) ListPermission(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||
typ := ps.MustGetParameter("type")
|
||||
var err error
|
||||
var permissons interface{}
|
||||
switch typ {
|
||||
case Console:
|
||||
permissons, err = biz.ListConsolePermisson()
|
||||
|
||||
case Elastisearch:
|
||||
permissons, err = biz.ListElasticsearchPermisson()
|
||||
default:
|
||||
err = errors.New("unsupport type parmeter " + typ)
|
||||
}
|
||||
if err != nil {
|
||||
_ = log.Error(err.Error())
|
||||
_ = h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
_ = h.WriteJSON(w, Response{
|
||||
Hit: permissons,
|
||||
}, http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue