Pfsense-Fauxapi在Pfsense主机上的客户端蟒

pfsense-fauxapi的Python项目详细描述


pfsensefauxapi-python接口

pfsense fauxapi的python客户端-https://github.com/ndejong/pfsense_fauxapi

作为PyPi包提供,要安装,请安装APIclient以便与 安装了fauxapi包的pfsense主机。

pip3 install pfsense-fauxapi

代码示例

提供了三个python代码示例,演示了接口用法

  • function-iterate.py-迭代(几乎)所有fauxapi函数以确认操作。
  • update-aws-aliases.py-下载最新的awsip-ranges.json并填充pfsense别名表。
  • usergroup-management.py-演示以编程方式管理用户和组的能力。

命令行

此外,这个pip包还提供了一个命令行界面,可以与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

命令行示例,使用环境变量传递FAUXAPI_APIKEY 以及FAUXAPI_APIKEY凭证

$ 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"}}}}

包装测试

对(几乎)所有客户端函数调用的测试都是用模拟的API响应数据实现的 您可以使用pytest检查它们

pytest -v tests

包构建

是否需要/希望从源代码构建包

# 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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java+Brave+Zipkin:问题是,跟踪总是一样的   swing能否取消Java中的特定TimerTask?   java以编程方式重新运行失败的TestNG测试   java DefaultMessageListenerContainer未从IBM MQ读取消息   使循环结果显示在一个数组到一个数组中。Java中的toString   tomcat java。lang.NoClassDefFoundError在对GlassFish/Payara部署战争时出错   Java中的增量算法   Java中lambda类的类名是什么意思?   java图像url无法加载安卓 Imageview实际图像为“PNG”格式   java如何使用JPA使库对象数据库持久化?   java如何让onClickListener从另一个活动接收意图信息   运行时如何使Java程序反复启动   java如何在Spring上的ApacheCamel中一开始就并行运行两条路由?   java如何使用SeleniumWebDriver从以下div获取文本   将Google电子表格API与JAVA一起使用时,引用中的excel公式单元格值未更新   fileinputstream如何在Java中读/写HashMap对象到文件?   使用java调用Postgresql的过程   仅在集合中使用java方法