Skip to content

Commit

Permalink
allow resource query to get multiple types
Browse files Browse the repository at this point in the history
  • Loading branch information
thorntonmc committed Apr 27, 2022
1 parent fd45952 commit 62d7aa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func main() {
fmt.Println(string(nodeList))

case "getResourceList":
resource, err := c.GetResourceList()
resource, err := c.GetResourceList("")
if err != nil {
log.Printf("Error listing resources %+v\n", err)
os.Exit(1)
Expand Down
10 changes: 7 additions & 3 deletions proxmox/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,17 @@ func (c *Client) GetNodeList() (list map[string]interface{}, err error) {
return
}

func (c *Client) GetResourceList() (list map[string]interface{}, err error) {
err = c.GetJsonRetryable("/cluster/resources", &list, 3)
func (c *Client) GetResourceList(resourceType string) (list map[string]interface{}, err error) {
var endpoint = "/cluster/resources"
if resourceType != "" {
endpoint = fmt.Sprintf("%s?type=%s", endpoint, resourceType)
}
err = c.GetJsonRetryable(endpoint, &list, 3)
return
}

func (c *Client) GetVmList() (list map[string]interface{}, err error) {
err = c.GetJsonRetryable("/cluster/resources?type=vm", &list, 3)
list, err = c.GetResourceList("vm")
return
}

Expand Down

0 comments on commit 62d7aa0

Please sign in to comment.