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 typing import Dict, Iterable, List, Optional, Tuple, TypeVar, Union | from typing import Dict, Iterable, List, Optional, Tuple, TypeVar, Union | ||||
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 SWHID | from swh.model.identifiers import SWHID | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
Content, | Content, | ||||
Directory, | Directory, | ||||
Origin, | Origin, | ||||
OriginVisit, | OriginVisit, | ||||
OriginVisitStatus, | OriginVisitStatus, | ||||
Revision, | Revision, | ||||
Release, | Release, | ||||
Snapshot, | Snapshot, | ||||
SkippedContent, | SkippedContent, | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
MetadataTargetType, | MetadataTargetType, | ||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | ||||
) | ) | ||||
vlorentz: docstring | |||||
Done Inline ActionsI don't really know what to say ;) ardumont: I don't really know what to say ;) | |||||
Done Inline Actionsin the docstring i mean. ardumont: in the docstring i mean. | |||||
Done Inline Actions"""Specifies the order for paginated endpoints returning sorted results.""" vlorentz: """Specifies the order for paginated endpoints returning sorted results.""" | |||||
def deprecated(f): | class ListOrder(Enum): | ||||
f.deprecated_endpoint = True | """Specifies the order for paginated endpoints returning sorted results.""" | ||||
return f | |||||
ASC = "asc" | |||||
DESC = "desc" | |||||
TResult = TypeVar("TResult") | TResult = TypeVar("TResult") | ||||
PagedResult = CorePagedResult[TResult, str] | PagedResult = CorePagedResult[TResult, str] | ||||
def deprecated(f): | |||||
f.deprecated_endpoint = True | |||||
return f | |||||
class StorageInterface: | class StorageInterface: | ||||
@remote_api_endpoint("check_config") | @remote_api_endpoint("check_config") | ||||
def check_config(self, *, check_write): | def check_config(self, *, check_write): | ||||
"""Check that the storage is configured and ready to go.""" | """Check that the storage is configured and ready to go.""" | ||||
... | ... | ||||
@remote_api_endpoint("content/add") | @remote_api_endpoint("content/add") | ||||
def content_add(self, content: Iterable[Content]) -> Dict: | def content_add(self, content: Iterable[Content]) -> Dict: | ||||
▲ Show 20 Lines • Show All 746 Lines • ▼ Show 20 Lines | ) -> None: | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("origin/visit/get") | @remote_api_endpoint("origin/visit/get") | ||||
def origin_visit_get( | def origin_visit_get( | ||||
self, | self, | ||||
origin: str, | origin: str, | ||||
page_token: Optional[str] = None, | page_token: Optional[str] = None, | ||||
order: str = "asc", | order: ListOrder = ListOrder.ASC, | ||||
limit: int = 10, | limit: int = 10, | ||||
) -> PagedResult[OriginVisit]: | ) -> PagedResult[OriginVisit]: | ||||
"""Retrieve page of OriginVisit information. | """Retrieve page of OriginVisit information. | ||||
Args: | Args: | ||||
origin: The visited origin | origin: The visited origin | ||||
page_token: opaque string used to get the next results of a search | page_token: opaque string used to get the next results of a search | ||||
order: Order on visit id fields to list origin visits (default to asc) | order: Order on visit id fields to list origin visits (default to asc) | ||||
▲ Show 20 Lines • Show All 455 Lines • Show Last 20 Lines |
docstring