Page MenuHomeSoftware Heritage

D7746.id28054.diff
No OneTemporary

D7746.id28054.diff

diff --git a/swh/web/api/views/origin.py b/swh/web/api/views/origin.py
--- a/swh/web/api/views/origin.py
+++ b/swh/web/api/views/origin.py
@@ -18,7 +18,7 @@
from swh.web.common import archive
from swh.web.common.exc import BadInputExc
from swh.web.common.origin_visits import get_origin_visits
-from swh.web.common.utils import reverse
+from swh.web.common.utils import origin_visit_types, reverse
DOC_RETURN_ORIGIN = """
:>json string origin_visits_url: link to in order to get information
@@ -146,13 +146,31 @@
)
+def _visit_types():
+ docstring = ""
+ # available visit types are queried using swh-search so we do it in a try
+ # block in case of failure (for instance in docker environment when
+ # elasticsearch service is not available)
+ try:
+ visit_types = origin_visit_types()
+ for visit_type in visit_types[:-1]:
+ docstring += f"**{visit_type}**, "
+ docstring += f"and **{visit_types[-1]}**"
+ except Exception:
+ docstring = "???"
+ pass
+ return docstring
+
+
@api_route(
r"/origin/search/(?P<url_pattern>.+)/",
"api-1-origin-search",
throttle_scope="swh_api_origin_search",
)
@api_doc("/origin/search/")
-@format_docstring(return_origin_array=DOC_RETURN_ORIGIN_ARRAY)
+@format_docstring(
+ return_origin_array=DOC_RETURN_ORIGIN_ARRAY, visit_types=_visit_types()
+)
def api_origin_search(request, url_pattern):
"""
.. http:get:: /api/1/origin/search/(url_pattern)/
@@ -174,6 +192,8 @@
(bounded to 1000)
:query boolean with_visit: if true, only return origins with at least
one visit by Software heritage
+ :query string visit_type: if provided, only return origins with that
+ specific visit type (currently the supported types are {visit_types})
{return_origin_array}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 17, 4:03 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3230383

Event Timeline