Start implementing nodestate rest api

This commit is contained in:
2025-06-05 14:27:21 +02:00
parent d1a7002422
commit 7db83d216e
3 changed files with 52 additions and 17 deletions

View File

@@ -7,6 +7,9 @@ package api
import (
"fmt"
"net/http"
"github.com/ClusterCockpit/cc-backend/internal/repository"
"github.com/ClusterCockpit/cc-backend/pkg/schema"
)
type Node struct {
@@ -27,4 +30,12 @@ func (api *RestApi) updateNodeStates(rw http.ResponseWriter, r *http.Request) {
handleError(fmt.Errorf("parsing request body failed: %w", err), http.StatusBadRequest, rw)
return
}
repo := repository.GetNodeRepository()
for _, node := range req.Nodes {
state := schema.NodeStateUnknown
// TODO: Determine valid node state
repo.UpdateNodeState(node.Name, req.Cluster, &state)
}
}