Skip to content

fmg_api

FMG API library

AnyFMG module-attribute #

AnyFMG = Union[FMG, AsyncFMG]

AnyFMGObject module-attribute #

AnyFMGObject = TypeVar('AnyFMGObject', FMGObject, FMGExecObject)

GetOption module-attribute #

GetOption = Literal['extra info', 'assignment info', 'loadsub', 'no loadsub', 'count', 'syntax', 'devinfo', 'obj flags', 'datasrc', 'chksum']

FMGBaseObject #

FMGBaseObject(*args, **kwargs)

Bases: BaseModel, ABC

Abstract base object for all high-level objects

Scope must be set before referencing the url! It's done by FMGBase requests as it defaults all objects to its selected ADOM.

In case of AsyncFMG, caller must ensure await-ing the request.

Attributes:

Name Type Description
fmg_scope str

FMG selected scope (adom or global)

_version str

Supported API version

_url str

template for API URL

_fmg FMG

FMG instance

Other Parameters:

Name Type Description
scope str

FMG selected scope (adom or global)

fmg AnyFMG

FMG instance

Source code in pyfortinet/fmg_api/__init__.py
def __init__(self, *args, **kwargs) -> None:
    """Initialize FMGObject

    Keyword Args:
        scope (str): FMG selected scope (adom or global)
        fmg (AnyFMG): FMG instance
    """
    super().__init__(*args, **kwargs)
    self.fmg_scope = kwargs.get("fmg_scope")
    self._fmg: "AnyFMG" = kwargs.get("fmg")

fmg_scope property writable #

fmg_scope: str

Object scope (adom)

get_url property #

get_url: str

General API URL assembly

To be overridden by more complex API URLs in different classes

FMGExecObject #

FMGExecObject(*args, **kwargs)

Bases: FMGBaseObject, ABC

FMG execute job type

Attributes:

Name Type Description
scope str

FMG selected scope (adom or global)

_version str

Supported API version

_url str

template for API URL

_fmg FMG

FMG instance

Other Parameters:

Name Type Description
scope str

FMG selected scope (adom or global)

fmg AnyFMG

FMG instance

Source code in pyfortinet/fmg_api/__init__.py
def __init__(self, *args, **kwargs) -> None:
    """Initialize FMGObject

    Keyword Args:
        scope (str): FMG selected scope (adom or global)
        fmg (AnyFMG): FMG instance
    """
    super().__init__(*args, **kwargs)
    self.fmg_scope = kwargs.get("fmg_scope")
    self._fmg: "AnyFMG" = kwargs.get("fmg")

exec #

exec()

Exec FMG operation on this object

Source code in pyfortinet/fmg_api/__init__.py
def exec(self):
    """Exec FMG operation on this object"""
    if self._fmg:
        return self._fmg.exec(self)
    raise FMGNotAssignedException

FMGObject #

FMGObject(*args, **kwargs)

Bases: FMGBaseObject, ABC

Abstract base object for all high-level objects

Scope must be set before referencing the url! It's done by FMGBase requests as it defaults all objects to its selected ADOM.

In case of AsyncFMG, caller must ensure await-ing the request.

Attributes:

Name Type Description
scope str

FMG selected scope (adom or global)

_version str

Supported API version

_url str

template for API URL

_fmg FMG

FMG instance

Other Parameters:

Name Type Description
scope str

FMG selected scope (adom or global)

fmg AnyFMG

FMG instance

Source code in pyfortinet/fmg_api/__init__.py
def __init__(self, *args, **kwargs) -> None:
    """Initialize FMGObject

    Keyword Args:
        scope (str): FMG selected scope (adom or global)
        fmg (AnyFMG): FMG instance
    """
    super().__init__(*args, **kwargs)
    self.fmg_scope = kwargs.get("fmg_scope")
    self._fmg: "AnyFMG" = kwargs.get("fmg")

add #

add()

Add this object to FMG

Source code in pyfortinet/fmg_api/__init__.py
def add(self):
    """Add this object to FMG"""
    if self._fmg:
        return self._fmg.add(self)
    raise FMGNotAssignedException

delete #

delete()

Delete FMG operation on this object

Source code in pyfortinet/fmg_api/__init__.py
def delete(self):
    """Delete FMG operation on this object"""
    if self._fmg:
        return self._fmg.delete(self)
    raise FMGNotAssignedException

set #

set()

Set FMG operation on this object

Source code in pyfortinet/fmg_api/__init__.py
def set(self):
    """Set FMG operation on this object"""
    if self._fmg:
        return self._fmg.set(self)
    raise FMGNotAssignedException

update #

update()

Update FMG operation on this object

Source code in pyfortinet/fmg_api/__init__.py
def update(self):
    """Update FMG operation on this object"""
    if self._fmg:
        return self._fmg.update(self)
    raise FMGNotAssignedException