diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2017-05-20 09:52:36 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-05-20 09:52:36 +0200 |
commit | 324f81b0869ffb8f75a0c207d12138201d01b097 (patch) | |
tree | f353d53a1d80a3f08076616a208f9894c2e4c1b0 /gitlab/objects.py | |
parent | 391417cd47d722760dfdaab577e9f419c5dca0e0 (diff) | |
download | gitlab-324f81b0869ffb8f75a0c207d12138201d01b097.tar.gz |
MR: add support for time tracking features
Fixes #248
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r-- | gitlab/objects.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py index 314a36b..58eb867 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1850,6 +1850,58 @@ class ProjectMergeRequest(GitlabObject): raise_error_from_response(r, GitlabGetError) return r.json() + def time_estimate(self, **kwargs): + """Set an estimated time of work for the merge request. + + Raises: + GitlabConnectionError: If the server cannot be reached. + """ + url = ('/projects/%(project_id)s/merge_requests/%(mr_id)s/' + 'time_estimate' % + {'project_id': self.project_id, 'mr_id': self.id}) + r = self.gitlab._raw_post(url, **kwargs) + raise_error_from_response(r, GitlabTimeTrackingError, 201) + return r.json() + + def reset_time_estimate(self, **kwargs): + """Resets estimated time for the merge request to 0 seconds. + + Raises: + GitlabConnectionError: If the server cannot be reached. + """ + url = ('/projects/%(project_id)s/merge_requests/%(mr_id)s/' + 'reset_time_estimate' % + {'project_id': self.project_id, 'mr_id': self.id}) + r = self.gitlab._raw_post(url, **kwargs) + raise_error_from_response(r, GitlabTimeTrackingError, 200) + return r.json() + + def add_spent_time(self, **kwargs): + """Set an estimated time of work for the merge request. + + Raises: + GitlabConnectionError: If the server cannot be reached. + """ + url = ('/projects/%(project_id)s/merge_requests/%(mr_id)s/' + 'add_spent_time' % + {'project_id': self.project_id, 'mr_id': self.id}) + r = self.gitlab._raw_post(url, **kwargs) + raise_error_from_response(r, GitlabTimeTrackingError, 200) + return r.json() + + def reset_spent_time(self, **kwargs): + """Set an estimated time of work for the merge request. + + Raises: + GitlabConnectionError: If the server cannot be reached. + """ + url = ('/projects/%(project_id)s/merge_requests/%(mr_id)s/' + 'reset_spent_time' % + {'project_id': self.project_id, 'mr_id': self.id}) + r = self.gitlab._raw_post(url, **kwargs) + raise_error_from_response(r, GitlabTimeTrackingError, 200) + return r.json() + class ProjectMergeRequestManager(BaseManager): obj_cls = ProjectMergeRequest |