3
3
:target: https://pypi.python.org/pypi/fortigate-api
4
4
.. image :: https://img.shields.io/pypi/pyversions/fortigate-api.svg
5
5
: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
6
8
7
9
fortigate-api
8
10
=============
9
11
10
12
Python 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
+ ----------------------------------------------------------------------------------------------------
15
26
16
27
.. contents :: **Contents**
17
28
:local:
18
29
30
+ ----------------------------------------------------------------------------------------------------
19
31
20
32
Requirements
21
33
------------
@@ -36,7 +48,7 @@ or install the package from github.com release
36
48
37
49
.. code :: bash
38
50
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
40
52
41
53
or install the package from github.com repository
42
54
@@ -45,6 +57,8 @@ or install the package from github.com repository
45
57
pip install git+https://github.com/vladimirs-git/fortigate-api
46
58
47
59
60
+ ----------------------------------------------------------------------------------------------------
61
+
48
62
Objects
49
63
-------
50
64
The objects implemented in `FortigateAPI `_.
@@ -57,40 +71,73 @@ access to any other objects is available via `Fortigate`_.
57
71
Object GUI and REST API URL to the object, FortiOS v6.4
58
72
=================== ================================================================================
59
73
`Address `_ https://hostname/ng/firewall/address
74
+
60
75
https://hostname/api/v2/cmdb/firewall/address/
76
+
61
77
`AddressGroup `_ https://hostname/ng/firewall/address
78
+
62
79
https://hostname/api/v2/cmdb/firewall/addrgrp/
80
+
63
81
`Antivirus `_ https://hostname/ng/utm/antivirus/profile
82
+
64
83
https://hostname/api/v2/cmdb/antivirus/profile/
84
+
65
85
`Application `_ https://hostname/ng/utm/appctrl/sensor
86
+
66
87
https://hostname/api/v2/cmdb/application/list/
88
+
67
89
`DhcpServer `_ https://hostname/ng/interface/edit/{name}
90
+
68
91
https://hostname/api/v2/cmdb/system.dhcp/server/
92
+
69
93
`Interface `_ https://hostname/ng/interface
94
+
70
95
https://hostname/api/v2/cmdb/system/interface/
96
+
71
97
`InternetService `_ https://hostname/ng/firewall/internet_service
98
+
72
99
https://hostname/api/v2/cmdb/firewall/internet-service/
100
+
73
101
`IpPool `_ https://hostname/ng/firewall/ip-pool
102
+
74
103
https://hostname/api/v2/cmdb/firewall/ippool/
104
+
75
105
`Policy `_ https://hostname/ng/firewall/policy/policy/standard
106
+
76
107
https://hostname/api/v2/cmdb/firewall/policy/
108
+
77
109
`Schedule `_ https://hostname/ng/firewall/schedule
110
+
78
111
https://hostname/api/v2/cmdb/firewall.schedule/onetime/
112
+
79
113
`Service `_ https://hostname/ng/firewall/service
114
+
80
115
https://hostname/api/v2/cmdb/firewall.service/custom/
116
+
81
117
`ServiceCategory `_ https://hostname/ng/firewall/service
118
+
82
119
https://hostname/api/v2/cmdb/firewall.service/category/
120
+
83
121
`ServiceGroup `_ https://hostname/ng/firewall/service
122
+
84
123
https://hostname/api/v2/cmdb/firewall.service/group/
124
+
85
125
`SnmpCommunity `_ https://hostname/ng/system/snmp
126
+
86
127
https://hostname/api/v2/cmdb/system.snmp/community/
128
+
87
129
`VirtualIp `_ https://hostname/ng/firewall/virtual-ip
130
+
88
131
https://hostname/api/v2/cmdb/firewall/vip/
132
+
89
133
`Zone `_ https://hostname/ng/interface
134
+
90
135
https://hostname/api/v2/cmdb/system/zone/
91
136
=================== ================================================================================
92
137
93
138
139
+ ----------------------------------------------------------------------------------------------------
140
+
94
141
FortigateAPI
95
142
------------
96
143
**FortigateAPI(host, username, password, scheme, port, timeout, vdom) **
@@ -111,6 +158,7 @@ vdom *str* Name of virtual domain (default "root")
111
158
=============== ======= ============================================================================
112
159
113
160
161
+ ----------------------------------------------------------------------------------------------------
114
162
115
163
Address
116
164
-------
@@ -217,6 +265,7 @@ Address examples:
217
265
`./examples/address.py `_
218
266
219
267
268
+ ----------------------------------------------------------------------------------------------------
220
269
221
270
AddressGroup
222
271
------------
@@ -321,6 +370,7 @@ AddressGroup examples:
321
370
`./examples/address_group.py `_
322
371
323
372
373
+ ----------------------------------------------------------------------------------------------------
324
374
325
375
Antivirus
326
376
---------
@@ -339,6 +389,7 @@ FortiOS v6.4 data example `./examples/yml/antivirus.yml`_
339
389
**FortigateAPI.antivirus.update(data, uid) **
340
390
341
391
392
+ ----------------------------------------------------------------------------------------------------
342
393
343
394
Application
344
395
-----------
@@ -357,6 +408,7 @@ FortiOS v6.4 data example `./examples/yml/application.yml`_
357
408
**FortigateAPI.antivirus.update(data, uid) **
358
409
359
410
411
+ ----------------------------------------------------------------------------------------------------
360
412
361
413
DhcpServer
362
414
----------
@@ -377,6 +429,7 @@ FortiOS v6.4 data example `./examples/yml/dhcp_server.yml`_
377
429
DhcpServer examples `./examples/dhcp_server.py `_
378
430
379
431
432
+ ----------------------------------------------------------------------------------------------------
380
433
381
434
Interface
382
435
---------
@@ -427,6 +480,7 @@ Interface examples:
427
480
`./examples/interface.py `_
428
481
429
482
483
+ ----------------------------------------------------------------------------------------------------
430
484
431
485
InternetService
432
486
---------------
@@ -445,6 +499,7 @@ FortiOS v6.4 data example `./examples/yml/internet_service.yml`_
445
499
**FortigateAPI.internet_service.update(data, uid) **
446
500
447
501
502
+ ----------------------------------------------------------------------------------------------------
448
503
449
504
IpPool
450
505
------
@@ -463,6 +518,14 @@ FortiOS v6.4 data example `./examples/yml/ip_pool.yml`_
463
518
**FortigateAPI.ip_pool.update(data, uid) **
464
519
465
520
521
+ Examples
522
+ ........
523
+ IpPool examples:
524
+
525
+ `./examples/ip_pool.py `_
526
+
527
+
528
+ ----------------------------------------------------------------------------------------------------
466
529
467
530
Policy
468
531
------
@@ -596,6 +659,7 @@ Policy Extended Filter examples:
596
659
`./examples/policy_extended_filter.py `_
597
660
598
661
662
+ ----------------------------------------------------------------------------------------------------
599
663
600
664
Schedule
601
665
--------
@@ -614,6 +678,7 @@ FortiOS v6.4 data example `./examples/yml/schedule.yml`_
614
678
**FortigateAPI.schedule.update(data, uid) **
615
679
616
680
681
+ ----------------------------------------------------------------------------------------------------
617
682
618
683
Service
619
684
-------
@@ -632,6 +697,7 @@ FortiOS v6.4 data example `./examples/yml/service.yml`_
632
697
**FortigateAPI.service.update(data, uid) **
633
698
634
699
700
+ ----------------------------------------------------------------------------------------------------
635
701
636
702
ServiceCategory
637
703
---------------
@@ -650,6 +716,7 @@ FortiOS v6.4 data example `./examples/yml/service_category.yml`_
650
716
**FortigateAPI.service_category.update(data, uid) **
651
717
652
718
719
+ ----------------------------------------------------------------------------------------------------
653
720
654
721
ServiceGroup
655
722
------------
@@ -668,6 +735,7 @@ FortiOS v6.4 data example `./examples/yml/service_group.yml`_
668
735
**FortigateAPI.service_group.update(data, uid) **
669
736
670
737
738
+ ----------------------------------------------------------------------------------------------------
671
739
672
740
SnmpCommunity
673
741
-------------
@@ -702,6 +770,7 @@ Examples
702
770
SnmpCommunity examples `./examples/snmp_community.py `_
703
771
704
772
773
+ ----------------------------------------------------------------------------------------------------
705
774
706
775
VirtualIP
707
776
---------
@@ -720,6 +789,7 @@ FortiOS v6.4 data example `./examples/yml/virtual_ip.yml`_
720
789
**FortigateAPI.virtual_ip.update(data, uid) **
721
790
722
791
792
+ ----------------------------------------------------------------------------------------------------
723
793
724
794
Zone
725
795
----
@@ -738,6 +808,7 @@ FortiOS v6.4 data example `./examples/yml/zone.yml`_
738
808
**FortigateAPI.zone.update(data, uid) **
739
809
740
810
811
+ ----------------------------------------------------------------------------------------------------
741
812
742
813
Fortigate
743
814
---------
@@ -857,6 +928,7 @@ Fortigate examples:
857
928
`./examples/fortigate.py `_
858
929
859
930
931
+ ----------------------------------------------------------------------------------------------------
860
932
861
933
SSH
862
934
---
@@ -925,7 +997,30 @@ SSH examples:
925
997
`./examples/ssh.py `_
926
998
927
999
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
+
928
1022
1023
+ .. _`./examples `: ./examples
929
1024
.. _`./examples/yml/address.yml `: ./examples/yml/address.yml
930
1025
.. _`./examples/yml/address_group.yml `: ./examples/yml/address_group.yml
931
1026
.. _`./examples/yml/antivirus.yml `: ./examples/yml/antivirus.yml
@@ -945,10 +1040,12 @@ SSH examples:
945
1040
946
1041
.. _`./examples/address.py `: ./examples/address.py
947
1042
.. _`./examples/address_group.py `: ./examples/address_group.py
1043
+ .. _`./examples/ccp.py `: ./examples/ccp.py
948
1044
.. _`./examples/dhcp_server.py `: ./examples/dhcp_server.py
949
1045
.. _`./examples/fortigate.py `: ./examples/fortigate.py
950
1046
.. _`./examples/interface.py `: ./examples/interface.py
1047
+ .. _`./examples/ip_pool.py `: ./examples/ip_pool.py
951
1048
.. _`./examples/policy.py `: ./examples/policy.py
952
1049
.. _`./examples/policy_extended_filter.py `: ./examples/policy_extended_filter.py
953
1050
.. _`./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