diff options
author | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2017-12-16 07:30:47 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2017-12-16 07:30:50 +0100 |
commit | b33265c7c235b4365c1a7b2b03ac519ba9e26fa4 (patch) | |
tree | b8b40089fa8191f3d258d9157070cfdc0baaca3b | |
parent | 2167409fd6388be6758ae71762af88a466ec648d (diff) | |
download | gitlab-b33265c7c235b4365c1a7b2b03ac519ba9e26fa4.tar.gz |
Add support for award emojis
Fixes #361
-rw-r--r-- | docs/api-objects.rst | 1 | ||||
-rw-r--r-- | gitlab/v4/objects.py | 94 | ||||
-rw-r--r-- | tools/python_test_v4.py | 4 |
3 files changed, 93 insertions, 6 deletions
diff --git a/docs/api-objects.rst b/docs/api-objects.rst index e549924..adfe5ff 100644 --- a/docs/api-objects.rst +++ b/docs/api-objects.rst @@ -6,6 +6,7 @@ API examples :maxdepth: 1 gl_objects/access_requests + gl_objects/emojis gl_objects/branches gl_objects/protected_branches gl_objects/messages diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 85aba12..0f947b4 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -1091,10 +1091,35 @@ class ProjectHookManager(CRUDMixin, RESTManager): ) -class ProjectIssueNote(SaveMixin, ObjectDeleteMixin, RESTObject): +class ProjectIssueAwardEmoji(ObjectDeleteMixin, RESTObject): pass +class ProjectIssueAwardEmojiManager(NoUpdateMixin, RESTManager): + _path = '/projects/%(project_id)s/issues/%(issue_iid)s/award_emoji' + _obj_cls = ProjectIssueAwardEmoji + _from_parent_attrs = {'project_id': 'project_id', 'issue_iid': 'iid'} + _create_attrs = (('name', ), tuple()) + + +class ProjectIssueNoteAwardEmoji(ObjectDeleteMixin, RESTObject): + pass + + +class ProjectIssueNoteAwardEmojiManager(NoUpdateMixin, RESTManager): + _path = ('/projects/%(project_id)s/issues/%(issue_iid)s' + '/notes/%(note_id)s/award_emoji') + _obj_cls = ProjectIssueNoteAwardEmoji + _from_parent_attrs = {'project_id': 'project_id', + 'issue_iid': 'issue_iid', + 'note_id': 'id'} + _create_attrs = (('name', ), tuple()) + + +class ProjectIssueNote(SaveMixin, ObjectDeleteMixin, RESTObject): + _managers = (('awardemojis', 'ProjectIssueNoteAwardEmojiManager'),) + + class ProjectIssueNoteManager(CRUDMixin, RESTManager): _path = '/projects/%(project_id)s/issues/%(issue_iid)s/notes' _obj_cls = ProjectIssueNote @@ -1107,7 +1132,10 @@ class ProjectIssue(SubscribableMixin, TodoMixin, TimeTrackingMixin, SaveMixin, ObjectDeleteMixin, RESTObject): _short_print_attr = 'title' _id_attr = 'iid' - _managers = (('notes', 'ProjectIssueNoteManager'), ) + _managers = ( + ('notes', 'ProjectIssueNoteManager'), + ('awardemojis', 'ProjectIssueAwardEmojiManager'), + ) @cli.register_custom_action('ProjectIssue') @exc.on_http_error(exc.GitlabUpdateError) @@ -1243,6 +1271,17 @@ class ProjectTagManager(NoUpdateMixin, RESTManager): _create_attrs = (('tag_name', 'ref'), ('message',)) +class ProjectMergeRequestAwardEmoji(ObjectDeleteMixin, RESTObject): + pass + + +class ProjectMergeRequestAwardEmojiManager(NoUpdateMixin, RESTManager): + _path = '/projects/%(project_id)s/merge_requests/%(mr_iid)s/award_emoji' + _obj_cls = ProjectMergeRequestAwardEmoji + _from_parent_attrs = {'project_id': 'project_id', 'mr_iid': 'iid'} + _create_attrs = (('name', ), tuple()) + + class ProjectMergeRequestDiff(RESTObject): pass @@ -1253,10 +1292,24 @@ class ProjectMergeRequestDiffManager(RetrieveMixin, RESTManager): _from_parent_attrs = {'project_id': 'project_id', 'mr_iid': 'iid'} -class ProjectMergeRequestNote(SaveMixin, ObjectDeleteMixin, RESTObject): +class ProjectMergeRequestNoteAwardEmoji(ObjectDeleteMixin, RESTObject): pass +class ProjectMergeRequestNoteAwardEmojiManager(NoUpdateMixin, RESTManager): + _path = ('/projects/%(project_id)s/merge_requests/%(mr_iid)s' + '/notes/%(note_id)s/award_emoji') + _obj_cls = ProjectMergeRequestNoteAwardEmoji + _from_parent_attrs = {'project_id': 'project_id', + 'mr_iid': 'issue_iid', + 'note_id': 'id'} + _create_attrs = (('name', ), tuple()) + + +class ProjectMergeRequestNote(SaveMixin, ObjectDeleteMixin, RESTObject): + _managers = (('awardemojis', 'ProjectMergeRequestNoteAwardEmojiManager'),) + + class ProjectMergeRequestNoteManager(CRUDMixin, RESTManager): _path = '/projects/%(project_id)s/merge_requests/%(mr_iid)s/notes' _obj_cls = ProjectMergeRequestNote @@ -1270,8 +1323,9 @@ class ProjectMergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, _id_attr = 'iid' _managers = ( + ('awardemojis', 'ProjectMergeRequestAwardEmojiManager'), + ('diffs', 'ProjectMergeRequestDiffManager'), ('notes', 'ProjectMergeRequestNoteManager'), - ('diffs', 'ProjectMergeRequestDiffManager') ) @cli.register_custom_action('ProjectMergeRequest') @@ -1764,10 +1818,24 @@ class ProjectPipelineManager(RetrieveMixin, CreateMixin, RESTManager): return CreateMixin.create(self, data, path=path, **kwargs) -class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject): +class ProjectSnippetNoteAwardEmoji(ObjectDeleteMixin, RESTObject): pass +class ProjectSnippetNoteAwardEmojiManager(NoUpdateMixin, RESTManager): + _path = ('/projects/%(project_id)s/snippets/%(snippet_id)s' + '/notes/%(note_id)s/award_emoji') + _obj_cls = ProjectSnippetNoteAwardEmoji + _from_parent_attrs = {'project_id': 'project_id', + 'snippet_id': 'snippet_id', + 'note_id': 'id'} + _create_attrs = (('name', ), tuple()) + + +class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject): + _managers = (('awardemojis', 'ProjectSnippetNoteAwardEmojiManager'),) + + class ProjectSnippetNoteManager(CRUDMixin, RESTManager): _path = '/projects/%(project_id)s/snippets/%(snippet_id)s/notes' _obj_cls = ProjectSnippetNote @@ -1777,10 +1845,24 @@ class ProjectSnippetNoteManager(CRUDMixin, RESTManager): _update_attrs = (('body', ), tuple()) +class ProjectSnippetAwardEmoji(ObjectDeleteMixin, RESTObject): + pass + + +class ProjectSnippetAwardEmojiManager(NoUpdateMixin, RESTManager): + _path = '/projects/%(project_id)s/snippets/%(snippet_id)s/award_emoji' + _obj_cls = ProjectSnippetAwardEmoji + _from_parent_attrs = {'project_id': 'project_id', 'snippet_id': 'id'} + _create_attrs = (('name', ), tuple()) + + class ProjectSnippet(SaveMixin, ObjectDeleteMixin, RESTObject): _url = '/projects/%(project_id)s/snippets' _short_print_attr = 'title' - _managers = (('notes', 'ProjectSnippetNoteManager'), ) + _managers = ( + ('awardemojis', 'ProjectSnippetAwardEmojiManager'), + ('notes', 'ProjectSnippetNoteManager'), + ) @cli.register_custom_action('ProjectSnippet') @exc.on_http_error(exc.GitlabGetError) diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py index f9ef83a..ce3c796 100644 --- a/tools/python_test_v4.py +++ b/tools/python_test_v4.py @@ -436,6 +436,10 @@ assert(len(admin_project.issues.list(milestone='milestone1')) == 1) assert(m1.issues().next().title == 'my issue 1') note = issue1.notes.create({'body': 'This is an issue note'}) assert(len(issue1.notes.list()) == 1) +emoji = note.awardemojis.create({'name': 'tractor'}) +assert(len(note.awardemojis.list()) == 1) +emoji.delete() +assert(len(note.awardemojis.list()) == 0) note.delete() assert(len(issue1.notes.list()) == 0) assert(isinstance(issue1.user_agent_detail(), dict)) |