]> git.puffer.fish Git - matthieu/pve-network.git/commit
ipam: netbox: factor out common api methods and unify error handling
authorStefan Hanreich <s.hanreich@proxmox.com>
Mon, 10 Mar 2025 08:50:56 +0000 (09:50 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 7 Apr 2025 15:43:31 +0000 (17:43 +0200)
commitf5a439d194109da893d0376c2833e9dd23f2de46
treefeaeedd278ef755f2c010d8db5055fa43796fe86
parentf79f21a1bc1959bf7fb141ca1cc2319b09495a6c
ipam: netbox: factor out common api methods and unify error handling

Create a helper method that abstracts the common code used in making
netbox requests. Move all api_request incovations over to using the
helper method. This saves us from writing lots of repeated code.

This also updates the helpers and introduces error checking there.
Helpers didn't catch any errors and the invoking methods didn't as
well. This meant that functions with $noerr set to 1 would still error
out. We now pass $noerr to the helper functions and they behave the
same as the parent methods. This requires some additional checks in
the call sites of the helpers.

Also canonicalize all URLs, since Netbox does that and it saves us a
redirect.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
Link: https://lore.proxmox.com/20250310085103.30549-1-s.hanreich@proxmox.com
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Network/SDN/Ipams/NetboxPlugin.pm