Skip to content

Commit 29e735d

Browse files
author
Gauvain Pocentek
committed
[v4] Triggers: update object
* Add support for the description attribute * Add ``take_ownership`` support * Triggers now use ``id`` as identifier
1 parent 5ea7f84 commit 29e735d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

gitlab/v4/objects.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,22 @@ class ProjectSnippetManager(BaseManager):
15901590

15911591
class ProjectTrigger(GitlabObject):
15921592
_url = '/projects/%(project_id)s/triggers'
1593-
canUpdate = False
1594-
idAttr = 'token'
1595-
requiredUrlAttrs = ['project_id', 'description']
1593+
requiredUrlAttrs = ['project_id']
1594+
requiredCreateAttrs = ['description']
1595+
optionalUpdateAttrs = ['description']
1596+
1597+
def take_ownership(self, **kwargs):
1598+
"""Update the owner of a trigger.
1599+
1600+
Raises:
1601+
GitlabConnectionError: If the server cannot be reached.
1602+
GitlabGetError: If the server fails to perform the request.
1603+
"""
1604+
url = ('/projects/%(project_id)s/triggers/%(id)s/take_ownership' %
1605+
{'project_id': self.project_id, 'id': self.id})
1606+
r = self.gitlab._raw_post(url, **kwargs)
1607+
raise_error_from_response(r, GitlabUpdateError, 200)
1608+
self._set_from_dict(r.json())
15961609

15971610

15981611
class ProjectTriggerManager(BaseManager):

0 commit comments

Comments
 (0)