Skip to content

Query

thehive4py.query

QueryExpr = List[Union[_FilterExpr, _SortExpr, Paginate, dict]] module-attribute

filters

FilterExpr = _Union['_FilterBase', dict] module-attribute

Lt(field, value)

Bases: _FilterBase

Field less than value.

Source code in thehive4py/query/filters.py
37
38
def __init__(self, field: str, value: _Any):
    super().__init__(_lt={"_field": field, "_value": value})

Gt(field, value)

Bases: _FilterBase

Field greater than value.

Source code in thehive4py/query/filters.py
44
45
def __init__(self, field: str, value: _Any):
    super().__init__(_gt={"_field": field, "_value": value})

Lte(field, value)

Bases: _FilterBase

Field less than or equal value.

Source code in thehive4py/query/filters.py
51
52
def __init__(self, field: str, value: _Any):
    super().__init__(_lte={"_field": field, "_value": value})

Gte(field, value)

Bases: _FilterBase

Field less than or equal value.

Source code in thehive4py/query/filters.py
58
59
def __init__(self, field: str, value: _Any):
    super().__init__(_gte={"_field": field, "_value": value})

Ne(field, value)

Bases: _FilterBase

Field not equal value.

Source code in thehive4py/query/filters.py
65
66
def __init__(self, field: str, value: _Any):
    super().__init__(_ne={"_field": field, "_value": value})

Eq(field, value)

Bases: _FilterBase

Field equal value.

Source code in thehive4py/query/filters.py
72
73
def __init__(self, field: str, value: _Any):
    super().__init__(_eq={"_field": field, "_value": value})

StartsWith(field, value)

Bases: _FilterBase

Field starts with value.

Source code in thehive4py/query/filters.py
79
80
def __init__(self, field: str, value: str):
    super().__init__(_startsWith={"_field": field, "_value": value})

EndsWith(field, value)

Bases: _FilterBase

Field ends with value.

Source code in thehive4py/query/filters.py
86
87
def __init__(self, field: str, value: str):
    super().__init__(_endsWith={"_field": field, "_value": value})

Id(id)

Bases: _FilterBase

FIlter by ID.

Source code in thehive4py/query/filters.py
93
94
def __init__(self, id: str):
    super().__init__(_id=id)

Between(field, start, end)

Bases: _FilterBase

Field between inclusive from and exclusive to values.

Source code in thehive4py/query/filters.py
100
101
def __init__(self, field: str, start: int, end: int):
    super().__init__(_between={"_field": field, "_from": start, "_to": end})

In(field, values)

Bases: _FilterBase

Field is one of the values.

Source code in thehive4py/query/filters.py
107
108
def __init__(self, field: _Any, values: list):
    super().__init__(_in={"_field": field, "_values": values})

Contains(field)

Bases: _FilterBase

Object contains the field.

Source code in thehive4py/query/filters.py
114
115
116
117
118
119
120
121
122
def __init__(self, field: str):
    warnings.warn(
        message="The `Contains` filter has been deprecated. "
        "Please use the `Has` filter to prevent breaking "
        "changes in the future.",
        category=DeprecationWarning,
        stacklevel=2,
    )
    super().__init__(_contains=field)

Has(field)

Bases: _FilterBase

Object contains the field.

Source code in thehive4py/query/filters.py
128
129
def __init__(self, field: str):
    super().__init__(_has=field)

Like(field, value)

Bases: _FilterBase

Field contains the value.

Source code in thehive4py/query/filters.py
135
136
def __init__(self, field: str, value: str):
    super().__init__(_like={"_field": field, "_value": value})

Match(field, value)

Bases: _FilterBase

Field contains the value

Source code in thehive4py/query/filters.py
142
143
def __init__(self, field: str, value: str):
    super().__init__(_match={"_field": field, "_value": value})

page

Paginate(start, end, extra_data=[])

Bases: UserDict

Source code in thehive4py/query/page.py
5
6
def __init__(self, start: int, end: int, extra_data=[]):
    super().__init__({"from": start, "to": end, "extraData": extra_data})

sort

SortExpr

Bases: UserDict

Base class for sort expressions.

__and__(other)
Source code in thehive4py/query/sort.py
7
8
def __and__(self, other: "SortExpr") -> "SortExpr":
    return self._concat_expressions("&", self, other)
__or__(other)
Source code in thehive4py/query/sort.py
10
11
def __or__(self, other: "SortExpr") -> "SortExpr":  # type:ignore
    return self._concat_expressions("|", self, other)

Asc(field)

Bases: SortExpr

Source code in thehive4py/query/sort.py
28
29
def __init__(self, field: str):
    super().__init__(_fields=[{field: "asc"}])

Desc(field)

Bases: SortExpr

Source code in thehive4py/query/sort.py
33
34
def __init__(self, field: str):
    super().__init__(_fields=[{field: "desc"}])