feat: support custom server deployment drafts
This commit is contained in:
@@ -37,6 +37,52 @@ func (h *coreHandlers) serverInstanceCreateWorkflow(w http.ResponseWriter, r *ht
|
||||
writeJSON(w, http.StatusOK, dto.ServerLifecycleFromDomain(result))
|
||||
}
|
||||
|
||||
// serverDeployment reads safe deployment metadata or updates protected deployment input.
|
||||
func (h *coreHandlers) serverDeployment(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
view, err := h.core.GetServerDeploymentForSession(bearerToken(r), r.PathValue("id"))
|
||||
if err != nil {
|
||||
writeServiceError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, dto.ServerDeploymentFromDomain(view))
|
||||
case http.MethodPut:
|
||||
request, err := decodeJSON[dto.ServerDeploymentRequest](r)
|
||||
if err != nil {
|
||||
writeDecodeError(w, err)
|
||||
return
|
||||
}
|
||||
view, err := h.core.UpdateServerDeploymentForSession(bearerToken(r), r.PathValue("id"), request.ToDomain())
|
||||
if err != nil {
|
||||
writeServiceError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, dto.ServerDeploymentFromDomain(view))
|
||||
default:
|
||||
writeMethodNotAllowed(w, http.MethodGet+", "+http.MethodPut)
|
||||
}
|
||||
}
|
||||
|
||||
// serverInstanceDeploy binds an existing draft definition to its configured Run and queues install.
|
||||
func (h *coreHandlers) serverInstanceDeploy(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
writeMethodNotAllowed(w, http.MethodPost)
|
||||
return
|
||||
}
|
||||
request, err := decodeJSON[dto.ServerLifecycleCommandRequest](r)
|
||||
if err != nil {
|
||||
writeDecodeError(w, err)
|
||||
return
|
||||
}
|
||||
result, err := h.core.DeployServerInstanceForSession(bearerToken(r), request.ToDomain(r.PathValue("id")))
|
||||
if err != nil {
|
||||
writeServiceError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusAccepted, dto.ServerLifecycleFromDomain(result))
|
||||
}
|
||||
|
||||
// serverInstanceStart godoc
|
||||
// @Summary Start server instance
|
||||
// @Description Validates lifecycle state and config version, then queues a start job through the platform job channel.
|
||||
|
||||
Reference in New Issue
Block a user