Python Wrapper for FortiGate API
Project description
.. highlight:: python
==========
PyFortiAPI
==========
.. image:: https://img.shields.io/github/license/jsimpso/PyFortiAPI.svg
:target: https://github.com/jsimpso/PyFortiAPI
A Python wrapper for the FortiGate REST API (FortiOS 5.4.x+)
Here's a quick usage example::
>>> 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.delete_firewall_address('Test')
200
>>> device.get_firewall_address('Test')
404
Installation
------------
This module has been packaged and uploaded to the PyPi test server. To install:
.. code-block:: none
pip install --index-url https://test.pypi.org/simple/ pyfortiapi
==========
PyFortiAPI
==========
.. image:: https://img.shields.io/github/license/jsimpso/PyFortiAPI.svg
:target: https://github.com/jsimpso/PyFortiAPI
A Python wrapper for the FortiGate REST API (FortiOS 5.4.x+)
Here's a quick usage example::
>>> 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.delete_firewall_address('Test')
200
>>> device.get_firewall_address('Test')
404
Installation
------------
This module has been packaged and uploaded to the PyPi test server. To install:
.. code-block:: none
pip install --index-url https://test.pypi.org/simple/ pyfortiapi
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
PyFortiAPI-0.0.2.tar.gz
(10.3 kB
view hashes)
Built Distribution
Close
Hashes for PyFortiAPI-0.0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49f8ea6d7507a6726462f189df1c875cb1942eb1dd49bb7bdffb06d81b3520c5 |
|
MD5 | 44e5dad9329fa07c68dde71b7d98cd16 |
|
BLAKE2b-256 | 23879e65ea79b145da6e4263afcca0db02e73e2b24bdcd3325da86ba0d957c93 |