swh.vault.api.client module#

class swh.vault.api.client.RemoteVaultClient(url: str, timeout: None | Tuple[float, float] | List[float] | float = None, chunk_size: int = 4096, max_retries: int = 3, pool_connections: int = 20, pool_maxsize: int = 100, adapter_kwargs: Dict[str, Any] | None = None, api_exception: Type[Exception] | None = None, reraise_exceptions: List[Type[Exception]] | None = None, **kwargs)[source]#

Bases: RPCClient

Client to the Software Heritage vault cache.


alias of VaultInterface

reraise_exceptions: List[Type[Exception]] = [<class 'swh.vault.exc.NotFoundExc'>]#

On server errors, if any of the exception classes in this list has the same name as the error name, then the exception will be instantiated and raised instead of a generic RemoteException.

extra_type_decoders: Dict[str, Callable] = {'core_swhid': <bound method _BaseSWHID.from_string of <class 'swh.model.swhids.CoreSWHID'>>}#

Value of extra_decoders passed to json_loads or msgpack_loads to be able to deserialize more object types.

extra_type_encoders: List[Tuple[type, str, Callable]] = [(<class 'swh.model.swhids.CoreSWHID'>, 'core_swhid', <class 'str'>)]#

Value of extra_encoders passed to json_dumps or msgpack_dumps to be able to serialize more object types.

batch_cook(batch: List[Tuple[str, str]]) int#

Cook a batch of bundles and returns the cooking id.

batch_progress(batch_id: int) Dict[str, Any]#

Fetch information from a batch of bundles

cook(bundle_type: str, swhid: CoreSWHID, email: str | None = None) Dict[str, Any]#

Main entry point for cooking requests. This starts a cooking task if needed, and add the given e-mail to the notify list

download_url(bundle_type: str, swhid: CoreSWHID, content_disposition: str | None = None, expiry: timedelta | None = None) str | None#

Obtain bundle direct download link if the vault cache backend supports it.

fetch(bundle_type: str, swhid: CoreSWHID) bytes | None#

Fetch information from a bundle

progress(bundle_type: str, swhid: CoreSWHID)#
put_bundle(bundle_type: str, swhid: CoreSWHID, bundle)#

Store bundle in vault cache

send_notif(bundle_type: str, swhid: CoreSWHID)#

Send all the e-mails in the notification list of a bundle

set_progress(bundle_type: str, swhid: CoreSWHID, progress: str) None#

Set the cooking progress of a bundle

set_status(bundle_type: str, swhid: CoreSWHID, status: str) bool#

Set the cooking status of a bundle