hfortix_fortios.FortiObject
- class hfortix_fortios.FortiObject(data, raw_envelope=None, response_time=None, request_info=None)[source]
Zero-maintenance wrapper for FortiOS API responses.
Provides clean attribute access to API response data with automatic flattening of member_table fields (lists of dicts with ‘name’ keys).
Features: - No schemas required - works with any FortiOS version - No code generation - same class for all endpoints - No maintenance - automatically handles new fields - Auto-flattening of member_table fields for clean access - Escape hatch via get_full() for raw data access - Access full API envelope via .raw property
Examples
>>> # From dict response >>> data = {"name": "policy1", "srcaddr": [{"name": "addr1"}]} >>> obj = FortiObject(data) >>> >>> # Clean attribute access >>> obj.name 'policy1' >>> >>> # Auto-flattened member_table fields >>> obj.srcaddr ['addr1'] >>> >>> # Get raw data when needed >>> obj.get_full('srcaddr') [{'name': 'addr1'}] >>> >>> # Convert back to dict >>> obj.to_dict() {'name': 'policy1', 'srcaddr': [{'name': 'addr1'}]} >>> >>> # Access full API envelope >>> obj.raw {'http_status': 200, 'status': 'success', 'results': {...}}
- Parameters:
- __init__(data, raw_envelope=None, response_time=None, request_info=None)[source]
Initialize FortiObject with API response data.
- Parameters:
data (
dict) – Dictionary containing the API response fieldsraw_envelope (
dict|None) – Optional full API response enveloperesponse_time (
float|None) – Optional response time in seconds (from HTTP request)request_info (
dict|None) – Optional HTTP request information (method, url, params, data)
Methods
__init__(data[, raw_envelope, ...])Initialize FortiObject with API response data.
get(key[, default])Get field value with optional default (dict-like interface).
get_full(name)Get raw field value without automatic processing.
items()Get all field name-value pairs (processed).
keys()Get all field names.
to_dict()Get the original dictionary data.
values()Get all field values (processed).
Attributes
dictGet the dictionary representation of the object.
fgt_actionAPI action performed (appears in some response types).
fgt_api_nameAPI endpoint name (e.g., 'address', 'policy', 'interface').
fgt_api_pathAPI path segment (e.g., 'firewall', 'system', 'user').
fgt_buildFortiOS firmware build number.
fgt_limit_reachedWhether the pagination limit was reached in a list query.
fgt_matched_countNumber of objects matching the query criteria.
fgt_mkeyFortiGate primary key (mkey) of created/modified object.
fgt_next_idxIndex for the next page in paginated results.
fgt_old_revisionFortiGate previous configuration revision number (before this change).
fgt_response_sizeNumber of objects returned in the response (for list operations).
fgt_revisionFortiGate configuration revision number.
fgt_revision_changedWhether the configuration revision changed (indicates config was modified).
fgt_serialFortiGate device serial number.
fgt_vdomFortiGate virtual domain name from API response.
fgt_versionFortiOS version string (e.g., 'v7.6.5').
fmg_api_requestAlias for http_api_request when using FortiManager proxy.
fmg_idFortiManager request ID.
fmg_proxy_status_codeFortiManager proxy status code for this request.
fmg_proxy_status_messageFortiManager proxy status message for this request.
fmg_proxy_targetTarget device name in FortiManager proxy request.
fmg_proxy_urlFortiManager proxy URL used for this request.
fmg_rawRaw FortiManager response data.
fmg_status_codeFortiManager status code for the device response.
fmg_status_messageFortiManager status message for the device response.
fmg_urlFortiGate API URL called through FortiManager.
http_api_requestHTTP API request information for this response.
http_methodHTTP method used (GET, POST, PUT, DELETE).
http_response_timeResponse time in milliseconds for this API request.
http_statsHTTP request/response statistics summary.
http_statusAPI response status ('success' or 'error').
http_status_codeHTTP status code (200, 404, 500, etc.).
jsonGet pretty-printed JSON string of the object.
rawGet the raw/full API response envelope.