docs(api): update swagger documentation for admin endpoints

Reflect recent API changes in Swagger documentation:
- Add endpoints for feature flag management (/admin/features)
- Add endpoint for issuing child keys to masters (/admin/masters/{id}/keys)
- Add endpoint for updating providers (/admin/providers/{id})
- Update provider model definitions with new fields (auto_ban, google_* attributes, status)
This commit is contained in:
zenfun
2025-12-15 16:12:56 +08:00
parent aa69ce3659
commit ca03ac1b79
3 changed files with 685 additions and 0 deletions

View File

@@ -24,6 +24,86 @@ const docTemplate = `{
"host": "{{.Host}}", "host": "{{.Host}}",
"basePath": "{{.BasePath}}", "basePath": "{{.BasePath}}",
"paths": { "paths": {
"/admin/features": {
"get": {
"security": [
{
"AdminAuth": []
}
],
"description": "Returns all feature flags stored in Redis (meta:features)",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "List feature flags",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
},
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Updates selected feature flags (meta:features). Values are stored as strings.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update feature flags",
"parameters": [
{
"description": "Feature map",
"name": "request",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/masters": { "/admin/masters": {
"post": { "post": {
"security": [ "security": [
@@ -75,6 +155,76 @@ const docTemplate = `{
} }
} }
}, },
"/admin/masters/{id}/keys": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Issue a new access token (child key) for a specified master. The key still belongs to the master; issuer is recorded as admin for audit.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Issue a child key on behalf of a master",
"parameters": [
{
"type": "integer",
"description": "Master ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Key Request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.IssueChildKeyRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/models": { "/admin/models": {
"get": { "get": {
"security": [ "security": [
@@ -273,6 +423,70 @@ const docTemplate = `{
} }
} }
}, },
"/admin/providers/{id}": {
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Update provider attributes including status/auto-ban flags",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update a provider",
"parameters": [
{
"type": "integer",
"description": "Provider ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Provider Info",
"name": "provider",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Provider"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/sync/snapshot": { "/admin/sync/snapshot": {
"post": { "post": {
"security": [ "security": [
@@ -448,9 +662,24 @@ const docTemplate = `{
"api_key": { "api_key": {
"type": "string" "type": "string"
}, },
"auto_ban": {
"type": "boolean"
},
"ban_reason": {
"type": "string"
},
"ban_until": {
"type": "string"
},
"base_url": { "base_url": {
"type": "string" "type": "string"
}, },
"google_location": {
"type": "string"
},
"google_project": {
"type": "string"
},
"group": { "group": {
"type": "string" "type": "string"
}, },
@@ -464,6 +693,13 @@ const docTemplate = `{
"name": { "name": {
"type": "string" "type": "string"
}, },
"skip_routing": {
"description": "Optional control params",
"type": "boolean"
},
"status": {
"type": "string"
},
"type": { "type": {
"type": "string" "type": "string"
} }
@@ -577,6 +813,18 @@ const docTemplate = `{
"api_key": { "api_key": {
"type": "string" "type": "string"
}, },
"auto_ban": {
"description": "whether DP-triggered disable is allowed",
"type": "boolean"
},
"ban_reason": {
"description": "reason for current disable",
"type": "string"
},
"ban_until": {
"description": "optional TTL for disable",
"type": "string"
},
"base_url": { "base_url": {
"type": "string" "type": "string"
}, },
@@ -586,6 +834,12 @@ const docTemplate = `{
"deletedAt": { "deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt" "$ref": "#/definitions/gorm.DeletedAt"
}, },
"google_location": {
"type": "string"
},
"google_project": {
"type": "string"
},
"group": { "group": {
"description": "routing group/tier", "description": "routing group/tier",
"type": "string" "type": "string"
@@ -600,6 +854,10 @@ const docTemplate = `{
"name": { "name": {
"type": "string" "type": "string"
}, },
"status": {
"description": "active, auto_disabled, manual_disabled",
"type": "string"
},
"type": { "type": {
"description": "openai, anthropic, etc.", "description": "openai, anthropic, etc.",
"type": "string" "type": "string"

View File

@@ -18,6 +18,86 @@
"host": "localhost:8080", "host": "localhost:8080",
"basePath": "/", "basePath": "/",
"paths": { "paths": {
"/admin/features": {
"get": {
"security": [
{
"AdminAuth": []
}
],
"description": "Returns all feature flags stored in Redis (meta:features)",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "List feature flags",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
},
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Updates selected feature flags (meta:features). Values are stored as strings.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update feature flags",
"parameters": [
{
"description": "Feature map",
"name": "request",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/masters": { "/admin/masters": {
"post": { "post": {
"security": [ "security": [
@@ -69,6 +149,76 @@
} }
} }
}, },
"/admin/masters/{id}/keys": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Issue a new access token (child key) for a specified master. The key still belongs to the master; issuer is recorded as admin for audit.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Issue a child key on behalf of a master",
"parameters": [
{
"type": "integer",
"description": "Master ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Key Request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.IssueChildKeyRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/models": { "/admin/models": {
"get": { "get": {
"security": [ "security": [
@@ -267,6 +417,70 @@
} }
} }
}, },
"/admin/providers/{id}": {
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Update provider attributes including status/auto-ban flags",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update a provider",
"parameters": [
{
"type": "integer",
"description": "Provider ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Provider Info",
"name": "provider",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Provider"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/sync/snapshot": { "/admin/sync/snapshot": {
"post": { "post": {
"security": [ "security": [
@@ -442,9 +656,24 @@
"api_key": { "api_key": {
"type": "string" "type": "string"
}, },
"auto_ban": {
"type": "boolean"
},
"ban_reason": {
"type": "string"
},
"ban_until": {
"type": "string"
},
"base_url": { "base_url": {
"type": "string" "type": "string"
}, },
"google_location": {
"type": "string"
},
"google_project": {
"type": "string"
},
"group": { "group": {
"type": "string" "type": "string"
}, },
@@ -458,6 +687,13 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"skip_routing": {
"description": "Optional control params",
"type": "boolean"
},
"status": {
"type": "string"
},
"type": { "type": {
"type": "string" "type": "string"
} }
@@ -571,6 +807,18 @@
"api_key": { "api_key": {
"type": "string" "type": "string"
}, },
"auto_ban": {
"description": "whether DP-triggered disable is allowed",
"type": "boolean"
},
"ban_reason": {
"description": "reason for current disable",
"type": "string"
},
"ban_until": {
"description": "optional TTL for disable",
"type": "string"
},
"base_url": { "base_url": {
"type": "string" "type": "string"
}, },
@@ -580,6 +828,12 @@
"deletedAt": { "deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt" "$ref": "#/definitions/gorm.DeletedAt"
}, },
"google_location": {
"type": "string"
},
"google_project": {
"type": "string"
},
"group": { "group": {
"description": "routing group/tier", "description": "routing group/tier",
"type": "string" "type": "string"
@@ -594,6 +848,10 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"status": {
"description": "active, auto_disabled, manual_disabled",
"type": "string"
},
"type": { "type": {
"description": "openai, anthropic, etc.", "description": "openai, anthropic, etc.",
"type": "string" "type": "string"

View File

@@ -26,8 +26,18 @@ definitions:
properties: properties:
api_key: api_key:
type: string type: string
auto_ban:
type: boolean
ban_reason:
type: string
ban_until:
type: string
base_url: base_url:
type: string type: string
google_location:
type: string
google_project:
type: string
group: group:
type: string type: string
models: models:
@@ -37,6 +47,11 @@ definitions:
type: array type: array
name: name:
type: string type: string
skip_routing:
description: Optional control params
type: boolean
status:
type: string
type: type:
type: string type: string
type: object type: object
@@ -112,12 +127,25 @@ definitions:
properties: properties:
api_key: api_key:
type: string type: string
auto_ban:
description: whether DP-triggered disable is allowed
type: boolean
ban_reason:
description: reason for current disable
type: string
ban_until:
description: optional TTL for disable
type: string
base_url: base_url:
type: string type: string
createdAt: createdAt:
type: string type: string
deletedAt: deletedAt:
$ref: '#/definitions/gorm.DeletedAt' $ref: '#/definitions/gorm.DeletedAt'
google_location:
type: string
google_project:
type: string
group: group:
description: routing group/tier description: routing group/tier
type: string type: string
@@ -128,6 +156,9 @@ definitions:
type: string type: string
name: name:
type: string type: string
status:
description: active, auto_disabled, manual_disabled
type: string
type: type:
description: openai, anthropic, etc. description: openai, anthropic, etc.
type: string type: string
@@ -177,6 +208,57 @@ info:
title: EZ-API Control Plane title: EZ-API Control Plane
version: 0.0.1 version: 0.0.1
paths: paths:
/admin/features:
get:
description: Returns all feature flags stored in Redis (meta:features)
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: List feature flags
tags:
- admin
put:
consumes:
- application/json
description: Updates selected feature flags (meta:features). Values are stored
as strings.
parameters:
- description: Feature map
in: body
name: request
required: true
schema:
type: object
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/gin.H'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Update feature flags
tags:
- admin
/admin/masters: /admin/masters:
post: post:
consumes: consumes:
@@ -209,6 +291,52 @@ paths:
summary: Create a new master tenant summary: Create a new master tenant
tags: tags:
- admin - admin
/admin/masters/{id}/keys:
post:
consumes:
- application/json
description: Issue a new access token (child key) for a specified master. The
key still belongs to the master; issuer is recorded as admin for audit.
parameters:
- description: Master ID
in: path
name: id
required: true
type: integer
- description: Key Request
in: body
name: request
required: true
schema:
$ref: '#/definitions/internal_api.IssueChildKeyRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/gin.H'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"403":
description: Forbidden
schema:
$ref: '#/definitions/gin.H'
"404":
description: Not Found
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Issue a child key on behalf of a master
tags:
- admin
/admin/models: /admin/models:
get: get:
description: Get a list of all registered models description: Get a list of all registered models
@@ -334,6 +462,47 @@ paths:
summary: Create a new provider summary: Create a new provider
tags: tags:
- admin - admin
/admin/providers/{id}:
put:
consumes:
- application/json
description: Update provider attributes including status/auto-ban flags
parameters:
- description: Provider ID
in: path
name: id
required: true
type: integer
- description: Provider Info
in: body
name: provider
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Provider'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"404":
description: Not Found
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Update a provider
tags:
- admin
/admin/sync/snapshot: /admin/sync/snapshot:
post: post:
description: Force full synchronization of DB state to Redis description: Force full synchronization of DB state to Redis