Skip to main content

A simple Python wrapper for the OPNsense REST API.

Project description

PyOPN

Code style: black Ruff Auto Release Checked with mypy tests PyPI version

A simple Python wrapper for the OPNsense REST API.

Forked from mtrinish/pyopnsense and modeled after proxmoxer/proxmoxer.

The purpose of this library is also to extend the existing OPNsense API reference. Each endpoint that has been implemented in this library has a corresponding docstring with a brief explanation of what the endpoint does. Additionally, POST requests that require payloads include the corresponding JSON payloads that are required and other relevant information.

Installation

pip install pyopn

Usage

Prerequisites

In order to access the OPNsense API you first need to generate an API key.

Example

from pyopn import OPNsenseAPI

opn = OPNsenseAPI("https://192.168.199.1", api_key_file="OPNsense.localdomain_apikey.txt")

print(opn.kea.dhcpv4.search_reservation())

Structure

The endpoints are organized as opn.module.controller.command(param1, param2, data). Anytime camel case is used in the endpoint names, this wrapper uses snake case.

Parameters are passed in as arguments and are positioned in the order of they appear in the OPNsense API reference. If an endpoint accepts a JSON payload, the function will have a data arguement in the last position where you can pass in a Python dictionary.

Ex: kea/dhcpv4/setSubnet --> opn.kea.dhcpv4.set_subnet(uuid, data) (Kea API Reference)

Implementation Checklist

Below is a checklist of core OPNsense API modules. Checked off modules are completed

Contributing

Feel free to contribute to the library if there are missing endpoints you need. See CONTRIBUTING.md for guidelines and a quick tutorial on how to add new endpoints.

License

This project is licensed under the GPL-3.0 license - see the LICENSE file for details

Acknowledgments

  • mtreinish for original code base this project was forked from
  • proxmoxer for the design pattern

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

pyopn-0.2.0.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyopn-0.2.0-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

Details for the file pyopn-0.2.0.tar.gz.

File metadata

  • Download URL: pyopn-0.2.0.tar.gz
  • Upload date:
  • Size: 42.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pyopn-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3043d48180c0e3113455d22910d1c6cbcaa7813af6460ea0b9ea220cd819f7f0
MD5 1b578913b3d94662651456028159690f
BLAKE2b-256 f9f76e8be02bacb3878e4413b1a815b6732b2d3a4f7e442147a66d7073cfad62

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyopn-0.2.0.tar.gz:

Publisher: publish.yml on alexchristy/PyOPN

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyopn-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyopn-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 41.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pyopn-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2cca7b16800ffdd2314e324e45f27c7c4801395266b8259b71e266f7a8a67c2c
MD5 f364b7c0f8d81731b31c754fd4e82a13
BLAKE2b-256 67795ef0246fa74a222bd88dcd50c9f1b56ef078ff6d50742acaa510d503f5d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyopn-0.2.0-py3-none-any.whl:

Publisher: publish.yml on alexchristy/PyOPN

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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