33 :target: https://pypi.python.org/pypi/fortigate-api
44.. image :: https://img.shields.io/pypi/pyversions/fortigate-api.svg
55 :target: https://pypi.python.org/pypi/fortigate-api
6+ .. image :: https://img.shields.io/github/last-commit/vladimirs-git/fortigate-api
7+ :target: https://pypi.python.org/pypi/fortigate-api
68
79fortigate-api
810=============
911
1012Python package to configure Fortigate (Fortios) devices using REST API and SSH.
11- With this package, you can create, delete, get, update any objects in the Fortigate.
12- The most commonly used `Objects `_ are implemented in the `FortigateAPI `_ methods, but you can
13- manipulate any other objects that can be accessed through the REST API using the `Fortigate `_
14- methods. You can also get and change the Fortigate configuration through SSH.
13+ With this package, you can change objects in the Fortigate. The most commonly used `Objects `_
14+ are implemented in the `FortigateAPI `_ methods, but you can manipulate any other objects
15+ that can be accessed through the REST API using the `Fortigate `_ methods.
16+ You can also get and change the Fortigate configuration through SSH.
17+
18+ Main features:
19+
20+ - REST API to create, delete, get, update objects. Move policy before, after other policy.
21+ - SSH Netmiko connector to work with CLI commands.
22+ - CiscoConfParse to search and modify commands in config.
23+ - Usage examples in `./examples `_
24+
25+ ----------------------------------------------------------------------------------------------------
1526
1627.. contents :: **Contents**
1728 :local:
1829
30+ ----------------------------------------------------------------------------------------------------
1931
2032Requirements
2133------------
@@ -36,7 +48,7 @@ or install the package from github.com release
3648
3749.. code :: bash
3850
39- pip install https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.0.2 .tar.gz
51+ pip install https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.0 .tar.gz
4052
4153 or install the package from github.com repository
4254
@@ -45,6 +57,8 @@ or install the package from github.com repository
4557 pip install git+https://github.com/vladimirs-git/fortigate-api
4658
4759
60+ ----------------------------------------------------------------------------------------------------
61+
4862Objects
4963-------
5064The objects implemented in `FortigateAPI `_.
@@ -57,40 +71,73 @@ access to any other objects is available via `Fortigate`_.
5771Object GUI and REST API URL to the object, FortiOS v6.4
5872=================== ================================================================================
5973`Address `_ https://hostname/ng/firewall/address
74+
6075 https://hostname/api/v2/cmdb/firewall/address/
76+
6177`AddressGroup `_ https://hostname/ng/firewall/address
78+
6279 https://hostname/api/v2/cmdb/firewall/addrgrp/
80+
6381`Antivirus `_ https://hostname/ng/utm/antivirus/profile
82+
6483 https://hostname/api/v2/cmdb/antivirus/profile/
84+
6585`Application `_ https://hostname/ng/utm/appctrl/sensor
86+
6687 https://hostname/api/v2/cmdb/application/list/
88+
6789`DhcpServer `_ https://hostname/ng/interface/edit/{name}
90+
6891 https://hostname/api/v2/cmdb/system.dhcp/server/
92+
6993`Interface `_ https://hostname/ng/interface
94+
7095 https://hostname/api/v2/cmdb/system/interface/
96+
7197`InternetService `_ https://hostname/ng/firewall/internet_service
98+
7299 https://hostname/api/v2/cmdb/firewall/internet-service/
100+
73101`IpPool `_ https://hostname/ng/firewall/ip-pool
102+
74103 https://hostname/api/v2/cmdb/firewall/ippool/
104+
75105`Policy `_ https://hostname/ng/firewall/policy/policy/standard
106+
76107 https://hostname/api/v2/cmdb/firewall/policy/
108+
77109`Schedule `_ https://hostname/ng/firewall/schedule
110+
78111 https://hostname/api/v2/cmdb/firewall.schedule/onetime/
112+
79113`Service `_ https://hostname/ng/firewall/service
114+
80115 https://hostname/api/v2/cmdb/firewall.service/custom/
116+
81117`ServiceCategory `_ https://hostname/ng/firewall/service
118+
82119 https://hostname/api/v2/cmdb/firewall.service/category/
120+
83121`ServiceGroup `_ https://hostname/ng/firewall/service
122+
84123 https://hostname/api/v2/cmdb/firewall.service/group/
124+
85125`SnmpCommunity `_ https://hostname/ng/system/snmp
126+
86127 https://hostname/api/v2/cmdb/system.snmp/community/
128+
87129`VirtualIp `_ https://hostname/ng/firewall/virtual-ip
130+
88131 https://hostname/api/v2/cmdb/firewall/vip/
132+
89133`Zone `_ https://hostname/ng/interface
134+
90135 https://hostname/api/v2/cmdb/system/zone/
91136=================== ================================================================================
92137
93138
139+ ----------------------------------------------------------------------------------------------------
140+
94141FortigateAPI
95142------------
96143**FortigateAPI(host, username, password, scheme, port, timeout, vdom) **
@@ -111,6 +158,7 @@ vdom *str* Name of virtual domain (default "root")
111158=============== ======= ============================================================================
112159
113160
161+ ----------------------------------------------------------------------------------------------------
114162
115163Address
116164-------
@@ -217,6 +265,7 @@ Address examples:
217265`./examples/address.py `_
218266
219267
268+ ----------------------------------------------------------------------------------------------------
220269
221270AddressGroup
222271------------
@@ -321,6 +370,7 @@ AddressGroup examples:
321370`./examples/address_group.py `_
322371
323372
373+ ----------------------------------------------------------------------------------------------------
324374
325375Antivirus
326376---------
@@ -339,6 +389,7 @@ FortiOS v6.4 data example `./examples/yml/antivirus.yml`_
339389**FortigateAPI.antivirus.update(data, uid) **
340390
341391
392+ ----------------------------------------------------------------------------------------------------
342393
343394Application
344395-----------
@@ -357,6 +408,7 @@ FortiOS v6.4 data example `./examples/yml/application.yml`_
357408**FortigateAPI.antivirus.update(data, uid) **
358409
359410
411+ ----------------------------------------------------------------------------------------------------
360412
361413DhcpServer
362414----------
@@ -377,6 +429,7 @@ FortiOS v6.4 data example `./examples/yml/dhcp_server.yml`_
377429DhcpServer examples `./examples/dhcp_server.py `_
378430
379431
432+ ----------------------------------------------------------------------------------------------------
380433
381434Interface
382435---------
@@ -427,6 +480,7 @@ Interface examples:
427480`./examples/interface.py `_
428481
429482
483+ ----------------------------------------------------------------------------------------------------
430484
431485InternetService
432486---------------
@@ -445,6 +499,7 @@ FortiOS v6.4 data example `./examples/yml/internet_service.yml`_
445499**FortigateAPI.internet_service.update(data, uid) **
446500
447501
502+ ----------------------------------------------------------------------------------------------------
448503
449504IpPool
450505------
@@ -463,6 +518,14 @@ FortiOS v6.4 data example `./examples/yml/ip_pool.yml`_
463518**FortigateAPI.ip_pool.update(data, uid) **
464519
465520
521+ Examples
522+ ........
523+ IpPool examples:
524+
525+ `./examples/ip_pool.py `_
526+
527+
528+ ----------------------------------------------------------------------------------------------------
466529
467530Policy
468531------
@@ -596,6 +659,7 @@ Policy Extended Filter examples:
596659`./examples/policy_extended_filter.py `_
597660
598661
662+ ----------------------------------------------------------------------------------------------------
599663
600664Schedule
601665--------
@@ -614,6 +678,7 @@ FortiOS v6.4 data example `./examples/yml/schedule.yml`_
614678**FortigateAPI.schedule.update(data, uid) **
615679
616680
681+ ----------------------------------------------------------------------------------------------------
617682
618683Service
619684-------
@@ -632,6 +697,7 @@ FortiOS v6.4 data example `./examples/yml/service.yml`_
632697**FortigateAPI.service.update(data, uid) **
633698
634699
700+ ----------------------------------------------------------------------------------------------------
635701
636702ServiceCategory
637703---------------
@@ -650,6 +716,7 @@ FortiOS v6.4 data example `./examples/yml/service_category.yml`_
650716**FortigateAPI.service_category.update(data, uid) **
651717
652718
719+ ----------------------------------------------------------------------------------------------------
653720
654721ServiceGroup
655722------------
@@ -668,6 +735,7 @@ FortiOS v6.4 data example `./examples/yml/service_group.yml`_
668735**FortigateAPI.service_group.update(data, uid) **
669736
670737
738+ ----------------------------------------------------------------------------------------------------
671739
672740SnmpCommunity
673741-------------
@@ -702,6 +770,7 @@ Examples
702770SnmpCommunity examples `./examples/snmp_community.py `_
703771
704772
773+ ----------------------------------------------------------------------------------------------------
705774
706775VirtualIP
707776---------
@@ -720,6 +789,7 @@ FortiOS v6.4 data example `./examples/yml/virtual_ip.yml`_
720789**FortigateAPI.virtual_ip.update(data, uid) **
721790
722791
792+ ----------------------------------------------------------------------------------------------------
723793
724794Zone
725795----
@@ -738,6 +808,7 @@ FortiOS v6.4 data example `./examples/yml/zone.yml`_
738808**FortigateAPI.zone.update(data, uid) **
739809
740810
811+ ----------------------------------------------------------------------------------------------------
741812
742813Fortigate
743814---------
@@ -857,6 +928,7 @@ Fortigate examples:
857928`./examples/fortigate.py `_
858929
859930
931+ ----------------------------------------------------------------------------------------------------
860932
861933SSH
862934---
@@ -925,7 +997,30 @@ SSH examples:
925997`./examples/ssh.py `_
926998
927999
1000+ ----------------------------------------------------------------------------------------------------
1001+
1002+ CiscoConfParse
1003+ --------------
1004+ Helper that parses the Fortigate configuration to find and modify command lines.
1005+ CiscoConfParse doesn't natively support Fortigate configuration,
1006+ but after some tweaking in this package it has become a good tool to play with Fortigate config lines.
1007+ For more information, see the documentation for the JunosCfgLine object at https://github.com/mpenning/ciscoconfparse
1008+
1009+
1010+ Examples
1011+ ........
1012+ CiscoConfParse examples:
1013+
1014+ - get config from the Fortigate by SSH
1015+ - create CiscoConfParse object
1016+ - filter all JunosCfgLine objects of wan interfaces
1017+ - print some data in CiscoConfParse objects
1018+ - filter all wan interfaces blocks
1019+
1020+ `./examples/ccp.py `_
1021+
9281022
1023+ .. _`./examples `: ./examples
9291024.. _`./examples/yml/address.yml `: ./examples/yml/address.yml
9301025.. _`./examples/yml/address_group.yml `: ./examples/yml/address_group.yml
9311026.. _`./examples/yml/antivirus.yml `: ./examples/yml/antivirus.yml
@@ -945,10 +1040,12 @@ SSH examples:
9451040
9461041.. _`./examples/address.py `: ./examples/address.py
9471042.. _`./examples/address_group.py `: ./examples/address_group.py
1043+ .. _`./examples/ccp.py `: ./examples/ccp.py
9481044.. _`./examples/dhcp_server.py `: ./examples/dhcp_server.py
9491045.. _`./examples/fortigate.py `: ./examples/fortigate.py
9501046.. _`./examples/interface.py `: ./examples/interface.py
1047+ .. _`./examples/ip_pool.py `: ./examples/ip_pool.py
9511048.. _`./examples/policy.py `: ./examples/policy.py
9521049.. _`./examples/policy_extended_filter.py `: ./examples/policy_extended_filter.py
9531050.. _`./examples/snmp_community.py `: ./examples/snmp_community.py
954- .. _`./examples/ssh.py` : ./examples/ssh.py
1051+ .. _`./examples/ssh.py `: ./examples/ssh.py
0 commit comments