Open nrnvgh opened 1 month ago
Testing code
# Import pynautobot
import pynautobot
# Connect to the Nautobot SDK
nb = pynautobot.api(url="https://demo.nautobot.com", token="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
prefix = nb.ipam.prefixes.get(prefix="10.0.192.0/18")
I tried to stuff the status required into the data of the create() endpoint, but that failed, generating the following error:
(Pdb) prefix.available_ips.create(data={"status": "Active"})
*** pynautobot.core.query.RequestError: The request failed with code 500 Internal Server Error: {'error': 'duplicate key value violates unique constraint "ipam_ipaddress_parent_id_host_89330d7e_uniq"\nDETAIL: Key (parent_id, host)=(85449467-4eae-4df0-a4df-eab7fdab4ed9, \\x0a00c001) already exists.\n', 'exception': 'IntegrityError', 'nautobot_version': '2.2.4', 'python_version': '3.11.9'}
I then set x to be the first IP Address:
(Pdb) x = prefix.available_ips.list()
(Pdb) x[0]
<pynautobot.models.ipam.IpAddresses ('10.0.192.1/18') at 0x103bdebd0>
(Pdb) x[0].address
'10.0.192.1/18'
Environment
pynautobot: 1.5.2 nautobot: 1.6.21 client-side python: 3.11.8
Details
Using the example in the pynautobot docs as a starting point: Code:
Execution result: