Skip to content

Commit 5b8401d

Browse files
committed
Reintroduced Action response "links"
1 parent e241c96 commit 5b8401d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/labthings/server/schema.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,28 @@ class ActionSchema(Schema):
8989
log = fields.List(fields.Dict())
9090

9191
href = fields.String()
92+
links = fields.Dict()
9293

9394
@pre_dump
9495
def generate_links(self, data, **kwargs):
96+
# Add Mozilla format href
97+
# TODO: This should eventually point to the Mozilla action URL
9598
try:
9699
url = url_for(TASK_ENDPOINT, task_id=data.id, _external=True)
97100
except BuildError:
98101
url = None
99102
data.href = url
103+
104+
# Add full link description
105+
# TODO: Reintroduce this type of link to other Thing Description elements
106+
data.links = {
107+
"self": {
108+
"href": url,
109+
"mimetype": "application/json",
110+
**description_from_view(view_class_from_endpoint(TASK_ENDPOINT)),
111+
}
112+
}
113+
100114
return data
101115

102116

0 commit comments

Comments
 (0)