user_role

package
v0.0.0-...-48f5382 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateUserRoles

func CreateUserRoles(w http.ResponseWriter, r *http.Request)

CreateUserRoles godoc @Summary Create a new user role @Description Create a new user role @Tags user-roles @Accept json @Produce json @Param cid path int true "User CID" @Param user_role body Request true "User Role" @Success 201 {object} Response @Failure 400 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /user/{cid}/roles [post]

func Ctx

func Ctx(next http.Handler) http.Handler

func DeleteUserRoles

func DeleteUserRoles(w http.ResponseWriter, r *http.Request)

DeleteUserRoles godoc @Summary Remove a user role @Description Remove a user role @Tags user-roles @Accept json @Produce json @Param cid path int true "User CID" @Param role_id path string true "Role ID" @Success 204 @Failure 400 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /user/{cid}/roles/{role_id} [delete]

func GetSelfRoles

func GetSelfRoles(w http.ResponseWriter, r *http.Request)

GetSelfRoles godoc @Summary Get your roles @Description Get roles for the user logged in @Tags user-roles @Accept json @Produce json @Param cid path int true "User CID" @Success 200 {object} Response @Failure 400 {object} utils.ErrResponse @Failure 500 {object} utils.ErrResponse @Router /user/{cid}/roles [get]

func NewUserRoleListResponse

func NewUserRoleListResponse(userRoles []models.UserRole) []render.Renderer

func Router

func Router(r chi.Router)

Types

type Request

type Request struct {
	RoleID     constants.RoleID     `json:"role_id" example:"ATM" validate:"required"`
	FacilityID constants.FacilityID `json:"facility_id" example:"ZDV" validate:"required"`
}

func (*Request) Bind

func (req *Request) Bind(r *http.Request) error

func (*Request) Validate

func (req *Request) Validate() error

type Response

type Response struct {
	Role       constants.RoleID     `json:"role" example:"ATM"`
	FacilityID constants.FacilityID `json:"facility_id" example:"ZDV"`
	CreatedAt  time.Time            `json:"created_at" example:"2021-01-01T00:00:00Z"`
}

func NewUserRoleResponse

func NewUserRoleResponse(roleID constants.RoleID, facilityId constants.FacilityID, createdAt time.Time) *Response

func (*Response) Render

func (res *Response) Render(w http.ResponseWriter, r *http.Request) error

Jump to

Keyboard shortcuts

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