swh.web.api.apiurls module#
- class swh.web.api.apiurls.APIUrls[source]#
Bases:
UrlsIndex
Class to manage API URLs and endpoint documentation URLs.
- apidoc_routes: Dict[str, Dict[str, str]] = {'/add-forge/request/create': {'category': 'Request archival', 'docstring': '', 'route': '/api/1/add-forge/request/create', 'route_view_name': 'api-1-add-forge-request-creat-doc', 'tags': {}}, '/add-forge/request/get': {'category': 'Request archival', 'docstring': '', 'route': '/api/1/add-forge/request/get', 'route_view_name': 'api-1-add-forge-request-ge-doc', 'tags': {}}, '/add-forge/request/list': {'category': 'Request archival', 'docstring': '', 'route': '/api/1/add-forge/request/list', 'route_view_name': 'api-1-add-forge-request-lis-doc', 'tags': {}}}#
- swh.web.api.apiurls.api_route(url_pattern: str, view_name: str, methods: ~typing.List[str] = ['GET', 'HEAD', 'OPTIONS'], throttle_scope: str = 'swh_api', api_version: str = '1', checksum_args: ~typing.Optional[~typing.List[str]] = None, never_cache: bool = False, api_urls: ~swh.web.api.apiurls.APIUrls = <swh.web.api.apiurls.APIUrls object>)[source]#
Decorator to ease the registration of an API endpoint using the Django REST Framework.
- Parameters:
url_pattern – the url pattern used by DRF to identify the API route
view_name – the name of the API view associated to the route used to reverse the url
methods – array of HTTP methods supported by the API route
throttle_scope – Named scope for rate limiting
api_version – web API version
checksum_args – list of view argument names holding checksum values
never_cache – define if api response must be cached