Unofficial SPAN Panel Python API and CLI
Project description
Unofficial SPAN Panel Python API and CLI
span-panel
is an unofficial API for the SPAN Smart Panel. There is no affiliation with SPAN.
Documentation
Full documentation for the project.
Requirements
- A SPAN Smart Panel.
- Latest version of library is generally only tested against the latest firmware version.
- Python 3.9+
- POSIX compatible system
- Library is only test on Linux, specifically the latest Debian version available for the official Python Docker images, but there is no reason the library should not work on any Linux distro or MacOS.
Alternatively you can use the provided Docker container, in which case the only requirement is Docker or another OCI compatible orchestrator (such as Kubernetes or podman).
Windows is not supported. If you need to use span-panel
on Windows, use Docker Desktop and the provided docker container or WSL.
Install
From PyPi
span-panel
is available on PyPi:
pip install span-panel
From Github
pip install git+https://github.com/AngellusMortis/span-panel.git#egg=span-panel
Using Docker Container
A Docker container is also provided so you do not need to install/manage Python as well. You can add the following to your .bashrc
or similar.
function span-panel() {
docker run --rm -it \
-e SPAN_HOST=http://your_span_ip \
-e SPAN_TOKEN=your_token \
ghcr.io/angellusmortis/span-panel:latest "$@"
}
Some notes about the Docker version since it is running inside of a container:
- You can update at any time using the command
docker pull ghcr.io/AngellusMortis/span-panel:latest
- The container supports
linux/amd64
andlinux/arm64
natively. This means it will also work well on MacOS or Windows using Docker Desktop.
Quickstart
Getting an Auth Token
Before being able to do anything, you need to get an auth token from your SPAN Panel. The generate-token
subcommand will walk you through how.
export SPAN_HOST=http://your_span_ip
span-panel generate-token
CLI
export SPAN_HOST=http://your_span_ip
export SPAN_TOKEN=your_token
span-panel --help
span-panel panel meter
span-panel circuits list-ids
Python
span-panel
itself is 100% async, so as such this library is primarily designed to be used in an async context.
The main interface for the library is the span_panel.SpanClient
:
import asyncio
from span_panel import SpanClient
client = SpanClient(host=host, token=token)
async def main():
return await client.get_circuits()
for circuit_id, circuit in asyncio.run(main()).circuits:
# do stuff
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
Built Distribution
Hashes for span_panel-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a829db05028131135214bdac702428b6080be3be487a6183a2e8073998648559 |
|
MD5 | 9ff743839fcadb879a989a525b94cc20 |
|
BLAKE2b-256 | 969624337572b524f9a65cab31abdd5f287af200d1f59b3dcdb19c7ad9a0e6c9 |