mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +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:
@@ -91,7 +91,7 @@ type ListAlertsResponse struct {
|
||||
// @Param severity query string false "filter by severity (info, warning, critical)"
|
||||
// @Param type query string false "filter by type (rate_limit, error_spike, quota_exceeded, key_disabled, key_expired, provider_down, traffic_spike)"
|
||||
// @Success 200 {object} ResponseEnvelope{data=ListAlertsResponse}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/alerts [get]
|
||||
func (h *AlertHandler) ListAlerts(c *gin.Context) {
|
||||
limit, offset := parseLimitOffset(c)
|
||||
@@ -141,8 +141,8 @@ func (h *AlertHandler) ListAlerts(c *gin.Context) {
|
||||
// @Security AdminAuth
|
||||
// @Param id path int true "Alert ID"
|
||||
// @Success 200 {object} ResponseEnvelope{data=AlertView}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 400 {object} ResponseEnvelope{data=MapData}
|
||||
// @Failure 404 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/alerts/{id} [get]
|
||||
func (h *AlertHandler) GetAlert(c *gin.Context) {
|
||||
id, ok := parseUintParam(c, "id")
|
||||
@@ -181,8 +181,8 @@ type CreateAlertRequest struct {
|
||||
// @Security AdminAuth
|
||||
// @Param request body CreateAlertRequest true "Alert data"
|
||||
// @Success 201 {object} ResponseEnvelope{data=AlertView}
|
||||
// @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/alerts [post]
|
||||
func (h *AlertHandler) CreateAlert(c *gin.Context) {
|
||||
var req CreateAlertRequest
|
||||
@@ -248,9 +248,9 @@ type AckAlertRequest struct {
|
||||
// @Param id path int true "Alert ID"
|
||||
// @Param request body AckAlertRequest false "Ack data"
|
||||
// @Success 200 {object} ResponseEnvelope{data=AlertView}
|
||||
// @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/alerts/{id}/ack [post]
|
||||
func (h *AlertHandler) AcknowledgeAlert(c *gin.Context) {
|
||||
id, ok := parseUintParam(c, "id")
|
||||
@@ -295,9 +295,9 @@ func (h *AlertHandler) AcknowledgeAlert(c *gin.Context) {
|
||||
// @Security AdminAuth
|
||||
// @Param id path int true "Alert ID"
|
||||
// @Success 200 {object} ResponseEnvelope{data=AlertView}
|
||||
// @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/alerts/{id}/resolve [post]
|
||||
func (h *AlertHandler) ResolveAlert(c *gin.Context) {
|
||||
id, ok := parseUintParam(c, "id")
|
||||
@@ -337,10 +337,10 @@ func (h *AlertHandler) ResolveAlert(c *gin.Context) {
|
||||
// @Produce json
|
||||
// @Security AdminAuth
|
||||
// @Param id path int true "Alert 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/alerts/{id} [delete]
|
||||
func (h *AlertHandler) DismissAlert(c *gin.Context) {
|
||||
id, ok := parseUintParam(c, "id")
|
||||
@@ -380,7 +380,7 @@ type AlertStats struct {
|
||||
// @Produce json
|
||||
// @Security AdminAuth
|
||||
// @Success 200 {object} ResponseEnvelope{data=AlertStats}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/alerts/stats [get]
|
||||
func (h *AlertHandler) GetAlertStats(c *gin.Context) {
|
||||
var total, active, acknowledged, resolved, critical, warning, info int64
|
||||
@@ -436,7 +436,7 @@ func toAlertThresholdView(cfg model.AlertThresholdConfig) AlertThresholdView {
|
||||
// @Produce json
|
||||
// @Security AdminAuth
|
||||
// @Success 200 {object} ResponseEnvelope{data=AlertThresholdView}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=gin.H}
|
||||
// @Failure 500 {object} ResponseEnvelope{data=MapData}
|
||||
// @Router /admin/alerts/thresholds [get]
|
||||
func (h *AlertHandler) GetAlertThresholds(c *gin.Context) {
|
||||
cfg, err := h.loadThresholdConfig()
|
||||
@@ -467,8 +467,8 @@ type UpdateAlertThresholdsRequest struct {
|
||||
// @Security AdminAuth
|
||||
// @Param request body UpdateAlertThresholdsRequest true "Threshold configuration"
|
||||
// @Success 200 {object} ResponseEnvelope{data=AlertThresholdView}
|
||||
// @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/alerts/thresholds [put]
|
||||
func (h *AlertHandler) UpdateAlertThresholds(c *gin.Context) {
|
||||
var req UpdateAlertThresholdsRequest
|
||||
|
||||
Reference in New Issue
Block a user