swh.web.api.apiurls module

class swh.web.api.apiurls.APIUrls[source]

Bases: swh.web.utils.urlsindex.UrlsIndex

Class to manage API documentation URLs.

  • Indexes all routes documented using apidoc’s decorators.

  • Tracks endpoint/request processing method relationships for use in generating related urls in API documentation

scope = 'api'
classmethod get_app_endpoints() Dict[str, Dict[str, str]][source]
classmethod add_doc_route(route: str, category: typing_extensions.Literal[Archive, Batch download, Metadata, Request archival, Miscellaneous, test], docstring: str, noargs: bool = False, api_version: str = '1', **kwargs) None[source]

Add a route to the self-documenting API reference

swh.web.api.apiurls.api_route(url_pattern: str, view_name: str, methods: List[str] = ['GET', 'HEAD', 'OPTIONS'], throttle_scope: str = 'swh_api', api_version: str = '1', checksum_args: Optional[List[str]] = None, never_cache: bool = False)[source]

Decorator to ease the registration of an API endpoint using the Django REST Framework.

  • 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