Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/identifiers.py
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | def api_resolve_swhid(request, swhid): | ||||
# id is well-formed, now check that the pointed | # id is well-formed, now check that the pointed | ||||
# object is present in the archive, NotFoundExc | # object is present in the archive, NotFoundExc | ||||
# will be raised otherwise | # will be raised otherwise | ||||
swhid_parsed = swhid_resolved["swhid_parsed"] | swhid_parsed = swhid_resolved["swhid_parsed"] | ||||
object_type = swhid_parsed.object_type | object_type = swhid_parsed.object_type | ||||
object_id = swhid_parsed.object_id | object_id = swhid_parsed.object_id | ||||
service.lookup_object(object_type, object_id) | service.lookup_object(object_type, object_id) | ||||
# id is well-formed and the pointed object exists | # id is well-formed and the pointed object exists | ||||
swhid_data = swhid_parsed._asdict() | swhid_data = swhid_parsed.to_dict() | ||||
swhid_data["browse_url"] = request.build_absolute_uri(swhid_resolved["browse_url"]) | swhid_data["browse_url"] = request.build_absolute_uri(swhid_resolved["browse_url"]) | ||||
return swhid_data | return swhid_data | ||||
@api_route(r"/known/", "api-1-known", methods=["POST"]) | @api_route(r"/known/", "api-1-known", methods=["POST"]) | ||||
@api_doc("/known/") | @api_doc("/known/") | ||||
@format_docstring() | @format_docstring() | ||||
def api_swhid_known(request): | def api_swhid_known(request): | ||||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |