hfortix_fortios.ContentResponse
- class hfortix_fortios.ContentResponse(data, raw_envelope=None, response_time=None, endpoint_path=None, request_info=None)[source]
Response wrapper for endpoints that return binary/text content.
Some FortiOS endpoints return raw content (config files, certificates, crash logs, etc.) instead of structured JSON. This class provides a consistent interface for accessing both the content and standard API response metadata.
- Properties:
content: Raw bytes content from the response content_type: MIME type of the content (e.g., “text/plain”) text: Content decoded as UTF-8 string
# Standard API response fields (same as FortiObject): http_status_code: HTTP status code (200, 404, etc.) http_status: API status (‘success’ or ‘error’) http_method: HTTP method used http_response_time: Response time in milliseconds vdom: Virtual domain name serial: Device serial number version: FortiOS version build: FortiOS build number raw: Full API response envelope
# Endpoint-specific fields from query params: # These are dynamically available based on the endpoint schema
- Parameters:
Examples
>>> # Download config revision >>> result = fgt.api.monitor.system.config_revision.file.get(config_id=45) >>> >>> # Access raw content >>> result.content b'#config-version=FGVM64-7.6.5...' >>> >>> # Get as text >>> result.text '#config-version=FGVM64-7.6.5...' >>> >>> # Access standard response fields >>> result.http_status_code 200 >>> result.content_type 'text/plain' >>> >>> # Access endpoint-specific fields >>> result.config_id 45 >>> >>> # Parse FortiOS config to dict (if supported) >>> config = result.to_dict() >>> config['global']['system global']['admin-host'] 'fgt.example.com' >>> >>> # Save to file >>> result.save('/tmp/config_backup.conf')
- __init__(data, raw_envelope=None, response_time=None, endpoint_path=None, request_info=None)[source]
Initialize ContentResponse.
- Parameters:
Methods
__init__(data[, raw_envelope, ...])Initialize ContentResponse.
save(path[, mode])Save content to file.
to_dict()Parse content to dictionary (for parseable content types).
to_json([indent])Get parsed content as JSON string.
to_text([encoding])Decode content to string with specified encoding.
Attributes
buildFortiOS firmware build number.
contentRaw bytes content from the response.
content_typeMIME type of the content.
fmg_api_requestAlias for http_api_request when using FortiManager proxy.
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.).
rawFull API response envelope.
revisionConfiguration revision number.
serialDevice serial number.
textContent decoded as UTF-8 string.
vdomVirtual domain name.
versionFortiOS version string (e.g., 'v7.6.5').