swag fmt
This commit is contained in:
@@ -10,12 +10,12 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
// @Summary Get all roles
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Success 200 {array} getRolesResponse
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles [get]
|
||||
// @Summary Get all roles
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Success 200 {array} getRolesResponse
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles [get]
|
||||
func (h *aclAdminHandler) getRoles(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
roles, err := h.a.GetRoles()
|
||||
@@ -43,15 +43,15 @@ func (h *aclAdminHandler) getRoles(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(resp)
|
||||
}
|
||||
|
||||
// @Summary Get role by ID
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 200 {object} getRoleResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId} [get]
|
||||
// @Summary Get role by ID
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 200 {object} getRoleResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId} [get]
|
||||
func (h *aclAdminHandler) getRole(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
roleIDStr := chi.URLParam(r, "roleId")
|
||||
@@ -81,15 +81,15 @@ func (h *aclAdminHandler) getRole(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary Get role users
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 200 {array} getRoleUsersResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId}/users [get]
|
||||
// @Summary Get role users
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 200 {array} getRoleUsersResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId}/users [get]
|
||||
func (h *aclAdminHandler) getRoleUsers(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
roleIDStr := chi.URLParam(r, "roleId")
|
||||
@@ -127,15 +127,15 @@ func (h *aclAdminHandler) getRoleUsers(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(respUsers)
|
||||
}
|
||||
|
||||
// @Summary Get role resources
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 200 {array} getRoleResourcesResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId}/resources [get]
|
||||
// @Summary Get role resources
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 200 {array} getRoleResourcesResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId}/resources [get]
|
||||
func (h *aclAdminHandler) getRoleResources(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
roleIDStr := chi.URLParam(r, "roleId")
|
||||
@@ -171,16 +171,16 @@ func (h *aclAdminHandler) getRoleResources(w http.ResponseWriter, r *http.Reques
|
||||
_ = json.NewEncoder(w).Encode(respResources)
|
||||
}
|
||||
|
||||
// @Summary Create role
|
||||
// @Tags acl/roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body createRoleRequest true "Role"
|
||||
// @Success 201 {object} createRoleResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles [post]
|
||||
// @Summary Create role
|
||||
// @Tags acl/roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body createRoleRequest true "Role"
|
||||
// @Success 201 {object} createRoleResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles [post]
|
||||
func (h *aclAdminHandler) createRole(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -213,18 +213,18 @@ func (h *aclAdminHandler) createRole(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary Update role
|
||||
// @Tags acl/roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Param request body updateRoleRequest true "Role"
|
||||
// @Success 200 {object} updateRoleResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId} [patch]
|
||||
// @Summary Update role
|
||||
// @Tags acl/roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Param request body updateRoleRequest true "Role"
|
||||
// @Success 200 {object} updateRoleResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId} [patch]
|
||||
func (h *aclAdminHandler) updateRole(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -265,16 +265,16 @@ func (h *aclAdminHandler) updateRole(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary Delete role
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 204
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId} [delete]
|
||||
// @Summary Delete role
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 204
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId} [delete]
|
||||
func (h *aclAdminHandler) deleteRole(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
roleIDStr := chi.URLParam(r, "roleId")
|
||||
@@ -303,17 +303,17 @@ func (h *aclAdminHandler) deleteRole(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// @Summary Assign resource to role
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Param request body assignResourceToRoleRequest true "Resource"
|
||||
// @Success 201
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId}/resources [post]
|
||||
// @Summary Assign resource to role
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Param request body assignResourceToRoleRequest true "Resource"
|
||||
// @Success 201
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId}/resources [post]
|
||||
func (h *aclAdminHandler) assignResourceToRole(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
roleIDStr := chi.URLParam(r, "roleId")
|
||||
@@ -346,16 +346,16 @@ func (h *aclAdminHandler) assignResourceToRole(w http.ResponseWriter, r *http.Re
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
}
|
||||
|
||||
// @Summary Remove resource from role
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Param resId path int true "Resource ID" example(1)
|
||||
// @Success 204
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId}/resources/{resId} [delete]
|
||||
// @Summary Remove resource from role
|
||||
// @Tags acl/roles
|
||||
// @Produce json
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Param resId path int true "Resource ID" example(1)
|
||||
// @Success 204
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/roles/{roleId}/resources/{resId} [delete]
|
||||
func (h *aclAdminHandler) removeResourceFromRole(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
roleIDStr := chi.URLParam(r, "roleId")
|
||||
|
||||
Reference in New Issue
Block a user