Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/gitlab/lister.py
# Copyright (C) 2018 the Software Heritage developers | # Copyright (C) 2018-2019 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 | ||||
import random | import random | ||||
import time | import time | ||||
from urllib3.util import parse_url | from urllib3.util import parse_url | ||||
from ..core.page_by_page_lister import PageByPageHttpLister | from ..core.page_by_page_lister import PageByPageHttpLister | ||||
Show All 13 Lines | def __init__(self, api_baseurl, instance=None, | ||||
if instance is None: | if instance is None: | ||||
instance = parse_url(api_baseurl).host | instance = parse_url(api_baseurl).host | ||||
self.instance = instance | self.instance = instance | ||||
self.PATH_TEMPLATE = '%s&sort=%s' % (self.PATH_TEMPLATE, sort) | self.PATH_TEMPLATE = '%s&sort=%s' % (self.PATH_TEMPLATE, sort) | ||||
if per_page != 20: | if per_page != 20: | ||||
self.PATH_TEMPLATE = '%s&per_page=%s' % ( | self.PATH_TEMPLATE = '%s&per_page=%s' % ( | ||||
self.PATH_TEMPLATE, per_page) | self.PATH_TEMPLATE, per_page) | ||||
@property | |||||
def ADDITIONAL_CONFIG(self): | |||||
"""Override additional config as the 'credentials' structure change | |||||
between the ancestor classes and this class. | |||||
cf. request_params method below | |||||
""" | |||||
default_config = super().ADDITIONAL_CONFIG | |||||
# 'credentials' is a dict of (instance, {username, password}) dict | |||||
default_config['credentials'] = ('dict', {}) | |||||
return default_config | |||||
def request_params(self, identifier): | def request_params(self, identifier): | ||||
"""Get the full parameters passed to requests given the | """Get the full parameters passed to requests given the | ||||
transport_request identifier. | transport_request identifier. | ||||
For the gitlab lister, the 'credentials' entries is configured | For the gitlab lister, the 'credentials' entries is configured | ||||
per instance. For example:: | per instance. For example:: | ||||
- credentials: | - credentials: | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |