Skip to content

settings

Fortimanager settings

FMGSettings #

Bases: BaseSettings

Connection and resilience settings for FortiManager clients.

Attributes:

Name Type Description
base_url Annotated[HttpUrl, Field(description='Base URL to access FMG (e.g.: https://myfmg/jsonrpc)')]

FortiManager HTTPS URL; /jsonrpc is appended if absent.

username Annotated[str, Field(description='User to authenticate')]

Account with JSON-RPC API access.

password Annotated[SecretStr, Field(description='Password for authentication')]

Authentication password, stored as a Pydantic SecretStr.

adom Annotated[str, Field(description='ADOM to use for this connection')]

Selected ADOM or "global" for the Global Database. Defaults to "global".

verify Annotated[bool, Field(description='Verify SSL certificate (REQUESTS_CA_BUNDLE can set accepted CA cert)')]

Verify TLS certificates. Defaults to True. REQUESTS_CA_BUNDLE applies to the sync transport.

timeout Annotated[float, Field(gt=0, allow_inf_nan=False, description='Connect/read timeout in seconds')]

Connect/read inactivity timeout per transport attempt, in seconds.

retry_attempts Annotated[int, Field(ge=1, description='Total transport attempts for read requests')]

Maximum transport attempts for read requests, including the initial call.

retry_delay Annotated[float, Field(ge=0, allow_inf_nan=False, description='Initial retry delay in seconds')]

Initial retry delay in seconds.

retry_backoff Annotated[float, Field(ge=1, allow_inf_nan=False, description='Retry delay multiplier')]

Retry delay multiplier.

retry_max_delay Annotated[float, Field(ge=0, allow_inf_nan=False, description='Maximum retry delay in seconds')]

Maximum retry delay in seconds.

retry_jitter bool

Randomize retry delays.

raise_on_error Annotated[bool, Field(description='Raise exception on error')]

Raise library exceptions for decorated API operations instead of failed responses.

discard_on_close Annotated[bool, Field(description='Discard changes after connection close (workspace mode)')]

Skip workspace commits during close. Defaults to False.

discard_on_error Annotated[bool, Field(description='Discard changes when exception occurs (workspace mode)')]

Skip workspace commits when an exception exits the context. Defaults to True.

Notes

Discard settings do not reverse configuration installations or every device operation.

check_base_url #

check_base_url(v: str)

check and fix base_url

Source code in pyfortinet/settings.py
@field_validator("base_url", mode="before")
def check_base_url(cls, v: str):
    """check and fix base_url"""
    v = v.rstrip("/ ")
    if not v.endswith("/jsonrpc"):
        v += "/jsonrpc"
    return HttpUrl(v)