admin

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package admin defines the admin controllers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RoleController

type RoleController struct {
	// contains filtered or unexported fields
}

RoleController is a struct that holds the service

func NewAdminRoleController

func NewAdminRoleController(s models.Querier) *RoleController

NewAdminRoleController creates a new RoleController

func (*RoleController) AddUsersToRole

func (ctr *RoleController) AddUsersToRole(c echo.Context) error

AddUsersToRole adds a role to a user @Summary Assign users to role @Description Assigns users to a role @Tags admin @Accept json @Produce json @Param id path int true "Role ID" @Param data body UsersRequest true "List of usernames" @Success 200 @Router /admin/roles/{id}/users [post] @Security JWTBearerToken

func (*RoleController) CreateRole

func (ctr *RoleController) CreateRole(c echo.Context) error

CreateRole creates a new role @Summary Create role @Description Creates a new role @Tags admin @Accept json @Produce json @Param data body RoleDataRequest true "Role data" @Success 201 {object} RoleCreateResponse @Router /admin/roles [post] @Security JWTBearerToken

func (*RoleController) DeleteRole

func (ctr *RoleController) DeleteRole(c echo.Context) error

DeleteRole deletes a role @Summary Delete role @Description Deletes a role @Tags admin @Param id path int true "Role ID" @Success 200 @Router /admin/roles/{id} [delete] @Security JWTBearerToken

func (*RoleController) GetRoles

func (ctr *RoleController) GetRoles(c echo.Context) error

GetRoles returns a list of roles @Summary List roles @Description Returns a list of roles @Tags admin @Produce json @Success 200 {object} RoleListResponse @Router /admin/roles [get] @Security JWTBearerToken

func (*RoleController) RemoveUsersFromRole

func (ctr *RoleController) RemoveUsersFromRole(c echo.Context) error

RemoveUsersFromRole removes a role from a user @Summary Remove users from role @Description Removes users from a role @Tags admin @Accept json @Produce json @Param id path int true "Role ID" @Param data body UsersRequest true "List of usernames" @Success 200 @Router /admin/roles/{id}/users [delete] @Security JWTBearerToken

func (*RoleController) UpdateRole

func (ctr *RoleController) UpdateRole(c echo.Context) error

UpdateRole updates a role @Summary Update role @Description Updates a role @Tags admin @Accept json @Produce json @Param id path int true "Role ID" @Param data body RoleDataRequest true "Role data" @Success 200 {object} roleUpdateResponse @Router /admin/roles/{id} [put] @Security JWTBearerToken

type RoleCreateResponse

type RoleCreateResponse struct {
	ID int32 `json:"id"`
}

RoleCreateResponse is a struct that holds the response for the create role endpoint

type RoleDataRequest

type RoleDataRequest struct {
	Name        string `json:"name" validate:"required,min=3,max=50" extensions:"x-order=0"`
	Description string `json:"description" validate:"min=3,max=255" extensions:"x-order=1"`
}

RoleDataRequest is a struct that holds the request for the create role endpoint

type RoleListResponse

type RoleListResponse struct {
	Roles []RoleNameResponse `json:"roles,omitempty"`
}

RoleListResponse is a struct that holds the response for the list roles endpoint

type RoleNameResponse

type RoleNameResponse struct {
	ID          int32  `json:"id" extensions:"x-order=0"`
	Name        string `json:"name" extensions:"x-order=1"`
	Description string `json:"description" extensions:"x-order=2"`
}

RoleNameResponse is a struct that holds the response for the role name endpoint

type UsersRequest

type UsersRequest struct {
	Users []string `json:"users" validate:"required"`
}

UsersRequest is a struct that holds the request for the assign users to role endpoint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL