Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/apiurls.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import functools | import functools | ||||
from typing import Dict | |||||
from rest_framework.decorators import api_view | from rest_framework.decorators import api_view | ||||
from swh.web.common.urlsindex import UrlsIndex | from swh.web.common.urlsindex import UrlsIndex | ||||
from swh.web.common import throttling | from swh.web.common import throttling | ||||
class APIUrls(UrlsIndex): | class APIUrls(UrlsIndex): | ||||
""" | """ | ||||
Class to manage API documentation URLs. | Class to manage API documentation URLs. | ||||
- Indexes all routes documented using apidoc's decorators. | - Indexes all routes documented using apidoc's decorators. | ||||
- Tracks endpoint/request processing method relationships for use in | - Tracks endpoint/request processing method relationships for use in | ||||
generating related urls in API documentation | generating related urls in API documentation | ||||
""" | """ | ||||
_apidoc_routes = {} | _apidoc_routes = {} # type: Dict[str, Dict[str, str]] | ||||
_method_endpoints = {} | |||||
scope = 'api' | scope = 'api' | ||||
@classmethod | @classmethod | ||||
def get_app_endpoints(cls): | def get_app_endpoints(cls): | ||||
return cls._apidoc_routes | return cls._apidoc_routes | ||||
@classmethod | @classmethod | ||||
def add_route(cls, route, docstring, **kwargs): | def add_route(cls, route, docstring, **kwargs): | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |