Fortigate API的Python包装器

PyFortiA的Python项目详细描述


PyFortiapi

imageimageimage

Fortigate Rest API的Python包装程序(Fortios 5.4.x+)

下面是一个快速使用示例:

>>> import pyfortiapi
>>> 
>>> device = pyfortiapi.FortiGate(ipaddr="192.168.0.99", username="admin", password="Guest")
>>> device.get_firewall_address('Test')
404
>>> create_payload = "{'name': 'Test', 'type': 'subnet', 'subnet': '192.168.0.0 255.255.255.0'}"
>>> device.create_firewall_address('Test', create_payload)
200
>>> device.get_firewall_address('Test')
[{'name': 'Test', 'q_origin_key': 'Test', 'uuid': '9bf2e12a-977b-51e7-ff8d-22d7cf593ab9', 'subnet': '192.168.0.0 255.255.255.0', 'type': 'ipmask', 'start-ip': '192.168.0.0', 'end-ip': '255.255.0.0', 'fqdn': '', 'country': '\n\x05', 'wildcard-fqdn': '', 'cache-ttl': 0, 'wildcard': '192.168.0.0 255.255.0.0', 'comment': '', 'visibility': 'enable', 'associated-interface': '', 'color': 0, 'tags': [], 'allow-routing': 'disable'}]
>>> update_payload = "{'subnet': '10.0.0.0 255.0.0.0'}"
>>> device.update_firewall_address('Test', update_payload)
200
>>> device.get_firewall_address('Test')
[{'name': 'Test', 'q_origin_key': 'Test', 'uuid': '9bf2e12a-977b-51e7-ff8d-22d7cf593ab9', 'subnet': '10.0.0.0 255.0.0.0', 'type': 'ipmask', 'start-ip': '10.0.0.0', 'end-ip': '255.0.0.0', 'fqdn': '', 'country': '\n', 'wildcard-fqdn': '', 'cache-ttl': 0, 'wildcard': '10.0.0.0 255.0.0.0', 'comment': '', 'visibility': 'enable', 'associated-interface': '', 'color': 0, 'tags': [], 'allow-routing': 'disable'}]
>>> device.get_firewall_address(filters='start-ip==10.0.0.0&visibility==enable')
[{'name': 'Test', 'q_origin_key': 'Test', 'uuid': '9bf2e12a-977b-51e7-ff8d-22d7cf593ab9', 'subnet': '10.0.0.0 255.0.0.0', 'type': 'ipmask', 'start-ip': '10.0.0.0', 'end-ip': '255.0.0.0', 'fqdn': '', 'country': '\n', 'wildcard-fqdn': '', 'cache-ttl': 0, 'wildcard': '10.0.0.0 255.0.0.0', 'comment': '', 'visibility': 'enable', 'associated-interface': '', 'color': 0, 'tags': [], 'allow-routing': 'disable'}]
>>> device.delete_firewall_address('Test')
200
>>> device.get_firewall_address('Test')
404

安装

要安装,请执行以下操作:

pip install pyfortiapi

文档

扩展文档可在 https://pyfortiapi.readthedocs.io

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

推荐PyPI第三方库


热门话题
带有字符串的java JNA调用与带有字节[]的java JNA调用的行为不同   java基于键列表获取子映射   重启后永久增加java堆大小?   JavaHTTPS服务器:相互SSL身份验证   java为什么接受接口的方法会拒绝该接口的实现?   片段中的java视图无法应用于()   ms access Java SQL更新命令不工作   java将web服务自动打包和部署到Oracle Application Server 10g   java有没有办法在安卓 studio中为安卓时钟设置多个警报?   位于FTP服务器上的文件上的Java校验和md5   在Java中创建类时遇到问题。有些方法不太确定   java错误:在类chrome\u驱动程序中找不到主方法   通用海图(Javascript\Java)