diff --git a/docs/uri-scheme-api-identifiers.rst b/docs/uri-scheme-api-identifiers.rst --- a/docs/uri-scheme-api-identifiers.rst +++ b/docs/uri-scheme-api-identifiers.rst @@ -2,3 +2,6 @@ ---------------------- .. autosimple:: swh.web.api.views.identifiers.api_resolve_swh_pid + +.. autosimple:: swh.web.api.views.identifiers.api_swh_pid_known + diff --git a/swh/web/api/views/identifiers.py b/swh/web/api/views/identifiers.py --- a/swh/web/api/views/identifiers.py +++ b/swh/web/api/views/identifiers.py @@ -67,23 +67,32 @@ @api_route(r'/known/', - 'api-1-swh-pid-known', methods=['POST']) -@api_doc('/known/', tags=['hidden']) + 'api-1-known', methods=['POST']) +@api_doc('/known/') @format_docstring() def api_swh_pid_known(request): """ .. http:post:: /api/1/known/ - Check if a list of Software Heritage persistent identifier is present - in the archive depending on their id (sha1_git). + Check if a list of objects are present in the Software Heritage archive. - Returns: - A dictionary with: - keys(str): Persistent identifier - values(dict): A dictionary containing the key 'known'. (true if - the pid is present, False otherwise) + The objects to check existence must be provided using Software Heritage + persistent identifiers (based on sha1_git checksums). - """ + :json object : an object whose keys are input persistent identifiers + and values objects with the following keys: + + * **known (bool)**: whether the object was found + + {common_headers} + + **Allowed HTTP Methods:** :http:method:`post`, :http:method:`head`, :http:method:`options` + + :statuscode 200: no error + :statuscode 400: an invalid persistent identifier has been provided + """ # noqa persistent_ids = [get_persistent_identifier(pid) for pid in request.data] diff --git a/swh/web/tests/api/views/test_identifiers.py b/swh/web/tests/api/views/test_identifiers.py --- a/swh/web/tests/api/views/test_identifiers.py +++ b/swh/web/tests/api/views/test_identifiers.py @@ -109,7 +109,7 @@ input_pids = [content_, directory_, unknown_revision_, unknown_release_, unknown_snapshot_] - url = reverse('api-1-swh-pid-known') + url = reverse('api-1-known') resp = api_client.post(url, data=input_pids, format='json', HTTP_ACCEPT='application/json') @@ -129,7 +129,7 @@ invalid_pid_sha1 = ['swh:1:cnt:8068d0075010b590762c6cb5682ed53cb3c13de;'] invalid_pid_type = ['swh:1:cnn:8068d0075010b590762c6cb5682ed53cb3c13deb'] - url = reverse('api-1-swh-pid-known') + url = reverse('api-1-known') resp = api_client.post(url, data=invalid_pid_sha1, format='json', HTTP_ACCEPT='application/json')