Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/interface.py
# Copyright (C) 2021-2022 The Software Heritage developers | # Copyright (C) 2021-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 General Public License version 3, or any later version | # License: GNU 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 __future__ import annotations | from __future__ import annotations | ||||||||||
from dataclasses import dataclass | from dataclasses import dataclass | ||||||||||
from datetime import datetime | from datetime import datetime | ||||||||||
import enum | import enum | ||||||||||
from types import TracebackType | from types import TracebackType | ||||||||||
from typing import Dict, Generator, Iterable, Optional, Set, Type, Union | from typing import Dict, Generator, Iterable, List, Optional, Set, Type, Union | ||||||||||
from typing_extensions import Protocol, runtime_checkable | from typing_extensions import Protocol, runtime_checkable | ||||||||||
from swh.core.api import remote_api_endpoint | from swh.core.api import remote_api_endpoint | ||||||||||
from swh.model.model import Sha1Git | from swh.model.model import Sha1Git | ||||||||||
from .model import DirectoryEntry, FileEntry, OriginEntry, RevisionEntry | from .model import DirectoryEntry, FileEntry, OriginEntry, RevisionEntry | ||||||||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | class ProvenanceStorageInterface(Protocol): | ||||||||||
@remote_api_endpoint("directory_get") | @remote_api_endpoint("directory_get") | ||||||||||
def directory_get(self, ids: Iterable[Sha1Git]) -> Dict[Sha1Git, DirectoryData]: | def directory_get(self, ids: Iterable[Sha1Git]) -> Dict[Sha1Git, DirectoryData]: | ||||||||||
"""Retrieve the associated date and (optional) flatten flag for each directory | """Retrieve the associated date and (optional) flatten flag for each directory | ||||||||||
sha1 in `ids`. If some directories has no associated date, it is not present in | sha1 in `ids`. If some directories has no associated date, it is not present in | ||||||||||
the resulting dictionary. | the resulting dictionary. | ||||||||||
""" | """ | ||||||||||
... | ... | ||||||||||
@remote_api_endpoint("directory_iter_not_flattenned") | |||||||||||
def directory_iter_not_flattenned( | |||||||||||
self, limit: int, start_id: Sha1Git | |||||||||||
) -> List[Sha1Git]: | |||||||||||
olasdUnsubmitted Done Inline Actions
olasd: | |||||||||||
"""Retrieve the unflattenned directories after ``start_id`` up to ``limit`` entries.""" | |||||||||||
... | |||||||||||
@remote_api_endpoint("entity_get_all") | @remote_api_endpoint("entity_get_all") | ||||||||||
def entity_get_all(self, entity: EntityType) -> Set[Sha1Git]: | def entity_get_all(self, entity: EntityType) -> Set[Sha1Git]: | ||||||||||
"""Retrieve all sha1 ids for entities of type `entity` present in the provenance | """Retrieve all sha1 ids for entities of type `entity` present in the provenance | ||||||||||
model. This method is used only in tests. | model. This method is used only in tests. | ||||||||||
""" | """ | ||||||||||
... | ... | ||||||||||
@remote_api_endpoint("location_add") | @remote_api_endpoint("location_add") | ||||||||||
▲ Show 20 Lines • Show All 247 Lines • Show Last 20 Lines |