mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat: Add Swagger documentation for admin and master API endpoints
- Added Swagger documentation for the following admin endpoints: - Create a new master tenant - Create a new provider - Register a new model - List all models - Update a model - Force sync snapshot - Ingest logs - Added Swagger documentation for the master endpoint: - Issue a child key - Updated go.mod and go.sum to include necessary dependencies for Swagger.
This commit is contained in:
431
docs/swagger.yaml
Normal file
431
docs/swagger.yaml
Normal file
@@ -0,0 +1,431 @@
|
||||
basePath: /
|
||||
definitions:
|
||||
gin.H:
|
||||
additionalProperties: {}
|
||||
type: object
|
||||
github_com_ez-api_ez-api_internal_dto.ModelDTO:
|
||||
properties:
|
||||
context_window:
|
||||
type: integer
|
||||
cost_per_token:
|
||||
type: number
|
||||
max_output_tokens:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
supports_fim:
|
||||
type: boolean
|
||||
supports_functions:
|
||||
type: boolean
|
||||
supports_tool_choice:
|
||||
type: boolean
|
||||
supports_vision:
|
||||
type: boolean
|
||||
type: object
|
||||
github_com_ez-api_ez-api_internal_dto.ProviderDTO:
|
||||
properties:
|
||||
api_key:
|
||||
type: string
|
||||
base_url:
|
||||
type: string
|
||||
group:
|
||||
type: string
|
||||
models:
|
||||
description: List of supported model names
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
name:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
github_com_ez-api_ez-api_internal_model.LogRecord:
|
||||
properties:
|
||||
audit_reason:
|
||||
type: string
|
||||
client_ip:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
deletedAt:
|
||||
$ref: '#/definitions/gorm.DeletedAt'
|
||||
error_message:
|
||||
type: string
|
||||
group:
|
||||
type: string
|
||||
id:
|
||||
type: integer
|
||||
key_id:
|
||||
type: integer
|
||||
latency_ms:
|
||||
type: integer
|
||||
model:
|
||||
type: string
|
||||
request_body:
|
||||
description: optional, only when audit triggered
|
||||
type: string
|
||||
request_size:
|
||||
type: integer
|
||||
response_body:
|
||||
description: optional, only when audit triggered
|
||||
type: string
|
||||
response_size:
|
||||
type: integer
|
||||
status_code:
|
||||
type: integer
|
||||
tokens_in:
|
||||
type: integer
|
||||
tokens_out:
|
||||
type: integer
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
github_com_ez-api_ez-api_internal_model.Model:
|
||||
properties:
|
||||
context_window:
|
||||
type: integer
|
||||
cost_per_token:
|
||||
type: number
|
||||
createdAt:
|
||||
type: string
|
||||
deletedAt:
|
||||
$ref: '#/definitions/gorm.DeletedAt'
|
||||
id:
|
||||
type: integer
|
||||
max_output_tokens:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
supports_fim:
|
||||
type: boolean
|
||||
supports_functions:
|
||||
type: boolean
|
||||
supports_tool_choice:
|
||||
type: boolean
|
||||
supports_vision:
|
||||
type: boolean
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
github_com_ez-api_ez-api_internal_model.Provider:
|
||||
properties:
|
||||
api_key:
|
||||
type: string
|
||||
base_url:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
deletedAt:
|
||||
$ref: '#/definitions/gorm.DeletedAt'
|
||||
group:
|
||||
description: routing group/tier
|
||||
type: string
|
||||
id:
|
||||
type: integer
|
||||
models:
|
||||
description: comma-separated list of supported models (e.g. "gpt-4,gpt-3.5-turbo")
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type:
|
||||
description: openai, anthropic, etc.
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
gorm.DeletedAt:
|
||||
properties:
|
||||
time:
|
||||
type: string
|
||||
valid:
|
||||
description: Valid is true if Time is not NULL
|
||||
type: boolean
|
||||
type: object
|
||||
internal_api.CreateMasterRequest:
|
||||
properties:
|
||||
global_qps:
|
||||
type: integer
|
||||
group:
|
||||
type: string
|
||||
max_child_keys:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
required:
|
||||
- group
|
||||
- name
|
||||
type: object
|
||||
internal_api.IssueChildKeyRequest:
|
||||
properties:
|
||||
group:
|
||||
type: string
|
||||
scopes:
|
||||
type: string
|
||||
type: object
|
||||
host: localhost:8080
|
||||
info:
|
||||
contact:
|
||||
email: support@swagger.io
|
||||
name: API Support
|
||||
url: http://www.swagger.io/support
|
||||
description: Management API for EZ-API Gateway system.
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
termsOfService: http://swagger.io/terms/
|
||||
title: EZ-API Control Plane
|
||||
version: 0.0.1
|
||||
paths:
|
||||
/admin/masters:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Create a new master account (tenant)
|
||||
parameters:
|
||||
- description: Master Info
|
||||
in: body
|
||||
name: master
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/internal_api.CreateMasterRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
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: Create a new master tenant
|
||||
tags:
|
||||
- admin
|
||||
/admin/models:
|
||||
get:
|
||||
description: Get a list of all registered models
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Model'
|
||||
type: array
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
security:
|
||||
- AdminAuth: []
|
||||
summary: List all models
|
||||
tags:
|
||||
- admin
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Register a supported model with its capabilities
|
||||
parameters:
|
||||
- description: Model Info
|
||||
in: body
|
||||
name: model
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ModelDTO'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"201":
|
||||
description: Created
|
||||
schema:
|
||||
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Model'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
security:
|
||||
- AdminAuth: []
|
||||
summary: Register a new model
|
||||
tags:
|
||||
- admin
|
||||
/admin/models/{id}:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Update an existing model's configuration
|
||||
parameters:
|
||||
- description: Model ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
- description: Model Info
|
||||
in: body
|
||||
name: model
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ModelDTO'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Model'
|
||||
"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 model
|
||||
tags:
|
||||
- admin
|
||||
/admin/providers:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Register a new upstream AI provider
|
||||
parameters:
|
||||
- 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:
|
||||
"201":
|
||||
description: Created
|
||||
schema:
|
||||
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Provider'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
security:
|
||||
- AdminAuth: []
|
||||
summary: Create a new provider
|
||||
tags:
|
||||
- admin
|
||||
/admin/sync/snapshot:
|
||||
post:
|
||||
description: Force full synchronization of DB state to Redis
|
||||
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: Force sync snapshot
|
||||
tags:
|
||||
- admin
|
||||
/logs:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Internal endpoint for ingesting logs from Balancer
|
||||
parameters:
|
||||
- description: Log Record
|
||||
in: body
|
||||
name: log
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.LogRecord'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"202":
|
||||
description: Accepted
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
summary: Ingest logs
|
||||
tags:
|
||||
- system
|
||||
/v1/tokens:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Issue a new access token (child key) for the authenticated master
|
||||
parameters:
|
||||
- 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'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
"403":
|
||||
description: Forbidden
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/gin.H'
|
||||
security:
|
||||
- MasterAuth: []
|
||||
summary: Issue a child key
|
||||
tags:
|
||||
- master
|
||||
securityDefinitions:
|
||||
AdminAuth:
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
MasterAuth:
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
swagger: "2.0"
|
||||
Reference in New Issue
Block a user