-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
------------------ * [fix] Fortigate._valid_url()
- Loading branch information
1 parent
b19f7bd
commit ae5031c
Showing
9 changed files
with
140 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
"""Monitor examples. | ||
- Get directory of monitor options (schema) | ||
- Get all ipv4 routes | ||
- Get static ipv4 routes | ||
- Get route to interested ip address | ||
""" | ||
import logging | ||
from pprint import pprint | ||
|
||
from fortigate_api import Fortigate | ||
|
||
logging.getLogger().setLevel(logging.DEBUG) | ||
|
||
HOST = "host" | ||
USERNAME = "username" | ||
PASSWORD = "password" | ||
|
||
fgt = Fortigate(host=HOST, username=USERNAME, password=PASSWORD) | ||
|
||
# Get directory of monitor options (schema) | ||
directory = fgt.directory("api/v2/monitor") | ||
pprint(directory) | ||
# [{"access_group": "sysgrp.cfg", | ||
# "action": "select", | ||
# "name": "health", | ||
# "path": "firewall", | ||
# "request": {"http_method": "GET"}, | ||
# "response": {"type": "array"}, | ||
# "summary": "List configured load balance server health monitors.", | ||
# "supported": True}, | ||
# ... | ||
|
||
# Get all ipv4 routes | ||
routes = fgt.get(url="api/v2/monitor/router/ipv4") | ||
pprint(routes) | ||
# [{"distance": 20, | ||
# "gateway": "10.0.0.1", | ||
# "install_date": 1681965487, | ||
# "interface": "tunnel1", | ||
# "ip_mask": "10.0.0.0/8", | ||
# "ip_version": 4, | ||
# "is_tunnel_route": True, | ||
# "metric": 100, | ||
# "priority": 1, | ||
# "tunnel_parent": "tunnel1", | ||
# "type": "bgp", | ||
# "vrf": 0}, | ||
# ... | ||
# ] | ||
|
||
# Get static ipv4 routes | ||
routes = fgt.get(url="api/v2/monitor/router/ipv4?type=static") | ||
pprint(routes) | ||
# [{"distance": 10, | ||
# "gateway": "10.0.1.1", | ||
# "interface": "wan1", | ||
# "ip_mask": "0.0.0.0/0", | ||
# "ip_version": 4, | ||
# "metric": 0, | ||
# "priority": 1, | ||
# "type": "static", | ||
# "vrf": 0}, | ||
# ... | ||
# ] | ||
|
||
# Get route to interested ip address | ||
routes = fgt.get(url="api/v2/monitor/router/lookup?destination=10.1.1.1") | ||
pprint(routes) | ||
# {"gateway": "10.0.0.1", | ||
# "interface": "tunnel1", | ||
# "network": "10.0.0.0/10", | ||
# "success": True} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "fortigate_api" | ||
version = "1.2.3" | ||
version = "1.2.4" | ||
description = "Python package to configure Fortigate (Fortios) devices using REST API and SSH" | ||
authors = ["Vladimir Prusakov <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -44,4 +44,4 @@ test = ["pytest"] | |
|
||
[tool.poetry.urls] | ||
"Bug Tracker" = "https://github.com/vladimirs-git/fortigate-api/issues" | ||
"Download URL" = "https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.2.3.tar.gz" | ||
"Download URL" = "https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.2.4.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters