Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/views/api.py
Show First 20 Lines • Show All 483 Lines • ▼ Show 20 Lines | Example: | ||||
GET /api/1/revision/baf18f9fc50a0b6fef50460a76c33b2ddc57486e | GET /api/1/revision/baf18f9fc50a0b6fef50460a76c33b2ddc57486e | ||||
""" | """ | ||||
return _api_lookup( | return _api_lookup( | ||||
sha1_git, | sha1_git, | ||||
lookup_fn=service.lookup_revision, | lookup_fn=service.lookup_revision, | ||||
error_msg_if_not_found='Revision with sha1_git %s not' | error_msg_if_not_found='Revision with sha1_git %s not' | ||||
' found.' % sha1_git, | ' found.' % sha1_git, | ||||
enrich_fn=utils.enrich_revision) | enrich_fn=utils.enrich_revision) | ||||
ardumont: That'd be here that i'd add the message_url if message is None.
In utils.enrich_revision's… | |||||
@app.route('/api/1/revision/<string:sha1_git>/raw/') | @app.route('/api/1/revision/<string:sha1_git>/raw/') | ||||
def api_revision_raw_message(sha1_git): | def api_revision_raw_message(sha1_git): | ||||
"""Return the raw data of the revision's message | """Return the raw data of the revision's message | ||||
Args: | Args: | ||||
sha1_git: the revision's hash | sha1_git: the revision's hash | ||||
Returns: | Returns: | ||||
The raw revision message, possibly in an illegible | The raw revision message, possibly in an illegible | ||||
format for humans, decoded in utf-8 by default. | format for humans, decoded in utf-8 by default. | ||||
Raises: | Raises: | ||||
BadInputExc in case of unknown algo_hash or bad hash. | BadInputExc in case of unknown algo_hash or bad hash. | ||||
NotFoundExc if the revision is not found or the revision has no | NotFoundExc if the revision is not found or the revision has no | ||||
message | message | ||||
Example: | Example: | ||||
GET /api/1/revision/baf18f9fc50a0b6fef50460a76c33b2ddc57486e/raw/ | GET /api/1/revision/baf18f9fc50a0b6fef50460a76c33b2ddc57486e/raw/ | ||||
""" | """ | ||||
raw = service.lookup_revision_message(sha1_git) | |||||
return service.lookup_revision_message(sha1_git) | return Response(raw['message'], | ||||
headers={'Content-disposition': 'attachment;' | |||||
'filename=rev_%s_raw' % sha1_git}, | |||||
mimetype='application/octet-stream') | |||||
@app.route('/api/1/revision/<string:sha1_git>/directory/') | @app.route('/api/1/revision/<string:sha1_git>/directory/') | ||||
@app.route('/api/1/revision/<string:sha1_git>/directory/<path:dir_path>/') | @app.route('/api/1/revision/<string:sha1_git>/directory/<path:dir_path>/') | ||||
def api_revision_directory(sha1_git, | def api_revision_directory(sha1_git, | ||||
dir_path=None, | dir_path=None, | ||||
with_data=False): | with_data=False): | ||||
"""Return information on directory pointed by revision with sha1_git. | """Return information on directory pointed by revision with sha1_git. | ||||
▲ Show 20 Lines • Show All 376 Lines • Show Last 20 Lines |
That'd be here that i'd add the message_url if message is None.
In utils.enrich_revision's function definition (to be transverse to all).
utils is not api agnostic.