Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/interface.py
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
@runtime_checkable | @runtime_checkable | ||||
class StorageInterface(Protocol): | class StorageInterface(Protocol): | ||||
@remote_api_endpoint("check_config") | @remote_api_endpoint("check_config") | ||||
def check_config(self, *, check_write: bool) -> bool: | def check_config(self, *, check_write: bool) -> bool: | ||||
"""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: List[Content]) -> Dict: | def content_add(self, content: List[Content]) -> Dict[str, int]: | ||||
"""Add content blobs to the storage | """Add content blobs to the storage | ||||
Args: | Args: | ||||
contents (iterable): iterable of dictionaries representing | contents (iterable): iterable of dictionaries representing | ||||
individual pieces of content to add. Each dictionary has the | individual pieces of content to add. Each dictionary has the | ||||
following keys: | following keys: | ||||
- data (bytes): the actual content | - data (bytes): the actual content | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | def content_get_random(self) -> Sha1Git: | ||||
"""Finds a random content id. | """Finds a random content id. | ||||
Returns: | Returns: | ||||
a sha1_git | a sha1_git | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("content/skipped/add") | @remote_api_endpoint("content/skipped/add") | ||||
def skipped_content_add(self, content: List[SkippedContent]) -> Dict: | def skipped_content_add(self, content: List[SkippedContent]) -> Dict[str, int]: | ||||
"""Add contents to the skipped_content list, which contains | """Add contents to the skipped_content list, which contains | ||||
(partial) information about content missing from the archive. | (partial) information about content missing from the archive. | ||||
Args: | Args: | ||||
contents (iterable): iterable of dictionaries representing | contents (iterable): iterable of dictionaries representing | ||||
individual pieces of content to add. Each dictionary has the | individual pieces of content to add. Each dictionary has the | ||||
following keys: | following keys: | ||||
Show All 36 Lines | ) -> Iterable[Dict[str, Any]]: | ||||
Returns: | Returns: | ||||
Iterable of missing skipped contents as dict | Iterable of missing skipped contents as dict | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("directory/add") | @remote_api_endpoint("directory/add") | ||||
def directory_add(self, directories: List[Directory]) -> Dict: | def directory_add(self, directories: List[Directory]) -> Dict[str, int]: | ||||
"""Add directories to the storage | """Add directories to the storage | ||||
Args: | Args: | ||||
directories (iterable): iterable of dictionaries representing the | directories (iterable): iterable of dictionaries representing the | ||||
individual directories to add. Each dict has the following | individual directories to add. Each dict has the following | ||||
keys: | keys: | ||||
- id (sha1_git): the id of the directory to add | - id (sha1_git): the id of the directory to add | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | def directory_get_random(self) -> Sha1Git: | ||||
"""Finds a random directory id. | """Finds a random directory id. | ||||
Returns: | Returns: | ||||
a sha1_git | a sha1_git | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("revision/add") | @remote_api_endpoint("revision/add") | ||||
def revision_add(self, revisions: List[Revision]) -> Dict: | def revision_add(self, revisions: List[Revision]) -> Dict[str, int]: | ||||
"""Add revisions to the storage | """Add revisions to the storage | ||||
Args: | Args: | ||||
revisions (List[dict]): iterable of dictionaries representing | revisions (List[dict]): iterable of dictionaries representing | ||||
the individual revisions to add. Each dict has the following | the individual revisions to add. Each dict has the following | ||||
keys: | keys: | ||||
- **id** (:class:`sha1_git`): id of the revision to add | - **id** (:class:`sha1_git`): id of the revision to add | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | def revision_get_random(self) -> Sha1Git: | ||||
"""Finds a random revision id. | """Finds a random revision id. | ||||
Returns: | Returns: | ||||
a sha1_git | a sha1_git | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("release/add") | @remote_api_endpoint("release/add") | ||||
def release_add(self, releases: List[Release]) -> Dict: | def release_add(self, releases: List[Release]) -> Dict[str, int]: | ||||
"""Add releases to the storage | """Add releases to the storage | ||||
Args: | Args: | ||||
releases (List[dict]): iterable of dictionaries representing | releases (List[dict]): iterable of dictionaries representing | ||||
the individual releases to add. Each dict has the following | the individual releases to add. Each dict has the following | ||||
keys: | keys: | ||||
- **id** (:class:`sha1_git`): id of the release to add | - **id** (:class:`sha1_git`): id of the release to add | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | def release_get_random(self) -> Sha1Git: | ||||
"""Finds a random release id. | """Finds a random release id. | ||||
Returns: | Returns: | ||||
a sha1_git | a sha1_git | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("snapshot/add") | @remote_api_endpoint("snapshot/add") | ||||
def snapshot_add(self, snapshots: List[Snapshot]) -> Dict: | def snapshot_add(self, snapshots: List[Snapshot]) -> Dict[str, int]: | ||||
"""Add snapshots to the storage. | """Add snapshots to the storage. | ||||
Args: | Args: | ||||
snapshot ([dict]): the snapshots to add, containing the | snapshot ([dict]): the snapshots to add, containing the | ||||
following keys: | following keys: | ||||
- **id** (:class:`bytes`): id of the snapshot | - **id** (:class:`bytes`): id of the snapshot | ||||
- **branches** (:class:`dict`): branches the snapshot contains, | - **branches** (:class:`dict`): branches the snapshot contains, | ||||
▲ Show 20 Lines • Show All 588 Lines • Show Last 20 Lines |