Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/origin.py
Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | .. http:get:: /api/1/origin/search/(url_pattern)/ | ||||
.. warning:: | .. warning:: | ||||
This endpoint used to provide an ``offset`` query parameter, | This endpoint used to provide an ``offset`` query parameter, | ||||
and guarantee an order on results. This is no longer true, | and guarantee an order on results. This is no longer true, | ||||
and only the Link header should be used for paginating through | and only the Link header should be used for paginating through | ||||
results. | results. | ||||
:param string url_pattern: a string pattern | :param string url_pattern: a string pattern | ||||
:query string query_string: search query language string | |||||
:query int limit: the maximum number of found origins to return | :query int limit: the maximum number of found origins to return | ||||
(bounded to 1000) | (bounded to 1000) | ||||
:query boolean with_visit: if true, only return origins with at least | :query boolean with_visit: if true, only return origins with at least | ||||
one visit by Software heritage | one visit by Software heritage | ||||
{return_origin_array} | {return_origin_array} | ||||
{common_headers} | {common_headers} | ||||
{resheader_link} | {resheader_link} | ||||
:statuscode 200: no error | :statuscode 200: no error | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
:swh_web_api:`origin/search/python/?limit=2` | :swh_web_api:`origin/search/python/?limit=2` | ||||
""" | """ | ||||
result = {} | result = {} | ||||
limit = min(int(request.query_params.get("limit", "70")), 1000) | limit = min(int(request.query_params.get("limit", "70")), 1000) | ||||
page_token = request.query_params.get("page_token") | page_token = request.query_params.get("page_token") | ||||
query_string = request.query_params.get("query", "") | |||||
with_visit = request.query_params.get("with_visit", "false") | with_visit = request.query_params.get("with_visit", "false") | ||||
visit_type = request.query_params.get("visit_type") | visit_type = request.query_params.get("visit_type") | ||||
(results, page_token) = api_lookup( | (results, page_token) = api_lookup( | ||||
archive.search_origin, | archive.search_origin, | ||||
url_pattern, | url_pattern, | ||||
query_string, | |||||
limit, | limit, | ||||
bool(strtobool(with_visit)), | bool(strtobool(with_visit)), | ||||
[visit_type] if visit_type else None, | [visit_type] if visit_type else None, | ||||
page_token, | page_token, | ||||
enrich_fn=enrich_origin_search_result, | enrich_fn=enrich_origin_search_result, | ||||
request=request, | request=request, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 270 Lines • Show Last 20 Lines |