Skip to content

Commit 7f4edb5

Browse files
committed
feat(api): add support for epic notes
Added support for notes on group epics Signed-off-by: Raimund Hook <raimund.hook@exfo.com>
1 parent 3225f2c commit 7f4edb5

File tree

3 files changed

+96
-2
lines changed

3 files changed

+96
-2
lines changed

docs/gl_objects/notes.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@
44
Notes
55
#####
66

7-
You can manipulate notes (comments) on project issues, merge requests and
7+
You can manipulate notes (comments) on group epics, project issues, merge requests and
88
snippets.
99

1010
Reference
1111
---------
1212

1313
* v4 API:
1414

15+
Epics:
16+
17+
* :class:`gitlab.v4.objects.GroupEpicNote`
18+
* :class:`gitlab.v4.objects.GroupEpicNoteManager`
19+
* :attr:`gitlab.v4.objects.GroupEpic.notes`
20+
1521
Issues:
1622

1723
+ :class:`gitlab.v4.objects.ProjectIssueNote`
@@ -37,18 +43,21 @@ Examples
3743

3844
List the notes for a resource::
3945

46+
e_notes = epic.notes.list()
4047
i_notes = issue.notes.list()
4148
mr_notes = mr.notes.list()
4249
s_notes = snippet.notes.list()
4350

4451
Get a note for a resource::
4552

53+
e_note = epic.notes.get(note_id)
4654
i_note = issue.notes.get(note_id)
4755
mr_note = mr.notes.get(note_id)
4856
s_note = snippet.notes.get(note_id)
4957

5058
Create a note for a resource::
5159

60+
e_note = epic.notes.create({'body': 'note content'})
5261
i_note = issue.notes.create({'body': 'note content'})
5362
mr_note = mr.notes.create({'body': 'note content'})
5463
s_note = snippet.notes.create({'body': 'note content'})

gitlab/v4/objects/award_emojis.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin
55

66
__all__ = [
7+
"GroupEpicAwardEmoji",
8+
"GroupEpicAwardEmojiManager",
9+
"GroupEpicNoteAwardEmoji",
10+
"GroupEpicNoteAwardEmojiManager",
711
"ProjectIssueAwardEmoji",
812
"ProjectIssueAwardEmojiManager",
913
"ProjectIssueNoteAwardEmoji",
@@ -19,6 +23,42 @@
1923
]
2024

2125

26+
class GroupEpicAwardEmoji(ObjectDeleteMixin, RESTObject):
27+
pass
28+
29+
30+
class GroupEpicAwardEmojiManager(NoUpdateMixin, RESTManager):
31+
_path = "/groups/{group_id}/epics/{epic_iid}/award_emoji"
32+
_obj_cls = GroupEpicAwardEmoji
33+
_from_parent_attrs = {"group_id": "group_id", "epic_iid": "iid"}
34+
_create_attrs = RequiredOptional(required=("name",))
35+
36+
def get(
37+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
38+
) -> GroupEpicAwardEmoji:
39+
return cast(GroupEpicAwardEmoji, super().get(id=id, lazy=lazy, **kwargs))
40+
41+
42+
class GroupEpicNoteAwardEmoji(ObjectDeleteMixin, RESTObject):
43+
pass
44+
45+
46+
class GroupEpicNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
47+
_path = "/groups/{group_id}/epics/{epic_iid}/notes/{note_id}/award_emoji"
48+
_obj_cls = GroupEpicNoteAwardEmoji
49+
_from_parent_attrs = {
50+
"group_id": "group_id",
51+
"epic_iid": "epic_iid",
52+
"note_id": "id",
53+
}
54+
_create_attrs = RequiredOptional(required=("name",))
55+
56+
def get(
57+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
58+
) -> GroupEpicNoteAwardEmoji:
59+
return cast(GroupEpicNoteAwardEmoji, super().get(id=id, lazy=lazy, **kwargs))
60+
61+
2262
class ProjectIssueAwardEmoji(ObjectDeleteMixin, RESTObject):
2363
pass
2464

gitlab/v4/objects/notes.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@
1313
)
1414

1515
from .award_emojis import ( # noqa: F401
16+
GroupEpicNoteAwardEmojiManager,
1617
ProjectIssueNoteAwardEmojiManager,
1718
ProjectMergeRequestNoteAwardEmojiManager,
1819
ProjectSnippetNoteAwardEmojiManager,
1920
)
2021

2122
__all__ = [
23+
"GroupEpicNote",
24+
"GroupEpicNoteManager",
25+
"GroupEpicDiscussionNote",
26+
"GroupEpicDiscussionNoteManager",
2227
"ProjectNote",
2328
"ProjectNoteManager",
2429
"ProjectCommitDiscussionNote",
@@ -38,6 +43,46 @@
3843
]
3944

4045

46+
class GroupEpicNote(SaveMixin, ObjectDeleteMixin, RESTObject):
47+
awardemojis: GroupEpicNoteAwardEmojiManager
48+
49+
50+
class GroupEpicNoteManager(CRUDMixin, RESTManager):
51+
_path = "/groups/{group_id}/epics/{epic_iid}/notes"
52+
_obj_cls = GroupEpicNote
53+
_from_parent_attrs = {"group_id": "group_id", "epic_iid": "iid"}
54+
_create_attrs = RequiredOptional(required=("body",), optional=("created_at",))
55+
_update_attrs = RequiredOptional(required=("body",))
56+
57+
def get(
58+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
59+
) -> GroupEpicNote:
60+
return cast(GroupEpicNote, super().get(id=id, lazy=lazy, **kwargs))
61+
62+
63+
class GroupEpicDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject):
64+
pass
65+
66+
67+
class GroupEpicDiscussionNoteManager(
68+
GetMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
69+
):
70+
_path = "/groups/{group_id}/epics/{epic_iid}/discussions/{discussion_id}/notes"
71+
_obj_cls = GroupEpicDiscussionNote
72+
_from_parent_attrs = {
73+
"group_id": "group_id",
74+
"epic_iid": "epic_iid",
75+
"discussion_id": "id",
76+
}
77+
_create_attrs = RequiredOptional(required=("body",), optional=("created_at",))
78+
_update_attrs = RequiredOptional(required=("body",))
79+
80+
def get(
81+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
82+
) -> GroupEpicDiscussionNote:
83+
return cast(GroupEpicDiscussionNote, super().get(id=id, lazy=lazy, **kwargs))
84+
85+
4186
class ProjectNote(RESTObject):
4287
pass
4388

@@ -172,7 +217,7 @@ def get(
172217

173218

174219
class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject):
175-
awardemojis: ProjectMergeRequestNoteAwardEmojiManager
220+
awardemojis: ProjectSnippetNoteAwardEmojiManager
176221

177222

178223
class ProjectSnippetNoteManager(CRUDMixin, RESTManager):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy