This project implements subset of Netbox API methods
- Install
sync
orasync
version
pip install 'annetbox[sync]'
- Create client instance according to your netbox version (only some are supported)
from annetbox.v37.client_sync import NetboxV37
netbox = NetboxV37(url="https://demo.netbox.dev", token="YOUR NETBOX TOKEN")
- Call methods
res = netbox.dcim_devices(limit=1)
For sync client
import http.client
import logging
logging.basicConfig()
http.client.HTTPConnection.debuglevel = 1
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
- Create context
import ssl
context = ssl.create_default_context(cafile="path/to/cacert.pem")
- Pass it to client
netbox = NetboxV37(url=url, token=token, ssl_context=context)
- Read openapi spec
- Edit
models.py
- Edit
client_async.py
, do not forget addinglimit
/offset
- Convert async code to sync
python transform_to_sync.py src/annetbox/v37/client_async.py > src/annetbox/v37/client_sync.py