Corsinvest.ProxmoxVE.Api
The client. It is the only package an application needs to call the Proxmox VE API; the others build on it.
dotnet add package Corsinvest.ProxmoxVE.ApiNuGet · targets .NET 8, 9 and 10.
What is in it
Section titled “What is in it”| Type | For |
|---|---|
PveClient |
The whole API as a tree of properties, indexers and methods, generated from the Proxmox VE API schema: API structure |
PveClientBase |
What PveClient derives from: connection, login, the four raw calls, task helpers. Usable on its own when only raw calls are needed |
Result |
The outcome of every call: Results |
ResultExtension |
ToData(), ToEnumerable(), ToModel<T>(), ToLogs(), InError() |
PveResultException, PveAuthenticationException |
The exceptions of the few methods that throw: Errors |
ResponseType, MethodType |
JSON or PNG answers; the four kinds of call |
A complete program
Section titled “A complete program”using Corsinvest.ProxmoxVE.Api;
var client = new PveClient("pve01"){ ApiToken = Environment.GetEnvironmentVariable("PVE_API_TOKEN")};
var result = await client.Cluster.Resources.Resources(type: "vm");if (!result.IsSuccessStatusCode){ Console.Error.WriteLine($"{(int)result.StatusCode} {result.ReasonPhrase}"); return 1;}
foreach (var guest in result.ToEnumerable().OrderBy(a => a.vmid)){ Console.WriteLine($"{guest.vmid,6} {guest.type,-5} {guest.node,-10} {guest.status}");}
return 0;Where to go
Section titled “Where to go”- Connect: Connection, with token, password, two-factor authentication, OpenID, certificates, timeout and a custom
HttpClient. - Find the method for an endpoint: API structure.
- Read the answer: Results.
- Long operations: Tasks.
- Failures: Errors.
- See the requests: Troubleshooting.
Dependencies
Section titled “Dependencies”The client reads the answers with Newtonsoft.Json and logs through Microsoft.Extensions.Logging.
It does not depend on the other packages of this repository.