mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-14 02:37:52 +00:00
feat(api): add admin master key listing/revoke
Add admin endpoints to list and revoke child keys under a master. Standardize OpenAPI responses to use ResponseEnvelope with MapData for error payloads, and regenerate swagger specs accordingly.
This commit is contained in:
@@ -18,8 +18,8 @@ import (
|
||||
// @Security AdminAuth
|
||||
// @Param key body dto.APIKeyDTO true "API key payload"
|
||||
// @Success 201 {object} ResponseEnvelope{data=model.APIKey}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/api-keys [post]
|
||||
func (h *Handler) CreateAPIKey(c *gin.Context) {
|
||||
var req dto.APIKeyDTO
|
||||
@@ -101,7 +101,7 @@ func (h *Handler) CreateAPIKey(c *gin.Context) {
|
||||
// @Param group_id query int false "filter by group_id"
|
||||
// @Param status query string false "filter by status (active, suspended, auto_disabled, manual_disabled)"
|
||||
// @Success 200 {object} ResponseEnvelope{data=[]model.APIKey}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/api-keys [get]
|
||||
func (h *Handler) ListAPIKeys(c *gin.Context) {
|
||||
var keys []model.APIKey
|
||||
@@ -129,9 +129,9 @@ func (h *Handler) ListAPIKeys(c *gin.Context) {
|
||||
// @Security AdminAuth
|
||||
// @Param id path int true "APIKey ID"
|
||||
// @Success 200 {object} ResponseEnvelope{data=model.APIKey}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/api-keys/{id} [get]
|
||||
func (h *Handler) GetAPIKey(c *gin.Context) {
|
||||
id, ok := parseUintParam(c, "id")
|
||||
@@ -156,9 +156,9 @@ func (h *Handler) GetAPIKey(c *gin.Context) {
|
||||
// @Param id path int true "APIKey ID"
|
||||
// @Param key body dto.APIKeyDTO true "API key payload"
|
||||
// @Success 200 {object} ResponseEnvelope{data=model.APIKey}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/api-keys/{id} [put]
|
||||
func (h *Handler) UpdateAPIKey(c *gin.Context) {
|
||||
id, ok := parseUintParam(c, "id")
|
||||
@@ -275,10 +275,10 @@ func (h *Handler) UpdateAPIKey(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Security AdminAuth
|
||||
// @Param id path int true "APIKey ID"
|
||||
// @Success 200 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Success 200 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/api-keys/{id} [delete]
|
||||
func (h *Handler) DeleteAPIKey(c *gin.Context) {
|
||||
id, ok := parseUintParam(c, "id")
|
||||
|
||||
Reference in New Issue
Block a user