Compare commits
2 Commits
1f14678997
...
58d3cff531
Author | SHA1 | Date |
---|---|---|
Jef Roosens | 58d3cff531 | |
Jef Roosens | a84eecc687 |
|
@ -6,19 +6,45 @@ class VieterTargets:
|
|||
params = {"offset": offset, "limit": limit, "repo": repo}
|
||||
|
||||
return await self._vieter._get("/targets", params=params)
|
||||
|
||||
async def info(self, repo_id: int) -> dict:
|
||||
return await self._vieter._get(f"/targets/{repo_id}")
|
||||
|
||||
async def create(self, url: str, branch: str, repo: str, schedule: str = None, arch: [str] = None):
|
||||
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,
|
||||
"url": url,
|
||||
"branch": branch,
|
||||
"repo": repo,
|
||||
"schedule": schedule,
|
||||
}
|
||||
|
||||
if arch is not None:
|
||||
params['arch'] = arch.join(',')
|
||||
params["arch"] = arch.join(",")
|
||||
|
||||
await self._vieter._post('/targets', params=params)
|
||||
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}")
|
||||
|
|
|
@ -4,7 +4,7 @@ from .targets import VieterTargets
|
|||
from .logs import VieterBuildLogs
|
||||
|
||||
|
||||
API_PREFIX = '/api/v1'
|
||||
API_PREFIX = "/api/v1"
|
||||
|
||||
|
||||
class VieterApiException(Exception):
|
||||
|
@ -35,7 +35,12 @@ class Vieter:
|
|||
if params is not None:
|
||||
params = {k: v for k, v in params.items() if v is not None}
|
||||
|
||||
async with self._client.request(method, f"{API_PREFIX}{path}", params=params) as res:
|
||||
async with self._client.request(
|
||||
method, f"{API_PREFIX}{path}", params=params
|
||||
) as res:
|
||||
if res.status == 404:
|
||||
return VieterApiException("Error 404")
|
||||
|
||||
data = await res.json()
|
||||
|
||||
if res.status != 200:
|
||||
|
@ -48,3 +53,9 @@ class Vieter:
|
|||
|
||||
async def _post(self, *args, **kwargs):
|
||||
return await self._do_req("POST", *args, **kwargs)
|
||||
|
||||
async def _patch(self, *args, **kwargs):
|
||||
return await self._do_req("PATCH", *args, **kwargs)
|
||||
|
||||
async def _delete(self, *args, **kwargs):
|
||||
return await self._do_req("DELETE", *args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue