summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2017-05-24 13:28:31 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2017-05-24 13:30:16 +0200
commit29e735d11af3464da56bb11da58fa6028a96546d (patch)
tree253e7527944836a28e114699857eee11e3c86e94
parent5ea7f8431fc14e4d33c2fe0babd0401f2543f2c6 (diff)
downloadgitlab-29e735d11af3464da56bb11da58fa6028a96546d.tar.gz
[v4] Triggers: update object
* Add support for the description attribute * Add ``take_ownership`` support * Triggers now use ``id`` as identifier
-rw-r--r--gitlab/v4/objects.py19
1 files changed, 16 insertions, 3 deletions
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):