hfortix_fortios.FortiObjectList

class hfortix_fortios.FortiObjectList(items=None, raw_envelope=None, response_time=None, request_info=None)[source]

A list of FortiObject instances with convenient access to raw API response.

This class extends the standard list to provide additional properties for accessing the data in different formats. It stores the full API envelope so you can access metadata like http_status, vdom, etc.

Properties:

dict: Returns list of dictionaries (each FortiObject as dict) json: Returns pretty-printed JSON string raw: Returns the full API response envelope

Examples

>>> policies = fgt.api.cmdb.firewall.policy.get()
>>> policies[0].name  # Access like normal list of FortiObjects
'my-policy'
>>>
>>> # Get as list of dicts
>>> policies.dict
[{'policyid': 1, 'name': 'my-policy', ...}, ...]
>>>
>>> # Get pretty JSON string
>>> print(policies.json)
[
  {
    "policyid": 1,
    "name": "my-policy",
    ...
  }
]
>>>
>>> # Get full API envelope with metadata
>>> policies.raw
{'http_status': 200, 'vdom': 'root', 'results': [...], ...}
Parameters:
  • items (list | None)

  • raw_envelope (dict | None)

  • response_time (float | None)

  • request_info (dict | None)

__init__(items=None, raw_envelope=None, response_time=None, request_info=None)[source]

Initialize FortiObjectList.

Parameters:
  • items (list | None) – List of FortiObject instances or other items

  • raw_envelope (dict | None) – The full API response envelope (optional)

  • response_time (float | None) – Response time in seconds for the HTTP request (optional)

  • request_info (dict | None) – HTTP request information (method, url, params, data) (optional)

Methods

__init__([items, raw_envelope, ...])

Initialize FortiObjectList.

append(object, /)

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value[, start, stop])

Return first index of value.

insert(index, object, /)

Insert object before index.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

reverse()

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.

Attributes

build

FortiOS firmware build number.

dict

Get list of dictionaries.

fmg_api_request

Alias for http_api_request when using FortiManager proxy.

fmg_id

FortiManager request ID.

fmg_proxy_status_code

FortiManager proxy status code for this request.

fmg_proxy_status_message

FortiManager proxy status message for this request.

fmg_proxy_target

Target device name in FortiManager proxy request.

fmg_proxy_url

FortiManager proxy URL used for this request.

fmg_raw

Raw FortiManager response data.

fmg_status_code

FortiManager status code for the device response.

fmg_status_message

FortiManager status message for the device response.

fmg_url

FortiGate API URL called through FortiManager.

http_api_request

HTTP API request information for this response.

http_method

HTTP method used (GET, POST, PUT, DELETE).

http_response_time

Response time in milliseconds for this API request.

http_stats

HTTP request/response statistics summary.

http_status

API response status ('success' or 'error').

http_status_code

HTTP status code (200, 404, 500, etc.).

json

Get pretty-printed JSON string of the list.

raw

Get the full API response envelope.

serial

Device serial number.

vdom

Virtual domain name.

version

FortiOS version string (e.g., 'v7.6.5').