Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/api/client.py
Show All 11 Lines | class VaultAPIError(Exception): | ||||
def __str__(self): | def __str__(self): | ||||
return ('An unexpected error occurred in the Vault backend: {}' | return ('An unexpected error occurred in the Vault backend: {}' | ||||
.format(self.args)) | .format(self.args)) | ||||
class RemoteVaultClient(SWHRemoteAPI): | class RemoteVaultClient(SWHRemoteAPI): | ||||
"""Client to the Software Heritage vault cache.""" | """Client to the Software Heritage vault cache.""" | ||||
def __init__(self, base_url, timeout=None): | def __init__(self, url, timeout=None): | ||||
super().__init__( | super().__init__( | ||||
api_exception=VaultAPIError, url=base_url, timeout=timeout) | api_exception=VaultAPIError, url=url, timeout=timeout) | ||||
# Web API endpoints | # Web API endpoints | ||||
def fetch(self, obj_type, obj_id): | def fetch(self, obj_type, obj_id): | ||||
hex_id = hashutil.hash_to_hex(obj_id) | hex_id = hashutil.hash_to_hex(obj_id) | ||||
return self.get('fetch/{}/{}'.format(obj_type, hex_id)) | return self.get('fetch/{}/{}'.format(obj_type, hex_id)) | ||||
def cook(self, obj_type, obj_id, email=None): | def cook(self, obj_type, obj_id, email=None): | ||||
Show All 39 Lines |