Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/interface.py
# Copyright (C) 2015-2022 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 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 typing import Dict, Iterable, List, Optional, Tuple, TypeVar, Union | from typing import Dict, Iterable, List, Optional, Tuple, TypeVar, 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.core.api.classes import PagedResult as CorePagedResult | from swh.core.api.classes import PagedResult as CorePagedResult | ||||
from swh.indexer.storage.model import ( | from swh.indexer.storage.model import ( | ||||
ContentLanguageRow, | |||||
ContentLicenseRow, | ContentLicenseRow, | ||||
ContentMetadataRow, | ContentMetadataRow, | ||||
ContentMimetypeRow, | ContentMimetypeRow, | ||||
DirectoryIntrinsicMetadataRow, | DirectoryIntrinsicMetadataRow, | ||||
OriginExtrinsicMetadataRow, | OriginExtrinsicMetadataRow, | ||||
OriginIntrinsicMetadataRow, | OriginIntrinsicMetadataRow, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | def content_mimetype_get(self, ids: Iterable[Sha1]) -> List[ContentMimetypeRow]: | ||||
ids: sha1 identifiers | ids: sha1 identifiers | ||||
Returns: | Returns: | ||||
mimetype row objects | mimetype row objects | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("content_language/missing") | |||||
def content_language_missing( | |||||
self, languages: Iterable[Dict] | |||||
) -> List[Tuple[Sha1, int]]: | |||||
"""List languages missing from storage. | |||||
Args: | |||||
languages (iterable): dictionaries with keys: | |||||
- **id** (bytes): sha1 identifier | |||||
- **indexer_configuration_id** (int): tool used to compute | |||||
the results | |||||
Returns: | |||||
list of tuple (id, indexer_configuration_id) missing | |||||
""" | |||||
... | |||||
@remote_api_endpoint("content_language") | |||||
def content_language_get(self, ids: Iterable[Sha1]) -> List[ContentLanguageRow]: | |||||
"""Retrieve full content language per ids. | |||||
Args: | |||||
ids (iterable): sha1 identifier | |||||
Returns: | |||||
language row objects | |||||
""" | |||||
... | |||||
@remote_api_endpoint("content_language/add") | |||||
def content_language_add( | |||||
self, languages: List[ContentLanguageRow] | |||||
) -> Dict[str, int]: | |||||
"""Add languages not present in storage. | |||||
Args: | |||||
languages: language row objects | |||||
Returns: | |||||
Dict summary of number of rows added | |||||
""" | |||||
... | |||||
@remote_api_endpoint("content/fossology_license") | @remote_api_endpoint("content/fossology_license") | ||||
def content_fossology_license_get( | def content_fossology_license_get( | ||||
self, ids: Iterable[Sha1] | self, ids: Iterable[Sha1] | ||||
) -> List[ContentLicenseRow]: | ) -> List[ContentLicenseRow]: | ||||
"""Retrieve licenses per id. | """Retrieve licenses per id. | ||||
Args: | Args: | ||||
ids: sha1 identifiers | ids: sha1 identifiers | ||||
▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines |