From 29e735d11af3464da56bb11da58fa6028a96546d Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Wed, 24 May 2017 13:28:31 +0200 Subject: [v4] Triggers: update object * Add support for the description attribute * Add ``take_ownership`` support * Triggers now use ``id`` as identifier --- gitlab/v4/objects.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'gitlab/v4/objects.py') diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 7f41114..d5fbd4d 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -1590,9 +1590,22 @@ class ProjectSnippetManager(BaseManager): class ProjectTrigger(GitlabObject): _url = '/projects/%(project_id)s/triggers' - canUpdate = False - idAttr = 'token' - requiredUrlAttrs = ['project_id', 'description'] + requiredUrlAttrs = ['project_id'] + requiredCreateAttrs = ['description'] + optionalUpdateAttrs = ['description'] + + def take_ownership(self, **kwargs): + """Update the owner of a trigger. + + Raises: + GitlabConnectionError: If the server cannot be reached. + GitlabGetError: If the server fails to perform the request. + """ + url = ('/projects/%(project_id)s/triggers/%(id)s/take_ownership' % + {'project_id': self.project_id, 'id': self.id}) + r = self.gitlab._raw_post(url, **kwargs) + raise_error_from_response(r, GitlabUpdateError, 200) + self._set_from_dict(r.json()) class ProjectTriggerManager(BaseManager): -- cgit v1.2.1