docs(api): add alert thresholds endpoints to swagger documentation

Add OpenAPI documentation for the new alert threshold management
endpoints used in traffic spike detection:

- GET /admin/alerts/thresholds - retrieve current threshold config
- PUT /admin/alerts/thresholds - update threshold configuration

Include AlertThresholdView and UpdateAlertThresholdsRequest schema
definitions with properties for QPS, RPM, TPM, RPD, TPD limits.
This commit is contained in:
zenfun
2025-12-31 15:57:27 +08:00
parent ba54abd424
commit 0b9556ee7e
3 changed files with 356 additions and 0 deletions

View File

@@ -187,6 +187,86 @@ const docTemplate = `{
}
}
},
"/admin/alerts/thresholds": {
"get": {
"security": [
{
"AdminAuth": []
}
],
"description": "Get current alert threshold configuration for traffic spike detection",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Get alert thresholds",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_api.AlertThresholdView"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
},
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Update alert threshold configuration for traffic spike detection",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update alert thresholds",
"parameters": [
{
"description": "Threshold configuration",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.UpdateAlertThresholdsRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_api.AlertThresholdView"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/alerts/{id}": {
"get": {
"security": [
@@ -4829,6 +4909,35 @@ const docTemplate = `{
}
}
},
"internal_api.AlertThresholdView": {
"type": "object",
"properties": {
"global_qps": {
"type": "integer"
},
"master_rpd": {
"type": "integer"
},
"master_rpm": {
"type": "integer"
},
"master_tpd": {
"type": "integer"
},
"master_tpm": {
"type": "integer"
},
"min_rpm_requests_1m": {
"type": "integer"
},
"min_tpm_tokens_1m": {
"type": "integer"
},
"updated_at": {
"type": "integer"
}
}
},
"internal_api.AlertView": {
"type": "object",
"properties": {
@@ -5745,6 +5854,32 @@ const docTemplate = `{
}
}
},
"internal_api.UpdateAlertThresholdsRequest": {
"type": "object",
"properties": {
"global_qps": {
"type": "integer"
},
"master_rpd": {
"type": "integer"
},
"master_rpm": {
"type": "integer"
},
"master_tpd": {
"type": "integer"
},
"master_tpm": {
"type": "integer"
},
"min_rpm_requests_1m": {
"type": "integer"
},
"min_tpm_tokens_1m": {
"type": "integer"
}
}
},
"internal_api.UpdateMasterRequest": {
"type": "object",
"properties": {