Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/backends/archive.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 2022 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 typing import List, Optional | |||||
from swh.graphql import server | from swh.graphql import server | ||||
from swh.model import model as swh_model | |||||
class Archive: | class Archive: | ||||
def __init__(self): | def __init__(self): | ||||
self.storage = server.get_storage() | self.storage = server.get_storage() | ||||
def get_origin(self, url): | def get_origins_with_urls(self, urls: List) -> List[Optional[swh_model.Origin]]: | ||||
return self.storage.origin_get([url])[0] | return self.storage.origin_get(urls) | ||||
def get_origins(self, after=None, first=50, url_pattern=None): | def get_origins(self, after=None, first=50, url_pattern=None): | ||||
# STORAGE-TODO | # STORAGE-TODO | ||||
# Make them a single function in the backend | # Make them a single function in the backend | ||||
if url_pattern is None: | if url_pattern is None: | ||||
return self.storage.origin_list(page_token=after, limit=first) | return self.storage.origin_list(page_token=after, limit=first) | ||||
return self.storage.origin_search( | return self.storage.origin_search( | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |