Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/vault.py
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | .. http:post:: /api/1/vault/directory/(dir_id)/ | ||||
(either **new**, **pending**, **done** or **failed**) | (either **new**, **pending**, **done** or **failed**) | ||||
:>json string obj_id: the identifier of the object to cook | :>json string obj_id: the identifier of the object to cook | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, | **Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, | ||||
:http:method:`head`, :http:method:`options` | :http:method:`head`, :http:method:`options` | ||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid directory identifier has been provided | :statuscode 400: an invalid directory identifier has been provided | ||||
:statuscode 404: requested directory can not be found in the archive | :statuscode 404: requested directory did not receive any cooking | ||||
request yet (in case of GET) or can not be found in the archive | |||||
(in case of POST) | |||||
anlambert: Indeed, this is the meaning of the 404 code in case of a GET request:
```
15:39 $ curl http… | |||||
""" | """ | ||||
_, obj_id = query.parse_hash_with_algorithms_or_throws( | _, obj_id = query.parse_hash_with_algorithms_or_throws( | ||||
dir_id, ['sha1'], 'Only sha1_git is supported.') | dir_id, ['sha1'], 'Only sha1_git is supported.') | ||||
res = _dispatch_cook_progress(request, 'directory', obj_id) | res = _dispatch_cook_progress(request, 'directory', obj_id) | ||||
res['fetch_url'] = reverse('api-1-vault-fetch-directory', | res['fetch_url'] = reverse('api-1-vault-fetch-directory', | ||||
url_args={'dir_id': dir_id}) | url_args={'dir_id': dir_id}) | ||||
return res | return res | ||||
Show All 16 Lines | .. http:get:: /api/1/vault/directory/(dir_id)/raw/ | ||||
:resheader Content-Type: application/octet-stream | :resheader Content-Type: application/octet-stream | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, | **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, | ||||
:http:method:`options` | :http:method:`options` | ||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid directory identifier has been provided | :statuscode 400: an invalid directory identifier has been provided | ||||
:statuscode 404: requested directory can not be found in the archive | :statuscode 404: requested directory did not receive any cooking | ||||
request yet (in case of GET) or can not be found in the archive | |||||
(in case of POST) | |||||
""" | """ | ||||
_, obj_id = query.parse_hash_with_algorithms_or_throws( | _, obj_id = query.parse_hash_with_algorithms_or_throws( | ||||
dir_id, ['sha1'], 'Only sha1_git is supported.') | dir_id, ['sha1'], 'Only sha1_git is supported.') | ||||
res = api_lookup( | res = api_lookup( | ||||
service.vault_fetch, 'directory', obj_id, | service.vault_fetch, 'directory', obj_id, | ||||
notfound_msg="Directory with ID '{}' not found.".format(dir_id)) | notfound_msg="Directory with ID '{}' not found.".format(dir_id)) | ||||
fname = '{}.tar.gz'.format(dir_id) | fname = '{}.tar.gz'.format(dir_id) | ||||
response = HttpResponse(res, content_type='application/gzip') | response = HttpResponse(res, content_type='application/gzip') | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | .. http:post:: /api/1/vault/revision/(rev_id)/gitfast/ | ||||
:>json string status: the cooking task status (new/pending/done/failed) | :>json string status: the cooking task status (new/pending/done/failed) | ||||
:>json string obj_id: the identifier of the object to cook | :>json string obj_id: the identifier of the object to cook | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, | **Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, | ||||
:http:method:`head`, :http:method:`options` | :http:method:`head`, :http:method:`options` | ||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid revision identifier has been provided | :statuscode 400: an invalid revision identifier has been provided | ||||
:statuscode 404: requested revision can not be found in the archive | :statuscode 404: requested directory did not receive any cooking | ||||
request yet (in case of GET) or can not be found in the archive | |||||
(in case of POST) | |||||
""" | """ | ||||
_, obj_id = query.parse_hash_with_algorithms_or_throws( | _, obj_id = query.parse_hash_with_algorithms_or_throws( | ||||
rev_id, ['sha1'], 'Only sha1_git is supported.') | rev_id, ['sha1'], 'Only sha1_git is supported.') | ||||
res = _dispatch_cook_progress(request, 'revision_gitfast', obj_id) | res = _dispatch_cook_progress(request, 'revision_gitfast', obj_id) | ||||
res['fetch_url'] = reverse('api-1-vault-fetch-revision_gitfast', | res['fetch_url'] = reverse('api-1-vault-fetch-revision_gitfast', | ||||
url_args={'rev_id': rev_id}) | url_args={'rev_id': rev_id}) | ||||
return res | return res | ||||
Show All 16 Lines | .. http:get:: /api/1/vault/revision/(rev_id)/gitfast/raw/ | ||||
:resheader Content-Type: application/octet-stream | :resheader Content-Type: application/octet-stream | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, | **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, | ||||
:http:method:`options` | :http:method:`options` | ||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid revision identifier has been provided | :statuscode 400: an invalid revision identifier has been provided | ||||
:statuscode 404: requested revision can not be found in the archive | :statuscode 404: requested directory did not receive any cooking | ||||
request yet (in case of GET) or can not be found in the archive | |||||
(in case of POST) | |||||
""" | """ | ||||
_, obj_id = query.parse_hash_with_algorithms_or_throws( | _, obj_id = query.parse_hash_with_algorithms_or_throws( | ||||
rev_id, ['sha1'], 'Only sha1_git is supported.') | rev_id, ['sha1'], 'Only sha1_git is supported.') | ||||
res = api_lookup( | res = api_lookup( | ||||
service.vault_fetch, 'revision_gitfast', obj_id, | service.vault_fetch, 'revision_gitfast', obj_id, | ||||
notfound_msg="Revision with ID '{}' not found.".format(rev_id)) | notfound_msg="Revision with ID '{}' not found.".format(rev_id)) | ||||
fname = '{}.gitfast.gz'.format(rev_id) | fname = '{}.gitfast.gz'.format(rev_id) | ||||
response = HttpResponse(res, content_type='application/gzip') | response = HttpResponse(res, content_type='application/gzip') | ||||
Show All 17 Lines |
Indeed, this is the meaning of the 404 code in case of a GET request:
But in case of a POST request, the 404 code really means that the directory is not archived:
So to be exhaustive in the doc, both cases should be present.