package api

import (
	"fr.latosa-escrima/api/roles"
	"fr.latosa-escrima/core"
)

var RolesRoutes = map[string]core.Handler{
	"/roles": {
		Handler: roles.HandleRoles,
		Middlewares: []core.Middleware{Methods("GET"),
			HasPermissions("roles", "get"), AuthJWT},
	},
	"/roles/new": {
		Handler: roles.HandleNew,
		Middlewares: []core.Middleware{Methods("POST"),
			HasPermissions("roles", "insert"), AuthJWT},
	},
	"/roles/{role_uuid}": {
		Handler: roles.HandleRole,
		Middlewares: []core.Middleware{Methods("GET"),
			HasPermissions("roles", "get"), AuthJWT},
	},
	"/roles/{role_uuid}/update": {
		Handler: roles.HandleUpdate,
		Middlewares: []core.Middleware{Methods("PATCH"),
			HasPermissions("roles", "update"), AuthJWT},
	},
	"/roles/{role_uuid}/delete": {
		Handler: roles.HandleDelete,
		Middlewares: []core.Middleware{Methods("DELETE"),
			HasPermissions("roles", "delete"), AuthJWT},
	},
	"/roles/{role_uuid}/permissions/": {
		Handler: roles.HandleRolePermissions,
		Middlewares: []core.Middleware{Methods("GET"),
			HasPermissions("roles", "get"), AuthJWT},
	},
	"/roles/{role_uuid}/permissions/{resource}/{action}/add": {
		Handler: roles.HandleAddPermission,
		Middlewares: []core.Middleware{Methods("PATCH"),
			HasPermissions("roles", "update"), AuthJWT},
	},
	"/roles/{role_uuid}/permissions/{resource}/{action}/remove": {
		Handler: roles.HandleRemovePermission,
		Middlewares: []core.Middleware{Methods("PATCH"),
			HasPermissions("roles", "update"), AuthJWT},
	},
}
