Changeset View
Changeset View
Standalone View
Standalone View
swh/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 | ||||
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, Union | ||||
import attr | import attr | ||||
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.model import ( | from swh.model.model import ( | ||||
Content, | Content, | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | def content_add_metadata(self, content: List[Content]) -> Dict[str, int]: | ||||
Summary dict with the following key and associated values: | Summary dict with the following key and associated values: | ||||
content:add: New contents added | content:add: New contents added | ||||
skipped_content:add: New skipped contents (no data) added | skipped_content:add: New skipped contents (no data) added | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("content/data") | @remote_api_endpoint("content/data") | ||||
def content_get_data(self, content: Sha1) -> Optional[bytes]: | def content_get_data(self, content: Union[HashDict, Sha1]) -> Optional[bytes]: | ||||
"""Given a content identifier, returns its associated data if any. | """Given a content identifier, returns its associated data if any. | ||||
Args: | Args: | ||||
content: sha1 identifier | content: dict of hashes (or just sha1 identifier) | ||||
Returns: | Returns: | ||||
raw content data (bytes) | raw content data (bytes) | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("content/partition") | @remote_api_endpoint("content/partition") | ||||
▲ Show 20 Lines • Show All 1,221 Lines • Show Last 20 Lines |