Python client for the pfSense-FauxAPI on a pfSense host
Project description
PfsenseFauxapi - Python Interface
Python client for pfSense-FauxAPI - https://github.com/ndejong/pfsense_fauxapi
Available as a PyPi package, to install, installs an API client for to interact with a pfSense host that has the FauxAPI package installed.
pip3 install pfsense-fauxapi
Code Examples
Three Python code samples are provided that demonstrate interface usage
function-iterate.py
- iterates (almost) all the FauxAPI functions to confirm operation.update-aws-aliases.py
- downloads the latest AWSip-ranges.json
and populates the pfsense alias table(s).usergroup-management.py
- demonstrates the ability to manage users and groups programmatically.
Command Line
Additionally this pip-package provides a command-line interface to work with FauxAPI
usage: fauxapi [-h] [--host [host]] [--apikey [key]] [--apisecret [secret]]
[--verified-ssl] [--debug]
[function] [[function] ...] [[function-args]]
FauxAPI
optional arguments:
-h, --help show this help message and exit
Call:
--host [host] Host address of the target pfSense host with the
PfsenseFauxapi package installed.
--apikey [key] FauxAPI apikey value - alternatively via the
FAUXAPI_APIKEY environment variable.
--apisecret [secret] FauxAPI apisecret value - alternatively via the
FAUXAPI_APIKEY environment variable.
--verified-ssl Enable SSL certificate checks - default does NOT check
SSL certificates.
--debug Enable debug response from the remote FauxAPI -
helpful in tracking down issues.
[function] The FauxAPI function being called
[function-args] Arguments to the function, space separated
Command line example, using environment variables to pass the FAUXAPI_APIKEY
and FAUXAPI_APIKEY
credentials.
$ fauxapi --host 192.168.1.200 gateway_status | jq .
{
"callid": "5c8d0f7361cba",
"action": "gateway_status",
"message": "ok",
"data": {
"gateway_status": {
"10.11.12.1": {
"monitorip": "10.10.10.1",
"srcip": "10.10.10.200",
"name": "WAN_DHCP",
"delay": "0.422ms",
"stddev": "0.073ms",
"loss": "0.0%",
"status": "none"
}
}
}
}
Package Testing
Tests for (almost) all client-side function calls are implemented with mocked API response data you can check them with pytest
pytest -v tests
Package Build
Should you need/want to build the package from source
# obtain the source material
git clone https://github.com/ndejong/pfsense_fauxapi_client_python.git
cd pfsense_fauxapi_client_python
# build the package
python3 setup.py sdist bdist_wheel
# install the package from the .whl file in the dist path
pip install dist/pfsense*.whl
Project details
Release history Release notifications | RSS feed
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 pfsense-fauxapi-20190317.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3dad9587c0ac9d9a423e114fba03f639354f4232ce3bf7df5477dc78e078b98 |
|
MD5 | cf12313f4064f9525de6a83a6548e9f6 |
|
BLAKE2b-256 | a81f2664dd013727d54351dd887c61db7783cbfa8f04c7173e286cbcd91d2b75 |
Hashes for pfsense_fauxapi-20190317.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 140ac2c36cbcfcc3acf47e7d075328d2b2e806b19b05dc2c521e47637432ac7e |
|
MD5 | c8b156cc8cd4f4ba8e158355c4b55629 |
|
BLAKE2b-256 | 74559ad607fcaf57082b07065e95567db10a4bb1cd79d6553f86e904b310d012 |