Bases: InteractionAffordance
creates event affordance schema from events.
Schema
UML Diagram
Source code in .venv/lib/python3.13/site-packages/hololinked/td/interaction_affordance.py
| class EventAffordance(InteractionAffordance):
"""
creates event affordance schema from events.
[Schema](https://www.w3.org/TR/wot-thing-description11/#eventaffordance) <br>
[UML Diagram](https://docs.hololinked.dev/UML/PDF/InteractionAffordance.pdf) <br>
"""
# [Supported Fields]() <br>
subscription: str = None
data: JSON = None
def __init__(self):
super().__init__()
@property
def what(self):
return ResourceTypes.EVENT
def build(self) -> None:
event = self.objekt
assert isinstance(event, Event) # type definition
if event.__doc__:
title = get_summary(event.doc)
description = self.format_doc(event.doc)
if title == description:
self.description = description
else:
self.title = title
self.description = description
if event.schema:
self.data = event.schema
# def build_forms(self, protocol, authority):
# form = Form()
# form.op = "subscribeevent"
# form.href = f"{authority}{owner._full_URL_path_prefix}{event.URL_path}"
# form.htv_methodName = "GET"
# form.contentType = "text/plain"
# form.subprotocol = "sse"
# self.forms = [form.asdict()]
@classmethod
def generate(cls, event: Event, owner, **kwargs) -> "EventAffordance":
affordance = EventAffordance()
affordance.owner = owner
affordance.objekt = event
affordance.build()
return affordance
|