Skip to content

Commit

Permalink
Add more filter expressions: Before, After, StartsWith, EndsWith, Match
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Apr 9, 2022
1 parent 1483b0a commit cc64ac2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ __pycache__/
thehive4py.egg-info/
build/
dist/
venv/
tmp/

# local garbage yet
tests/resources/
Expand Down
1 change: 1 addition & 0 deletions thehive4py/query/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .filters import Between, Contains, Eq # noqa
from .filters import FilterExpr as _FilterExpr # noqa
from .filters import Gt, Gte, Like, Lt, Lte # noqa
from .filters import Match, Before, After, StartsWith, EndsWith # noqa
from .page import Paginate
from .sort import Asc, Desc # noqa
from .sort import SortExpr as _SortExpr
Expand Down
25 changes: 25 additions & 0 deletions thehive4py/query/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ def __init__(self, field: str, value):
super().__init__(_like={"_field": field, "_value": value})


class Match(FilterExpr):
def __init__(self, field: str, value):
super().__init__(_match={"_field": field, "_value": value})


class StartsWith(FilterExpr):
def __init__(self, field: str, value):
super().__init__(_startsWith={"_field": field, "_value": value})


class EndsWith(FilterExpr):
def __init__(self, field: str, value):
super().__init__(_endsWith={"_field": field, "_value": value})


class Contains(FilterExpr):
def __init__(self, field: str):
super().__init__(_contains=field)
Expand Down Expand Up @@ -65,3 +80,13 @@ def __init__(self, field: str, value):
class Between(FilterExpr):
def __init__(self, field: str, start: int, end: int):
super().__init__(_between={"_field": field, "_from": start, "_to": end})


class Before(FilterExpr):
def __init__(self, field: str, end: int):
super().__init__(_between={"_field": field, "_to": end})


class After(FilterExpr):
def __init__(self, field: str, start: int):
super().__init__(_between={"_field": field, "_from": start})

0 comments on commit cc64ac2

Please sign in to comment.