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

Function ExampleUsage

pkg/api/example_usage.go:62–96  ·  view source on GitHub ↗

ExampleUsage demonstrates how to use the reusable API package.

()

Source from the content-addressed store, hash-verified

60
61// ExampleUsage demonstrates how to use the reusable API package.
62func ExampleUsage() {
63 // Create configuration
64 config := NewExampleConfig(
65 "https://proxmox.example.com:8006",
66 "root",
67 "password",
68 "pam",
69 true, // insecure
70 )
71
72 // Create logger
73 logger := &ExampleLogger{}
74
75 // Create client with custom logger (cache will use NoOpCache by default)
76 client, err := NewClient(config, WithLogger(logger))
77 if err != nil {
78 log.Fatalf("Failed to create client: %v", err)
79 }
80
81 // Use the client
82 version, err := client.Version(context.Background())
83 if err != nil {
84 log.Fatalf("Failed to get version: %v", err)
85 }
86
87 logger.Info("Proxmox version: %.1f", version)
88
89 // Get VM list
90 vms, err := client.GetVmList(context.Background())
91 if err != nil {
92 log.Fatalf("Failed to get VMs: %v", err)
93 }
94
95 logger.Info("Found %d VMs", len(vms))
96}

Callers

nothing calls this directly

Calls 6

VersionMethod · 0.95
InfoMethod · 0.95
GetVmListMethod · 0.95
NewExampleConfigFunction · 0.85
NewClientFunction · 0.85
WithLoggerFunction · 0.85

Tested by

no test coverage detected