feat: 完整游戏运维功能

This commit is contained in:
npc0-hue
2026-07-18 09:04:01 +08:00
parent f3b14b7945
commit 48b8ad8d6c
187 changed files with 16607 additions and 1140 deletions
+74 -1
View File
@@ -7,6 +7,48 @@ import (
"browser.local/platform/dto"
)
// serverRuntimeBinding godoc
// @Summary Review or update a server runtime binding
// @Description GET returns redacted logical readiness metadata. PUT changes the selected declared profile and logical refs for an authorized owner or platform administrator.
// @Tags server-instances
// @Accept json
// @Produce json
// @Param id path string true "Server instance ID"
// @Param body body dto.RuntimeBindingUpdateRequest false "Runtime binding update"
// @Success 200 {object} dto.RuntimeBindingResponse
// @Failure 400 {object} dto.ErrorResponse
// @Failure 401 {object} dto.ErrorResponse
// @Failure 403 {object} dto.ErrorResponse
// @Failure 404 {object} dto.ErrorResponse
// @Failure 405 {object} dto.ErrorResponse
// @Router /api/v1/server-instances/{id}/runtime-binding [get]
// @Router /api/v1/server-instances/{id}/runtime-binding [put]
func (h *coreHandlers) serverRuntimeBinding(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
binding, err := h.core.GetServerRuntimeBindingForSession(bearerToken(r), r.PathValue("id"))
if err != nil {
writeServiceError(w, err)
return
}
writeJSON(w, http.StatusOK, dto.RuntimeBindingFromDomain(binding))
case http.MethodPut:
request, err := decodeJSON[dto.RuntimeBindingUpdateRequest](r)
if err != nil {
writeDecodeError(w, err)
return
}
binding, err := h.core.UpdateServerRuntimeBindingForSession(bearerToken(r), r.PathValue("id"), request.ToDomain())
if err != nil {
writeServiceError(w, err)
return
}
writeJSON(w, http.StatusOK, dto.RuntimeBindingFromDomain(binding))
default:
writeMethodNotAllowed(w, "GET, PUT")
}
}
func (h *coreHandlers) serverRuntimeActions(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
writeMethodNotAllowed(w, http.MethodGet)
@@ -65,8 +107,17 @@ func (h *coreHandlers) serverRunKeyReset(w http.ResponseWriter, r *http.Request)
}
func (h *coreHandlers) serverRunUpdate(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {
jobs, err := h.core.ListRunUpdateJobsForSession(bearerToken(r), r.PathValue("id"))
if err != nil {
writeServiceError(w, err)
return
}
writeJSON(w, http.StatusOK, dto.RunUpdateJobListFromDomain(jobs))
return
}
if r.Method != http.MethodPost {
writeMethodNotAllowed(w, http.MethodPost)
writeMethodNotAllowed(w, "GET, POST")
return
}
request, err := decodeJSON[dto.RunUpdateRequest](r)
@@ -82,6 +133,28 @@ func (h *coreHandlers) serverRunUpdate(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusAccepted, dto.RunUpdateJobFromDomain(job))
}
// serverDependencies godoc
// @Summary List declared dependency probes, reviewable install plans, and safe status
// @Description Returns only target, digest, typed step, and bounded dependency evidence for an authorized server user.
// @Tags server-instances
// @Produce json
// @Success 200 {object} dto.DependencyCatalogResponse
// @Failure 401 {object} dto.ErrorResponse
// @Failure 403 {object} dto.ErrorResponse
// @Router /api/v1/server-instances/{id}/dependencies [get]
func (h *coreHandlers) serverDependencies(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
writeMethodNotAllowed(w, http.MethodGet)
return
}
catalog, err := h.core.GetDependencyCatalogForSession(bearerToken(r), r.PathValue("id"))
if err != nil {
writeServiceError(w, err)
return
}
writeJSON(w, http.StatusOK, dto.DependencyCatalogFromDomain(catalog))
}
func (h *coreHandlers) serverClientManagerGenerate(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
writeMethodNotAllowed(w, http.MethodPost)