-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplugin.py
43 lines (35 loc) · 1.98 KB
/
plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from hansken_extraction_plugin.api.extraction_plugin import ExtractionPlugin
from hansken_extraction_plugin.api.plugin_info import Author, MaturityLevel, PluginId, PluginInfo, PluginResources
from hansken_extraction_plugin.decorators.transformer import transformer
from hansken_extraction_plugin.runtime.extraction_plugin_runner import run_with_hanskenpy
from logbook import Logger
log = Logger(__name__)
class Plugin(ExtractionPlugin):
def plugin_info(self):
plugin_info = PluginInfo(
id=PluginId(domain='domain', category='category', name='your_plugin_name'),
version='0.0.0',
description='description of your plugin',
author=Author('Your name', '[email protected]', 'your organisation'),
maturity=MaturityLevel.PROOF_OF_CONCEPT,
webpage_url='', # e.g. url to the code repository of your plugin
matcher='$data.type=raw', # add the query for the types of traces your plugin should match
license='Apache License 2.0',
resources=PluginResources(maximum_cpu=2, maximum_memory=512, maximum_workers=6),
)
return plugin_info
def process(self, trace, data_context):
log.info(f"processing trace {trace.get('name')}")
# Add your plugin implementation here
@transformer
def example_transformer(self, name: str) -> str:
# Optional transformer method that can be executed on-demand via the Hansken REST API.
# Multiple argument types and return types are supported.
# For more information see:
# https://netherlandsforensicinstitute.github.io/hansken-extraction-plugin-sdk-documentation/latest/dev/python/transformers.html
return f"Hello {name}"
if __name__ == '__main__':
# Optional main method to run your plugin with Hansken.py
# See detail at:
# https://netherlandsforensicinstitute.github.io/hansken-extraction-plugin-sdk-documentation/latest/dev/python/hanskenpy.html
run_with_hanskenpy(Plugin)