Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/interface.py
Show All 21 Lines | from swh.model.model import ( | ||||
Release, | Release, | ||||
Snapshot, | Snapshot, | ||||
SkippedContent, | SkippedContent, | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
MetadataTargetType, | MetadataTargetType, | ||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | ||||
Sha1, | |||||
Sha1Git, | Sha1Git, | ||||
) | ) | ||||
vlorentz: move this to model | |||||
Done Inline Actionsyes, D3738 now model 0.6.6 has it. ardumont: yes, D3738
now model 0.6.6 has it. | |||||
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 100 Lines • ▼ Show 20 Lines | def content_add_metadata(self, content: List[Content]) -> Dict: | ||||
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( | def content_get_data(self, content: Sha1) -> Optional[bytes]: | ||||
self, contents: List[bytes] | """Given a content identifier, returns its associated data if any. | ||||
) -> Iterable[Optional[Dict[str, bytes]]]: | |||||
"""Retrieve in bulk contents and their data. | |||||
This generator yields exactly as many items than provided sha1 | |||||
identifiers, but callers should not assume this will always be true. | |||||
It may also yield `None` values in case an object was not found. | |||||
TODO: | |||||
Rename to content_get_data | |||||
Args: | Args: | ||||
contents: iterables of sha1 | content: sha1 identifier | ||||
Raises: | |||||
StorageArgumentException in case of too much contents are required. | |||||
(cf. BULK_BLOCK_CONTENT_LEN_MAX) | |||||
Yields: | |||||
Streams of contents as dict with their raw data: | |||||
- sha1 (bytes): content id | Returns: | ||||
- data (bytes): content's raw data | raw content data (bytes) | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("content/partition") | @remote_api_endpoint("content/partition") | ||||
def content_get_partition( | def content_get_partition( | ||||
self, | self, | ||||
partition_id: int, | partition_id: int, | ||||
▲ Show 20 Lines • Show All 1,111 Lines • Show Last 20 Lines |
move this to model