Skip to content

Commit

Permalink
Added support for classification_aliases and metadata_suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
cccs-sgaron committed Aug 26, 2024
1 parent 79bc427 commit 586ae77
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion assemblyline_client/v4_client/module/system.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from json import dumps

from assemblyline_client.v4_client.common.utils import api_path
from assemblyline_client.v4_client.common.utils import api_path, get_function_kwargs


class System(object):
Expand Down Expand Up @@ -49,3 +49,58 @@ def set_tag_safelist(self, yaml_file):
yaml_file: New tag_safelist.yml file
"""
return self._connection.put(api_path('system', 'tag_safelist'), data=dumps(yaml_file))

def get_classification_aliases(self):
"""\
Get the current display aliases for the classification engine
"""
return self._connection.get(api_path('system', 'classification_aliases'))

def set_classification_aliases(self, aliases):
"""\
Save display aliases for the classification engine
Required:
aliases: A dictionary of alias name and short_names for a given classifications strings
Example data block:
{
"ORG_000000": {"name": "Communication Security Establishment",
"short_name": "CSE"},
"ORG_000001": {"name": "Canadian Center for Cyber Security",
"short_name": "CCCS"},
...
}
"""
return self._connection.put(api_path('system', 'classification_aliases'), data=dumps(aliases))

def get_metadata_suggestions(self, key=None):
"""\
Get the current metadata suggestions
Optional:
key: Get only the suggestions values for the given key
"""
kw = get_function_kwargs('key')
return self._connection.get(api_path('system', 'metadata_suggestions', **kw))

def set_metadata_suggestions(self, suggestions, key=None):
"""\
Set the metadata suggestions
Required:
aliases: A dictionary with a list of suggestions for each key or
A list of suggestion if used on a specific key
Example data block:
{
"key_1": ["a", "b", "c"],
"key_2": ["d", "e", "f"],
}
or
["a", "b", "c"] # If use with a key
"""
kw = get_function_kwargs('key')
return self._connection.put(api_path('system', 'metadata_suggestions', **kw), data=dumps(suggestions))

0 comments on commit 586ae77

Please sign in to comment.