summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-06-09 18:08:38 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2018-06-09 18:08:38 +0200
commit8873edaeebd18d6b2ed08a8609c011ad29249b48 (patch)
treecfc3674a94211996646b83f9666e812af94a4843 /gitlab/v4/objects.py
parent39c8ad5a9405469370e429548e08aa475797b92b (diff)
downloadgitlab-8873edaeebd18d6b2ed08a8609c011ad29249b48.tar.gz
Add support for issue links (EE)
Fixes #422
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r--gitlab/v4/objects.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 8feb09b..f5160e5 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -1539,6 +1539,43 @@ class ProjectIssueDiscussionManager(RetrieveMixin, CreateMixin, RESTManager):
_create_attrs = (('body',), ('created_at',))
+class ProjectIssueLink(ObjectDeleteMixin, RESTObject):
+ _id_attr = 'issue_link_id'
+
+
+class ProjectIssueLinkManager(ListMixin, CreateMixin, DeleteMixin,
+ RESTManager):
+ _path = '/projects/%(project_id)s/issues/%(issue_iid)s/links'
+ _obj_cls = ProjectIssueLink
+ _from_parent_attrs = {'project_id': 'project_id', 'issue_iid': 'iid'}
+ _create_attrs = (('target_project_id', 'target_issue_iid'), tuple())
+
+ @exc.on_http_error(exc.GitlabCreateError)
+ def create(self, data, **kwargs):
+ """Create a new object.
+
+ Args:
+ data (dict): parameters to send to the server to create the
+ resource
+ **kwargs: Extra options to send to the Gitlab server (e.g. sudo)
+
+ Returns:
+ RESTObject, RESTObject: The source and target issues
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabCreateError: If the server cannot perform the request
+ """
+ self._check_missing_create_attrs(data)
+ server_data = self.gitlab.http_post(self.path, post_data=data,
+ **kwargs)
+ source_issue = ProjectIssue(self._parent.manager,
+ server_data['source_issue'])
+ target_issue = ProjectIssue(self._parent.manager,
+ server_data['target_issue'])
+ return source_issue, target_issue
+
+
class ProjectIssue(UserAgentDetailMixin, SubscribableMixin, TodoMixin,
TimeTrackingMixin, ParticipantsMixin, SaveMixin,
ObjectDeleteMixin, RESTObject):
@@ -1547,6 +1584,7 @@ class ProjectIssue(UserAgentDetailMixin, SubscribableMixin, TodoMixin,
_managers = (
('awardemojis', 'ProjectIssueAwardEmojiManager'),
('discussions', 'ProjectIssueDiscussionManager'),
+ ('links', 'ProjectIssueLinkManager'),
('notes', 'ProjectIssueNoteManager'),
)