Annetbox - Netbox client used by annet and related projects
This project implements subset of Netbox API methods
Usage
- Install
syncorasyncversion
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)
Configuration
Verbose logging
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
Custom SSL context
- 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)
Development
Adding new methods
- 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
python transform_to_sync.py src/annetbox/v41/client_async.py > src/annetbox/v41/client_sync.py
python transform_to_sync.py src/annetbox/v42/client_async.py > src/annetbox/v42/client_sync.py
Integration tests
Integration tests are declarade in tests/integration/definitions.yaml.
They are defined as call to specific client method:
#
# client.dcim_cables(limit=5)
#
- id: dcim_cables_01
method: dcim_cables
versions: ["v37", "v41", "v42"]
args:
limit: 5
Also supported chaining two calls:
#
# client.dcim_console_port(
# id=client.dcim_console_ports(limit=5)[0]
# )
#
- id: dcim_console_port_01
method: dcim_console_port
versions: ["v37", "v41", "v42"]
args:
id: !from_call
call: dcim_console_ports
args: {limit: 5}
extract: results[0].id
Frozen snapshot of data is stored in tests/integration/fixtures/v<client version>/<test case>/:
expected.yaml: holds name of a method, passed args and results.cassette.yaml: holds raw netbox query and response generated byvcrpylib.
Adding/modifying a test
- Spin up local netbox instances
make docker(once) - Edit
tests/integration/definitions.yaml - Run
make fixturesand commit new generated files.
Metadata
Release files for annetbox 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| annetbox-1.1.2.tar.gz | 17.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| annetbox-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.1 kB
Release files / annetbox-1.1.2.tar.gz
| Download URL | annetbox-1.1.2.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a820fb1c1ede42faa22e7920eba70d51c135924e7f0a7ebfcecab2fd7597ab66
|
|
BLAKE2b-256 checksum How to use checksums |
b6862ed1959131afca3c546aaee334f1edd717c1aba96c46c20e659283bc3130
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency logRelease files / annetbox-1.1.2-py3-none-any.whl
| Download URL | annetbox-1.1.2-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27dc6c557051a0b333734c7d8906f396b6dd6c69903eaaa693e49a83bfba9765
|
|
BLAKE2b-256 checksum How to use checksums |
25bedd230826e3fce47d357774f5bafb41ec599638ea0632ae294a5aa9fc6438
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 18, 2026.
Transparency log