summaryrefslogtreecommitdiff
path: root/gitlab/objects.py
diff options
context:
space:
mode:
authorsavenger <github@smahmood.de>2017-03-03 13:57:46 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2017-03-03 13:57:46 +0100
commit92151b22b5b03b3d529caf1865a2e35738a2f3d2 (patch)
treef29231c671394f16e3117b3ed8d5d914c4f7d144 /gitlab/objects.py
parentcd696240ec9000ce12c4232db3436fbca58b8fdd (diff)
downloadgitlab-92151b22b5b03b3d529caf1865a2e35738a2f3d2.tar.gz
Time tracking (#222)
* Added gitlab time tracking features - get/set/remove estimated time per issue - get/set/remove time spent per issue * Added documentation for time tracking functions
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r--gitlab/objects.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py
index ea40b6f..efe75d0 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -1523,6 +1523,69 @@ class ProjectIssue(GitlabObject):
r = self.gitlab._raw_post(url, **kwargs)
raise_error_from_response(r, GitlabTodoError, [201, 304])
+ def time_stats(self, **kwargs):
+ """Get time stats for the issue.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ """
+ url = ('/projects/%(project_id)s/issues/%(issue_id)s/time_stats' %
+ {'project_id': self.project_id, 'issue_id': self.id})
+ r = self.gitlab._raw_get(url, **kwargs)
+ raise_error_from_response(r, GitlabGetError)
+ return r.json()
+
+ def time_estimate(self, **kwargs):
+ """Set an estimated time of work for the issue.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ """
+ url = ('/projects/%(project_id)s/issues/%(issue_id)s/time_estimate' %
+ {'project_id': self.project_id, 'issue_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 issue to 0 seconds.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ """
+ url = ('/projects/%(project_id)s/issues/%(issue_id)s/'
+ 'reset_time_estimate' %
+ {'project_id': self.project_id, 'issue_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 issue.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ """
+ url = ('/projects/%(project_id)s/issues/%(issue_id)s/'
+ 'reset_spent_time' %
+ {'project_id': self.project_id, 'issue_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 issue.
+
+ Raises:
+ GitlabConnectionError: If the server cannot be reached.
+ """
+ url = ('/projects/%(project_id)s/issues/%(issue_id)s/'
+ 'add_spent_time' %
+ {'project_id': self.project_id, 'issue_id': self.id})
+ r = self.gitlab._raw_post(url, **kwargs)
+ raise_error_from_response(r, GitlabTimeTrackingError, 200)
+ return r.json()
+
class ProjectIssueManager(BaseManager):
obj_cls = ProjectIssue