feat: 自动更新
This commit is contained in:
@@ -74,6 +74,7 @@ func (h *coreHandlers) register(mux *http.ServeMux) {
|
||||
mux.HandleFunc("/api/v1/run/jobs/ack", h.runJobAck)
|
||||
mux.HandleFunc("/api/v1/run/jobs/progress", h.runJobProgress)
|
||||
mux.HandleFunc("/api/v1/run/jobs/result", h.runJobResult)
|
||||
mux.HandleFunc("/api/v1/run/jobs/build-input", h.runJobBuildInput)
|
||||
mux.HandleFunc("/api/v1/run/jobs/cancel", h.runJobCancelPoll)
|
||||
mux.HandleFunc("/api/v1/run/jobs/reconcile", h.runJobReconcile)
|
||||
mux.HandleFunc("/api/v1/run/logs/batches", h.runLogBatchIngest)
|
||||
@@ -462,6 +463,9 @@ func (h *coreHandlers) requirePlatformAdmin(w http.ResponseWriter, r *http.Reque
|
||||
// @Router /api/v1/ai-providers [get]
|
||||
// @Router /api/v1/ai-providers [post]
|
||||
func (h *coreHandlers) aiProviders(w http.ResponseWriter, r *http.Request) {
|
||||
if _, ok := h.requirePlatformAdmin(w, r); !ok {
|
||||
return
|
||||
}
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
providers, err := h.core.ListAIProviders(domain.AIProviderFilter{
|
||||
@@ -504,6 +508,9 @@ func (h *coreHandlers) aiProviders(w http.ResponseWriter, r *http.Request) {
|
||||
// @Router /api/v1/ai-providers/{id} [get]
|
||||
// @Router /api/v1/ai-providers/{id} [put]
|
||||
func (h *coreHandlers) aiProviderDetail(w http.ResponseWriter, r *http.Request) {
|
||||
if _, ok := h.requirePlatformAdmin(w, r); !ok {
|
||||
return
|
||||
}
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
provider, err := h.core.GetAIProvider(r.PathValue("id"))
|
||||
@@ -548,6 +555,9 @@ func (h *coreHandlers) aiProviderDetail(w http.ResponseWriter, r *http.Request)
|
||||
// @Failure 405 {object} dto.ErrorResponse
|
||||
// @Router /api/v1/ai-providers/{id}/status [post]
|
||||
func (h *coreHandlers) aiProviderStatus(w http.ResponseWriter, r *http.Request) {
|
||||
if _, ok := h.requirePlatformAdmin(w, r); !ok {
|
||||
return
|
||||
}
|
||||
if r.Method != http.MethodPost {
|
||||
writeMethodNotAllowed(w, http.MethodPost)
|
||||
return
|
||||
@@ -576,6 +586,9 @@ func (h *coreHandlers) aiProviderStatus(w http.ResponseWriter, r *http.Request)
|
||||
// @Failure 405 {object} dto.ErrorResponse
|
||||
// @Router /api/v1/ai-providers/{id}/test [post]
|
||||
func (h *coreHandlers) aiProviderTest(w http.ResponseWriter, r *http.Request) {
|
||||
if _, ok := h.requirePlatformAdmin(w, r); !ok {
|
||||
return
|
||||
}
|
||||
if r.Method != http.MethodPost {
|
||||
writeMethodNotAllowed(w, http.MethodPost)
|
||||
return
|
||||
@@ -599,6 +612,9 @@ func (h *coreHandlers) aiProviderTest(w http.ResponseWriter, r *http.Request) {
|
||||
// @Failure 405 {object} dto.ErrorResponse
|
||||
// @Router /api/v1/ai-providers/{id}/models [get]
|
||||
func (h *coreHandlers) aiProviderModels(w http.ResponseWriter, r *http.Request) {
|
||||
if _, ok := h.requirePlatformAdmin(w, r); !ok {
|
||||
return
|
||||
}
|
||||
if r.Method != http.MethodGet {
|
||||
writeMethodNotAllowed(w, http.MethodGet)
|
||||
return
|
||||
@@ -1383,6 +1399,25 @@ func (h *coreHandlers) runJobResult(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, dto.RunJobResultFromDomain(result))
|
||||
}
|
||||
|
||||
// runJobBuildInput returns secret-bearing build input only to the active leased run worker.
|
||||
func (h *coreHandlers) runJobBuildInput(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
writeMethodNotAllowed(w, http.MethodPost)
|
||||
return
|
||||
}
|
||||
request, err := decodeJSON[dto.DistributionBuildInputRequest](r)
|
||||
if err != nil {
|
||||
writeDecodeError(w, err)
|
||||
return
|
||||
}
|
||||
result, err := h.core.GetDistributionBuildInput(request.ToDomain())
|
||||
if err != nil {
|
||||
writeServiceError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, dto.DistributionBuildInputFromDomain(result))
|
||||
}
|
||||
|
||||
// runJobCancelPoll godoc
|
||||
// @Summary Poll run job cancellation
|
||||
// @Description Lets a registered run endpoint poll for cancellation requests on active leased jobs.
|
||||
|
||||
Reference in New Issue
Block a user