Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/interface.py
# Copyright (C) 2015-2020 The Software Heritage developers | # Copyright (C) 2015-2020 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 | |||||||||
import datetime | import datetime | |||||||||
from enum import Enum | from enum import Enum | |||||||||
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, TypeVar | from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, TypeVar | |||||||||
from typing_extensions import Protocol, TypedDict, runtime_checkable | from typing_extensions import Protocol, TypedDict, runtime_checkable | |||||||||
from swh.core.api import remote_api_endpoint | from swh.core.api import remote_api_endpoint | |||||||||
from swh.core.api.classes import PagedResult as CorePagedResult | from swh.core.api.classes import PagedResult as CorePagedResult | |||||||||
from swh.model.identifiers import ExtendedSWHID | from swh.model.identifiers import ExtendedSWHID, ObjectType | |||||||||
from swh.model.model import ( | from swh.model.model import ( | |||||||||
Content, | Content, | |||||||||
Directory, | Directory, | |||||||||
ExtID, | ||||||||||
MetadataAuthority, | MetadataAuthority, | |||||||||
MetadataAuthorityType, | MetadataAuthorityType, | |||||||||
MetadataFetcher, | MetadataFetcher, | |||||||||
Origin, | Origin, | |||||||||
OriginVisit, | OriginVisit, | |||||||||
OriginVisitStatus, | OriginVisitStatus, | |||||||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | |||||||||
Release, | Release, | |||||||||
▲ Show 20 Lines • Show All 469 Lines • ▼ Show 20 Lines | def revision_get(self, revision_ids: List[Sha1Git]) -> List[Optional[Revision]]: | |||||||||
revisions: revision ids | revisions: revision ids | |||||||||
Returns: | Returns: | |||||||||
list of revision object (if the revision exists or None otherwise) | list of revision object (if the revision exists or None otherwise) | |||||||||
""" | """ | |||||||||
... | ... | |||||||||
@remote_api_endpoint("extid/from_extid") | ||||||||||
def extid_get_from_extid( | ||||||||||
self, id_type: str, ids: List[bytes] | ||||||||||
) -> List[Optional[ExtID]]: | ||||||||||
"""Get ExtID objects from external IDs | ||||||||||
Args: | ||||||||||
vlorentzUnsubmitted Not Done Inline Actions
vlorentz: | ||||||||||
id_type: type the external identifiers the SWH objects comes from | ||||||||||
ids: list of external IDs | ||||||||||
Returns: | ||||||||||
list of ExtID objects (if the ext ID is known, None otherwise) | ||||||||||
""" | ||||||||||
... | ||||||||||
@remote_api_endpoint("extid/from_target") | ||||||||||
def extid_get_from_target( | ||||||||||
self, target_type: ObjectType, ids: List[Sha1Git] | ||||||||||
) -> List[Optional[ExtID]]: | ||||||||||
Not Done Inline Actions
vlorentz: | ||||||||||
"""Get ExtID objects from target IDs and taget_type | ||||||||||
Args: | ||||||||||
target_type: type the SWH object | ||||||||||
ids: list of target IDs | ||||||||||
Returns: | ||||||||||
list of ExtID objects (if the SWH ID is known, None otherwise) | ||||||||||
""" | ||||||||||
... | ||||||||||
@remote_api_endpoint("extid/add") | ||||||||||
def extid_add(self, ids: List[ExtID]) -> Dict[str, int]: | ||||||||||
"""Add a series of ExtID objects | ||||||||||
Args: | ||||||||||
ids: list of ExtID objects | ||||||||||
Returns: | ||||||||||
Summary dict of keys with associated count as values | ||||||||||
extid:add: New ExtID objects actually stored in db | ||||||||||
""" | ||||||||||
... | ||||||||||
@remote_api_endpoint("revision/log") | @remote_api_endpoint("revision/log") | |||||||||
def revision_log( | def revision_log( | |||||||||
self, revisions: List[Sha1Git], limit: Optional[int] = None | self, revisions: List[Sha1Git], limit: Optional[int] = None | |||||||||
) -> Iterable[Optional[Dict[str, Any]]]: | ) -> Iterable[Optional[Dict[str, Any]]]: | |||||||||
"""Fetch revision entry from the given root revisions. | """Fetch revision entry from the given root revisions. | |||||||||
Args: | Args: | |||||||||
revisions: array of root revisions to lookup | revisions: array of root revisions to lookup | |||||||||
▲ Show 20 Lines • Show All 688 Lines • Show Last 20 Lines |