Skip to content

Commit

Permalink
Merge pull request #57 from CybercentreCanada/facet/size
Browse files Browse the repository at this point in the history
Expose facet size parameter to client
  • Loading branch information
cccs-rs authored Dec 6, 2024
2 parents c9f101d + 4047857 commit de19086
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
45 changes: 27 additions & 18 deletions assemblyline_client/v4_client/module/search/facet.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _do_facet(self, index, field, **kwargs):
path = api_path('search', 'facet', index, field, **kwargs)
return self._connection.get(path)

def alert(self, field, query=None, mincount=None, filters=None, timeout=None):
def alert(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the alert collection.
Expand All @@ -34,12 +34,13 @@ def alert(self, field, query=None, mincount=None, filters=None, timeout=None):
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('alert', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('alert', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)

def badlist(self, field, query=None, mincount=None, filters=None, timeout=None):
def badlist(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the badlist collection.
Expand All @@ -51,12 +52,13 @@ def badlist(self, field, query=None, mincount=None, filters=None, timeout=None):
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('badlist', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('badlist', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)

def file(self, field, query=None, mincount=None, filters=None, timeout=None):
def file(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the file collection.
Expand All @@ -68,12 +70,13 @@ def file(self, field, query=None, mincount=None, filters=None, timeout=None):
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('file', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('file', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)

def heuristic(self, field, query=None, mincount=None, filters=None, timeout=None):
def heuristic(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the heuristic collection.
Expand All @@ -85,12 +88,13 @@ def heuristic(self, field, query=None, mincount=None, filters=None, timeout=None
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('heuristic', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('heuristic', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)

def result(self, field, query=None, mincount=None, filters=None, timeout=None):
def result(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the result collection.
Expand All @@ -102,12 +106,13 @@ def result(self, field, query=None, mincount=None, filters=None, timeout=None):
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('result', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('result', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)

def safelist(self, field, query=None, mincount=None, filters=None, timeout=None):
def safelist(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the safelist collection.
Expand All @@ -119,12 +124,13 @@ def safelist(self, field, query=None, mincount=None, filters=None, timeout=None)
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('safelist', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('safelist', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)

def signature(self, field, query=None, mincount=None, filters=None, timeout=None):
def signature(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the signature collection.
Expand All @@ -136,12 +142,13 @@ def signature(self, field, query=None, mincount=None, filters=None, timeout=None
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('signature', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('signature', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)

def submission(self, field, query=None, mincount=None, filters=None, timeout=None):
def submission(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the submission collection.
Expand All @@ -153,12 +160,13 @@ def submission(self, field, query=None, mincount=None, filters=None, timeout=Non
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('submission', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('submission', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)

def workflow(self, field, query=None, mincount=None, filters=None, timeout=None):
def workflow(self, field, query=None, mincount=None, filters=None, timeout=None, size=None):
"""\
List most frequent value for a field in the workflow collection.
Expand All @@ -170,7 +178,8 @@ def workflow(self, field, query=None, mincount=None, filters=None, timeout=None)
filters : Additional lucene queries used to filter the data (list of strings)
mincount : Minimum amount of hits for the value to be returned
timeout : Maximum execution time in milliseconds (integer)
size : Maxium number of facets to return (integer)
Returns all results.
"""
return self._do_facet('workflow', field, query=query, mincount=mincount, filters=filters, timeout=timeout)
return self._do_facet('workflow', field, query=query, mincount=mincount, filters=filters, timeout=timeout, size=size)
2 changes: 1 addition & 1 deletion test/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_submit_dynamic(datastore, client):
assert res == datastore.submission.get(res['sid'], as_obj=False)
assert 'Dynamic Analysis' in res['params']['services']['selected']
for k, v in submission_data['params'].items():
if k not in ['submitter', 'services', 'description', 'quota_item']:
if k not in ['submitter', 'services', 'description', 'quota_item', 'priority']:
assert res['params'].get(k) == v


Expand Down

0 comments on commit de19086

Please sign in to comment.