8000 Add support for award emojis · python-gitlab/python-gitlab@b33265c · GitHub
[go: up one dir, main page]

Skip to content

Commit b33265c

Browse files
author
Gauvain Pocentek
committed
Add support for award emojis
Fixes #361
1 parent 2167409 commit b33265c

File tree

3 files changed

+93
-6
lines changed

3 files changed

+93
-6
lines changed

docs/api-objects.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ API examples
66
:maxdepth: 1
77

88
gl_objects/access_requests
9+
gl_objects/emojis
910
gl_objects/branches
1011
gl_objects/protected_branches
1112
gl_objects/messages

gitlab/v4/objects.py

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,10 +1091,35 @@ class ProjectHookManager(CRUDMixin, RESTManager):
10911091
)
10921092

10931093

1094-
class ProjectIssueNote(SaveMixin, ObjectDeleteMixin, RESTObject):
1094+
class ProjectIssueAwardEmoji(ObjectDeleteMixin, RESTObject):
10951095
pass
10961096

10971097

1098+
class ProjectIssueAwardEmojiManager(NoUpdateMixin, RESTManager):
1099+
_path = '/projects/%(project_id)s/issues/%(issue_iid)s/award_emoji'
1100+
_obj_cls = ProjectIssueAwardEmoji
1101+
_from_parent_attrs = {'project_id': 'project_id', 'issue_iid': 'iid'}
1102+
_create_attrs = (('name', ), tuple())
1103+
1104+
1105+
class ProjectIssueNoteAwardEmoji(ObjectDeleteMixin, RESTObject):
1106+
pass
1107+
1108+
1109+
class ProjectIssueNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
1110+
_path = ('/projects/%(project_id)s/issues/%(issue_iid)s'
1111+
'/notes/%(note_id)s/award_emoji')
1112+
_obj_cls = ProjectIssueNoteAwardEmoji
1113+
_from_parent_attrs = {'project_id': 'project_id',
1114+
'issue_iid': 'issue_iid',
1115+
'note_id': 'id'}
1116+
_create_attrs = (('name', ), tuple())
1117+
1118+
1119+
class ProjectIssueNote(SaveMixin, ObjectDeleteMixin, RESTObject):
1120+
_managers = (('awardemojis', 'ProjectIssueNoteAwardEmojiManager'),)
1121+
1122+
10981123
class ProjectIssueNoteManager(CRUDMixin, RESTManager):
10991124
_path = '/projects/%(project_id)s/issues/%(issue_iid)s/notes'
11001125
_obj_cls = ProjectIssueNote
@@ -1107,7 +1132,10 @@ class ProjectIssue(SubscribableMixin, TodoMixin, TimeTrackingMixin, SaveMixin,
11071132
ObjectDeleteMixin, RESTObject):
11081133
_short_print_attr = 'title'
11091134
_id_attr = 'iid'
1110-
_managers = (('notes', 'ProjectIssueNoteManager'), )
1135+
_managers = (
1136+
('notes', 'ProjectIssueNoteManager'),
1137+
('awardemojis', 'ProjectIssueAwardEmojiManager'),
1138+
)
11111139

11121140
@cli.register_custom_action('ProjectIssue')
11131141
@exc.on_http_error(exc.GitlabUpdateError)
@@ -1243,6 +1271,17 @@ class ProjectTagManager(NoUpdateMixin, RESTManager):
12431271
_create_attrs = (('tag_name', 'ref'), ('message',))
12441272

12451273

1274+
class ProjectMergeRequestAwardEmoji(ObjectDeleteMixin, RESTObject):
1275+
pass
1276+
1277+
1278+
class ProjectMergeRequestAwardEmojiManager(NoUpdateMixin, RESTManager):
1279+
_path = '/projects/%(project_id)s/merge_requests/%(mr_iid)s/award_emoji'
1280+
_obj_cls = ProjectMergeRequestAwardEmoji
1281+
_from_parent_attrs = {'project_id': 'project_id', 'mr_iid': 'iid'}
1282+
_create_attrs = (('name', ), tuple())
1283+
1284+
12461285
class ProjectMergeRequestDiff(RESTObject):
12471286
pass
12481287

@@ -1253,10 +1292,24 @@ class ProjectMergeRequestDiffManager(RetrieveMixin, RESTManager):
12531292
_from_parent_attrs = {'project_id': 'project_id', 'mr_iid': 'iid'}
12541293

12551294

1256-
class ProjectMergeRequestNote(SaveMixin, ObjectDeleteMixin, RESTObject):
1295+
class ProjectMergeRequestNoteAwardEmoji(ObjectDeleteMixin, RESTObject):
12571296
pass
12581297

12591298

1299+
class ProjectMergeRequestNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
1300+
_path = ('/projects/%(project_id)s/merge_requests/%(mr_iid)s'
1301+
'/notes/%(note_id)s/award_emoji')
1302+
_obj_cls = ProjectMergeRequestNoteAwardEmoji
1303+
_from_parent_attrs = {'project_id': 'project_id',
1304+
'mr_iid': 'issue_iid',
1305+
'note_id': 'id'}
1306+
_create_attrs = (('name', ), tuple())
1307+
1308+
1309+
class ProjectMergeRequestNote(SaveMixin, ObjectDeleteMixin, RESTObject):
1310+
_managers = (('awardemojis', 'ProjectMergeRequestNoteAwardEmojiManager'),)
1311+
1312+
12601313
class ProjectMergeRequestNoteManager(CRUDMixin, RESTManager):
12611314
_path = '/projects/%(project_id)s/merge_requests/%(mr_iid)s/notes'
12621315
_obj_cls = ProjectMergeRequestNote
@@ -1270,8 +1323,9 @@ class ProjectMergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin,
12701323
_id_attr = 'iid'
12711324

12721325
_managers = (
1326+
('awardemojis', 'ProjectMergeRequestAwardEmojiManager'),
1327+
('diffs', 'ProjectMergeRequestDiffManager'),
12731328
('notes', 'ProjectMergeRequestNoteManager'),
1274-
('diffs', 'ProjectMergeRequestDiffManager')
12751329
)
12761330

12771331
@cli.register_custom_action('ProjectMergeRequest')
@@ -1764,10 +1818,24 @@ def create(self, data, **kwargs):
17641818
return CreateMixin.create(self, data, path=path, **kwargs)
17651819

17661820

1767-
class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject):
1821+
class ProjectSnippetNoteAwardEmoji(ObjectDeleteMixin, RESTObject):
17681822
pass
17691823

17701824

1825+
class ProjectSnippetNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
1826+
_path = ('/projects/%(project_id)s/snippets/%(snippet_id)s'
1827+
'/notes/%(note_id)s/award_emoji')
1828+
_obj_cls = ProjectSnippetNoteAwardEmoji
1829+
_from_parent_attrs = {'project_id': 'project_id',
1830+
'snippet_id': 'snippet_id',
1831+
'note_id': 'id'}
1832+
_create_attrs = (('name', ), tuple())
1833+
1834+
1835+
class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject):
1836+
_managers = (('awardemojis', 'ProjectSnippetNoteAwardEmojiManager'),)
1837+
1838+
17711839
class ProjectSnippetNoteManager(CRUDMixin, RESTManager):
17721840
_path = '/projects/%(project_id)s/snippets/%(snippet_id)s/notes'
17731841
_obj_cls = ProjectSnippetNote
@@ -1777,10 +1845,24 @@ class ProjectSnippetNoteManager(CRUDMixin, RESTManager):
17771845
_update_attrs = (('body', ), tuple())
17781846

17791847

1848+
class ProjectSnippetAwardEmoji(ObjectDeleteMixin, RESTObject):
1849+
pass
1850+
1851+
1852+
class ProjectSnippetAwardEmojiManager(NoUpdateMixin, RESTManager):
1853+
_path = '/projects/%(project_id)s/snippets/%(snippet_id)s/award_emoji'
1854+
_obj_cls = ProjectSnippetAwardEmoji
1855+
_from_parent_attrs = {'project_id': 'project_id', 'snippet_id': 'id'}
1856+
_create_attrs = (('name', ), tuple())
1857+
1858+
17801859
class ProjectSnippet(SaveMixin, ObjectDeleteMixin, RESTObject):
17811860
_url = '/projects/%(project_id)s/snippets'
17821861
_short_print_attr = 'title'
1783-
_managers = (('notes', 'ProjectSnippetNoteManager'), )
1862+
_managers = (
1863+
('awardemojis', 'ProjectSnippetAwardEmojiManager'),
1864+
('notes', 'ProjectSnippetNoteManager'),
1865+
)
17841866

17851867
@cli.register_custom_action('ProjectSnippet')
17861868
@exc.on_http_error(exc.GitlabGetError)

tools/python_test_v4.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@
436436
assert(m1.issues().next().title == 'my issue 1')
437437
note = issue1.notes.create({'body': 'This is an issue note'})
438438
assert(len(issue1.notes.list()) == 1)
439+
emoji = note.awardemojis.create({'name': 'tractor'})
440+
assert(len(note.awardemojis.list()) == 1)
441+
emoji.delete()
442+
assert(len(note.awardemojis.list()) == 0)
439443
note.delete()
440444
assert(len(issue1.notes.list()) == 0)
441445
assert(isinstance(issue1.user_agent_detail(), dict))

0 commit comments

Comments
 (0)
0