ci: added linting config & pipeline; renamed project to aiovieter
Some checks failed
ci/woodpecker/push/lint Pipeline failed
Some checks failed
ci/woodpecker/push/lint Pipeline failed
This commit is contained in:
parent
242d685a6c
commit
e9a189b309
11 changed files with 67 additions and 19 deletions
3
aiovieter/__init__.py
Normal file
3
aiovieter/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from .vieter import Vieter
|
||||
|
||||
__all__ = "Vieter"
|
||||
8
aiovieter/logs.py
Normal file
8
aiovieter/logs.py
Normal 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
8
aiovieter/repos.py
Normal 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
26
aiovieter/vieter.py
Normal 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)
|
||||
Reference in a new issue