Skip to content

httpapi

HTTPAPI for python-cmk.

HTTPAPI(url, user=None, password=None)

Bases: API

Source code in src/cmk/httpapi.py
22
23
24
25
26
27
28
29
def __init__(self, url, user=None, password=None):
    super().__init__(url, user, password)
    self._credentials = {
        "_username": self._user,
        "_secret": self._password,
        "request_format": "json",
        "output_format": "json",
    }

view(view_name, limit='none', **filters)

Fetches data from a View.

Retrieves rows of the view specified by name.

Parameters:

Name Type Description Default
view_name str

Name of the View

required
limit Literal['soft', 'hard', 'none']

Limit the amount of results

'none'
**filters

Filter parameters

{}
Source code in src/cmk/httpapi.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def view(
    self, view_name: str, limit: Literal["soft", "hard", "none"] = "none", **filters
):
    """Fetches data from a View.

    Retrieves rows of the view specified by name.

    Args:
       view_name: Name of the View
       limit: Limit the amount of results
       **filters: Filter parameters
    """
    parameter = {"view_name": view_name, "limit": limit}
    parameter.update(filters)
    result = self._request("view.py", parameter)
    header = result[0]
    return [dict(zip(header, row)) for row in result[1:]]