Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/origin.py
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
@api_doc('/origins/', noargs=True) | @api_doc('/origins/', noargs=True) | ||||
@format_docstring(return_origin_array=DOC_RETURN_ORIGIN_ARRAY) | @format_docstring(return_origin_array=DOC_RETURN_ORIGIN_ARRAY) | ||||
def api_origins(request): | def api_origins(request): | ||||
""" | """ | ||||
.. http:get:: /api/1/origins/ | .. http:get:: /api/1/origins/ | ||||
Get list of archived software origins. | Get list of archived software origins. | ||||
Origins are sorted by ids before returning them. | .. warning:: | ||||
This endpoint used to provide an `origin_from` query parameter, | |||||
and guarantee an order on results. This is no longer true, | |||||
and only the Link header should be used for paginating through | |||||
results. | |||||
:query int origin_from: The first origin id that will be included | |||||
in returned results (default to 1) | |||||
:query int origin_count: The maximum number of origins to return | :query int origin_count: The maximum number of origins to return | ||||
(default to 100, can not exceed 10000) | (default to 100, can not exceed 10000) | ||||
{return_origin_array} | {return_origin_array} | ||||
{common_headers} | {common_headers} | ||||
{resheader_link} | {resheader_link} | ||||
**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 | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
:swh_web_api:`origins?origin_from=50000&origin_count=500` | :swh_web_api:`origins?origin_count=500` | ||||
""" | """ | ||||
origin_from = int(request.query_params.get('origin_from', '1')) | origin_from = int(request.query_params.get('origin_from', '1')) | ||||
origin_count = int(request.query_params.get('origin_count', '100')) | origin_count = int(request.query_params.get('origin_count', '100')) | ||||
origin_count = min(origin_count, 10000) | origin_count = min(origin_count, 10000) | ||||
results = api_lookup( | results = api_lookup( | ||||
service.lookup_origins, origin_from, origin_count+1, | service.lookup_origins, origin_from, origin_count+1, | ||||
enrich_fn=_enrich_origin) | enrich_fn=_enrich_origin) | ||||
response = {'results': results, 'headers': {}} | response = {'results': results, 'headers': {}} | ||||
▲ Show 20 Lines • Show All 410 Lines • Show Last 20 Lines |