diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2016-08-11 10:58:40 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2016-08-11 10:58:40 +0200 |
commit | 131739f492946ba1cd58852be1caf000af451384 (patch) | |
tree | e0fc7e848fc93f90e6fcad8685a5eff18547dd29 /gitlab/objects.py | |
parent | 3e026d2ee62eba3ad92ff2cdd53db19f5e0e9f6a (diff) | |
download | gitlab-131739f492946ba1cd58852be1caf000af451384.tar.gz |
implement the todo API
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r-- | gitlab/objects.py | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py index 4db6354..0e9c75f 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1237,6 +1237,17 @@ class ProjectIssue(GitlabObject): raise_error_from_response(r, GitlabUpdateError, 201) self._set_from_dict(r.json()) + def todo(self, **kwargs): + """Create a todo for the issue. + + Raises: + GitlabConnectionError: If the server cannot be reached. + """ + url = ('/projects/%(project_id)s/issues/%(issue_id)s/todo' % + {'project_id': self.project_id, 'issue_id': self.id}) + r = self.gitlab._raw_post(url, **kwargs) + raise_error_from_response(r, GitlabTodoError, [201, 304]) + class ProjectIssueManager(BaseManager): obj_cls = ProjectIssue @@ -1498,6 +1509,17 @@ class ProjectMergeRequest(GitlabObject): raise_error_from_response(r, errors) self._set_from_dict(r.json()) + def todo(self, **kwargs): + """Create a todo for the merge request. + + Raises: + GitlabConnectionError: If the server cannot be reached. + """ + url = ('/projects/%(project_id)s/merge_requests/%(mr_id)s/todo' % + {'project_id': self.project_id, 'mr_id': self.id}) + r = self.gitlab._raw_post(url, **kwargs) + raise_error_from_response(r, GitlabTodoError, [201, 304]) + class ProjectMergeRequestManager(BaseManager): obj_cls = ProjectMergeRequest @@ -2154,7 +2176,7 @@ class RunnerManager(BaseManager): Raises: GitlabConnectionError: If the server cannot be reached. - GitlabListError; If the resource cannot be found + GitlabListError: If the resource cannot be found """ url = '/runners/all' if scope is not None: @@ -2170,6 +2192,33 @@ class TeamMember(GitlabObject): shortPrintAttr = 'username' +class Todo(GitlabObject): + _url = '/todos' + canGet = 'from_list' + canUpdate = False + canCreate = False + optionalListAttrs = ['action', 'author_id', 'project_id', 'state', 'type'] + + +class TodoManager(BaseManager): + obj_cls = Todo + + def delete_all(self, **kwargs): + """Mark all the todos as done. + + Raises: + GitlabConnectionError: If the server cannot be reached. + GitlabDeleteError: If the resource cannot be found + + Returns: + The number of todos maked done. + """ + url = '/todos' + r = self.gitlab._raw_delete(url, **kwargs) + raise_error_from_response(r, GitlabDeleteError) + return int(r.text) + + class UserProject(GitlabObject): _url = '/projects/user/%(user_id)s' _constructorTypes = {'owner': 'User', 'namespace': 'Group'} |