MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / Version

Method Version

pkg/api/client.go:216–241  ·  view source on GitHub ↗

Version gets the Proxmox API version.

(ctx context.Context)

Source from the content-addressed store, hash-verified

214
215// Version gets the Proxmox API version.
216func (c *Client) Version(ctx context.Context) (float64, error) {
217 var result map[string]interface{}
218
219 err := c.httpClient.Get(ctx, "/version", &result)
220 if err != nil {
221 return 0, fmt.Errorf("failed to get version: %w", err)
222 }
223
224 data, ok := result["data"].(map[string]interface{})
225 if !ok {
226 return 0, fmt.Errorf("invalid version response format")
227 }
228
229 version, ok := data["version"].(string)
230 if !ok {
231 return 0, fmt.Errorf("version not found in response")
232 }
233
234 // Parse version string (e.g., "7.4" -> 7.4)
235 var versionFloat float64
236 if _, err := fmt.Sscanf(version, "%f", &versionFloat); err != nil {
237 return 0, fmt.Errorf("failed to parse version: %w", err)
238 }
239
240 return versionFloat, nil
241}
242
243// GetVmList gets a list of VMs.
244func (c *Client) GetVmList(ctx context.Context) ([]map[string]interface{}, error) {

Calls 1

GetMethod · 0.65