Skip to main content

Type-safe Python SDK for FortiGate firewall automation and FortiOS REST API - 1,348+ endpoints with async support and complete type safety

Project description

HFortix

PyPI version Python 3.10+ Documentation Status License Typing: Typed

HFortix is the meta-package that installs all HFortix components for Fortinet automation. Install this package to get the complete suite of tools for FortiOS/FortiGate automation.

🚀 Quick Start

pip install hfortix

This single command installs:

  • hfortix-core - Core infrastructure and utilities
  • hfortix-fortios - FortiOS/FortiGate API client
from hfortix_fortios import FortiOS

# Connect to your FortiGate
with FortiOS(host="192.168.1.99", token="your-api-token") as fgt:
    # Get system status
    status = fgt.api.monitor.system.status.get()
    print(f"Hostname: {status['hostname']}, Model: {status['model']}")
    
    # Create firewall address
    fgt.api.cmdb.firewall.address.post(
        name="web-server",
        subnet="10.0.1.100/32",
        comment="Production web server"
    )

📦 What's Included

When you install hfortix, you automatically get:

hfortix-fortios

Complete FortiOS/FortiGate API client with:

  • 1,348 FortiOS 7.6.5 endpoints
  • Full type hints and IDE autocomplete
  • Async/await support
  • Batch transactions and atomic operations
  • Comprehensive error handling
  • Rate limiting and retry logic

hfortix-core

Foundational infrastructure including:

  • Observable HTTP client
  • Event-driven monitoring
  • Base abstractions and protocols
  • Shared utilities

✨ Key Features

  • 🎯 Complete API Coverage - All CMDB, Monitor, Log, and Service endpoints
  • 💪 Fully Typed - Complete type hints with .pyi stubs
  • ⚡ Modern & Fast - Async/await support, HTTP/2, connection pooling
  • 🛡️ Production Ready - Comprehensive error handling and validation
  • 🔄 Simplified Syntax - Simple list format auto-converts to FortiOS dict format
  • 📦 Batch Transactions - Atomic configuration changes with automatic commit/rollback
  • 🔍 API Inspection - Debug and audit API interactions

📚 Documentation

🔗 Individual Packages

If you only need specific components, you can install them separately:

# Just the FortiOS client (includes hfortix-core as dependency)
pip install hfortix-fortios

# Just the core infrastructure (for custom implementations)
pip install hfortix-core

🆚 Package Comparison

Package Purpose Dependencies Use When
hfortix Meta-package All packages You want everything
hfortix-fortios FortiOS API client hfortix-core FortiGate automation
hfortix-core Core infrastructure httpx, typing-extensions Building custom clients

📖 Quick Examples

Firewall Management

from hfortix_fortios import FortiOS

with FortiOS(host="192.168.1.99", token="token") as fgt:
    # Create firewall policy
    fgt.api.cmdb.firewall.policy.post(
        name="Allow-Web",
        srcintf=["internal"],
        dstintf=["wan1"],
        srcaddr=["all"],
        dstaddr=["web-server"],
        service=["HTTP", "HTTPS"],
        action="accept"
    )

Batch Transactions

from hfortix_fortios import FortiOS

with FortiOS(host="192.168.1.99", token="token") as fgt:
    # Atomic batch operation
    with fgt.transaction() as txn:
        txn.add(fgt.api.cmdb.firewall.address.post, name="server1", subnet="10.0.1.1/32")
        txn.add(fgt.api.cmdb.firewall.address.post, name="server2", subnet="10.0.1.2/32")
        # Both addresses created or both rolled back on error

Async Support

from hfortix_fortios import AsyncFortiOS

async with AsyncFortiOS(host="192.168.1.99", token="token") as fgt:
    status = await fgt.api.monitor.system.status.get()
    addresses = await fgt.api.cmdb.firewall.address.get()

🤝 Contributing

This is a proprietary library. For support or feature requests, please contact the maintainer.

📄 License

Proprietary License - See individual package LICENSE files for details.


HFortix - Modern Python SDKs for Fortinet automation

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

hfortix-0.5.163.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

hfortix-0.5.163-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file hfortix-0.5.163.tar.gz.

File metadata

  • Download URL: hfortix-0.5.163.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hfortix-0.5.163.tar.gz
Algorithm Hash digest
SHA256 7b84aec09893bda1ba91b1e8175a49cf8722921ce68609b99b9d07f57a4a9275
MD5 f0078f13bcf136e1495a0531b4ca39fa
BLAKE2b-256 2625adace841a2986f1ca218dcb2cd310a05c2fa48f3f23255153207d2eaf8dd

See more details on using hashes here.

File details

Details for the file hfortix-0.5.163-py3-none-any.whl.

File metadata

  • Download URL: hfortix-0.5.163-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hfortix-0.5.163-py3-none-any.whl
Algorithm Hash digest
SHA256 8270b1112569c0e1093e74aca2210f7624be13551f8d3f4f313f61e4d292ee40
MD5 884a71a8c869e4f7f7864b2dbe0ce37c
BLAKE2b-256 733cf522a226db7f653a4f77cd6504d3b3ebefde31001e8af84863a56363ecd9

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