37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
|
||
|
|
from iris_interface.IrisModuleInterface import IrisModuleInterface
|
||
|
|
|
||
|
|
class IrisScoringModule(IrisModuleInterface):
|
||
|
|
_module_name = interface_conf.module_name
|
||
|
|
_module_description = interface_conf.module_description
|
||
|
|
_interface_version = interface_conf.interface_version
|
||
|
|
_module_version = interface_conf.module_version
|
||
|
|
_pipeline_support = interface_conf.pipeline_support
|
||
|
|
_pipeline_info = interface_conf.pipeline_info
|
||
|
|
_module_configuration = interface_conf.module_configuration
|
||
|
|
_module_type = interface_conf.module_type
|
||
|
|
|
||
|
|
def register_hooks(self, module_id: int):
|
||
|
|
"""
|
||
|
|
Called by IRIS indicating it's time to register hooks.
|
||
|
|
:param module_id: Module ID provided by IRIS.
|
||
|
|
"""
|
||
|
|
status = self.register_to_hook(module_id, iris_hook_name='on_postload_ioc_create')
|
||
|
|
if status.is_failure():
|
||
|
|
self.log.error(status.get_message())
|
||
|
|
else:
|
||
|
|
self.log.info(f"Successfully subscribed to on_postload_ioc_create hook")
|
||
|
|
|
||
|
|
|
||
|
|
def hooks_handler(self, hook_name: str, data):
|
||
|
|
"""
|
||
|
|
Called by IRIS each time one of our hook is triggered.
|
||
|
|
"""
|
||
|
|
|
||
|
|
if self._dict_conf.get('log_received_hook') is True:
|
||
|
|
self.log.info(f'Received {hook_name}')
|
||
|
|
self.log.info(f'Received data of type {type(data)}')
|
||
|
|
|
||
|
|
return InterfaceStatus.I2Success(data=data, logs=list(self.message_queue))
|