Skip to content

Commit

Permalink
Add "logs"
Browse files Browse the repository at this point in the history
Including "log by ID".
  • Loading branch information
AnonymousX86 committed Jun 19, 2024
1 parent 1cb534e commit eda7328
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 8 additions & 0 deletions mikrus/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ def info(self) -> MikrusInfo:
def servers(self) -> MikrusServerList:
response = self._request(Endpoint.SERVERS)
return MikrusServerList(response)

def logs_list(self) -> MikrusLogsList:
response = self._request(Endpoint.LOGS_LIST)
return MikrusLogsList(response)

def log_by_id(self, log_id: int) -> MikrusLog:
response = self._request(Endpoint.LOG_BY_ID, log_id=log_id)
return MikrusLog(response)
19 changes: 14 additions & 5 deletions mikrus/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,33 @@ def __init__(self, payload: dict) -> None:
self.param_disk: int = int(payload.get('param_disk', 0))


class MikrusRestart:
def __init__(self, payload: dict) -> None:
self.payload = payload
class MikrusServerList:
def __init__(self, payload: list[dict]) -> None:
self.servers = []
for data in payload:
self.servers.append(MikrusServer(data))


class MikrusLogsList:
class MikrusRestart:
def __init__(self, payload: dict) -> None:
self.payload = payload


class MikrusLog:
def __init__(self, payload: dict) -> None:
self.payload = payload
self.id: int = int(payload.get('id', 0))
self.server_id: str = payload.get('server_id')
self.task: str = payload.get('task')
self.created: str = payload.get('when_created')
self.done: str = payload.get('when_done')
self.output: str = payload.get('output')


class MikrusLogsList:
def __init__(self, payload: list[dict]) -> None:
self.logs = []
for data in payload:
self.logs.append(MikrusLog(data))


class MikrusBoost:
Expand Down

0 comments on commit eda7328

Please sign in to comment.