python/aiovieter/targets.py

41 lines
1.3 KiB
Python

class VieterTargets:
def __init__(self, vieter):
self._vieter = vieter
async def list(self, offset: int = 0, limit: int = 25, repo: str = None) -> dict:
params = {"offset": offset, "limit": limit, "repo": repo}
return await self._vieter._get("/targets", params=params)
async def info(self, target_id: int) -> dict:
return await self._vieter._get(f"/targets/{target_id}")
async def create(self, url: str, branch: str, repo: str, schedule: str = None, arch: [str] = None):
params = {
'url': url,
'branch': branch,
'repo': repo,
'schedule': schedule,
}
if arch is not None:
params['arch'] = arch.join(',')
await self._vieter._post('/targets', params=params)
async def create(self, target_id: int, url: str = None, branch: str = None, repo: str = None, schedule: str = None, arch: [str] = None):
params = {
'url': url,
'branch': branch,
'repo': repo,
'schedule': schedule,
}
if arch is not None:
params['arch'] = arch.join(',')
await self._vieter._patch(f'/targets/{target_id}', params=params)
async def delete(self, target_id: int):
await self._vieter._delete(f'/targets/{target_id}')