ci: added linting config & pipeline; renamed project to aiovieter
Some checks failed
ci/woodpecker/push/lint Pipeline failed

This commit is contained in:
Jef Roosens 2022-06-05 17:16:29 +02:00
parent 242d685a6c
commit e9a189b309
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
11 changed files with 67 additions and 19 deletions

3
aiovieter/__init__.py Normal file
View file

@ -0,0 +1,3 @@
from .vieter import Vieter
__all__ = "Vieter"

8
aiovieter/logs.py Normal file
View file

@ -0,0 +1,8 @@
class VieterBuildLogs:
def __init__(self, vieter):
self._vieter = vieter
async def list(self, offset: int = 0, limit: int = 25):
params = {"offset": offset, "limit": limit}
return await self._vieter._get("/api/logs", params=params)

8
aiovieter/repos.py Normal file
View file

@ -0,0 +1,8 @@
class VieterRepos:
def __init__(self, vieter):
self._vieter = vieter
async def list(self, offset: int = 0, limit: int = 25):
params = {"offset": offset, "limit": limit}
return await self._vieter._get("/api/repos", params=params)

26
aiovieter/vieter.py Normal file
View file

@ -0,0 +1,26 @@
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)