diff --git a/requirements-swh.txt b/requirements-swh.txt index cea1983..6f36028 100644 --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,5 +1,5 @@ -swh.core >= 0.0.44 +swh.core >= 0.0.56 swh.model >= 0.0.27 swh.objstorage >= 0.0.17 swh.scheduler >= 0.0.39 swh.storage >= 0.0.106 diff --git a/swh/vault/api/client.py b/swh/vault/api/client.py index fcdfb9d..7c9f769 100644 --- a/swh/vault/api/client.py +++ b/swh/vault/api/client.py @@ -1,69 +1,58 @@ # Copyright (C) 2016-2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information from swh.model import hashutil from swh.core.api import SWHRemoteAPI -class VaultAPIError(Exception): - """Vault API Error""" - def __str__(self): - return ('An unexpected error occurred in the Vault backend: {}' - .format(self.args)) - - class RemoteVaultClient(SWHRemoteAPI): """Client to the Software Heritage vault cache.""" - def __init__(self, url, timeout=None): - super().__init__( - api_exception=VaultAPIError, url=url, timeout=timeout) - # Web API endpoints def fetch(self, obj_type, obj_id): hex_id = hashutil.hash_to_hex(obj_id) return self.get('fetch/{}/{}'.format(obj_type, hex_id)) def cook(self, obj_type, obj_id, email=None): hex_id = hashutil.hash_to_hex(obj_id) return self.post('cook/{}/{}'.format(obj_type, hex_id), data={}, params=({'email': email} if email else None)) def progress(self, obj_type, obj_id): hex_id = hashutil.hash_to_hex(obj_id) return self.get('progress/{}/{}'.format(obj_type, hex_id)) # Cookers endpoints def set_progress(self, obj_type, obj_id, progress): hex_id = hashutil.hash_to_hex(obj_id) return self.post('set_progress/{}/{}'.format(obj_type, hex_id), data=progress) def set_status(self, obj_type, obj_id, status): hex_id = hashutil.hash_to_hex(obj_id) return self.post('set_status/{}/{}' .format(obj_type, hex_id), data=status) # TODO: handle streaming properly def put_bundle(self, obj_type, obj_id, bundle): hex_id = hashutil.hash_to_hex(obj_id) return self.post('put_bundle/{}/{}' .format(obj_type, hex_id), data=bundle) def send_notif(self, obj_type, obj_id): hex_id = hashutil.hash_to_hex(obj_id) return self.post('send_notif/{}/{}' .format(obj_type, hex_id), data=None) # Batch endpoints def batch_cook(self, batch): return self.post('batch_cook', data=batch) def batch_progress(self, batch_id): return self.get('batch_progress/{}'.format(batch_id))