This repository has been archived on 2026-02-22. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
python/aiovieter/targets.py
Jef Roosens 58d3cff531
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
chore: configured flake8 & formatted code
2022-07-31 13:38:48 +02:00

50 lines
1.4 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 edit(
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}")