Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/api/client.py
# Copyright (C) 2016-2018 The Software Heritage developers | # Copyright (C) 2016-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from swh.model import hashutil | from swh.model import hashutil | ||||
from swh.core.api import RPCClient | from swh.core.api import RPCClient | ||||
from swh.vault.backend import NotFoundExc | |||||
class RemoteVaultClient(RPCClient): | class RemoteVaultClient(RPCClient): | ||||
"""Client to the Software Heritage vault cache.""" | """Client to the Software Heritage vault cache.""" | ||||
reraise_exceptions = [NotFoundExc] | |||||
# 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): | ||||
hex_id = hashutil.hash_to_hex(obj_id) | hex_id = hashutil.hash_to_hex(obj_id) | ||||
Show All 36 Lines |