Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions omeroweb/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,16 @@
GET Groups that an Experimenter is in, using omero-marshal to generate json
"""

api_annotations = re_path(
r"^v(?P<api_version>%s)/m/annotations/$" % versions,
views.AnnotationsView.as_view(),
name="api_annotations",
)
"""
GET Annotations, using omero-marshal to generate json
"""


urlpatterns = [
api_versions,
api_base,
Expand Down Expand Up @@ -443,4 +453,5 @@
api_groups,
api_group,
api_experimenter_groups,
api_annotations,
]
35 changes: 35 additions & 0 deletions omeroweb/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def api_base(request, api_version=None, **kwargs):
"url:screens": build_url(request, "api_screens", v),
"url:plates": build_url(request, "api_plates", v),
"url:rois": build_url(request, "api_rois", v),
"url:annotations": build_url(request, "api_annotations", v),
"url:token": build_url(request, "api_token", v),
"url:servers": build_url(request, "api_servers", v),
"url:login": build_url(request, "api_login", v),
Expand Down Expand Up @@ -787,6 +788,40 @@ def add_data(self, marshalled, request, conn, urls=None, **kwargs):
return marshalled


class AnnotationsView(ObjectsView):
"""Handles GET for /annotations/ to list available Annotations."""

OMERO_TYPE = "Annotation"

def get_opts(self, request, **kwargs):
"""Add extra parameters to the opts dict."""
opts = super(AnnotationsView, self).get_opts(request, **kwargs)

# TODO: add more types?
for key in [
"image",
"dataset",
"project",
"screen",
"plate",
"well",
"plateacquisition",
"roi",
]:
ids = request.GET.getlist(key)
if len(ids) > 0:
opts["parent_type"] = key
opts["parent_ids"] = [int(i) for i in ids]
break
if request.GET.get("ns") is not None:
opts["ns"] = request.GET.get("ns")
ann_type = request.GET.get("type")
if ann_type in ("file", "map", "tag", "rating", "long", "comment"):
opts["ann_type"] = ann_type

return opts


class ExperimentersView(ObjectsView):
"""Handles GET for /experimenters/ to list Experimenters."""

Expand Down
Loading