annetbox 0.1.6

Creator: bradpython12

Last updated:

Add to Cart

Description:

annetbox 0.1.6

Annetbox - Netbox client used by annet and related projects
This project implements subset of Netbox API methods
Usage

Install sync or async 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)

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 adding limit/offset
Convert async code to sync

python transform_to_sync.py src/annetbox/v37/client_async.py > src/annetbox/v37/client_sync.py

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.