hfortix_fortios.FortiManagerProxy

class hfortix_fortios.FortiManagerProxy(host, username, password, port=443, verify=True, timeout=60.0, adom=None, max_retries=3, circuit_breaker_threshold=5, circuit_breaker_timeout=60.0, rate_limit=False, rate_limit_strategy='queue', rate_limit_max_requests=100, rate_limit_window_seconds=60.0, rate_limit_queue_size=100, rate_limit_queue_timeout=30.0, rate_limit_queue_overflow='block', circuit_breaker=False, circuit_breaker_half_open_calls=3)[source]

FortiManager Proxy Client.

Allows making FortiOS API calls to managed devices through FortiManager.

Example

>>> from hfortix_fortios import FortiManagerProxy
>>>
>>> # Connect to FortiManager
>>> fmg = FortiManagerProxy(
...     host="fortimanager.example.com",
...     username="admin",
...     password="password",
... )
>>>
>>> # Get a proxied FortiOS client for a specific device
>>> fgt = fmg.proxy(adom="production", device="firewall-01")
>>>
>>> # Use the exact same FortiOS API!
>>> addresses = fgt.api.cmdb.firewall.address.get()
>>> for addr in addresses:
...     print(f"{addr.name}: {addr.subnet}")
Parameters:
  • host (str)

  • username (str)

  • password (str)

  • port (int)

  • verify (bool)

  • timeout (float)

  • adom (str | None)

  • max_retries (int)

  • circuit_breaker_threshold (int)

  • circuit_breaker_timeout (float)

  • rate_limit (bool)

  • rate_limit_strategy (str)

  • rate_limit_max_requests (int)

  • rate_limit_window_seconds (float)

  • rate_limit_queue_size (int)

  • rate_limit_queue_timeout (float)

  • rate_limit_queue_overflow (str)

  • circuit_breaker (bool)

  • circuit_breaker_half_open_calls (int)

__init__(host, username, password, port=443, verify=True, timeout=60.0, adom=None, max_retries=3, circuit_breaker_threshold=5, circuit_breaker_timeout=60.0, rate_limit=False, rate_limit_strategy='queue', rate_limit_max_requests=100, rate_limit_window_seconds=60.0, rate_limit_queue_size=100, rate_limit_queue_timeout=30.0, rate_limit_queue_overflow='block', circuit_breaker=False, circuit_breaker_half_open_calls=3)[source]

Initialize FortiManager proxy client.

Parameters:
  • host (str) – FortiManager hostname or IP

  • username (str) – Admin username

  • password (str) – Admin password

  • port (int) – HTTPS port (default: 443)

  • verify (bool) – Verify SSL certificate (default: True)

  • timeout (float) – Request timeout in seconds (default: 60)

  • adom (str | None) – Default ADOM for proxy requests

  • max_retries (int) – Maximum retry attempts on transient failures

  • circuit_breaker_threshold (int) – Failures before opening circuit breaker

  • circuit_breaker_timeout (float) – Seconds before retrying after circuit opens

  • rate_limit (bool) – Enable rate limiting enforcement (default: False)

  • rate_limit_strategy (str) – ‘queue’ or ‘reject’ (default: ‘queue’)

  • rate_limit_max_requests (int) – Max requests per window (default: 100)

  • rate_limit_window_seconds (float) – Time window in seconds (default: 60.0)

  • rate_limit_queue_size (int) – Max queue size (default: 100)

  • rate_limit_queue_timeout (float) – Max wait time in queue (default: 30.0)

  • rate_limit_queue_overflow (str) – ‘block’ or ‘drop’ on overflow (default: ‘block’)

  • circuit_breaker (bool) – Enable circuit breaker (default: False)

  • circuit_breaker_half_open_calls (int) – Calls to test in half-open state (default: 3)

Methods

__init__(host, username, password[, port, ...])

Initialize FortiManager proxy client.

close()

Close connection to FortiManager.

get_adoms()

Get list of ADOMs from FortiManager.

get_device(name[, adom])

Get a specific device by name.

get_devices([adom])

Get list of managed devices from FortiManager.

login()

Authenticate with FortiManager.

logout()

End FortiManager session.

proxy(device[, adom, vdom, timeout])

Get a FortiOS client that proxies through this FortiManager.

proxy_group(group[, adom, vdom, timeout])

Get a FortiOS client that proxies to a device group.

Attributes

adom

Default ADOM for proxy requests.

host

FortiManager hostname.

is_authenticated

Check if connected to FortiManager.

verify

SSL verification setting.