67 lines
1.7 KiB
Python
67 lines
1.7 KiB
Python
from ApiServices.TemplateService.initializer.event_clusters import EventCluster, Event
|
|
|
|
|
|
single_event = Event(
|
|
name="example_event",
|
|
key="176b829c-7622-4cf2-b474-411e5acb637c",
|
|
request_validator=None, # TODO: Add request validator
|
|
response_validator=None, # TODO: Add response validator
|
|
description="Example event description",
|
|
)
|
|
|
|
|
|
def example_callable():
|
|
"""
|
|
Example callable method
|
|
"""
|
|
return {
|
|
"completed": True,
|
|
"message": "Example callable method 2",
|
|
"info": {
|
|
"host": "example_host",
|
|
"user_agent": "example_user_agent",
|
|
},
|
|
}
|
|
|
|
|
|
single_event.event_callable = example_callable
|
|
|
|
other_event = Event(
|
|
name="example_event-2",
|
|
key="176b829c-7622-4cf2-b474-421e5acb637c",
|
|
request_validator=None, # TODO: Add request validator
|
|
response_validator=None, # TODO: Add response validator
|
|
description="Example event 2 description",
|
|
)
|
|
|
|
|
|
def example_callable_other():
|
|
"""
|
|
Example callable method
|
|
"""
|
|
return {
|
|
"completed": True,
|
|
"message": "Example callable method 1",
|
|
"info": {
|
|
"host": "example_host",
|
|
"user_agent": "example_user_agent",
|
|
},
|
|
}
|
|
|
|
|
|
other_event.event_callable = example_callable_other
|
|
|
|
tokens_in_redis = [
|
|
"3f510dcf-9f84-4eb9-b919-f582f30adab1",
|
|
"9f403034-deba-4e1f-b43e-b25d3c808d39",
|
|
"b8ec6e64-286a-4f60-8554-7a3865454944",
|
|
"176b829c-7622-4cf2-b474-421e5acb637c",
|
|
]
|
|
template_event_cluster = EventCluster(
|
|
endpoint_uu_id="bb20c8c6-a289-4cab-9da7-34ca8a36c8e5"
|
|
)
|
|
template_event_cluster.add_event([single_event, other_event])
|
|
# matched_event = template_event_cluster.match_event(event_keys=tokens_in_redis)
|
|
|
|
# print('event_callable', matched_event.event_callable())
|