Skip to content

feat(api): add support for epic notes #1712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/gl_objects/notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
Notes
#####

You can manipulate notes (comments) on project issues, merge requests and
You can manipulate notes (comments) on group epics, project issues, merge requests and
snippets.

Reference
---------

* v4 API:

Epics:

* :class:`gitlab.v4.objects.GroupEpicNote`
* :class:`gitlab.v4.objects.GroupEpicNoteManager`
* :attr:`gitlab.v4.objects.GroupEpic.notes`

Issues:

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

List the notes for a resource::

e_notes = epic.notes.list()
i_notes = issue.notes.list()
mr_notes = mr.notes.list()
s_notes = snippet.notes.list()

Get a note for a resource::

e_note = epic.notes.get(note_id)
i_note = issue.notes.get(note_id)
mr_note = mr.notes.get(note_id)
s_note = snippet.notes.get(note_id)

Create a note for a resource::

e_note = epic.notes.create({'body': 'note content'})
i_note = issue.notes.create({'body': 'note content'})
mr_note = mr.notes.create({'body': 'note content'})
s_note = snippet.notes.create({'body': 'note content'})
Expand Down
40 changes: 40 additions & 0 deletions gitlab/v4/objects/award_emojis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin

__all__ = [
"GroupEpicAwardEmoji",
"GroupEpicAwardEmojiManager",
"GroupEpicNoteAwardEmoji",
"GroupEpicNoteAwardEmojiManager",
"ProjectIssueAwardEmoji",
"ProjectIssueAwardEmojiManager",
"ProjectIssueNoteAwardEmoji",
Expand All @@ -19,6 +23,42 @@
]


class GroupEpicAwardEmoji(ObjectDeleteMixin, RESTObject):
pass


class GroupEpicAwardEmojiManager(NoUpdateMixin, RESTManager):
_path = "/groups/{group_id}/epics/{epic_iid}/award_emoji"
_obj_cls = GroupEpicAwardEmoji
_from_parent_attrs = {"group_id": "group_id", "epic_iid": "iid"}
_create_attrs = RequiredOptional(required=("name",))

def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
) -> GroupEpicAwardEmoji:
return cast(GroupEpicAwardEmoji, super().get(id=id, lazy=lazy, **kwargs))


class GroupEpicNoteAwardEmoji(ObjectDeleteMixin, RESTObject):
pass


class GroupEpicNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
_path = "/groups/{group_id}/epics/{epic_iid}/notes/{note_id}/award_emoji"
_obj_cls = GroupEpicNoteAwardEmoji
_from_parent_attrs = {
"group_id": "group_id",
"epic_iid": "epic_iid",
"note_id": "id",
}
_create_attrs = RequiredOptional(required=("name",))

def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
) -> GroupEpicNoteAwardEmoji:
return cast(GroupEpicNoteAwardEmoji, super().get(id=id, lazy=lazy, **kwargs))


class ProjectIssueAwardEmoji(ObjectDeleteMixin, RESTObject):
pass

Expand Down
47 changes: 46 additions & 1 deletion gitlab/v4/objects/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
)

from .award_emojis import ( # noqa: F401
GroupEpicNoteAwardEmojiManager,
ProjectIssueNoteAwardEmojiManager,
ProjectMergeRequestNoteAwardEmojiManager,
ProjectSnippetNoteAwardEmojiManager,
)

__all__ = [
"GroupEpicNote",
"GroupEpicNoteManager",
"GroupEpicDiscussionNote",
"GroupEpicDiscussionNoteManager",
"ProjectNote",
"ProjectNoteManager",
"ProjectCommitDiscussionNote",
Expand All @@ -38,6 +43,46 @@
]


class GroupEpicNote(SaveMixin, ObjectDeleteMixin, RESTObject):
awardemojis: GroupEpicNoteAwardEmojiManager


class GroupEpicNoteManager(CRUDMixin, RESTManager):
_path = "/groups/{group_id}/epics/{epic_iid}/notes"
_obj_cls = GroupEpicNote
_from_parent_attrs = {"group_id": "group_id", "epic_iid": "iid"}
_create_attrs = RequiredOptional(required=("body",), optional=("created_at",))
_update_attrs = RequiredOptional(required=("body",))

def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
) -> GroupEpicNote:
return cast(GroupEpicNote, super().get(id=id, lazy=lazy, **kwargs))


class GroupEpicDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject):
pass


class GroupEpicDiscussionNoteManager(
GetMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
):
_path = "/groups/{group_id}/epics/{epic_iid}/discussions/{discussion_id}/notes"
_obj_cls = GroupEpicDiscussionNote
_from_parent_attrs = {
"group_id": "group_id",
"epic_iid": "epic_iid",
"discussion_id": "id",
}
_create_attrs = RequiredOptional(required=("body",), optional=("created_at",))
_update_attrs = RequiredOptional(required=("body",))

def get(
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
) -> GroupEpicDiscussionNote:
return cast(GroupEpicDiscussionNote, super().get(id=id, lazy=lazy, **kwargs))


class ProjectNote(RESTObject):
pass

Expand Down Expand Up @@ -172,7 +217,7 @@ def get(


class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject):
awardemojis: ProjectMergeRequestNoteAwardEmojiManager
awardemojis: ProjectSnippetNoteAwardEmojiManager


class ProjectSnippetNoteManager(CRUDMixin, RESTManager):
Expand Down