Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd340d31

Browse files
author
Gauvain Pocentek
committed
Merge branch 'label-subscribe'
2 parents79feb87 +6f29ff1 commitd340d31

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

‎gitlab/objects.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,34 @@ class ProjectLabel(GitlabObject):
13581358
requiredUpdateAttrs= ['name']
13591359
optionalUpdateAttrs= ['new_name','color','description']
13601360

1361+
defsubscribe(self,**kwargs):
1362+
"""Subscribe to a label.
1363+
1364+
Raises:
1365+
GitlabConnectionError: If the server cannot be reached.
1366+
GitlabSubscribeError: If the subscription cannot be done
1367+
"""
1368+
url= ('/projects/%(project_id)s/labels/%(label_id)s/subscription'%
1369+
{'project_id':self.project_id,'label_id':self.name})
1370+
1371+
r=self.gitlab._raw_post(url,**kwargs)
1372+
raise_error_from_response(r,GitlabSubscribeError, [201,304])
1373+
self._set_from_dict(r.json())
1374+
1375+
defunsubscribe(self,**kwargs):
1376+
"""Unsubscribe a label.
1377+
1378+
Raises:
1379+
GitlabConnectionError: If the server cannot be reached.
1380+
GitlabSubscribeError: If the unsubscription cannot be done
1381+
"""
1382+
url= ('/projects/%(project_id)s/labels/%(label_id)s/subscription'%
1383+
{'project_id':self.project_id,'label_id':self.name})
1384+
1385+
r=self.gitlab._raw_delete(url,**kwargs)
1386+
raise_error_from_response(r,GitlabUnsubscribeError, [200,304])
1387+
self._set_from_dict(r.json())
1388+
13611389

13621390
classProjectLabelManager(BaseManager):
13631391
obj_cls=ProjectLabel

‎tools/python_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@
163163
label1.new_name='label1updated'
164164
label1.save()
165165
assert(label1.name=='label1updated')
166+
label1.subscribe()
167+
assert(label1.subscribed==True)
168+
label1.unsubscribe()
169+
assert(label1.subscribed==False)
166170
label1.delete()
167171

168172
# milestones

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp