Skip to main content

Modern, fully-typed Python SDK for FortiManager JSON-RPC API (2,376 endpoints, FMG 7.6.6)

Project description

HFortix-FortiManager

PyPI version Python 3.10+ License Typing: Typed

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), and task monitoring
  • 💪 Fully typed.pyi stubs for every endpoint; Literal[...] enums for every documented value; PEP 561 py.typed
  • 🔑 Dual auth — session (username/password with automatic re-login) or API key (Bearer, FMG 7.4.7+/7.6.2+, incl. api_user for 7.6.6+)
  • 🧭 Navigation mirrors the API — URL scoping segments are kept: /pm/config/adom/{adom}/obj/firewall/addressfmg.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 modedvmdb.adom.workspace lock / 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 raw fmg.client.execute() escape hatch (see above). Planned for an upcoming release.
  • model_registry / as_models() / typed response models are experimental placeholders — they currently return None / 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:

📄 License

Proprietary license. All rights reserved.

🤝 Support


Version: 0.1.0-beta
FortiManager Support: 7.6.6 (specs; 7.4.x compatible)
Python: 3.10+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hfortix_fortimanager-0.1.0.tar.gz (5.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hfortix_fortimanager-0.1.0-py3-none-any.whl (12.6 MB view details)

Uploaded Python 3

File details

Details for the file hfortix_fortimanager-0.1.0.tar.gz.

File metadata

  • Download URL: hfortix_fortimanager-0.1.0.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

Hashes for hfortix_fortimanager-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4bc30d18b6e8a444609ea23f5ca8c238833884e7e66f48403c2ecc59a729f428
MD5 4fe655e3a3af0d010919c2b5cbab4bee
BLAKE2b-256 7435f6d92e9e392087457d14be1960b686f8b4aaab38268fec0ecea7f44b63b1

See more details on using hashes here.

File details

Details for the file hfortix_fortimanager-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hfortix_fortimanager-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ac330dc3ecc51e446353c6a0842916cca926a0edaf45a783cc3b784d0994aaa
MD5 596a52760a247f4ae45e74996a6d7bb9
BLAKE2b-256 48b8c9b7d40b87f61c994b8d2f6094e353d525bb9871e22c1ca6a3315cee7171

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page