AI网关新增TTS/重排/审核端点,xAI工具扩展,swagger修缺
CI / test (push) Successful in 32s
Release / release (push) Successful in 1m4s

- 新端点 /ai/v1/audio/speech(xai.grok-tts)、/rerank(cohere.rerank-v4)、/moderations(OCI Guardrails)
- Responses 放行 code_interpreter 与远程 mcp 工具,web_search/x_search 解除仅非流式限制
- 模型能力映射扩展:TEXT_RERANK→RERANK、TEXT_TO_AUDIO→TTS
- AI 网关文档独立 docs/ai-gateway.md,字段兼容矩阵只列支持项;README 精简引用
- swagger 修缺:135 处响应注解具体化,RawMessage/联合类型统一渲染 AnyJSON,overrides 迁至 docs/.swaggo
- CHANGELOG 0.4.0,版本段不再记日期;DASH_VERSION v0.4.0
This commit is contained in:
2026-07-13 20:17:06 +08:00
parent 9309ad1ffc
commit 0a86b5a291
50 changed files with 10699 additions and 1371 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ func SetAboutRuntime(dbDriver, dbPath string) {
//
// @Summary 返回构建、运行时长与资源占用信息,「设置 · 关于」页展示
// @Tags 设置
// @Success 200 {object} map[string]any
// @Success 200 {object} aboutResponse
// @Security BearerAuth
// @Router /api/v1/about [get]
func about(c *gin.Context) {
+15 -12
View File
@@ -6,6 +6,9 @@ import (
"github.com/gin-gonic/gin"
_ "oci-portal/internal/aiwire" // swagger 注解引用
_ "oci-portal/internal/model" // swagger 注解引用
"oci-portal/internal/service"
)
@@ -18,7 +21,7 @@ type aiAdminHandler struct {
// @Summary ---- 密钥 ----
// @Tags AI 管理
// @Success 200 {object} map[string]any
// @Success 200 {object} itemsResponse[model.AiKey]
// @Security BearerAuth
// @Router /api/v1/ai-keys [get]
func (h *aiAdminHandler) listKeys(c *gin.Context) {
@@ -35,7 +38,7 @@ func (h *aiAdminHandler) listKeys(c *gin.Context) {
// @Summary 生成密钥
// @Tags AI 管理
// @Param body body object true "请求体(见接口说明)"
// @Success 201 {object} map[string]any
// @Success 201 {object} aiKeyCreateResponse "key 为明文密钥,仅本次返回"
// @Security BearerAuth
// @Router /api/v1/ai-keys [post]
func (h *aiAdminHandler) createKey(c *gin.Context) {
@@ -110,7 +113,7 @@ func (h *aiAdminHandler) deleteKey(c *gin.Context) {
// @Tags AI 管理
// @Param id path int true "配置 ID"
// @Param body body object true "请求体(见接口说明)"
// @Success 200 {object} map[string]any
// @Success 200 {object} model.AiKey
// @Security BearerAuth
// @Router /api/v1/ai-keys/{id}/content-log [put]
func (h *aiAdminHandler) updateKeyContentLog(c *gin.Context) {
@@ -137,7 +140,7 @@ func (h *aiAdminHandler) updateKeyContentLog(c *gin.Context) {
//
// @Summary 分页查询内容日志
// @Tags AI 管理
// @Success 200 {object} map[string]any
// @Success 200 {object} pagedResponse[model.AiCallLog]
// @Security BearerAuth
// @Router /api/v1/ai-content-logs [get]
func (h *aiAdminHandler) listContentLogs(c *gin.Context) {
@@ -157,7 +160,7 @@ func (h *aiAdminHandler) listContentLogs(c *gin.Context) {
// @Summary ---- 渠道 ----
// @Tags AI 管理
// @Success 200 {object} map[string]any
// @Success 200 {object} itemsResponse[model.AiChannel]
// @Security BearerAuth
// @Router /api/v1/ai-channels [get]
func (h *aiAdminHandler) listChannels(c *gin.Context) {
@@ -172,7 +175,7 @@ func (h *aiAdminHandler) listChannels(c *gin.Context) {
// @Summary 创建 AI 渠道
// @Tags AI 管理
// @Param body body service.ChannelInput true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} model.AiChannel
// @Security BearerAuth
// @Router /api/v1/ai-channels [post]
func (h *aiAdminHandler) createChannel(c *gin.Context) {
@@ -236,7 +239,7 @@ func (h *aiAdminHandler) deleteChannel(c *gin.Context) {
// @Summary 触发探测:服务可见性 + 模型同步 + 配额试调,返回更新后的渠道
// @Tags AI 管理
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} model.AiChannel
// @Security BearerAuth
// @Router /api/v1/ai-channels/{id}/probe [post]
func (h *aiAdminHandler) probeChannel(c *gin.Context) {
@@ -255,7 +258,7 @@ func (h *aiAdminHandler) probeChannel(c *gin.Context) {
// @Summary 同步渠道模型缓存
// @Tags AI 管理
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} itemsResponse[model.AiModelCache]
// @Security BearerAuth
// @Router /api/v1/ai-channels/{id}/sync-models [post]
func (h *aiAdminHandler) syncChannelModels(c *gin.Context) {
@@ -275,7 +278,7 @@ func (h *aiAdminHandler) syncChannelModels(c *gin.Context) {
// @Summary ---- 聚合模型与调用日志 ----
// @Tags AI 管理
// @Success 200 {object} map[string]any
// @Success 200 {object} itemsResponse[aiwire.Model]
// @Security BearerAuth
// @Router /api/v1/ai-models [get]
func (h *aiAdminHandler) gatewayModels(c *gin.Context) {
@@ -291,7 +294,7 @@ func (h *aiAdminHandler) gatewayModels(c *gin.Context) {
// @Summary 模型黑名单列表
// @Tags AI 管理
// @Success 200 {object} map[string]any
// @Success 200 {object} itemsResponse[model.AiModelBlacklist]
// @Security BearerAuth
// @Router /api/v1/ai-blacklist [get]
func (h *aiAdminHandler) listBlacklist(c *gin.Context) {
@@ -308,7 +311,7 @@ func (h *aiAdminHandler) listBlacklist(c *gin.Context) {
// @Summary 添加模型黑名单
// @Tags AI 管理
// @Param body body object true "请求体:{name: 模型名}"
// @Success 201 {object} map[string]any
// @Success 201 {object} itemResponse[model.AiModelBlacklist]
// @Security BearerAuth
// @Router /api/v1/ai-blacklist [post]
func (h *aiAdminHandler) addBlacklist(c *gin.Context) {
@@ -347,7 +350,7 @@ func (h *aiAdminHandler) removeBlacklist(c *gin.Context) {
// @Summary AI 调用日志列表
// @Tags AI 管理
// @Success 200 {object} map[string]any
// @Success 200 {object} pagedResponse[model.AiContentLog]
// @Security BearerAuth
// @Router /api/v1/ai-logs [get]
func (h *aiAdminHandler) listLogs(c *gin.Context) {
+9 -9
View File
@@ -165,8 +165,8 @@ func fillUsage(entry *model.AiCallLog, u *aiwire.Usage) {
//
// @Summary OpenAI 兼容向量嵌入
// @Tags AI 网关
// @Param body body object true "OpenAI embeddings 请求体"
// @Success 200 {object} map[string]any "OpenAI 兼容响应"
// @Param body body aiwire.EmbeddingsRequest true "OpenAI embeddings 请求体"
// @Success 200 {object} aiwire.EmbeddingsResponse "OpenAI 兼容响应"
// @Router /ai/v1/embeddings [post]
func (h *aiGatewayHandler) embeddings(c *gin.Context) {
var req aiwire.EmbeddingsRequest
@@ -218,8 +218,8 @@ const anthDefaultMaxTokens = 8192
//
// @Summary Anthropic Messages 兼容端点
// @Tags AI 网关
// @Param body body object true "Anthropic messages 请求体(支持 stream;经 OCI OpenAI 兼容面直通;max_tokens 可缺省,默认 8192)"
// @Success 200 {object} map[string]any "Anthropic 兼容响应(流式为 SSE)"
// @Param body body aiwire.MessagesRequest true "Anthropic messages 请求体(支持 stream;经 OCI OpenAI 兼容面直通;max_tokens 可缺省,默认 8192)"
// @Success 200 {object} aiwire.MessagesResponse "Anthropic 兼容响应(非流式;流式为 SSE 事件序列)"
// @Router /ai/v1/messages [post]
func (h *aiGatewayHandler) messages(c *gin.Context) {
var req aiwire.MessagesRequest
@@ -381,8 +381,8 @@ func writeAnthEvents(c *gin.Context, events []service.AnthEvent) {
//
// @Summary OpenAI Chat Completions 兼容端点
// @Tags AI 网关
// @Param body body object true "OpenAI chat/completions 请求体(支持 stream;经 Responses 转换直通)"
// @Success 200 {object} map[string]any "OpenAI 兼容响应(流式为 SSE,末尾 data: [DONE])"
// @Param body body aiwire.ChatRequest true "OpenAI chat/completions 请求体(支持 stream;经 Responses 转换直通)"
// @Success 200 {object} aiwire.ChatResponse "OpenAI 兼容响应(非流式;流式为 SSE,末尾 data: [DONE])"
// @Router /ai/v1/chat/completions [post]
func (h *aiGatewayHandler) chatCompletions(c *gin.Context) {
var req aiwire.ChatRequest
@@ -528,7 +528,7 @@ func writeChatChunks(c *gin.Context, chunks []aiwire.ChatChunk) {
//
// @Summary 可用模型列表
// @Tags AI 网关
// @Success 200 {object} map[string]any "OpenAI 兼容 models 列表"
// @Success 200 {object} aiwire.ModelList "OpenAI 兼容 models 列表"
// @Router /ai/v1/models [get]
func (h *aiGatewayHandler) listModels(c *gin.Context) {
list, err := h.gw.GatewayModels(c.Request.Context(), keyGroup(c))
@@ -552,8 +552,8 @@ func (h *aiGatewayHandler) listModels(c *gin.Context) {
//
// @Summary OpenAI Responses 兼容端点
// @Tags AI 网关
// @Param body body object true "OpenAI responses 请求体(支持 stream;web_search/x_search 服务端工具仅非流式)"
// @Success 200 {object} map[string]any "OpenAI 兼容响应(流式为 SSE)"
// @Param body body aiwire.RespRequest true "OpenAI responses 请求体(支持 stream;服务端工具 web_search/x_search/code_interpreter/mcp 含流式;未列字段原样透传上游)"
// @Success 200 {object} aiwire.RespResponse "OpenAI 兼容响应(非流式;流式为 SSE);直通仅建模常用字段,未列字段原样返回"
// @Router /ai/v1/responses [post]
func (h *aiGatewayHandler) responses(c *gin.Context) {
raw, err := c.GetRawData()
+119
View File
@@ -0,0 +1,119 @@
package api
import (
"net/http"
"strings"
"time"
"github.com/gin-gonic/gin"
"oci-portal/internal/aiwire"
"oci-portal/internal/service"
)
// audioSpeech 是 OpenAI /ai/v1/audio/speech 端点(TTS,直通兼容面)。
//
// @Summary OpenAI Audio Speech 兼容端点(文本转语音)
// @Tags AI 网关
// @Param body body aiwire.SpeechRequest true "OpenAI audio speech 请求体(model/input 必填,voice 见 xAI Grok Voice 列表,language 缺省 auto;未列字段原样透传)"
// @Success 200 {file} binary "音频字节(Content-Type 透传上游,默认 audio/mpeg)"
// @Router /ai/v1/audio/speech [post]
func (h *aiGatewayHandler) audioSpeech(c *gin.Context) {
raw, err := c.GetRawData()
if err != nil {
aiError(c, http.StatusBadRequest, "invalid_request_error", err.Error())
return
}
modelName, body, err := service.SpeechBodyNormalize(raw)
if err != nil {
aiError(c, http.StatusBadRequest, "invalid_request_error", err.Error())
return
}
if !checkKeyModel(c, modelName) {
return
}
start := time.Now()
audio, contentType, meta, err := h.gw.Speech(c.Request.Context(), modelName, body, keyGroup(c))
entry := h.logEntry(c, "speech", modelName, false, meta, start)
if err != nil {
upstreamError(c, err)
entry.ErrMsg = err.Error()
h.logFailure(c, entry, string(raw))
return
}
entry.Status = http.StatusOK
callID := h.gw.LogCall(entry)
h.maybeLogContent(c, callID, "speech", modelName, false, string(raw), nil)
if contentType == "" {
contentType = "audio/mpeg"
}
c.Data(http.StatusOK, contentType, audio)
}
// rerank 是 /ai/v1/rerank 端点(Jina / Cohere 风格文档重排)。
//
// @Summary 文档重排端点(Cohere Rerank)
// @Tags AI 网关
// @Param body body aiwire.RerankRequest true "重排请求体(model/query/documents 必填,可选 top_n/return_documents)"
// @Success 200 {object} aiwire.RerankResponse "重排结果(results[].index 指向入参下标)"
// @Router /ai/v1/rerank [post]
func (h *aiGatewayHandler) rerank(c *gin.Context) {
var req aiwire.RerankRequest
if err := c.ShouldBindJSON(&req); err != nil {
aiError(c, http.StatusBadRequest, "invalid_request_error", err.Error())
return
}
if strings.TrimSpace(req.Model) == "" || strings.TrimSpace(req.Query) == "" || len(req.Documents) == 0 {
aiError(c, http.StatusBadRequest, "invalid_request_error", "model、query 与 documents 不能为空")
return
}
if !checkKeyModel(c, req.Model) {
return
}
start := time.Now()
resp, meta, err := h.gw.Rerank(c.Request.Context(), req, keyGroup(c))
entry := h.logEntry(c, "rerank", req.Model, false, meta, start)
if err != nil {
upstreamError(c, err)
entry.ErrMsg = err.Error()
h.logFailure(c, entry, req)
return
}
entry.Status = http.StatusOK
callID := h.gw.LogCall(entry)
h.maybeLogContent(c, callID, "rerank", req.Model, false, req, resp)
c.JSON(http.StatusOK, resp)
}
// moderations 是 /ai/v1/moderations 端点(OpenAI 外壳映射 OCI Guardrails)。
//
// @Summary 内容审核端点(OCI Guardrails)
// @Tags AI 网关
// @Param body body aiwire.ModerationsRequest true "审核请求体(input 为字符串或字符串数组,单次至多 8 条;model 接受但忽略)"
// @Success 200 {object} aiwire.ModerationsResponse "审核结果(categories/category_scores 为 overall/blocklist/prompt_injection,pii 为扩展字段)"
// @Router /ai/v1/moderations [post]
func (h *aiGatewayHandler) moderations(c *gin.Context) {
var req aiwire.ModerationsRequest
if err := c.ShouldBindJSON(&req); err != nil {
aiError(c, http.StatusBadRequest, "invalid_request_error", err.Error())
return
}
inputs, err := service.ModerationInputs(req.Input)
if err != nil {
aiError(c, http.StatusBadRequest, "invalid_request_error", err.Error())
return
}
start := time.Now()
resp, meta, err := h.gw.Moderations(c.Request.Context(), aiRandID("modr_"), inputs, keyGroup(c))
entry := h.logEntry(c, "moderations", "oci-guardrails", false, meta, start)
if err != nil {
upstreamError(c, err)
entry.ErrMsg = err.Error()
h.logFailure(c, entry, req)
return
}
entry.Status = http.StatusOK
callID := h.gw.LogCall(entry)
h.maybeLogContent(c, callID, "moderations", "oci-guardrails", false, req, resp)
c.JSON(http.StatusOK, resp)
}
+8
View File
@@ -95,6 +95,14 @@ func TestAiGatewayKeyModelRestrict(t *testing.T) {
{"chat completions 不支持内容块拒绝", "open-key-12345", "/ai/v1/chat/completions",
`{"model":"ghost-model","messages":[{"role":"user","content":[{"type":"input_audio"}]}]}`,
400, []string{"invalid_request_error"}},
{"audio speech 白名单外拦截", "limited-key-1234", "/ai/v1/audio/speech",
`{"model":"meta.llama-3.3-70b-instruct","input":"你好"}`, 404, deny},
{"rerank 白名单外拦截", "limited-key-1234", "/ai/v1/rerank",
`{"model":"meta.llama-3.3-70b-instruct","query":"q","documents":["d"]}`, 404, deny},
{"rerank 缺 documents 拒绝", "open-key-12345", "/ai/v1/rerank",
`{"model":"ghost-model","query":"q"}`, 400, []string{"invalid_request_error"}},
{"moderations 空 input 拒绝", "open-key-12345", "/ai/v1/moderations",
`{"input":[]}`, 400, []string{"invalid_request_error"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
+11 -11
View File
@@ -15,7 +15,7 @@ import (
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body object true "请求体(见接口说明)"
// @Success 200 {object} map[string]any
// @Success 200 {object} publicIpResponse
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/change-public-ip [post]
func (h *ociConfigHandler) changePublicIP(c *gin.Context) {
@@ -40,7 +40,7 @@ func (h *ociConfigHandler) changePublicIP(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body object true "请求体(见接口说明)"
// @Success 201 {object} map[string]any
// @Success 201 {object} ipv6AddressResponse
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/ipv6-addresses [post]
func (h *ociConfigHandler) addInstanceIpv6(c *gin.Context) {
@@ -92,7 +92,7 @@ type attachVnicRequest struct {
// @Tags 计算
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.Vnic
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/vnics [get]
func (h *ociConfigHandler) listInstanceVnics(c *gin.Context) {
@@ -113,7 +113,7 @@ func (h *ociConfigHandler) listInstanceVnics(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body attachVnicRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.Vnic
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/vnics [post]
func (h *ociConfigHandler) attachVnic(c *gin.Context) {
@@ -160,7 +160,7 @@ func (h *ociConfigHandler) detachVnic(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param vnicId path string true "vnicId"
// @Param body body object true "请求体(见接口说明)"
// @Success 201 {object} map[string]any
// @Success 201 {object} addressResponse
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/vnics/{vnicId}/ipv6-addresses [post]
func (h *ociConfigHandler) addVnicIpv6(c *gin.Context) {
@@ -195,7 +195,7 @@ type attachBootVolumeRequest struct {
// @Tags 存储
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.BootVolumeAttachment
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/boot-volume-attachments [get]
func (h *ociConfigHandler) listBootVolumeAttachments(c *gin.Context) {
@@ -216,7 +216,7 @@ func (h *ociConfigHandler) listBootVolumeAttachments(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body attachBootVolumeRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.BootVolumeAttachment
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/boot-volume-attachments [post]
func (h *ociConfigHandler) attachBootVolume(c *gin.Context) {
@@ -242,7 +242,7 @@ func (h *ociConfigHandler) attachBootVolume(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body attachBootVolumeRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.BootVolumeAttachment
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/replace-boot-volume [post]
func (h *ociConfigHandler) replaceBootVolume(c *gin.Context) {
@@ -293,7 +293,7 @@ type attachVolumeRequest struct {
// @Summary 块存储卷列表
// @Tags 存储
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.BlockVolume
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/volumes [get]
func (h *ociConfigHandler) listBlockVolumes(c *gin.Context) {
@@ -313,7 +313,7 @@ func (h *ociConfigHandler) listBlockVolumes(c *gin.Context) {
// @Tags 存储
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.VolumeAttachment
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/volume-attachments [get]
func (h *ociConfigHandler) listVolumeAttachments(c *gin.Context) {
@@ -334,7 +334,7 @@ func (h *ociConfigHandler) listVolumeAttachments(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body attachVolumeRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.VolumeAttachment
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/volume-attachments [post]
func (h *ociConfigHandler) attachVolume(c *gin.Context) {
+3 -3
View File
@@ -32,9 +32,9 @@ type loginRequest struct {
// @Accept json
// @Produce json
// @Param body body loginRequest true "登录凭据"
// @Success 200 {object} map[string]any "token 与 expiresAt"
// @Failure 401 {object} map[string]string "凭据错误"
// @Failure 428 {object} map[string]any "需要两步验证码(totpRequired=true)"
// @Success 200 {object} tokenResponse "token 与 expiresAt"
// @Failure 401 {object} errorResponse "凭据错误"
// @Failure 428 {object} totpRequiredResponse "需要两步验证码(totpRequired=true)"
// @Router /api/v1/auth/login [post]
func (h *authHandler) login(c *gin.Context) {
var req loginRequest
+13 -11
View File
@@ -8,6 +8,8 @@ import (
"github.com/gin-gonic/gin"
_ "oci-portal/internal/model" // swagger 注解引用
"oci-portal/internal/service"
)
@@ -23,7 +25,7 @@ type authxHandler struct {
//
// @Summary 两步验证状态
// @Tags 认证
// @Success 200 {object} map[string]bool "enabled"
// @Success 200 {object} enabledResponse "enabled"
// @Security BearerAuth
// @Router /api/v1/auth/totp [get]
func (h *authxHandler) totpStatus(c *gin.Context) {
@@ -39,8 +41,8 @@ func (h *authxHandler) totpStatus(c *gin.Context) {
//
// @Summary 发起两步验证设置
// @Tags 认证
// @Success 200 {object} map[string]string "secret 与 otpauthUri"
// @Failure 409 {object} map[string]string "已启用"
// @Success 200 {object} totpSetupResponse "secret 与 otpauthUri"
// @Failure 409 {object} errorResponse "已启用"
// @Security BearerAuth
// @Router /api/v1/auth/totp/setup [post]
func (h *authxHandler) totpSetup(c *gin.Context) {
@@ -128,7 +130,7 @@ func (h *authxHandler) respondFreshToken(c *gin.Context) {
//
// @Summary 撤销全部会话
// @Tags 认证
// @Success 200 {object} map[string]string "新 token 与 expiresAt"
// @Success 200 {object} tokenResponse "新 token 与 expiresAt"
// @Security BearerAuth
// @Router /api/v1/auth/revoke-sessions [post]
func (h *authxHandler) revokeSessions(c *gin.Context) {
@@ -146,7 +148,7 @@ func (h *authxHandler) revokeSessions(c *gin.Context) {
//
// @Summary 登录凭据摘要
// @Tags 认证
// @Success 200 {object} map[string]any "username 与 passwordLoginDisabled"
// @Success 200 {object} credentialsResponse "username 与 passwordLoginDisabled"
// @Security BearerAuth
// @Router /api/v1/auth/credentials [get]
func (h *authxHandler) getCredentials(c *gin.Context) {
@@ -167,7 +169,7 @@ func (h *authxHandler) getCredentials(c *gin.Context) {
// @Tags 认证
// @Param body body service.UpdateCredentialsInput true "新凭据(当前密码必验)"
// @Success 204 "已更新,请重新登录"
// @Failure 401 {object} map[string]string "当前密码错误"
// @Failure 401 {object} errorResponse "当前密码错误"
// @Security BearerAuth
// @Router /api/v1/auth/credentials [put]
func (h *authxHandler) updateCredentials(c *gin.Context) {
@@ -199,7 +201,7 @@ func (h *authxHandler) updateCredentials(c *gin.Context) {
// @Tags 认证
// @Param body body object true "{disabled: bool}"
// @Success 204 "已保存"
// @Failure 409 {object} map[string]string "未绑定外部身份"
// @Failure 409 {object} errorResponse "未绑定外部身份"
// @Security BearerAuth
// @Router /api/v1/auth/password-login [put]
func (h *authxHandler) updatePasswordLogin(c *gin.Context) {
@@ -230,7 +232,7 @@ func (h *authxHandler) updatePasswordLogin(c *gin.Context) {
//
// @Summary 外部登录 provider 列表
// @Tags 认证
// @Success 200 {object} map[string]any "providers 与 passwordLoginDisabled"
// @Success 200 {object} oauthProvidersResponse "providers 与 passwordLoginDisabled"
// @Router /api/v1/auth/oauth/providers [get]
func (h *authxHandler) oauthProviders(c *gin.Context) {
providers := h.oauth.Providers(c.Request.Context())
@@ -247,7 +249,7 @@ func (h *authxHandler) oauthProviders(c *gin.Context) {
// @Tags 认证
// @Param provider path string true "oidc / github"
// @Param mode query string false "bind=绑定当前账号(需 Bearer),缺省登录"
// @Success 200 {object} map[string]string "url"
// @Success 200 {object} urlResponse "url"
// @Router /api/v1/auth/oauth/{provider}/authorize [get]
func (h *authxHandler) oauthAuthorize(c *gin.Context) {
provider := c.Param("provider")
@@ -333,7 +335,7 @@ func oauthErrText(err error) string {
//
// @Summary 已绑定外部身份
// @Tags 认证
// @Success 200 {object} map[string]any "items"
// @Success 200 {object} itemsResponse[model.UserIdentity] "items"
// @Security BearerAuth
// @Router /api/v1/auth/identities [get]
func (h *authxHandler) identities(c *gin.Context) {
@@ -351,7 +353,7 @@ func (h *authxHandler) identities(c *gin.Context) {
// @Tags 认证
// @Param id path int true "身份 ID"
// @Success 204 "已解绑"
// @Failure 409 {object} map[string]string "最后一个身份不可解绑"
// @Failure 409 {object} errorResponse "最后一个身份不可解绑"
// @Security BearerAuth
// @Router /api/v1/auth/identities/{id} [delete]
func (h *authxHandler) unbindIdentity(c *gin.Context) {
+4 -2
View File
@@ -4,6 +4,8 @@ import (
"net/http"
"github.com/gin-gonic/gin"
_ "oci-portal/internal/oci" // swagger 注解引用
)
// ---- 控制台连接(VNC / 串口) ----
@@ -18,7 +20,7 @@ type createConsoleConnectionRequest struct {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body createConsoleConnectionRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.ConsoleConnection
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/console-connections [post]
func (h *ociConfigHandler) createConsoleConnection(c *gin.Context) {
@@ -43,7 +45,7 @@ func (h *ociConfigHandler) createConsoleConnection(c *gin.Context) {
// @Tags 计算
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.ConsoleConnection
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/console-connections [get]
func (h *ociConfigHandler) listConsoleConnections(c *gin.Context) {
+6 -6
View File
@@ -41,7 +41,7 @@ func boolOr(v *bool, def bool) bool {
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.IdentityProviderInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/identity-providers [get]
func (h *ociConfigHandler) listIdentityProviders(c *gin.Context) {
@@ -62,7 +62,7 @@ func (h *ociConfigHandler) listIdentityProviders(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param body body createIdpRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.IdentityProviderInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/identity-providers [post]
func (h *ociConfigHandler) createIdentityProvider(c *gin.Context) {
@@ -102,7 +102,7 @@ func (h *ociConfigHandler) createIdentityProvider(c *gin.Context) {
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param idpId path string true "idpId"
// @Param body body object true "请求体(见接口说明)"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.IdentityProviderInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/identity-providers/{idpId}/activate [post]
func (h *ociConfigHandler) activateIdentityProvider(c *gin.Context) {
@@ -149,7 +149,7 @@ func (h *ociConfigHandler) deleteIdentityProvider(c *gin.Context) {
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Success 200 {object} map[string]any
// @Success 200 {file} file "SAML 元数据 XML(附件下载)"
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/saml-metadata [get]
func (h *ociConfigHandler) downloadSamlMetadata(c *gin.Context) {
@@ -170,7 +170,7 @@ func (h *ociConfigHandler) downloadSamlMetadata(c *gin.Context) {
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.SignOnRuleInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/sign-on-rules [get]
func (h *ociConfigHandler) listSignOnRules(c *gin.Context) {
@@ -191,7 +191,7 @@ func (h *ociConfigHandler) listSignOnRules(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param body body object true "请求体(见接口说明)"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.SignOnRuleInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/sign-on-exemptions [post]
func (h *ociConfigHandler) createMfaExemption(c *gin.Context) {
+9 -9
View File
@@ -11,7 +11,7 @@ import (
// @Summary 可用域列表
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} string
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/availability-domains [get]
func (h *ociConfigHandler) availabilityDomains(c *gin.Context) {
@@ -67,7 +67,7 @@ type instanceActionRequest struct {
// @Summary 实例列表
// @Tags 计算
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.Instance
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances [get]
func (h *ociConfigHandler) listInstances(c *gin.Context) {
@@ -87,7 +87,7 @@ func (h *ociConfigHandler) listInstances(c *gin.Context) {
// @Tags 计算
// @Param id path int true "配置 ID"
// @Param body body createInstanceRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} createInstancesResponse "部分成功仍 201,errors 为逐台失败信息"
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances [post]
func (h *ociConfigHandler) createInstance(c *gin.Context) {
@@ -147,7 +147,7 @@ func (h *ociConfigHandler) createInstance(c *gin.Context) {
// @Tags 计算
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.Instance
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId} [get]
func (h *ociConfigHandler) getInstance(c *gin.Context) {
@@ -168,7 +168,7 @@ func (h *ociConfigHandler) getInstance(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body updateInstanceRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.Instance
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId} [put]
func (h *ociConfigHandler) updateInstance(c *gin.Context) {
@@ -220,7 +220,7 @@ func (h *ociConfigHandler) terminateInstance(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Param body body instanceActionRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.Instance
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/action [post]
func (h *ociConfigHandler) instanceAction(c *gin.Context) {
@@ -253,7 +253,7 @@ type updateBootVolumeRequest struct {
// @Summary 引导卷列表
// @Tags 存储
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.BootVolume
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/boot-volumes [get]
func (h *ociConfigHandler) listBootVolumes(c *gin.Context) {
@@ -273,7 +273,7 @@ func (h *ociConfigHandler) listBootVolumes(c *gin.Context) {
// @Tags 存储
// @Param id path int true "配置 ID"
// @Param bootVolumeId path string true "bootVolumeId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.BootVolume
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/boot-volumes/{bootVolumeId} [get]
func (h *ociConfigHandler) getBootVolume(c *gin.Context) {
@@ -294,7 +294,7 @@ func (h *ociConfigHandler) getBootVolume(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param bootVolumeId path string true "bootVolumeId"
// @Param body body updateBootVolumeRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.BootVolume
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/boot-volumes/{bootVolumeId} [put]
func (h *ociConfigHandler) updateBootVolume(c *gin.Context) {
+7 -5
View File
@@ -7,6 +7,8 @@ import (
"github.com/gin-gonic/gin"
_ "oci-portal/internal/model" // swagger 注解引用
"oci-portal/internal/service"
)
@@ -20,7 +22,7 @@ type logEventHandler struct {
// @Summary 查询配置的回调地址
// @Tags 任务与日志回传
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} logWebhookStatusResponse
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/log-webhook [get]
func (h *logEventHandler) getWebhook(c *gin.Context) {
@@ -45,7 +47,7 @@ func (h *logEventHandler) getWebhook(c *gin.Context) {
// @Summary 生成
// @Tags 任务与日志回传
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.LogWebhookInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/log-webhook [post]
func (h *logEventHandler) ensureWebhook(c *gin.Context) {
@@ -87,7 +89,7 @@ func (h *logEventHandler) revokeWebhook(c *gin.Context) {
// @Tags 任务与日志回传
// @Param configId query int false "按配置过滤"
// @Param q query string false "关键字"
// @Success 200 {object} map[string]any "items 与 total"
// @Success 200 {object} pagedResponse[model.LogEvent] "items 与 total"
// @Security BearerAuth
// @Router /api/v1/log-events [get]
func (h *logEventHandler) list(c *gin.Context) {
@@ -111,7 +113,7 @@ func (h *logEventHandler) list(c *gin.Context) {
// @Summary 查询 OCI 侧链路状态与关键事件清单
// @Tags 任务与日志回传
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.RelayView
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/log-relay [get]
func (h *logEventHandler) getRelay(c *gin.Context) {
@@ -132,7 +134,7 @@ func (h *logEventHandler) getRelay(c *gin.Context) {
// @Summary 一键建立回传链路
// @Tags 任务与日志回传
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.RelayView
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/log-relay [post]
func (h *logEventHandler) setupRelay(c *gin.Context) {
+16 -16
View File
@@ -11,7 +11,7 @@ import (
// @Summary 实例形状列表
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.ComputeShape
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/shapes [get]
func (h *ociConfigHandler) shapes(c *gin.Context) {
@@ -30,7 +30,7 @@ func (h *ociConfigHandler) shapes(c *gin.Context) {
// @Summary 镜像列表
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.Image
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/images [get]
func (h *ociConfigHandler) images(c *gin.Context) {
@@ -54,7 +54,7 @@ func (h *ociConfigHandler) images(c *gin.Context) {
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Param imageId path string true "imageId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.Image
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/images/{imageId} [get]
func (h *ociConfigHandler) getImage(c *gin.Context) {
@@ -89,7 +89,7 @@ type renameRequest struct {
// @Summary VCN 列表
// @Tags 网络
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.VCN
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/vcns [get]
func (h *ociConfigHandler) listVCNs(c *gin.Context) {
@@ -109,7 +109,7 @@ func (h *ociConfigHandler) listVCNs(c *gin.Context) {
// @Tags 网络
// @Param id path int true "配置 ID"
// @Param body body createVCNRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.VCN
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/vcns [post]
func (h *ociConfigHandler) createVCN(c *gin.Context) {
@@ -141,7 +141,7 @@ func (h *ociConfigHandler) createVCN(c *gin.Context) {
// @Tags 网络
// @Param id path int true "配置 ID"
// @Param vcnId path string true "vcnId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.VCN
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/vcns/{vcnId} [get]
func (h *ociConfigHandler) getVCN(c *gin.Context) {
@@ -162,7 +162,7 @@ func (h *ociConfigHandler) getVCN(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param vcnId path string true "vcnId"
// @Param body body renameRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.VCN
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/vcns/{vcnId} [put]
func (h *ociConfigHandler) updateVCN(c *gin.Context) {
@@ -211,7 +211,7 @@ type enableIPv6Request struct {
// @Param id path int true "配置 ID"
// @Param vcnId path string true "vcnId"
// @Param body body enableIPv6Request true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} ipv6StepsResponse
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/vcns/{vcnId}/enable-ipv6 [post]
func (h *ociConfigHandler) enableVCNIPv6(c *gin.Context) {
@@ -247,7 +247,7 @@ type createSubnetRequest struct {
// @Summary 子网列表
// @Tags 网络
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.Subnet
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/subnets [get]
func (h *ociConfigHandler) listSubnets(c *gin.Context) {
@@ -267,7 +267,7 @@ func (h *ociConfigHandler) listSubnets(c *gin.Context) {
// @Tags 网络
// @Param id path int true "配置 ID"
// @Param body body createSubnetRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.Subnet
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/subnets [post]
func (h *ociConfigHandler) createSubnet(c *gin.Context) {
@@ -300,7 +300,7 @@ func (h *ociConfigHandler) createSubnet(c *gin.Context) {
// @Tags 网络
// @Param id path int true "配置 ID"
// @Param subnetId path string true "subnetId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.Subnet
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/subnets/{subnetId} [get]
func (h *ociConfigHandler) getSubnet(c *gin.Context) {
@@ -321,7 +321,7 @@ func (h *ociConfigHandler) getSubnet(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param subnetId path string true "subnetId"
// @Param body body renameRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.Subnet
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/subnets/{subnetId} [put]
func (h *ociConfigHandler) updateSubnet(c *gin.Context) {
@@ -381,7 +381,7 @@ type updateSecurityListRequest struct {
// @Summary 安全列表清单
// @Tags 网络
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.SecurityList
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/security-lists [get]
func (h *ociConfigHandler) listSecurityLists(c *gin.Context) {
@@ -401,7 +401,7 @@ func (h *ociConfigHandler) listSecurityLists(c *gin.Context) {
// @Tags 网络
// @Param id path int true "配置 ID"
// @Param body body createSecurityListRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.SecurityList
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/security-lists [post]
func (h *ociConfigHandler) createSecurityList(c *gin.Context) {
@@ -432,7 +432,7 @@ func (h *ociConfigHandler) createSecurityList(c *gin.Context) {
// @Tags 网络
// @Param id path int true "配置 ID"
// @Param securityListId path string true "securityListId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.SecurityList
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/security-lists/{securityListId} [get]
func (h *ociConfigHandler) getSecurityList(c *gin.Context) {
@@ -453,7 +453,7 @@ func (h *ociConfigHandler) getSecurityList(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param securityListId path string true "securityListId"
// @Param body body updateSecurityListRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.SecurityList
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/security-lists/{securityListId} [put]
func (h *ociConfigHandler) updateSecurityList(c *gin.Context) {
+10 -8
View File
@@ -9,8 +9,10 @@ import (
"strconv"
"github.com/gin-gonic/gin"
"github.com/oracle/oci-go-sdk/v65/common"
"gorm.io/gorm"
_ "oci-portal/internal/model" // swagger 注解引用
"oci-portal/internal/oci"
"oci-portal/internal/service"
@@ -39,7 +41,7 @@ type importRequest struct {
// @Summary 导入租户配置
// @Tags 租户配置
// @Param body body importRequest true "API Key 配置(私钥密文落库)"
// @Success 201 {object} map[string]any
// @Success 201 {object} model.OciConfig
// @Security BearerAuth
// @Router /api/v1/oci-configs [post]
func (h *ociConfigHandler) create(c *gin.Context) {
@@ -71,7 +73,7 @@ func (h *ociConfigHandler) create(c *gin.Context) {
// @Summary 租户配置列表
// @Tags 租户配置
// @Success 200 {object} map[string]any "items"
// @Success 200 {array} service.ConfigSummary
// @Security BearerAuth
// @Router /api/v1/oci-configs [get]
func (h *ociConfigHandler) list(c *gin.Context) {
@@ -86,7 +88,7 @@ func (h *ociConfigHandler) list(c *gin.Context) {
// @Summary 租户配置详情
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} model.OciConfig
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id} [get]
func (h *ociConfigHandler) get(c *gin.Context) {
@@ -105,7 +107,7 @@ func (h *ociConfigHandler) get(c *gin.Context) {
// @Summary 验证配置连通性并刷新画像
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} configChangesResponse "config 与 changes 字段变更对照"
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/verify [post]
func (h *ociConfigHandler) verify(c *gin.Context) {
@@ -139,7 +141,7 @@ type updateConfigRequest struct {
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Param body body object true "可更新字段(别名/分组/代理/多区域开关等)"
// @Success 200 {object} map[string]any
// @Success 200 {object} configChangesResponse "config 与 changes 字段变更对照"
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id} [put]
func (h *ociConfigHandler) update(c *gin.Context) {
@@ -194,7 +196,7 @@ func (h *ociConfigHandler) remove(c *gin.Context) {
// @Summary 列出租户下全部 ACTIVE compartment
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.Compartment
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/compartments [get]
func (h *ociConfigHandler) compartments(c *gin.Context) {
@@ -216,7 +218,7 @@ func (h *ociConfigHandler) compartments(c *gin.Context) {
// @Summary 返回筛选器用区域列表:未开多区域支持只含默认区域
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} service.RegionSubscriptionView
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/cached-regions [get]
func (h *ociConfigHandler) cachedRegions(c *gin.Context) {
@@ -237,7 +239,7 @@ func (h *ociConfigHandler) cachedRegions(c *gin.Context) {
// @Summary 返回筛选器用区间列表:未开多区间支持返回空数组
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.Compartment
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/cached-compartments [get]
func (h *ociConfigHandler) cachedCompartments(c *gin.Context) {
+3 -1
View File
@@ -4,13 +4,15 @@ import (
"net/http"
"github.com/gin-gonic/gin"
_ "oci-portal/internal/service" // swagger 注解引用
)
// overview 返回总览页聚合数据(本地快照,不发云端请求)。
//
// @Summary 返回总览页聚合数据
// @Tags 租户配置
// @Success 200 {object} map[string]any
// @Success 200 {object} service.Overview
// @Security BearerAuth
// @Router /api/v1/overview [get]
func (h *ociConfigHandler) overview(c *gin.Context) {
+6 -6
View File
@@ -18,7 +18,7 @@ type proxyHandler struct {
//
// @Summary 代理列表
// @Tags 设置
// @Success 200 {object} map[string]any "items"
// @Success 200 {object} itemsResponse[service.ProxyView] "items"
// @Security BearerAuth
// @Router /api/v1/proxies [get]
func (h *proxyHandler) list(c *gin.Context) {
@@ -35,7 +35,7 @@ func (h *proxyHandler) list(c *gin.Context) {
// @Summary 创建代理
// @Tags 设置
// @Param body body service.ProxyInput true "代理配置(密码只写不回)"
// @Success 201 {object} map[string]any
// @Success 201 {object} service.ProxyView
// @Security BearerAuth
// @Router /api/v1/proxies [post]
func (h *proxyHandler) create(c *gin.Context) {
@@ -58,7 +58,7 @@ func (h *proxyHandler) create(c *gin.Context) {
// @Tags 设置
// @Param id path int true "代理 ID"
// @Param body body service.ProxyInput true "代理配置(密码缺省沿用)"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.ProxyView
// @Security BearerAuth
// @Router /api/v1/proxies/{id} [put]
func (h *proxyHandler) update(c *gin.Context) {
@@ -104,7 +104,7 @@ func (h *proxyHandler) remove(c *gin.Context) {
// @Summary 批量导入代理
// @Tags 设置
// @Param body body object true "请求体(见接口说明)"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.ImportResult
// @Security BearerAuth
// @Router /api/v1/proxies/import [post]
func (h *proxyHandler) importBatch(c *gin.Context) {
@@ -128,7 +128,7 @@ func (h *proxyHandler) importBatch(c *gin.Context) {
// @Summary 手动重测代理出口地区,同步返回最新视图
// @Tags 设置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.ProxyView
// @Security BearerAuth
// @Router /api/v1/proxies/{id}/probe [post]
func (h *proxyHandler) probe(c *gin.Context) {
@@ -150,7 +150,7 @@ func (h *proxyHandler) probe(c *gin.Context) {
// @Tags 设置
// @Param id path int true "代理 ID"
// @Param body body object true "请求体 {\"ociConfigIds\": [1,2]}"
// @Success 200 {object} map[string]any "usedBy"
// @Success 200 {object} usedByResponse "usedBy"
// @Security BearerAuth
// @Router /api/v1/proxies/{id}/tenants [put]
func (h *proxyHandler) setTenants(c *gin.Context) {
+6 -4
View File
@@ -6,6 +6,8 @@ import (
"github.com/gin-gonic/gin"
_ "oci-portal/internal/service" // swagger 注解引用
"oci-portal/internal/oci"
)
@@ -13,7 +15,7 @@ import (
//
// @Summary 返回本地维护的完整区域表
// @Tags 租户配置
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.RegionInfo
// @Security BearerAuth
// @Router /api/v1/regions [get]
func listRegions(c *gin.Context) {
@@ -28,7 +30,7 @@ func listRegions(c *gin.Context) {
// @Summary 区域订阅列表
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} service.RegionSubscriptionView
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/region-subscriptions [get]
func (h *ociConfigHandler) regionSubscriptions(c *gin.Context) {
@@ -52,7 +54,7 @@ type subscribeRegionRequest struct {
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Param body body subscribeRegionRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {array} service.RegionSubscriptionView
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/region-subscriptions [post]
func (h *ociConfigHandler) subscribeRegion(c *gin.Context) {
@@ -76,7 +78,7 @@ func (h *ociConfigHandler) subscribeRegion(c *gin.Context) {
// @Summary 服务限额查询
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.LimitValue
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/limits [get]
func (h *ociConfigHandler) limits(c *gin.Context) {
+3
View File
@@ -15,6 +15,9 @@ func registerAiGateway(r *gin.Engine, aiGateway *service.AiGatewayService) {
ai.POST("/responses", aih.responses)
ai.POST("/messages", aih.messages)
ai.POST("/embeddings", aih.embeddings)
ai.POST("/audio/speech", aih.audioSpeech)
ai.POST("/rerank", aih.rerank)
ai.POST("/moderations", aih.moderations)
ai.GET("/models", aih.listModels)
}
+11 -11
View File
@@ -19,7 +19,7 @@ type settingsHandler struct {
//
// @Summary 返回脱敏后的 Telegram 配置,绝不回 token 明文
// @Tags 设置
// @Success 200 {object} map[string]any
// @Success 200 {object} service.TelegramView
// @Security BearerAuth
// @Router /api/v1/settings/telegram [get]
func (h *settingsHandler) getTelegram(c *gin.Context) {
@@ -44,7 +44,7 @@ type updateTelegramRequest struct {
// @Summary 保存配置并返回最新脱敏视图
// @Tags 设置
// @Param body body updateTelegramRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.TelegramView
// @Security BearerAuth
// @Router /api/v1/settings/telegram [put]
func (h *settingsHandler) updateTelegram(c *gin.Context) {
@@ -84,7 +84,7 @@ func (h *settingsHandler) testTelegram(c *gin.Context) {
//
// @Summary 返回全部通知渠道的脱敏视图
// @Tags 设置
// @Success 200 {object} map[string]any
// @Success 200 {object} itemsResponse[service.NotifyChannelView]
// @Security BearerAuth
// @Router /api/v1/settings/notify-channels [get]
func (h *settingsHandler) listNotifyChannels(c *gin.Context) {
@@ -119,7 +119,7 @@ type updateNotifyChannelRequest struct {
// @Tags 设置
// @Param type path string true "渠道类型(webhook/ntfy/bark/smtp)"
// @Param body body updateNotifyChannelRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} itemsResponse[service.NotifyChannelView]
// @Security BearerAuth
// @Router /api/v1/settings/notify-channels/{type} [put]
func (h *settingsHandler) updateNotifyChannel(c *gin.Context) {
@@ -160,7 +160,7 @@ func (h *settingsHandler) testNotifyChannel(c *gin.Context) {
//
// @Summary 返回全部通知事件开关
// @Tags 设置
// @Success 200 {object} map[string]any
// @Success 200 {object} service.NotifyEventsView
// @Security BearerAuth
// @Router /api/v1/settings/notify-events [get]
func (h *settingsHandler) getNotifyEvents(c *gin.Context) {
@@ -178,7 +178,7 @@ func (h *settingsHandler) getNotifyEvents(c *gin.Context) {
// @Summary 全量保存五个事件开关并返回最新值
// @Tags 设置
// @Param body body service.NotifyEventsView true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.NotifyEventsView
// @Security BearerAuth
// @Router /api/v1/settings/notify-events [put]
func (h *settingsHandler) updateNotifyEvents(c *gin.Context) {
@@ -198,7 +198,7 @@ func (h *settingsHandler) updateNotifyEvents(c *gin.Context) {
//
// @Summary 返回全部通知模板
// @Tags 设置
// @Success 200 {object} map[string]any
// @Success 200 {object} itemsResponse[service.NotifyTemplateView]
// @Security BearerAuth
// @Router /api/v1/settings/notify-templates [get]
func (h *settingsHandler) listNotifyTemplates(c *gin.Context) {
@@ -263,7 +263,7 @@ func (h *settingsHandler) testNotifyTemplate(c *gin.Context) {
//
// @Summary 返回任务行为设置
// @Tags 设置
// @Success 200 {object} map[string]any
// @Success 200 {object} service.TaskSettingsView
// @Security BearerAuth
// @Router /api/v1/settings/task [get]
func (h *settingsHandler) getTaskSettings(c *gin.Context) {
@@ -280,7 +280,7 @@ func (h *settingsHandler) getTaskSettings(c *gin.Context) {
// @Summary 保存任务行为设置并返回最新值
// @Tags 设置
// @Param body body service.TaskSettingsView true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.TaskSettingsView
// @Security BearerAuth
// @Router /api/v1/settings/task [put]
func (h *settingsHandler) updateTaskSettings(c *gin.Context) {
@@ -304,7 +304,7 @@ func (h *settingsHandler) updateTaskSettings(c *gin.Context) {
//
// @Summary 返回安全设置
// @Tags 设置
// @Success 200 {object} map[string]any
// @Success 200 {object} service.SecuritySettings
// @Security BearerAuth
// @Router /api/v1/settings/security [get]
func (h *settingsHandler) getSecurity(c *gin.Context) {
@@ -321,7 +321,7 @@ func (h *settingsHandler) getSecurity(c *gin.Context) {
// @Summary 保存安全设置并返回最新值
// @Tags 设置
// @Param body body service.SecuritySettings true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.SecuritySettings
// @Security BearerAuth
// @Router /api/v1/settings/security [put]
func (h *settingsHandler) updateSecurity(c *gin.Context) {
+5 -3
View File
@@ -4,12 +4,14 @@ import (
"net/http"
"github.com/gin-gonic/gin"
_ "oci-portal/internal/oci" // swagger 注解引用
)
// @Summary 订阅列表
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.SubscriptionInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/subscriptions [get]
func (h *ociConfigHandler) subscriptions(c *gin.Context) {
@@ -29,7 +31,7 @@ func (h *ociConfigHandler) subscriptions(c *gin.Context) {
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Param subscriptionId path string true "subscriptionId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.SubscriptionDetail
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/subscriptions/{subscriptionId} [get]
func (h *ociConfigHandler) subscriptionDetail(c *gin.Context) {
@@ -48,7 +50,7 @@ func (h *ociConfigHandler) subscriptionDetail(c *gin.Context) {
// @Summary 限额服务列表
// @Tags 租户配置
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.LimitService
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/limits/services [get]
func (h *ociConfigHandler) limitServices(c *gin.Context) {
+176
View File
@@ -0,0 +1,176 @@
package api
import (
"encoding/json"
"time"
"oci-portal/internal/model"
"oci-portal/internal/oci"
"oci-portal/internal/service"
)
// 本文件的类型仅供 swagger 文档渲染(@Success/@Failure 注解引用),
// 运行时代码不使用;字段与各 handler 返回的 gin.H 外壳保持一致。
// errorResponse 是统一错误响应外壳。
type errorResponse struct {
Error string `json:"error"`
}
// itemsResponse 是 {"items": [...]} 列表外壳。
type itemsResponse[T any] struct {
Items []T `json:"items"`
}
// pagedResponse 是 {"items": [...], "total": n} 分页外壳。
type pagedResponse[T any] struct {
Items []T `json:"items"`
Total int64 `json:"total"`
}
// itemResponse 是 {"item": {...}} 单项外壳。
type itemResponse[T any] struct {
Item T `json:"item"`
}
// triggerResponse 是任务触发受理响应。
type triggerResponse struct {
Triggered bool `json:"triggered"`
}
// tokenResponse 是登录 / 换发令牌响应。
type tokenResponse struct {
Token string `json:"token"`
ExpiresAt time.Time `json:"expiresAt"`
}
// totpRequiredResponse 是密码通过但需两步验证码的 428 响应。
type totpRequiredResponse struct {
Error string `json:"error"`
TotpRequired bool `json:"totpRequired"`
}
// enabledResponse 是布尔开关查询响应。
type enabledResponse struct {
Enabled bool `json:"enabled"`
}
// totpSetupResponse 是 TOTP 初始化响应。
type totpSetupResponse struct {
Secret string `json:"secret"`
OtpauthUri string `json:"otpauthUri"`
}
// credentialsResponse 是当前登录账号信息。
type credentialsResponse struct {
Username string `json:"username"`
PasswordLoginDisabled bool `json:"passwordLoginDisabled"`
}
// oauthProvidersResponse 是外部登录 provider 列表。
type oauthProvidersResponse struct {
Providers []service.ProviderInfo `json:"providers"`
PasswordLoginDisabled bool `json:"passwordLoginDisabled"`
}
// urlResponse 是跳转地址响应。
type urlResponse struct {
URL string `json:"url"`
}
// aboutResponse 是「设置 · 关于」页构建与运行信息。
type aboutResponse struct {
Version string `json:"version"`
BuildTime string `json:"buildTime"`
GoVersion string `json:"goVersion"`
Platform string `json:"platform"`
StartedAt string `json:"startedAt"`
UptimeSeconds int64 `json:"uptimeSeconds"`
Resources aboutResources `json:"resources"`
}
// aboutResources 是进程资源占用快照。
type aboutResources struct {
CpuAvgPercent float64 `json:"cpuAvgPercent"`
NumCpu int `json:"numCpu"`
Goroutines int `json:"goroutines"`
MemHeapBytes uint64 `json:"memHeapBytes"`
MemSysBytes uint64 `json:"memSysBytes"`
DbEngine string `json:"dbEngine"`
DbBytes int64 `json:"dbBytes"`
}
// publicIpResponse 是换绑公网 IP 结果。
type publicIpResponse struct {
PublicIp string `json:"publicIp"`
}
// ipv6AddressResponse 是实例新增 IPv6 结果。
type ipv6AddressResponse struct {
Ipv6Address string `json:"ipv6Address"`
}
// addressResponse 是 VNIC 新增 IPv6 结果。
type addressResponse struct {
Address string `json:"address"`
}
// ipv6StepsResponse 是 VCN 开启 IPv6 的分步结果。
type ipv6StepsResponse struct {
Steps []oci.IPv6Step `json:"steps"`
}
// configChangesResponse 是租户配置校验 / 更新结果(config 与字段变更对照)。
type configChangesResponse struct {
Config *model.OciConfig `json:"config"`
Changes service.Changes `json:"changes"`
}
// aiKeyCreateResponse 是 AI 密钥创建结果;key 为明文,仅本次返回。
type aiKeyCreateResponse struct {
Key string `json:"key"`
Item model.AiKey `json:"item"`
}
// usedByResponse 是代理关联租户结果(关联数)。
type usedByResponse struct {
UsedBy int64 `json:"usedBy"`
}
// rawDetailResponse 是审计事件原文响应。
type rawDetailResponse struct {
Raw json.RawMessage `json:"raw"`
}
// passwordResponse 是租户用户重置密码结果(一次性明文)。
type passwordResponse struct {
Password string `json:"password"`
}
// deletedTotpResponse 是清除 MFA 设备结果。
type deletedTotpResponse struct {
DeletedTotpDevices int `json:"deletedTotpDevices"`
}
// deletedApiKeysResponse 是清理用户 API Key 结果。
type deletedApiKeysResponse struct {
DeletedApiKeys int `json:"deletedApiKeys"`
}
// createInstancesResponse 是批量创建实例结果;部分成功仍 201,errors 为逐台失败信息。
type createInstancesResponse struct {
Instances []oci.Instance `json:"instances"`
Errors []string `json:"errors"`
}
// logWebhookStatusResponse 是日志回传 webhook 状态。
type logWebhookStatusResponse struct {
Exists bool `json:"exists"`
Webhook *service.LogWebhookInfo `json:"webhook,omitempty"`
}
// webConsoleSessionResponse 是网页控制台会话创建结果。
type webConsoleSessionResponse struct {
SessionId string `json:"sessionId"`
Type string `json:"type"`
}
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"github.com/gin-gonic/gin"
_ "oci-portal/internal/model" // swagger 注解引用
"oci-portal/internal/service"
)
@@ -18,7 +19,7 @@ type systemLogHandler struct {
//
// @Summary 系统操作日志列表
// @Tags 设置
// @Success 200 {object} map[string]any "items 与 total"
// @Success 200 {object} pagedResponse[model.SystemLog] "items 与 total"
// @Security BearerAuth
// @Router /api/v1/system-logs [get]
func (h *systemLogHandler) list(c *gin.Context) {
+8 -7
View File
@@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/gin"
_ "oci-portal/internal/model" // swagger 注解引用
"oci-portal/internal/service"
)
@@ -33,7 +34,7 @@ type updateTaskRequest struct {
// @Summary 创建任务
// @Tags 任务与日志回传
// @Param body body createTaskRequest true "任务定义(类型/cron/payload)"
// @Success 201 {object} map[string]any
// @Success 201 {object} model.Task
// @Security BearerAuth
// @Router /api/v1/tasks [post]
func (h *taskHandler) create(c *gin.Context) {
@@ -57,7 +58,7 @@ func (h *taskHandler) create(c *gin.Context) {
// @Summary 任务列表
// @Tags 任务与日志回传
// @Success 200 {array} map[string]any
// @Success 200 {array} model.Task
// @Security BearerAuth
// @Router /api/v1/tasks [get]
func (h *taskHandler) list(c *gin.Context) {
@@ -72,7 +73,7 @@ func (h *taskHandler) list(c *gin.Context) {
// @Summary 任务详情
// @Tags 任务与日志回传
// @Param id path int true "任务 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} model.Task
// @Security BearerAuth
// @Router /api/v1/tasks/{id} [get]
func (h *taskHandler) get(c *gin.Context) {
@@ -92,7 +93,7 @@ func (h *taskHandler) get(c *gin.Context) {
// @Tags 任务与日志回传
// @Param id path int true "任务 ID"
// @Param body body updateTaskRequest true "可更新字段"
// @Success 200 {object} map[string]any
// @Success 200 {object} model.Task
// @Security BearerAuth
// @Router /api/v1/tasks/{id} [put]
func (h *taskHandler) update(c *gin.Context) {
@@ -139,7 +140,7 @@ func (h *taskHandler) remove(c *gin.Context) {
// @Summary 任务执行日志
// @Tags 任务与日志回传
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} model.TaskLog
// @Security BearerAuth
// @Router /api/v1/tasks/{id}/logs [get]
func (h *taskHandler) logs(c *gin.Context) {
@@ -159,8 +160,8 @@ func (h *taskHandler) logs(c *gin.Context) {
// @Summary 立即执行任务(异步触发,结果经任务日志轮询获取)
// @Tags 任务与日志回传
// @Param id path int true "配置 ID"
// @Success 202 {object} map[string]any
// @Failure 409 {object} map[string]any "任务正在执行中"
// @Success 202 {object} triggerResponse
// @Failure 409 {object} errorResponse "任务正在执行中"
// @Security BearerAuth
// @Router /api/v1/tasks/{id}/run [post]
func (h *taskHandler) run(c *gin.Context) {
+18 -18
View File
@@ -18,7 +18,7 @@ import (
// @Tags 计算
// @Param id path int true "配置 ID"
// @Param instanceId path string true "instanceId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.InstanceTraffic
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/traffic [get]
func (h *ociConfigHandler) instanceTraffic(c *gin.Context) {
@@ -38,7 +38,7 @@ func (h *ociConfigHandler) instanceTraffic(c *gin.Context) {
// @Summary 配置成本快照
// @Tags 成本
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.CostItem
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/costs [get]
func (h *ociConfigHandler) costs(c *gin.Context) {
@@ -75,7 +75,7 @@ func (h *ociConfigHandler) costs(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param cursor query string false "续查游标(上次响应原样带回)"
// @Param limit query int false "单批目标条数,缺省 100,上限 200"
// @Success 200 {object} map[string]any
// @Success 200 {object} service.AuditEventsView
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/audit-events [get]
func (h *ociConfigHandler) getAuditEvents(c *gin.Context) {
@@ -103,7 +103,7 @@ func (h *ociConfigHandler) getAuditEvents(c *gin.Context) {
// @Summary 按 eventId 取回原始事件 JSON:缓存命中秒开,
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {object} rawDetailResponse "raw 为事件原文 JSON"
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/audit-events/detail [get]
func (h *ociConfigHandler) getAuditEventDetail(c *gin.Context) {
@@ -145,7 +145,7 @@ type createTenantUserRequest struct {
// @Summary 租户身份域列表
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.IdentityDomain
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/domains [get]
func (h *ociConfigHandler) listIdentityDomains(c *gin.Context) {
@@ -165,7 +165,7 @@ func (h *ociConfigHandler) listIdentityDomains(c *gin.Context) {
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.TenantUser
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/users [get]
func (h *ociConfigHandler) listTenantUsers(c *gin.Context) {
@@ -186,7 +186,7 @@ func (h *ociConfigHandler) listTenantUsers(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param userId path string true "userId"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.TenantUserDetail
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/users/{userId} [get]
func (h *ociConfigHandler) getTenantUserDetail(c *gin.Context) {
@@ -207,7 +207,7 @@ func (h *ociConfigHandler) getTenantUserDetail(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param body body createTenantUserRequest true "请求体"
// @Success 201 {object} map[string]any
// @Success 201 {object} oci.TenantUser
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/users [post]
func (h *ociConfigHandler) createTenantUser(c *gin.Context) {
@@ -253,7 +253,7 @@ type updateTenantUserRequest struct {
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param userId path string true "userId"
// @Param body body updateTenantUserRequest true "请求体"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.TenantUser
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/users/{userId} [put]
func (h *ociConfigHandler) updateTenantUser(c *gin.Context) {
@@ -306,7 +306,7 @@ func (h *ociConfigHandler) deleteTenantUser(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param userId path string true "userId"
// @Success 200 {object} map[string]any
// @Success 200 {object} passwordResponse "一次性明文密码"
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/users/{userId}/reset-password [post]
func (h *ociConfigHandler) resetTenantUserPassword(c *gin.Context) {
@@ -327,7 +327,7 @@ func (h *ociConfigHandler) resetTenantUserPassword(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param userId path string true "userId"
// @Success 200 {object} map[string]any
// @Success 200 {object} deletedTotpResponse
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/users/{userId}/mfa-devices [delete]
func (h *ociConfigHandler) deleteTenantUserMfa(c *gin.Context) {
@@ -347,7 +347,7 @@ func (h *ociConfigHandler) deleteTenantUserMfa(c *gin.Context) {
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Param userId path string true "userId"
// @Success 200 {object} map[string]any
// @Success 200 {object} deletedApiKeysResponse
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/users/{userId}/api-keys [delete]
func (h *ociConfigHandler) deleteTenantUserApiKeys(c *gin.Context) {
@@ -370,7 +370,7 @@ func (h *ociConfigHandler) deleteTenantUserApiKeys(c *gin.Context) {
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.NotificationRecipients
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/notification-recipients [get]
func (h *ociConfigHandler) getNotificationRecipients(c *gin.Context) {
@@ -391,7 +391,7 @@ func (h *ociConfigHandler) getNotificationRecipients(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param body body object true "请求体(见接口说明)"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.NotificationRecipients
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/notification-recipients [put]
func (h *ociConfigHandler) updateNotificationRecipients(c *gin.Context) {
@@ -418,7 +418,7 @@ func (h *ociConfigHandler) updateNotificationRecipients(c *gin.Context) {
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Success 200 {object} map[string]any
// @Success 200 {array} oci.PasswordPolicyInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/password-policies [get]
func (h *ociConfigHandler) listPasswordPolicies(c *gin.Context) {
@@ -440,7 +440,7 @@ func (h *ociConfigHandler) listPasswordPolicies(c *gin.Context) {
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param policyId path string true "policyId"
// @Param body body object true "请求体(见接口说明)"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.PasswordPolicyInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/password-policies/{policyId} [put]
func (h *ociConfigHandler) updatePasswordPolicy(c *gin.Context) {
@@ -473,7 +473,7 @@ func (h *ociConfigHandler) updatePasswordPolicy(c *gin.Context) {
// @Tags 租户 IAM
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.IdentitySettingInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/identity-settings [get]
func (h *ociConfigHandler) getIdentitySetting(c *gin.Context) {
@@ -494,7 +494,7 @@ func (h *ociConfigHandler) getIdentitySetting(c *gin.Context) {
// @Param id path int true "配置 ID"
// @Param domainId query string false "身份域 OCID(缺省 Default 域)"
// @Param body body object true "请求体(见接口说明)"
// @Success 200 {object} map[string]any
// @Success 200 {object} oci.IdentitySettingInfo
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/identity-settings [put]
func (h *ociConfigHandler) updateIdentitySetting(c *gin.Context) {
+1 -1
View File
@@ -29,7 +29,7 @@ type createConsoleSessionRequest struct {
// @Param id path int true "配置 ID"
// @Param instanceId path string true "实例 OCID"
// @Param body body object true "{type: serial|vnc}"
// @Success 200 {object} map[string]any "sessionId 与 wsPath"
// @Success 201 {object} webConsoleSessionResponse "sessionId 与 type"
// @Security BearerAuth
// @Router /api/v1/oci-configs/{id}/instances/{instanceId}/console-sessions [post]
func (h *consoleHandler) create(c *gin.Context) {
+1 -1
View File
@@ -53,7 +53,7 @@ type webhookHandler struct {
// @Param secret path string true "面板生成的回传密钥(鉴权凭据)"
// @Param body body object true "ONS 消息原文(SubscriptionConfirmation / Notification)"
// @Success 200 "已受理"
// @Failure 403 {object} map[string]string "时间戳超窗或证书源非 Oracle 域"
// @Failure 403 {object} errorResponse "时间戳超窗或证书源非 Oracle 域"
// @Failure 404 "secret 无效(不暴露端点存在性)"
// @Router /api/v1/webhooks/oci-logs/{secret} [post]
func (h *webhookHandler) handle(c *gin.Context) {