swag fmt
This commit is contained in:
@@ -10,12 +10,12 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
// @Summary Get all resources
|
||||
// @Tags acl/resources
|
||||
// @Produce json
|
||||
// @Success 200 {array} getResourcesResponse
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources [get]
|
||||
// @Summary Get all resources
|
||||
// @Tags acl/resources
|
||||
// @Produce json
|
||||
// @Success 200 {object} getResourcesResponse
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources [get]
|
||||
func (h *aclAdminHandler) getResources(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -44,15 +44,15 @@ func (h *aclAdminHandler) getResources(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(resp)
|
||||
}
|
||||
|
||||
// @Summary Get resource by ID
|
||||
// @Tags acl/resources
|
||||
// @Produce json
|
||||
// @Param resourceId path int true "Resource ID" example(1)
|
||||
// @Success 200 {object} getResourceResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources/{resourceId} [get]
|
||||
// @Summary Get resource by ID
|
||||
// @Tags acl/resources
|
||||
// @Produce json
|
||||
// @Param resourceId path int true "Resource ID" example(1)
|
||||
// @Success 200 {object} getResourceResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources/{resourceId} [get]
|
||||
func (h *aclAdminHandler) getResource(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -83,16 +83,16 @@ func (h *aclAdminHandler) getResource(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary Create resource
|
||||
// @Tags acl/resources
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body createResourceRequest true "Resource"
|
||||
// @Success 201 {object} createResourceResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources [post]
|
||||
// @Summary Create resource
|
||||
// @Tags acl/resources
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body createResourceRequest true "Resource"
|
||||
// @Success 201 {object} createResourceResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources [post]
|
||||
func (h *aclAdminHandler) createResource(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -127,18 +127,18 @@ func (h *aclAdminHandler) createResource(w http.ResponseWriter, r *http.Request)
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary Update resource
|
||||
// @Tags acl/resources
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param resourceId path int true "Resource ID" example(1)
|
||||
// @Param request body updateResourceRequest true "Resource"
|
||||
// @Success 200 {object} updateResourceResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources/{resourceId} [patch]
|
||||
// @Summary Update resource
|
||||
// @Tags acl/resources
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param resourceId path int true "Resource ID" example(1)
|
||||
// @Param request body updateResourceRequest true "Resource"
|
||||
// @Success 200 {object} updateResourceResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources/{resourceId} [patch]
|
||||
func (h *aclAdminHandler) updateResource(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -181,16 +181,16 @@ func (h *aclAdminHandler) updateResource(w http.ResponseWriter, r *http.Request)
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary Delete resource
|
||||
// @Tags acl/resources
|
||||
// @Produce json
|
||||
// @Param resourceId path int true "Resource ID" example(1)
|
||||
// @Success 200
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources/{resourceId} [delete]
|
||||
// @Summary Delete resource
|
||||
// @Tags acl/resources
|
||||
// @Produce json
|
||||
// @Param resourceId path int true "Resource ID" example(1)
|
||||
// @Success 200
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/resources/{resourceId} [delete]
|
||||
func (h *aclAdminHandler) deleteResource(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -10,15 +10,15 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
// @Summary Get user roles by user ID
|
||||
// @Tags acl/users
|
||||
// @Produce json
|
||||
// @Param userId path int true "User ID" example(1)
|
||||
// @Success 200 {object} getUserRolesResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/users/{userId}/roles [get]
|
||||
// @Summary Get user roles by user ID
|
||||
// @Tags acl/users
|
||||
// @Produce json
|
||||
// @Param userId path int true "User ID" example(1)
|
||||
// @Success 200 {object} getUserRolesResponse
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/users/{userId}/roles [get]
|
||||
func (h *aclAdminHandler) getUserRoles(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
userIDStr := chi.URLParam(r, "userId")
|
||||
@@ -49,17 +49,17 @@ func (h *aclAdminHandler) getUserRoles(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(resp)
|
||||
}
|
||||
|
||||
// @Summary Assign role to user
|
||||
// @Tags acl/users
|
||||
// @Produce json
|
||||
// @Param userId path int true "User ID" example(1)
|
||||
// @Param body body assignRoleToUserRequest true "Role ID"
|
||||
// @Success 201
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/users/{userId}/roles [post]
|
||||
// @Summary Assign role to user
|
||||
// @Tags acl/users
|
||||
// @Produce json
|
||||
// @Param userId path int true "User ID" example(1)
|
||||
// @Param body body assignRoleToUserRequest true "Role ID"
|
||||
// @Success 201
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 409 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/users/{userId}/roles [post]
|
||||
func (h *aclAdminHandler) assignRoleToUser(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
userIDStr := chi.URLParam(r, "userId")
|
||||
@@ -92,16 +92,16 @@ func (h *aclAdminHandler) assignRoleToUser(w http.ResponseWriter, r *http.Reques
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
}
|
||||
|
||||
// @Summary Remove role from user
|
||||
// @Tags acl/users
|
||||
// @Produce json
|
||||
// @Param userId path int true "User ID" example(1)
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 204
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/users/{userId}/roles/{roleId} [delete]
|
||||
// @Summary Remove role from user
|
||||
// @Tags acl/users
|
||||
// @Produce json
|
||||
// @Param userId path int true "User ID" example(1)
|
||||
// @Param roleId path int true "Role ID" example(1)
|
||||
// @Success 204
|
||||
// @Failure 400 {object} ProblemDetails
|
||||
// @Failure 404 {object} ProblemDetails
|
||||
// @Failure 500 {object} ProblemDetails
|
||||
// @Router /api/acl/users/{userId}/roles/{roleId} [delete]
|
||||
func (h *aclAdminHandler) removeRoleFromUser(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
userIDStr := chi.URLParam(r, "userId")
|
||||
|
||||
Reference in New Issue
Block a user