Skip to main content

pyfortiflex

Python client for the FortiFlex v2 API, plus safe per-node entitlement allocation for labs that license many VMs from one config.

from pyfortiflex import FortiFlexClient, mint_token, owner_description

flex = FortiFlexClient.from_env()  # FORTIFLEX_USER / FORTIFLEX_PASS (IAM API user)
owner = owner_description("soar-801-validate", "soar801", "fabric-pod.example.com")
result = mint_token(flex, 12345, owner)  # config id or name
result.serial_number, result.token  # redeem the token on the VM

Why allocation needs care

A FortiFlex entitlement is single-occupancy: the VM that redeems its token owns the serial. Hand two VMs the same serial and the second is blocked (FortiSOAR reports FSR-Auth-018: License is detected as duplicate).

mint_token records ownership in the entitlement's description (fabric <fabric> node <node> pod <pod>) and allocates in this order:

  1. the entitlement this owner already holds, so a re-run keeps its serial;
  2. this owner's stopped entitlement, reactivated;
  3. an active entitlement nobody owns and whose token was never redeemed;
  4. an unowned stopped entitlement, reactivated;
  5. a new entitlement (it can take ~30 min to turn active).

Tokens are single-use and consumed even by a failed redeem, so mint once per redeem attempt. Repeat calls reuse the same serial.

Client coverage

Programs; configs (list, get, resolve by name, create, update, enable, disable); entitlements (list, create VM / hardware, update, stop, reactivate, transfer, regenerate token, points); groups (list, next token). Product-family helpers (single_active_config, config_matches) pick or check a config for a product code such as FGT or SOAR.

Applying a token to a device (FortiGate, FortiManager, FortiSOAR) is the consumer's job: pyfsr's system.deploy_flex_license for FortiSOAR, fabric_studio_core for Fabric Studio VMs.

Tests

uv venv && uv pip install -e ".[test,typecheck]"
.venv/bin/python -m pytest          # offline: every endpoint + allocation rule, 100% line coverage
.venv/bin/mypy src                  # strict

Live checks against the real API are opt-in and read-only (programs, configs, entitlements, groups -- they verify the payload fields allocation depends on):

FORTIFLEX_LIVE=1 FORTIFLEX_USER=... FORTIFLEX_PASS=... .venv/bin/python -m pytest tests/live -v

Token regeneration, entitlement creation and stop/reactivate/transfer are never run live: they invalidate tokens, consume points or move licenses.

Metadata

Release files for pyfortiflex 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfortiflex 0.1.0
File Size Uploaded Provenance Actions
pyfortiflex-0.1.0.tar.gz 16.4 kB With provenance Details for pyfortiflex-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyfortiflex 0.1.0
File Interpreter ABI Platform Actions
pyfortiflex-0.1.0-py3-none-any.whl Python 3 none any Details for pyfortiflex-0.1.0-py3-none-any.whl

Total release size: 28.8 kB

Release files / pyfortiflex-0.1.0.tar.gz

Download URL pyfortiflex-0.1.0.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d298ac0b88460ed3b00b624d0b23b9d00d671613241e809b1463977ef2448fa6
BLAKE2b-256 checksum
How to use checksums
a32ecf6713e34362511a2d3b820fe5c75220318f152407dca1b01e14de7d155a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / pyfortiflex-0.1.0-py3-none-any.whl

Download URL pyfortiflex-0.1.0-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e980622cf6508776f6a83f0cd31aa0155227a7d3fefcb0012e0d8560c68b794
BLAKE2b-256 checksum
How to use checksums
bc667486221b84ac21ee459c271266d3f603f8439fab6a61eb130db9ad9f8dbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Security for pyfortiflex 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyfortiflex-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page