A simple Python wrapper for the OPNsense REST API.
Project description
PyOPN
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
- Captiveportal
- Core
- Cron
- Dhcp
- Dhcpv4
- Dhcpv6
- Dhcrelay
- Diagnostics
- Firewall
- Firmware
- Ids
- Interfaces
- Ipsec
- Kea
- Menu
- Monit
- Openvpn
- Proxy
- Routes
- Routing
- Syslog
- Trafficshaper
- Trust
- Unbound
- Wireguard
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3043d48180c0e3113455d22910d1c6cbcaa7813af6460ea0b9ea220cd819f7f0
|
|
| MD5 |
1b578913b3d94662651456028159690f
|
|
| BLAKE2b-256 |
f9f76e8be02bacb3878e4413b1a815b6732b2d3a4f7e442147a66d7073cfad62
|
Provenance
The following attestation bundles were made for pyopn-0.2.0.tar.gz:
Publisher:
publish.yml on alexchristy/PyOPN
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyopn-0.2.0.tar.gz -
Subject digest:
3043d48180c0e3113455d22910d1c6cbcaa7813af6460ea0b9ea220cd819f7f0 - Sigstore transparency entry: 157257749
- Sigstore integration time:
-
Permalink:
alexchristy/PyOPN@80ddceafe991de8adaf3baa8f551bfbc08451f93 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alexchristy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@80ddceafe991de8adaf3baa8f551bfbc08451f93 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cca7b16800ffdd2314e324e45f27c7c4801395266b8259b71e266f7a8a67c2c
|
|
| MD5 |
f364b7c0f8d81731b31c754fd4e82a13
|
|
| BLAKE2b-256 |
67795ef0246fa74a222bd88dcd50c9f1b56ef078ff6d50742acaa510d503f5d9
|
Provenance
The following attestation bundles were made for pyopn-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on alexchristy/PyOPN
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyopn-0.2.0-py3-none-any.whl -
Subject digest:
2cca7b16800ffdd2314e324e45f27c7c4801395266b8259b71e266f7a8a67c2c - Sigstore transparency entry: 157257751
- Sigstore integration time:
-
Permalink:
alexchristy/PyOPN@80ddceafe991de8adaf3baa8f551bfbc08451f93 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/alexchristy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@80ddceafe991de8adaf3baa8f551bfbc08451f93 -
Trigger Event:
release
-
Statement type: