Source code for gerrit.config.tasks

#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author: Jialiang Shi
from typing import Any, List
from gerrit import GerritClient

[docs] class Task: def __init__(self, task_id: str, gerrit: GerritClient) -> None: self.id = task_id self.gerrit = gerrit self.endpoint = f"/config/server/tasks/{self.id}"
[docs] def delete(self) -> None: """ Kills a task from the background work queue that the Gerrit daemon is currently performing, or will perform in the near future. :return: """ self.gerrit.delete(self.endpoint)
[docs] class Tasks: def __init__(self, gerrit: GerritClient) -> None: self.gerrit = gerrit self.endpoint = "/config/server/tasks"
[docs] def list(self) -> List[Any]: """ Lists the tasks from the background work queues that the Gerrit daemon is currently performing, or will perform in the near future. :return: """ result = self.gerrit.get(self.endpoint) return result
[docs] def get(self, id_: str) -> Task: """ Retrieves a task from the background work queue that the Gerrit daemon is currently performing, or will perform in the near future. :param id_: task id :return: """ result = self.gerrit.get(self.endpoint + f"/{id_}") task_id = result.get("id") return Task(task_id=task_id, gerrit=self.gerrit)
[docs] def delete(self, id_: str) -> None: """ Kills a task from the background work queue that the Gerrit daemon is currently performing, or will perform in the near future. :param id_: task id :return: """ self.gerrit.delete(self.endpoint + f"/{id_}")