Skip to main content

Annet Netbox client

Project description

Annetbox - Netbox client used by annet and related projects

This project implements subset of Netbox API methods

Usage

  1. Install sync or async version
pip install 'annetbox[sync]'
  1. 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")
  1. 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

  1. Create context
import ssl

context = ssl.create_default_context(cafile="path/to/cacert.pem")
  1. Pass it to client
netbox = NetboxV37(url=url, token=token, ssl_context=context)

Development

Adding new methods

  1. Read openapi spec
  2. Edit models.py
  3. Edit client_async.py, do not forget adding limit/offset
  4. Convert async code to sync
python transform_to_sync.py src/annetbox/v37/client_async.py > src/annetbox/v37/client_sync.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

annetbox-0.1.4.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

annetbox-0.1.4-py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page