diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2021-02-07 00:29:59 +0100 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2021-02-07 16:05:05 +0100 |
commit | a5a48ad08577be70c6ca511d3b4803624e5c2043 (patch) | |
tree | c1b80daad6dbb6ea3b1a3498d70016ef77abf6b3 /gitlab/v4/objects/todos.py | |
parent | 9d6c1882d567116e16484f3e0a1036da4967c537 (diff) | |
download | gitlab-a5a48ad08577be70c6ca511d3b4803624e5c2043.tar.gz |
refactor(v4): split objects and managers per API resource
Diffstat (limited to 'gitlab/v4/objects/todos.py')
-rw-r--r-- | gitlab/v4/objects/todos.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gitlab/v4/objects/todos.py b/gitlab/v4/objects/todos.py new file mode 100644 index 0000000..429005c --- /dev/null +++ b/gitlab/v4/objects/todos.py @@ -0,0 +1,45 @@ +from gitlab import cli +from gitlab import exceptions as exc +from gitlab.base import * # noqa +from gitlab.mixins import * # noqa + + +class Todo(ObjectDeleteMixin, RESTObject): + @cli.register_custom_action("Todo") + @exc.on_http_error(exc.GitlabTodoError) + def mark_as_done(self, **kwargs): + """Mark the todo as done. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabTodoError: If the server failed to perform the request + """ + path = "%s/%s/mark_as_done" % (self.manager.path, self.id) + server_data = self.manager.gitlab.http_post(path, **kwargs) + self._update_attrs(server_data) + + +class TodoManager(ListMixin, DeleteMixin, RESTManager): + _path = "/todos" + _obj_cls = Todo + _list_filters = ("action", "author_id", "project_id", "state", "type") + + @cli.register_custom_action("TodoManager") + @exc.on_http_error(exc.GitlabTodoError) + def mark_all_as_done(self, **kwargs): + """Mark all the todos as done. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabTodoError: If the server failed to perform the request + + Returns: + int: The number of todos maked done + """ + result = self.gitlab.http_post("/todos/mark_as_done", **kwargs) |