Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/phabricator/lister.py
# Copyright (C) 2019-2020 the Software Heritage developers | # Copyright (C) 2019-2021 the Software Heritage developers | ||||
# 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 collections import defaultdict | from collections import defaultdict | ||||
import logging | import logging | ||||
import random | import random | ||||
from typing import Any, Dict, Iterator, List, Optional | from typing import Any, Dict, Iterator, List, Optional | ||||
from urllib.parse import urljoin | from urllib.parse import urljoin | ||||
Show All 12 Lines | |||||
class PhabricatorLister(StatelessLister[PageType]): | class PhabricatorLister(StatelessLister[PageType]): | ||||
""" | """ | ||||
List all repositories hosted on a Phabricator instance. | List all repositories hosted on a Phabricator instance. | ||||
Args: | Args: | ||||
url: base URL of a phabricator forge | url: base URL of a phabricator forge | ||||
(for instance https://forge.softwareheritage.org) | (for instance https://forge.softwareheritage.org) | ||||
instance: string identifier for the listed forge | instance: string identifier for the listed forge, | ||||
URL network location will be used if not provided | |||||
api_token: authentication token for Conduit API | api_token: authentication token for Conduit API | ||||
""" | """ | ||||
LISTER_NAME = "phabricator" | LISTER_NAME = "phabricator" | ||||
API_REPOSITORY_PATH = "/api/diffusion.repository.search" | API_REPOSITORY_PATH = "/api/diffusion.repository.search" | ||||
def __init__( | def __init__( | ||||
self, | self, | ||||
scheduler: SchedulerInterface, | scheduler: SchedulerInterface, | ||||
url: str, | url: str, | ||||
instance: str, | instance: Optional[str] = None, | ||||
api_token: Optional[str] = None, | api_token: Optional[str] = None, | ||||
credentials: CredentialsType = None, | credentials: CredentialsType = None, | ||||
): | ): | ||||
super().__init__( | super().__init__( | ||||
scheduler, urljoin(url, self.API_REPOSITORY_PATH), instance, credentials | scheduler, urljoin(url, self.API_REPOSITORY_PATH), instance, credentials | ||||
) | ) | ||||
self.session = requests.Session() | self.session = requests.Session() | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |