mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-18 07:13:50 +01:00
Streamline Proxmox API route paths by removing incorrect /api/v1 prefix.
Changed endpoints:
- /api/v1/proxmox/journalctl/{node}/{vmid} → /proxmox/journalctl/{node}/{vmid}
- /api/v1/proxmox/journalctl/{node}/{vmid}/{service} → /proxmox/journalctl/{node}/{vmid}/{service}
- /api/v1/proxmox/lxc/:node/:vmid/restart → /proxmox/lxc/:node/:vmid/restart
- /api/v1/proxmox/lxc/:node/:vmid/start → /proxmox/lxc/:node/:vmid/start
- /api/v1/proxmox/lxc/:node/:vmid/stop → /proxmox/lxc/:node/:vmid/stop
- /api/v1/proxmox/stats/{node}/{vmid} → /proxmox/stats/{node}/{vmid}
Updated:
- Swagger annotations in 5 Go source files
- Generated swagger.json and swagger.yaml documentation
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package proxmoxapi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/yusing/godoxy/internal/proxmox"
|
|
apitypes "github.com/yusing/goutils/apitypes"
|
|
)
|
|
|
|
// @x-id "lxcRestart"
|
|
// @BasePath /api/v1
|
|
// @Summary Restart LXC container
|
|
// @Description Restart LXC container by node and vmid
|
|
// @Tags proxmox
|
|
// @Produce json
|
|
// @Param path path ActionRequest true "Request"
|
|
// @Success 200 {object} apitypes.SuccessResponse
|
|
// @Failure 400 {object} apitypes.ErrorResponse "Invalid request"
|
|
// @Failure 404 {object} apitypes.ErrorResponse "Node not found"
|
|
// @Failure 500 {object} apitypes.ErrorResponse
|
|
// @Router /proxmox/lxc/:node/:vmid/restart [post]
|
|
func Restart(c *gin.Context) {
|
|
var req ActionRequest
|
|
if err := c.ShouldBindUri(&req); err != nil {
|
|
c.JSON(http.StatusBadRequest, apitypes.Error("invalid request", err))
|
|
return
|
|
}
|
|
|
|
node, ok := proxmox.Nodes.Get(req.Node)
|
|
if !ok {
|
|
c.JSON(http.StatusNotFound, apitypes.Error("node not found"))
|
|
return
|
|
}
|
|
|
|
if err := node.LXCAction(c.Request.Context(), req.VMID, proxmox.LXCReboot); err != nil {
|
|
c.Error(apitypes.InternalServerError(err, "failed to restart container"))
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, apitypes.Success("container restarted"))
|
|
}
|