diff --git a/docs/docs.go b/docs/docs.go index 9938e67..240154e 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -24,6 +24,86 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "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": { "post": { "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": { "get": { "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": { "post": { "security": [ @@ -448,9 +662,24 @@ const docTemplate = `{ "api_key": { "type": "string" }, + "auto_ban": { + "type": "boolean" + }, + "ban_reason": { + "type": "string" + }, + "ban_until": { + "type": "string" + }, "base_url": { "type": "string" }, + "google_location": { + "type": "string" + }, + "google_project": { + "type": "string" + }, "group": { "type": "string" }, @@ -464,6 +693,13 @@ const docTemplate = `{ "name": { "type": "string" }, + "skip_routing": { + "description": "Optional control params", + "type": "boolean" + }, + "status": { + "type": "string" + }, "type": { "type": "string" } @@ -577,6 +813,18 @@ const docTemplate = `{ "api_key": { "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": { "type": "string" }, @@ -586,6 +834,12 @@ const docTemplate = `{ "deletedAt": { "$ref": "#/definitions/gorm.DeletedAt" }, + "google_location": { + "type": "string" + }, + "google_project": { + "type": "string" + }, "group": { "description": "routing group/tier", "type": "string" @@ -600,6 +854,10 @@ const docTemplate = `{ "name": { "type": "string" }, + "status": { + "description": "active, auto_disabled, manual_disabled", + "type": "string" + }, "type": { "description": "openai, anthropic, etc.", "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index d20f8c1..494a4fb 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -18,6 +18,86 @@ "host": "localhost:8080", "basePath": "/", "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": { "post": { "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": { "get": { "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": { "post": { "security": [ @@ -442,9 +656,24 @@ "api_key": { "type": "string" }, + "auto_ban": { + "type": "boolean" + }, + "ban_reason": { + "type": "string" + }, + "ban_until": { + "type": "string" + }, "base_url": { "type": "string" }, + "google_location": { + "type": "string" + }, + "google_project": { + "type": "string" + }, "group": { "type": "string" }, @@ -458,6 +687,13 @@ "name": { "type": "string" }, + "skip_routing": { + "description": "Optional control params", + "type": "boolean" + }, + "status": { + "type": "string" + }, "type": { "type": "string" } @@ -571,6 +807,18 @@ "api_key": { "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": { "type": "string" }, @@ -580,6 +828,12 @@ "deletedAt": { "$ref": "#/definitions/gorm.DeletedAt" }, + "google_location": { + "type": "string" + }, + "google_project": { + "type": "string" + }, "group": { "description": "routing group/tier", "type": "string" @@ -594,6 +848,10 @@ "name": { "type": "string" }, + "status": { + "description": "active, auto_disabled, manual_disabled", + "type": "string" + }, "type": { "description": "openai, anthropic, etc.", "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 30577a4..e14a988 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -26,8 +26,18 @@ definitions: properties: api_key: type: string + auto_ban: + type: boolean + ban_reason: + type: string + ban_until: + type: string base_url: type: string + google_location: + type: string + google_project: + type: string group: type: string models: @@ -37,6 +47,11 @@ definitions: type: array name: type: string + skip_routing: + description: Optional control params + type: boolean + status: + type: string type: type: string type: object @@ -112,12 +127,25 @@ definitions: properties: api_key: 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: type: string createdAt: type: string deletedAt: $ref: '#/definitions/gorm.DeletedAt' + google_location: + type: string + google_project: + type: string group: description: routing group/tier type: string @@ -128,6 +156,9 @@ definitions: type: string name: type: string + status: + description: active, auto_disabled, manual_disabled + type: string type: description: openai, anthropic, etc. type: string @@ -177,6 +208,57 @@ info: title: EZ-API Control Plane version: 0.0.1 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: post: consumes: @@ -209,6 +291,52 @@ paths: summary: Create a new master tenant tags: - 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: get: description: Get a list of all registered models @@ -334,6 +462,47 @@ paths: summary: Create a new provider tags: - 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: post: description: Force full synchronization of DB state to Redis