proxmoxer / proxmoxer

python wrapper for Proxmox API v2 (https://pve.proxmox.com/pve-docs/api-viewer/index.html)
MIT License
534 stars 78 forks source link

How to reach API endpoint options with '-' in the name ? #165

Closed Analepse129 closed 6 months ago

Analepse129 commented 6 months ago

Hello,

I'm trying to use an API endpoint's option that as a dash in it's name. As it's impossible to have dashes in Python variables, I'm facing a major problem.

I have this code I wrote :

getattr(proxmox.cluster.sdn.vnets, vnet_id).subnets.post(subnet='192.168.130.0/24', type='subnet', gateway='192.168.130.1', snat='1', dnszoneprefix='zone1', dhcp_range='start-address=192.168.130.10,end-address=192.168.130.20')

And this is the documentation page I'm following for the API : https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/sdn/vnets/{vnet}/subnets (POST)

The attended behavior : creates a vnet with the following parameters : subnet, type, gateway, snap, dnszoneprefix, dhcp-range.

The issue I'm facing is with the parameter dhcp_range='start-address=192.168.130.10,end-address=192.168.130.20'. When I put it, it's not recognized, because the API is waiting for dhcp-rangeans not dhcp_range. I've also tried dhcprange and dhcp.range but it's not working.

I read about the 'dotted notation' in the documentation but my programming skills are not good enough to determine if this method can work and if, how ; because from what I'm understanding I'm playing with endpoint options and not endpoint itself.

Many thanks in advance for your answers,

Best regards

jhollowe commented 6 months ago

For a hyphen in a path name, this is covered in the proxmoxer docs

for a hyphen in a parameter name, see my answer in another issue: https://github.com/proxmoxer/proxmoxer/issues/159#issuecomment-1981198470