[GH-ISSUE #197] [feat] Make API response from api2/json/cluster/status available #54

Closed
opened 2026-03-03 15:29:54 +03:00 by kerem · 1 comment
Owner

Originally created by @justusbunsi on GitHub (Jun 3, 2025).
Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/197

Hi, I saw the Cluster type has a function Status, but it doesn't make its api response available as return value. I am trying to implement this but have difficulties with the response content. It contains 2 different data types: Cluster information and Node information (see API reference). Here an example response:

{
    "data": [
        {
            "version": 10,
            "quorate": 1,
            "id": "cluster",
            "name": "my-proxmox-cluster",
            "type": "cluster",
            "nodes": 2
        },
        {
            "name": "proxmox-node01",
            "id": "node/proxmox-node01",
            "ip": "192.168.***.***",
            "online": 1,
            "nodeid": 1,
            "type": "node",
            "level": "",
            "local": 0
        },
        {
            "name": "proxmox-node02",
            "id": "node/proxmox-node02",
            "ip": "192.168.***.***",
            "online": 1,
            "nodeid": 1,
            "type": "node",
            "level": "",
            "local": 0
        }
    ]
}

As a user, it would be best if cluster.Status() would return 3 items:

  • an the object of "type": "cluster"
  • an array with the "type": "node" objects
  • error/nil

From an API perspective, cluster.Status() could also just return 2 items in 2 different ways:

  • First way:
    • The unprocessed []ClusterStatusItem that overlap both types. Something like this:
      type ClusterStatusItem struct {
      	// Common attributes for both types: cluster and node
      	Name string
      	Type string
      	Id   string
      
      	// 'cluster' type specific attributes
      	Version int
      	Quorate int
      	Nodes   int
      
      	// 'node' type specific attributes
      	Ip     string
      	Online int
      	NodeId int
      	Level  string
      	Local  int
      }
      
    • error/nil
  • Second way:
    • A wrapper object providing access cluster info and node infos and allows to extend it with functions like `. Something like this:
      type ClusterStatus struct {
      	ClusterInfo struct {
      		Name string
      		Type string
      		Id   string
      		Version int
      		Quorate int
      		Nodes   int
      	}
      	ClusterNodes []struct {
      		Name string
      		Type string
      		Id   string
      		Ip     string
      		Online int
      		NodeId int
      		Level  string
      		Local  int
      	}
      }
      
    • error/nil

@luthermonson I'd be happy for your thoughts on this. 🙂

Originally created by @justusbunsi on GitHub (Jun 3, 2025). Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/197 Hi, I saw the `Cluster` type has a function `Status`, but it doesn't make its api response available as return value. I am trying to implement this but have difficulties with the response content. It contains 2 different data types: Cluster information and Node information (see [API reference](https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/status)). Here an example response: ```json { "data": [ { "version": 10, "quorate": 1, "id": "cluster", "name": "my-proxmox-cluster", "type": "cluster", "nodes": 2 }, { "name": "proxmox-node01", "id": "node/proxmox-node01", "ip": "192.168.***.***", "online": 1, "nodeid": 1, "type": "node", "level": "", "local": 0 }, { "name": "proxmox-node02", "id": "node/proxmox-node02", "ip": "192.168.***.***", "online": 1, "nodeid": 1, "type": "node", "level": "", "local": 0 } ] } ``` As a user, it would be best if `cluster.Status()` would return 3 items: - an the object of `"type": "cluster"` - an array with the `"type": "node"` objects - error/nil From an API perspective, `cluster.Status()` could also just return 2 items in 2 different ways: - First way: - The unprocessed `[]ClusterStatusItem` that overlap both types. Something like this: ```golang type ClusterStatusItem struct { // Common attributes for both types: cluster and node Name string Type string Id string // 'cluster' type specific attributes Version int Quorate int Nodes int // 'node' type specific attributes Ip string Online int NodeId int Level string Local int } ``` - error/nil - Second way: - A wrapper object providing access cluster info and node infos and allows to extend it with functions like `. Something like this: ```golang type ClusterStatus struct { ClusterInfo struct { Name string Type string Id string Version int Quorate int Nodes int } ClusterNodes []struct { Name string Type string Id string Ip string Online int NodeId int Level string Local int } } ``` - error/nil @luthermonson I'd be happy for your thoughts on this. 🙂
kerem closed this issue 2026-03-03 15:29:54 +03:00
Author
Owner

@justusbunsi commented on GitHub (Jun 17, 2025):

🙈 https://github.com/luthermonson/go-proxmox/pull/203#issuecomment-2980793967. Sorry for the noise.

<!-- gh-comment-id:2980797633 --> @justusbunsi commented on GitHub (Jun 17, 2025): 🙈 https://github.com/luthermonson/go-proxmox/pull/203#issuecomment-2980793967. Sorry for the noise.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-proxmox#54
No description provided.