Proxmox PVE OpenApi generator for PowerShell Modules

Proxmox PVE is an opensource virtualization environment. I’m also having it as hypervisor for my personal environment at home.
I like having systems providing an api, it allows doing automation and makes administrators live much more easier for a script kiddie like me Ö.ö

Proxmox PVE is also providing an api. https://pve.proxmox.com/pve-docs/api-viewer/

This APi provides serveral methods to administrate your virtual environment. For example if I want to create a snapshot of an lxc container I have to send a POST request to the API endpoint, as described in https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/lxc/{vmid}/snapshot

The PowerShell code for this operation (without authentication stuff) must be someting like:

$apiUrl = "https://localpveserver.local/api2/json/nodes/node1/lxc/100/snapshot"
$postBody = [PSCustomObject] @{
    snapname = "snapshot$(Get-Date -Format "ddMMyyyy")"
    description = "automated snapshot"
}
Invoke-WebRequest -Uri $apiUrl -Method Post -Body $postBody -ContentType "application/json; charset=utf-8"

That’s pretty cool, so I can do this for every Method on all 398 paths of the proxmox pve api 🙂 Hmm. The code above only shows a short snipped of what needs to be done using one endpoint.

If Proxmox PVE would provide a REST API following the OpenAPI Specification then I could generate a PowerShell module via OpenApiGenerator containing PowerShell cmdlets as wrapper around the webcalls… I’ve done it several times.

What if I’m able to generate an OpenAPI description from the existing schema – challenge accepted.

A new project was born. Follow me on github:
https://github.com/EldoBam/proxmox-pve-module-builder