package role

import (
	"github.com/veypi/vbase/cfg"
	"github.com/veypi/vigo"
)

var Router = vigo.NewRouter()

func init() {
	Router.Get("/", "List Roles", cfg.Auth.RequireRead("role:*"), list)
	Router.Get("/{id}", "Get Role Detail", cfg.Auth.RequireRead("role:*"), get)
	Router.Post("/", "Create Role", cfg.Auth.RequireCreate("role"), create)
	Router.Patch("/{id}", "Update Role", cfg.Auth.RequireWrite("role:*"), patch)
	Router.Delete("/{id}", "Delete Role", cfg.Auth.RequireWrite("role:*"), del)
	Router.Get("/{id}/permissions", "Get Role Permissions", cfg.Auth.RequireRead("role:*"), getPermissions)
	Router.Put("/{id}/permissions", "Update Role Permissions", cfg.Auth.RequireWrite("role:*"), updatePermissions)
	Router.Get("/{id}/users", "Get Role Users", cfg.Auth.RequireRead("role:*"), getUsers)
	Router.Put("/{id}/users", "Update Role Users", cfg.Auth.RequireWrite("role:*"), updateUsers)
}
