zabgrab.adapters.zabbix.transport

HTTP transport for the Zabbix JSON-RPC API.

Functions

api_endpoint(url)

Get the JSON-RPC endpoint for a server URL.

Classes

HttpTransport(url, *[, verify_ssl, timeout])

Transport over HTTP(S) using aiohttp.

Transport(*args, **kwargs)

Sends JSON-RPC request bodies and returns decoded responses.

zabgrab.adapters.zabbix.transport.api_endpoint(url)[source]

Get the JSON-RPC endpoint for a server URL.

Parameters:

url (str) – The frontend’s base URL (https://example.org/zabbix) or the endpoint itself (.../api_jsonrpc.php).

Returns:

str – The endpoint URL.

Return type:

str

class zabgrab.adapters.zabbix.transport.Transport(*args, **kwargs)[source]

Bases: Protocol

Sends JSON-RPC request bodies and returns decoded responses.

async post(body, headers)[source]

Send a request body and return the decoded response.

Parameters:
  • body (dict) – The JSON-RPC request.

  • headers (dict of str to str) – Extra HTTP headers (e.g. Authorization).

Returns:

Any – The decoded JSON response.

Return type:

Any

async close()[source]

Release the connection, if any.

Return type:

None

class zabgrab.adapters.zabbix.transport.HttpTransport(url, *, verify_ssl=True, timeout=30.0)[source]

Bases: object

Transport over HTTP(S) using aiohttp.

Network problems are raised as ConnectionFailed with a hint.

Parameters:
  • url (str) – The server’s frontend or API URL.

  • verify_ssl (bool, optional) – Whether to check the server’s TLS certificate.

  • timeout (float, optional) – Seconds to wait for each request.

async post(body, headers)[source]

Send a request body and return the decoded response.

Parameters:
  • body (dict) – The JSON-RPC request.

  • headers (dict of str to str) – Extra HTTP headers (e.g. Authorization).

Returns:

Any – The decoded JSON response.

Raises:
  • Redirected – If the endpoint redirects elsewhere.

  • ConnectionFailed – If the server can’t be reached or doesn’t respond like Zabbix.

Return type:

Any

async close()[source]

Close the HTTP session, if one was opened.

Return type:

None