Refactor rest api

This commit is contained in:
2025-06-05 13:23:36 +02:00
parent 6f9737c2c2
commit 1d8e7e072f
5 changed files with 1249 additions and 1169 deletions

30
internal/api/node.go Normal file
View File

@@ -0,0 +1,30 @@
// Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
// All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package api
import (
"fmt"
"net/http"
)
type Node struct {
Name string `json:"hostname"`
States []string `json:"states"`
}
// updateNodeStatesRequest model
type UpdateNodeStatesRequest struct {
Nodes []Node `json:"nodes"`
Cluster string `json:"cluster" example:"fritz"`
}
func (api *RestApi) updateNodeStates(rw http.ResponseWriter, r *http.Request) {
// Parse request body
req := UpdateNodeStatesRequest{}
if err := decode(r.Body, &req); err != nil {
handleError(fmt.Errorf("parsing request body failed: %w", err), http.StatusBadRequest, rw)
return
}
}