FortiGateAPI.cmdb.system.vdom
- class fortigate_api.cmdb.system.VdomSC(fortigate: FortiGate, **kwargs)
Web UI
API
Data
- uid: str = 'name'
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
POSTmethod.- 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
DELETEmethod.
- 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 relatedGETmethod.- 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
PUTmethod.- 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/system/vdom
- Create vdom in the Fortigate
- Get all vdoms from the Fortigate
- Get vdom by name (unique identifier)
- Delete vdom from the Fortigate
- Check for presence of vdom in the Fortigate
"""
from pprint import pprint
from fortigate_api import FortiGateAPI
HOST = "host"
USERNAME = "username"
PASSWORD = "password"
api = FortiGateAPI(host=HOST, username=USERNAME, password=PASSWORD)
# Create vdom in the Fortigate
data = {"name": "VDOM1"}
response = api.cmdb.system.vdom.create(data)
print(f"vdom.create {response}") # vdoms.create <Response [200]>
# Get all vdoms from the Fortigate
items = api.cmdb.system.vdom.get()
print(f"vdoms count={len(items)}") # vdoms count=3
# Get vdom by name (unique identifier)
items = api.cmdb.system.vdom.get(name="VDOM1")
print(f"vdoms count={len(items)}") # vdoms count=1
pprint(items)
# [{'flag': 0,
# 'name': 'VDOM1',
# 'q_origin_key': 'VDOM1',
# 'short-name': 'VDOM1',
# 'vcluster-id': 0}]
# Delete vdom from the Fortigate
response = api.cmdb.system.vdom.delete("VDOM1")
print(f"vdom.delete {response}") # vdoms.delete <Response [200]>
# Check for presence of vdom in the Fortigate
response = api.cmdb.system.vdom.is_exist("VDOM1")
print("vdom.is_exist", response) # vdom.is_exist False
api.logout()