Closed jqueuniet closed 3 years ago
hrm, seems to work for me on latest pynetbox and NetBox 2.9.11
In [22]: x = nb.ipam.prefixes.get(1)
send: b'GET /api/ipam/prefixes/1/ HTTP/1.1\r\nHost: localhost:8000\r\nUser-Agent: python-requests/2.24.0\r\nAccept-Encoding: gzip, deflate\r\naccept: application/json;\r\nConnection: keep-alive\r\nauthorization: Token 0123456789abcdef0123456789abcdef01234567\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Tue, 29 Dec 2020 23:59:22 GMT
header: Content-Type: application/json
header: Content-Length: 354
header: Connection: keep-alive
header: Vary: Accept, Cookie, Origin
header: Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
header: API-Version: 2.9
header: X-Content-Type-Options: nosniff
header: Referrer-Policy: same-origin
header: X-Frame-Options: SAMEORIGIN
header: P3P: CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"
In [23]: ip = x.available_ips.create()
send: b'POST /api/ipam/prefixes/1/available-ips/ HTTP/1.1\r\nHost: localhost:8000\r\nUser-Agent: python-requests/2.24.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: application/json;\r\nauthorization: Token 0123456789abcdef0123456789abcdef01234567\r\nContent-Length: 2\r\n\r\n'
send: b'{}'
reply: 'HTTP/1.1 201 Created\r\n'
header: Server: nginx
header: Date: Tue, 29 Dec 2020 23:59:43 GMT
header: Content-Type: application/json
header: Content-Length: 447
header: Connection: keep-alive
header: Vary: Accept, Cookie, Origin
header: Allow: GET, POST, HEAD, OPTIONS
header: API-Version: 2.9
header: X-Content-Type-Options: nosniff
header: Referrer-Policy: same-origin
header: X-Frame-Options: SAMEORIGIN
header: P3P: CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"
In [24]: ip.description = 'testing'
In [25]: ip.save()
send: b'PATCH /api/ipam/ip-addresses/4/ HTTP/1.1\r\nHost: localhost:8000\r\nUser-Agent: python-requests/2.24.0\r\nAccept-Encoding: gzip, deflate\r\naccept: application/json;\r\nConnection: keep-alive\r\nauthorization: Token 0123456789abcdef0123456789abcdef01234567\r\nContent-Length: 26\r\nContent-Type: application/json\r\n\r\n'
send: b'{"description": "testing"}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Tue, 29 Dec 2020 23:59:51 GMT
header: Content-Type: application/json
header: Content-Length: 454
header: Connection: keep-alive
header: Vary: Accept, Cookie, Origin
header: Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
header: API-Version: 2.9
header: X-Content-Type-Options: nosniff
header: Referrer-Policy: same-origin
header: X-Frame-Options: SAMEORIGIN
header: P3P: CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"
Out[25]: True
When I try to update an IP object I just created with
available_ips
, it seems pynetbox tries to send the PATCH request to the prefixes endpoint.Tested with Netbox 2.8.8, pynetbox 5.0.8 and Python 3.8
I cheked the object type, is is ndeed
pynetbox.models.ipam.IpAddresses