diff --git a/swh/web/api/views/origin_save.py b/swh/web/api/views/origin_save.py --- a/swh/web/api/views/origin_save.py +++ b/swh/web/api/views/origin_save.py @@ -8,10 +8,20 @@ from swh.web.auth.utils import privileged_user from swh.web.common.origin_save import ( create_save_origin_request, + get_savable_visit_types, get_save_origin_requests, ) +def _savable_visit_types(): + visit_types = sorted(get_savable_visit_types()) + docstring = "" + for visit_type in visit_types[:-1]: + docstring += f"**{visit_type}**, " + docstring += f"and **{visit_types[-1]}**" + return docstring + + @api_route( r"/origin/save/(?P.+)/url/(?P.+)/", "api-1-save-origin", @@ -20,7 +30,7 @@ never_cache=True, ) @api_doc("/origin/save/") -@format_docstring() +@format_docstring(visit_types=_savable_visit_types()) def api_save_origin(request, visit_type, origin_url): """ .. http:get:: /api/1/origin/save/(visit_type)/url/(origin_url)/ @@ -56,7 +66,7 @@ might have been submitted for the same origin). :param string visit_type: the type of visit to perform - (currently the supported types are ``git``, ``hg`` and ``svn``) + (currently the supported types are {visit_types}) :param string origin_url: the url of the origin to save {common_headers} diff --git a/swh/web/common/origin_save.py b/swh/web/common/origin_save.py --- a/swh/web/common/origin_save.py +++ b/swh/web/common/origin_save.py @@ -170,12 +170,12 @@ else: task_types = _visit_type_task - # scheduler is not available when running cypress tests - if get_config().get("e2e_tests_mode"): - return task_types - else: + # filter visit types according to scheduler load task types if available + try: load_task_types = get_scheduler_load_task_types() return {k: v for k, v in task_types.items() if v in load_task_types} + except Exception: + return task_types def get_savable_visit_types(privileged_user: bool = False) -> List[str]: