Skip to main content

Unofficial SPAN Panel Python API and CLI

Project description

Unofficial SPAN Panel Python API and CLI

Latest PyPI version Supported Python Code Style CI Documentation

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 and linux/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

span_panel-0.2.1.tar.gz (48.2 kB view hashes)

Uploaded Source

Built Distribution

span_panel-0.2.1-py3-none-any.whl (100.9 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