Changeset View
Changeset View
Standalone View
Standalone View
swh/search/interface.py
# Copyright (C) 2020 The Software Heritage developers | # Copyright (C) 2020-2021 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 Any, Dict, Iterable, Optional, TypeVar | from typing import Any, Dict, Iterable, List, Optional, TypeVar | ||||
from swh.core.api import remote_api_endpoint | from swh.core.api import remote_api_endpoint | ||||
from swh.core.api.classes import PagedResult as CorePagedResult | from swh.core.api.classes import PagedResult as CorePagedResult | ||||
TResult = TypeVar("TResult") | TResult = TypeVar("TResult") | ||||
PagedResult = CorePagedResult[TResult, str] | PagedResult = CorePagedResult[TResult, str] | ||||
Show All 21 Lines | def origin_update(self, documents: Iterable[Dict]) -> None: | ||||
... | ... | ||||
@remote_api_endpoint("origin/search") | @remote_api_endpoint("origin/search") | ||||
def origin_search( | def origin_search( | ||||
self, | self, | ||||
*, | *, | ||||
url_pattern: Optional[str] = None, | url_pattern: Optional[str] = None, | ||||
metadata_pattern: Optional[str] = None, | metadata_pattern: Optional[str] = None, | ||||
with_visit: bool = False, | with_visit: bool = False, | ||||
anlambert: Maybe it will be better to allow the filtering on multiple visit types ? | |||||
Not Done Inline ActionsI was about to suggest that too, if it's not too much trouble. (If it it, accept a List[str] and error on len != 1, so we can easily add it in the future) vlorentz: I was about to suggest that too, if it's not too much trouble.
(If it it, accept a `List[str]`… | |||||
Done Inline ActionsThis seems pretty easy to implement so go for it. anlambert: This seems pretty easy to implement so go for it. | |||||
visit_types: Optional[List[str]] = None, | |||||
page_token: Optional[str] = None, | page_token: Optional[str] = None, | ||||
limit: int = 50, | limit: int = 50, | ||||
) -> PagedResult[Dict[str, Any]]: | ) -> PagedResult[Dict[str, Any]]: | ||||
"""Searches for origins matching the `url_pattern`. | """Searches for origins matching the `url_pattern`. | ||||
Args: | Args: | ||||
url_pattern: Part of the URL to search for | url_pattern: Part of the URL to search for | ||||
with_visit: Whether origins with no visit are to be | with_visit: Whether origins with no visit are to be | ||||
filtered out | filtered out | ||||
visit_types: Only origins with given visit types (e.g. git, svn, pypi) | |||||
will be returned | |||||
page_token: Opaque value used for pagination | page_token: Opaque value used for pagination | ||||
limit: number of results to return | limit: number of results to return | ||||
Returns: | Returns: | ||||
PagedResult of origin dicts matching the search criteria. If next_page_token | PagedResult of origin dicts matching the search criteria. If next_page_token | ||||
is None, there is no longer data to retrieve. | is None, there is no longer data to retrieve. | ||||
""" | """ | ||||
... | ... |
Maybe it will be better to allow the filtering on multiple visit types ?