add graph api:

This commit is contained in:
abhishek9686
2025-06-13 00:47:16 +05:30
parent 3625067080
commit a2982b802b
3 changed files with 38 additions and 0 deletions

View File

@@ -594,6 +594,24 @@ func GetAllNodesAPI(nodes []models.Node) []models.ApiNode {
return apiNodes[:]
}
// GetAllNodesAPI - get all nodes for api usage
func GetAllNodesAPIWithLocation(nodes []models.Node) []models.ApiNode {
apiNodes := []models.ApiNode{}
for i := range nodes {
node := nodes[i]
newApiNode := node.ConvertToAPINode()
if node.IsStatic {
newApiNode.Location = node.StaticNode.Location
} else {
host, _ := GetHost(node.HostID.String())
newApiNode.Location = host.Location
}
apiNodes = append(apiNodes, *newApiNode)
}
return apiNodes[:]
}
// GetNodesStatusAPI - gets nodes status
func GetNodesStatusAPI(nodes []models.Node) map[string]models.ApiNodeStatus {
apiStatusNodesMap := make(map[string]models.ApiNodeStatus)