Metadata-Version: 2.5
Name: pyfortinet
Version: 0.0.2
Summary: Fortinet Python library
Author-email: Viktor Kertesz <vkertesz2@gmail.com>
Requires-Python: >=3.9,<4
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: System :: Networking
License-File: LICENSE
Requires-Dist: pydantic>2,<3
Requires-Dist: pydantic-settings
Requires-Dist: typer
Requires-Dist: requests>=2.32.5,<2.33; python_version < '3.10'
Requires-Dist: requests>=2.33.0,<3; python_version >= '3.10'
Requires-Dist: ruamel.yaml~=0.18
Requires-Dist: more-itertools
Requires-Dist: pyresilience>=0.4.1,<0.5
Requires-Dist: rich ; extra == "all"
Requires-Dist: aiohttp ; extra == "all"
Requires-Dist: aiohttp ; extra == "async"
Requires-Dist: pytest-cov ; extra == "dev"
Requires-Dist: pytest ; extra == "dev"
Requires-Dist: pytest-asyncio>=0.24.0 ; extra == "dev"
Requires-Dist: pytest-dependency ; extra == "dev"
Requires-Dist: flit ; extra == "dev"
Requires-Dist: invoke ; extra == "dev"
Requires-Dist: pre-commit ; extra == "dev"
Requires-Dist: ruff ; extra == "dev"
Requires-Dist: zensical>=0.1.1,<0.2 ; extra == "dev" and ( python_version >= '3.11')
Requires-Dist: mkdocstrings-python ; extra == "dev" and ( python_version >= '3.11')
Requires-Dist: rich ; extra == "dev"
Requires-Dist: aiohttp ; extra == "dev"
Requires-Dist: rich ; extra == "rich"
Project-URL: Documentation, https://realvitya.github.io/pyfortinet/
Project-URL: Source, https://github.com/realvitya/pyfortinet
Provides-Extra: all
Provides-Extra: async
Provides-Extra: dev
Provides-Extra: rich
Import-Name: pyfortinet

# pyfortinet

[//]: # (--8<-- [start:intro])

pyfortinet is a Python library for the FortiManager JSON-RPC API. Work with addresses, groups,
services, policies, and other supported resources as Python objects. The library handles session
authentication, request construction, and typed GET responses.

## Features

- High-level configuration models with Pydantic validation and API field aliases.
- Synchronous and asynchronous clients with consistent object operations.
- ADOM workspace locking and connection cleanup.
- Background task polling with progress callbacks.
- Dictionary requests and low-level clients for endpoints without a model.

Coverage is evolving. Check the code reference for available models and the target firmware's API
reference for supported fields. Direct FortiGate connections, token/SAML authentication, and
workflow session approval automation are not implemented.

[//]: # (--8<-- [end:intro])

## Installation

Python 3.9 or later is required.

```shell
python -m pip install pyfortinet
# Optional asynchronous support:
python -m pip install "pyfortinet[async]"
# Both asynchronous support and Rich output:
python -m pip install "pyfortinet[all]"
```

## Read firewall addresses

Set the example's environment variables for your FortiManager account and selected ADOM.
The account needs JSON-RPC API access. TLS certificate verification is enabled by default.

```python
import os

from pyfortinet import FMG
from pyfortinet.fmg_api.common import F
from pyfortinet.fmg_api.firewall import Address

config = {
    "base_url": os.environ["FMG_URL"],
    "username": os.environ["FMG_USERNAME"],
    "password": os.environ["FMG_PASSWORD"],
    "adom": os.environ["FMG_ADOM"],
}

with FMG(**config) as fmg:
    for address in fmg.get(Address, F(name__like="server%")).data:
        print(address.name, address.subnet)
```

Use `async with FMG(**config) as fmg:` and `await fmg.get(...)` for asynchronous code.
`AsyncFMG` is also available directly.

## Documentation

- [Quickstart](https://realvitya.github.io/pyfortinet/user_guide/quickstart/):
  connect, read objects, and make a targeted update.
- [API concepts](https://realvitya.github.io/pyfortinet/user_guide/api_concepts/):
  move from JSON-RPC operations to high-level Python objects.
- [How-tos](https://realvitya.github.io/pyfortinet/user_guide/howto/):
  filtering, object lifecycle, groups, mappings, workspace locks, and installation tasks.
- [Developer guide](https://realvitya.github.io/pyfortinet/developer_guide/):
  setup, implementing models, testing, and documentation maintenance.

If you use [How to FortiManager API](https://how-to-fortimanager-api.readthedocs.io/en/latest/),
start with the API concepts page. That guide provides broad API context; pyfortinet's user guide
shows workflows using the models implemented by this library.

