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, Union | 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 SWHID | |||||
from swh.model.model import ( | from swh.model.model import ( | ||||
Content, | Content, | ||||
Directory, | Directory, | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
MetadataTargetType, | |||||
Origin, | Origin, | ||||
OriginVisit, | OriginVisit, | ||||
OriginVisitStatus, | OriginVisitStatus, | ||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | ||||
Release, | Release, | ||||
Revision, | Revision, | ||||
Sha1, | Sha1, | ||||
Sha1Git, | Sha1Git, | ||||
SkippedContent, | SkippedContent, | ||||
Snapshot, | Snapshot, | ||||
SnapshotBranch, | SnapshotBranch, | ||||
) | ) | ||||
from swh.model.swhid import SWHID | |||||
class ListOrder(Enum): | class ListOrder(Enum): | ||||
"""Specifies the order for paginated endpoints returning sorted results.""" | """Specifies the order for paginated endpoints returning sorted results.""" | ||||
ASC = "asc" | ASC = "asc" | ||||
DESC = "desc" | DESC = "desc" | ||||
▲ Show 20 Lines • Show All 1,049 Lines • ▼ Show 20 Lines | def raw_extrinsic_metadata_add(self, metadata: List[RawExtrinsicMetadata],) -> None: | ||||
Args: | Args: | ||||
metadata: iterable of RawExtrinsicMetadata objects to be inserted. | metadata: iterable of RawExtrinsicMetadata objects to be inserted. | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("raw_extrinsic_metadata/get") | @remote_api_endpoint("raw_extrinsic_metadata/get") | ||||
def raw_extrinsic_metadata_get( | def raw_extrinsic_metadata_get( | ||||
self, | self, | ||||
type: MetadataTargetType, | target: SWHID, | ||||
target: Union[str, SWHID], | |||||
authority: MetadataAuthority, | authority: MetadataAuthority, | ||||
after: Optional[datetime.datetime] = None, | after: Optional[datetime.datetime] = None, | ||||
page_token: Optional[bytes] = None, | page_token: Optional[bytes] = None, | ||||
limit: int = 1000, | limit: int = 1000, | ||||
) -> PagedResult[RawExtrinsicMetadata]: | ) -> PagedResult[RawExtrinsicMetadata]: | ||||
"""Retrieve list of all raw_extrinsic_metadata entries for the id | """Retrieve list of all raw_extrinsic_metadata entries for the id | ||||
Args: | Args: | ||||
type: one of the values of swh.model.model.MetadataTargetType | target: a core SWHID | ||||
target: an URL if type is 'origin', else a core SWHID | |||||
authority: a dict containing keys `type` and `url`. | authority: a dict containing keys `type` and `url`. | ||||
after: minimum discovery_date for a result to be returned | after: minimum discovery_date for a result to be returned | ||||
page_token: opaque token, used to get the next page of results | page_token: opaque token, used to get the next page of results | ||||
limit: maximum number of results to be returned | limit: maximum number of results to be returned | ||||
Returns: | Returns: | ||||
PagedResult of RawExtrinsicMetadata | PagedResult of RawExtrinsicMetadata | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |