FortiGateAPI.cmdb.firewall_ipmacbinding.table

class fortigate_api.cmdb.firewall_ipmacbinding.TableFiC(fortigate: FortiGate, **kwargs)

Web UI

API

https://172.16.177.65/api/v2/cmdb/firewall.ipmacbinding/table

Data

uid: str = 'seq-num'

Unique identifier of fortigate-object.

create(data: Dict[str, Any]) Response

Create the fortigate-object in the Fortigate.

Parameters:

data (dict) – Data of the fortigate-object. More details can be found at https://fndn.fortinet.net for related POST method.

Returns:

Session response.

  • <Response [200]> Object successfully created,

  • <Response [500]> Object already exists.

Return type:

Response

delete(uid: str | int = '', filter: str | Sequence[str] = '', **kwargs) Response

Delete the fortigate-object from the Fortigate.

Parameters:
  • uid (str or int) – Identifier of the fortigate-object. Used to delete a single object.

  • filter (str or List[str]) – Filter fortigate-objects by one or multiple Filtering conditions. Used to delete multiple objects.

  • kwargs – Fortigate REST API parameters. More details can be found at https://fndn.fortinet.net for related DELETE method.

Returns:

Session response.

  • <Response [200]> Object successfully deleted,

  • <Response [404]> Object not found in the Fortigate.

Return type:

Response

get(**kwargs) List[Dict[str, Any]]

Get fortigate-objects, all or filtered by some parameters.

Parameters:

kwargs – Fortigate REST API parameters. filter - Filter fortigate-objects by one or multiple Filtering conditions. More details can be found at https://fndn.fortinet.net for related GET method.

Returns:

List of the fortigate-objects.

Return type:

List[dict]

is_exist(uid: str | int) bool

Check if a fortigate-object exists in the Fortigate.

Parameters:

uid (str or int) – Identifier of the fortigate-object.

Returns:

True - object exists, False - object does not exist.

Return type:

bool

update(data: Dict[str, Any]) Response

Update fortigate-object on the Fortigate.

Parameters:

data (dict) – Data of the fortigate-object to update. More details can be found at https://fndn.fortinet.net for related PUT method.

Returns:

Session response.

  • <Response [200]> Object successfully updated,

  • <Response [404]> Object has not been updated.

Return type:

Response

property url: str

URL to the fortigate-object.

Usage

"""api/v2/cmdb/firewall.ipmacbinding/table

- Create table in the Fortigate
- Get all tables from the Fortigate
- Get filtered table by seq-num (unique identifier)
- Update table data in the Fortigate
- Delete table from the Fortigate by seq-num (unique identifier)
- Check for absence of table in the Fortigate
"""

from fortigate_api import FortiGateAPI

HOST = "host"
USERNAME = "username"
PASSWORD = "password"

api = FortiGateAPI(host=HOST, username=USERNAME, password=PASSWORD)

# Create table in the Fortigate
data = {
    "name": "TABLE",
    "ip": "10.0.0.1",
    "mac": "00:00:00:00:00:01",
    "status": "enable",
}
response = api.cmdb.firewall_ipmacbinding.table.create(data)
print("table.create", response)  # table.create <Response [200]>

# Get all tables from the Fortigate
items = api.cmdb.firewall_ipmacbinding.table.get()
print(f"tables count={len(items)}")  # tables count=1

# Get filtered table by seq-num (unique identifier)
items = api.cmdb.firewall_ipmacbinding.table.get(**{"seq-num": 1})
print(f"tables count={len(items)}")  # tables count=1

# Update table data in the Fortigate
seq_num = items[0]["seq-num"]
data = {"seq-num": seq_num, "mac": "00:00:00:00:00:02"}
response = api.cmdb.firewall_ipmacbinding.table.update(data)
print("table.update", response)  # table.update <Response [200]>

# Delete table from the Fortigate by seq-num (unique identifier)
response = api.cmdb.firewall_ipmacbinding.table.delete(seq_num)
print("table.delete", response)  # table.delete <Response [200]>

# Check for absence of table in the Fortigate
response = api.cmdb.firewall_ipmacbinding.table.is_exist(seq_num)
print("table.is_exist", response)  # table.is_exist False

api.logout()