Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/directory.py
# Copyright (C) 2015-2019 The Software Heritage developers | # Copyright (C) 2015-2022 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 | ||||
from typing import Optional | |||||
from rest_framework.request import Request | |||||
from swh.web.api import utils | from swh.web.api import utils | ||||
from swh.web.api.apidoc import api_doc, format_docstring | from swh.web.api.apidoc import api_doc, format_docstring | ||||
from swh.web.api.apiurls import api_route | from swh.web.api.apiurls import api_route | ||||
from swh.web.api.views.utils import api_lookup | from swh.web.api.views.utils import api_lookup | ||||
from swh.web.common import archive | from swh.web.common import archive | ||||
@api_route( | @api_route( | ||||
r"/directory/(?P<sha1_git>[0-9a-f]+)/", | r"/directory/(?P<sha1_git>[0-9a-f]+)/", | ||||
"api-1-directory", | "api-1-directory", | ||||
checksum_args=["sha1_git"], | checksum_args=["sha1_git"], | ||||
) | ) | ||||
@api_route( | @api_route( | ||||
r"/directory/(?P<sha1_git>[0-9a-f]+)/(?P<path>.+)/", | r"/directory/(?P<sha1_git>[0-9a-f]+)/(?P<path>.+)/", | ||||
"api-1-directory", | "api-1-directory", | ||||
checksum_args=["sha1_git"], | checksum_args=["sha1_git"], | ||||
) | ) | ||||
@api_doc("/directory/") | @api_doc("/directory/") | ||||
@format_docstring() | @format_docstring() | ||||
def api_directory(request, sha1_git, path=None): | def api_directory(request: Request, sha1_git: str, path: Optional[str] = None): | ||||
""" | """ | ||||
.. http:get:: /api/1/directory/(sha1_git)/[(path)/] | .. http:get:: /api/1/directory/(sha1_git)/[(path)/] | ||||
Get information about directory objects. | Get information about directory objects. | ||||
Directories are identified by **sha1** checksums, compatible with Git | Directories are identified by **sha1** checksums, compatible with Git | ||||
directory identifiers. | directory identifiers. | ||||
See :func:`swh.model.git_objects.directory_git_object` in our data model | See :func:`swh.model.git_objects.directory_git_object` in our data model | ||||
module for details about how they are computed. | module for details about how they are computed. | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |