27 lines
773 B
Python
27 lines
773 B
Python
import aiohttp
|
|
|
|
from .repos import VieterRepos
|
|
from .logs import VieterBuildLogs
|
|
|
|
|
|
class Vieter:
|
|
def __init__(self, address: str, api_key: str) -> None:
|
|
self._address = address
|
|
self._api_key = api_key
|
|
self._client = aiohttp.ClientSession(
|
|
base_url=address, headers={"X-Api-Key": api_key}
|
|
)
|
|
|
|
self.repos = VieterRepos(self)
|
|
self.logs = VieterBuildLogs(self)
|
|
|
|
async def close(self):
|
|
await self._client.close()
|
|
|
|
async def _do_req(self, method: str, path: str, params: dict = None):
|
|
async with self._client.request(method, path, params=params) as res:
|
|
return await res.json()
|
|
|
|
async def _get(self, *args, **kwargs):
|
|
return await self._do_req("GET", *args, **kwargs)
|