Modern, fully-typed Python SDK for FortiManager JSON-RPC API (2,376 endpoints, FMG 7.6.6)
Project description
HFortix-FortiManager
HFortix-FortiManager is a modern, fully-typed Python SDK for the FortiManager
JSON-RPC API — 2,376 endpoints generated from the official FMG 7.6.6 API
specification, with full .pyi type stubs for IDE autocomplete on every call.
🚀 Quick Start
pip install hfortix-fortimanager
from hfortix_fortimanager import FortiManager
# API key auth (FMG 7.4.7+ / 7.6.2+) — no login/logout needed
fmg = FortiManager(host="fmg.example.com", api_key="your-api-key")
# Session auth — context manager handles login/logout
with FortiManager(host="fmg.example.com", username="admin", password="pw") as fmg:
# Device inventory
devices = fmg.api.dvmdb.adom.device.get(adom="root")
for dev in devices:
print(dev.name, dev.ip, dev.os_ver)
# Firewall address objects (ADOM-scoped)
fmg.api.pm.config.adom.obj.firewall.address.add(
adom="root",
name="web-server",
subnet=["10.0.1.100", "255.255.255.255"],
)
# Firewall policy in a policy package — with placement control
fmg.api.pm.config.adom.pkg.firewall.policy.add(
adom="root",
pkg="default",
name="Allow-Web",
srcintf=["port1"], dstintf=["port2"],
srcaddr=["all"], dstaddr=["web-server"],
service=["HTTPS"], action="accept", schedule=["always"],
before="42", # insert before policyid 42 (omit to append)
)
✨ Key Features
- 🎯 2,376 endpoints — Device DB (
dvmdb), Policy & Objects (pm: ADOM objects, device-level config, policy packages, policy blocks, system/WAN templates), andtaskmonitoring - 💪 Fully typed —
.pyistubs for every endpoint;Literal[...]enums for every documented value; PEP 561py.typed - 🔑 Dual auth — session (username/password with automatic re-login) or
API key (Bearer, FMG 7.4.7+/7.6.2+, incl.
api_userfor 7.6.6+) - 🧭 Navigation mirrors the API — URL scoping segments are kept:
/pm/config/adom/{adom}/obj/firewall/address→fmg.api.pm.config.adom.obj.firewall.address - 📦 Minimal payloads — only the parameters you pass are sent; FMG applies its own server-side defaults (no surprise field writes)
- 🛡️ Production plumbing from hfortix-core — retry with backoff, optional rate limiting and circuit breaker, audit logging, sanitized logs
- 🔒 Workspace mode —
dvmdb.adom.workspacelock / commit / unlock endpoints for ADOMs in workspace mode
🧰 GET options
All JSON-RPC read options are typed parameters:
fmg.api.dvmdb.adom.device.get(
adom="root",
fields=["name", "ip", "os_ver"],
filter=["conf_status", "==", "insync"],
range=[0, 50],
loadsub=0,
)
🪄 Escape hatch — raw JSON-RPC
Anything not (yet) exposed as a typed endpoint can be called directly:
result = fmg.client.execute(
method="exec",
params=[{"url": "/securityconsole/install/package",
"data": {"adom": "root", "pkg": "default"}}],
)
⚠️ Known limitations (0.1.x)
- No
securityconsole/ install-deploy endpoints yet — configuration management is fully covered, but installing policy packages to devices currently requires the rawfmg.client.execute()escape hatch (see above). Planned for an upcoming release. model_registry/as_models()/ typed response models are experimental placeholders — they currently returnNone/ fall back to generic objects.- Sync only — no async client yet (unlike hfortix-fortios).
🔗 Related Packages
This package is part of the HFortix SDK ecosystem:
- hfortix-core — Core HTTP client and utilities
- hfortix-fortios — FortiOS/FortiGate SDK
- hfortix — Meta package
📄 License
Proprietary license. All rights reserved.
🤝 Support
- Issues: https://github.com/hermanwjacobsen/hfortix-fortimanager/issues
- PyPI: https://pypi.org/project/hfortix-fortimanager/
Version: 0.1.0 (Alpha)
FortiManager Support: 7.6.6 (specs; 7.4.x compatible)
Python: 3.10+
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hfortix_fortimanager-0.1.1.tar.gz.
File metadata
- Download URL: hfortix_fortimanager-0.1.1.tar.gz
- Upload date:
- Size: 5.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd99d8a49f7df35949432c61231fc84a9f6ac87d63b02725bb0c969b7df4ffc2
|
|
| MD5 |
43f26c2e7201348a594bbb7b9f95d090
|
|
| BLAKE2b-256 |
42e96ca0fcde912bceb21968955cda77810650405c87edf7d3983608feb4cc70
|
File details
Details for the file hfortix_fortimanager-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hfortix_fortimanager-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71ba68134be582eee7985f611c1b8ef42689948a4d5a5c169897f83a55000c67
|
|
| MD5 |
1488dc17dfa77012e363232b527d767d
|
|
| BLAKE2b-256 |
d7faee215ebf326de274ffe80b929fdaaa8bf554df507c5a661eaefa36e38dc0
|