Source code for copr.v3.proxies

import os
from ..helpers import config_from_file
from ..requests import Request

[docs]class BaseProxy(object): """ Parent class for all other proxies """ def __init__(self, config): self.config = config @classmethod def create_from_config_file(cls, path=None): config = config_from_file(path) return cls(config) @property def api_base_url(self): return os.path.join(self.config["copr_url"], "api_3", "") @property def auth(self): return self.config["login"], self.config["token"]
[docs] def home(self): """ Call the Copr APIv3 base URL :return: Munch """ endpoint = "" request = Request(endpoint, api_base_url=self.api_base_url) response = request.send() return response.munchify()
[docs] def auth_check(self): """ Call an endpoint protected by login to check whether the user auth key is valid :return: Munch """ endpoint = "/auth-check" request = Request(endpoint, api_base_url=self.api_base_url, auth=self.auth) response = request.send() return response.munchify()