| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6d3450c commit b15f17b
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ API objects manipulation | |||
| 7 | 7 | ||
| 8 | 8 | gl_objects/access_requests | |
| 9 | 9 | gl_objects/branches | |
| 10 | + gl_objects/messages | ||
| 10 | 11 | gl_objects/builds | |
| 11 | 12 | gl_objects/commits | |
| 12 | 13 | gl_objects/deploy_keys | |
@@ -16,7 +17,7 @@ API objects manipulation | |||
| 16 | 17 | gl_objects/issues | |
| 17 | 18 | gl_objects/labels | |
| 18 | 19 | gl_objects/licenses | |
| 19 | - gl_objects/messages | ||
| 20 | + gl_objects/notifications | ||
| 20 | 21 | gl_objects/mrs | |
| 21 | 22 | gl_objects/namespaces | |
| 22 | 23 | gl_objects/milestones | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + # get | ||
| 2 | + # global settings | ||
| 3 | + settings = gl.notificationsettings.get() | ||
| 4 | + # for a group | ||
| 5 | + settings = gl.groups.get(group_id).notificationsettings.get() | ||
| 6 | + # for a project | ||
| 7 | + settings = gl.projects.get(project_id).notificationsettings.get() | ||
| 8 | + # end get | ||
| 9 | + | ||
| 10 | + # update | ||
| 11 | + # use a predefined level | ||
| 12 | + settings.level = gitlab.NOTIFICATION_LEVEL_WATCH | ||
| 13 | + # create a custom setup | ||
| 14 | + settings.level = gitlab.NOTIFICATION_LEVEL_CUSTOM | ||
| 15 | + settings.save() # will create additional attributes, but not mandatory | ||
| 16 | + | ||
| 17 | + settings.new_merge_request = True | ||
| 18 | + settings.new_issue = True | ||
| 19 | + settings.new_note = True | ||
| 20 | + settings.save() | ||
| 21 | + # end update | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,38 @@ | |||
| 1 | + ##################### | ||
| 2 | + Notification settings | ||
| 3 | + ##################### | ||
| 4 | + | ||
| 5 | + You can define notification settings globally, for groups and for projects. | ||
| 6 | + Valid levels are defined as constants: | ||
| 7 | + | ||
| 8 | + * ``NOTIFICATION_LEVEL_DISABLED`` | ||
| 9 | + * ``NOTIFICATION_LEVEL_PARTICIPATING`` | ||
| 10 | + * ``NOTIFICATION_LEVEL_WATCH`` | ||
| 11 | + * ``NOTIFICATION_LEVEL_GLOBAL`` | ||
| 12 | + * ``NOTIFICATION_LEVEL_MENTION`` | ||
| 13 | + * ``NOTIFICATION_LEVEL_CUSTOM`` | ||
| 14 | + | ||
| 15 | + You get access to fine-grained settings if you use the | ||
| 16 | + ``NOTIFICATION_LEVEL_CUSTOM`` level. | ||
| 17 | + | ||
| 18 | + * Object classes: :class:`gitlab.objects.NotificationSettings` (global), | ||
| 19 | + :class:`gitlab.objects.GroupNotificationSettings` (groups) and | ||
| 20 | + :class:`gitlab.objects.ProjectNotificationSettings` (projects) | ||
| 21 | + * Manager objects: :attr:`gitlab.Gitlab.notificationsettings` (global), | ||
| 22 | + :attr:`gitlab.objects.Group.notificationsettings` (groups) and | ||
| 23 | + :attr:`gitlab.objects.Project.notificationsettings` (projects) | ||
| 24 | + | ||
| 25 | + Examples | ||
| 26 | + -------- | ||
| 27 | + | ||
| 28 | + Get the settings: | ||
| 29 | + | ||
| 30 | + .. literalinclude:: notifications.py | ||
| 31 | + :start-after: # get | ||
| 32 | + :end-before: # end get | ||
| 33 | + | ||
| 34 | + Update the settings: | ||
| 35 | + | ||
| 36 | + .. literalinclude:: notifications.py | ||
| 37 | + :start-after: # update | ||
| 38 | + :end-before: # end update | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,6 +82,8 @@ class Gitlab(object): | |||
| 82 | 82 | issues (IssueManager): Manager for GitLab issues | |
| 83 | 83 | licenses (LicenseManager): Manager for licenses | |
| 84 | 84 | namespaces (NamespaceManager): Manager for namespaces | |
| 85 | + notificationsettings (NotificationSettingsManager): Manager for global | ||
| 86 | + notification settings | ||
| 85 | 87 | project_accessrequests (ProjectAccessRequestManager): Manager for | |
| 86 | 88 | GitLab projects access requests | |
| 87 | 89 | project_boards (ProjectBoardManager): Manager for GitLab projects | |
@@ -181,6 +183,7 @@ def __init__(self, url, private_token=None, email=None, password=None, | |||
| 181 | 183 | self.issues = IssueManager(self) | |
| 182 | 184 | self.licenses = LicenseManager(self) | |
| 183 | 185 | self.namespaces = NamespaceManager(self) | |
| 186 | + self.notificationsettings = NotificationSettingsManager(self) | ||
| 184 | 187 | self.project_accessrequests = ProjectAccessRequestManager(self) | |
| 185 | 188 | self.project_boards = ProjectBoardManager(self) | |
| 186 | 189 | self.project_board_listss = ProjectBoardListManager(self) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,3 +24,10 @@ | |||
| 24 | 24 | VISIBILITY_PRIVATE = 0 | |
| 25 | 25 | VISIBILITY_INTERNAL = 10 | |
| 26 | 26 | VISIBILITY_PUBLIC = 20 | |
| 27 | + | ||
| 28 | + NOTIFICATION_LEVEL_DISABLED = 'disabled' | ||
| 29 | + NOTIFICATION_LEVEL_PARTICIPATING = 'participating' | ||
| 30 | + NOTIFICATION_LEVEL_WATCH = 'watch' | ||
| 31 | + NOTIFICATION_LEVEL_GLOBAL = 'global' | ||
| 32 | + NOTIFICATION_LEVEL_MENTION = 'mention' | ||
| 33 | + NOTIFICATION_LEVEL_CUSTOM = 'custom' | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -752,6 +752,30 @@ class KeyManager(BaseManager): | |||
| 752 | 752 | obj_cls = Key | |
| 753 | 753 | ||
| 754 | 754 | ||
| 755 | + class NotificationSettings(GitlabObject): | ||
| 756 | + _url = '/notification_settings' | ||
| 757 | + _id_in_update_url = False | ||
| 758 | + optionalUpdateAttrs = ['level', | ||
| 759 | + 'notification_email', | ||
| 760 | + 'new_note', | ||
| 761 | + 'new_issue', | ||
| 762 | + 'reopen_issue', | ||
| 763 | + 'close_issue', | ||
| 764 | + 'reassign_issue', | ||
| 765 | + 'new_merge_request', | ||
| 766 | + 'reopen_merge_request', | ||
| 767 | + 'close_merge_request', | ||
| 768 | + 'reassign_merge_request', | ||
| 769 | + 'merge_merge_request'] | ||
| 770 | + canList = False | ||
| 771 | + canCreate = False | ||
| 772 | + canDelete = False | ||
| 773 | + | ||
| 774 | + | ||
| 775 | + class NotificationSettingsManager(BaseManager): | ||
| 776 | + obj_cls = NotificationSettings | ||
| 777 | + | ||
| 778 | + | ||
| 755 | 779 | class GroupIssue(GitlabObject): | |
| 756 | 780 | _url = '/groups/%(group_id)s/issues' | |
| 757 | 781 | canGet = 'from_list' | |
@@ -783,6 +807,15 @@ class GroupMemberManager(BaseManager): | |||
| 783 | 807 | obj_cls = GroupMember | |
| 784 | 808 | ||
| 785 | 809 | ||
| 810 | + class GroupNotificationSettings(NotificationSettings): | ||
| 811 | + _url = '/groups/%(group_id)s/notification_settings' | ||
| 812 | + requiredUrlAttrs = ['group_id'] | ||
| 813 | + | ||
| 814 | + | ||
| 815 | + class GroupNotificationSettingsManager(BaseManager): | ||
| 816 | + obj_cls = GroupNotificationSettings | ||
| 817 | + | ||
| 818 | + | ||
| 786 | 819 | class GroupProject(GitlabObject): | |
| 787 | 820 | _url = '/groups/%(group_id)s/projects' | |
| 788 | 821 | canGet = 'from_list' | |
@@ -835,6 +868,8 @@ class Group(GitlabObject): | |||
| 835 | 868 | managers = [ | |
| 836 | 869 | ('accessrequests', GroupAccessRequestManager, [('group_id', 'id')]), | |
| 837 | 870 | ('members', GroupMemberManager, [('group_id', 'id')]), | |
| 871 | + ('notificationsettings', GroupNotificationSettingsManager, | ||
| 872 | + [('group_id', 'id')]), | ||
| 838 | 873 | ('projects', GroupProjectManager, [('group_id', 'id')]), | |
| 839 | 874 | ('issues', GroupIssueManager, [('group_id', 'id')]) | |
| 840 | 875 | ] | |
@@ -1385,6 +1420,15 @@ class ProjectNoteManager(BaseManager): | |||
| 1385 | 1420 | obj_cls = ProjectNote | |
| 1386 | 1421 | ||
| 1387 | 1422 | ||
| 1423 | + class ProjectNotificationSettings(NotificationSettings): | ||
| 1424 | + _url = '/projects/%(project_id)s/notification_settings' | ||
| 1425 | + requiredUrlAttrs = ['project_id'] | ||
| 1426 | + | ||
| 1427 | + | ||
| 1428 | + class ProjectNotificationSettingsManager(BaseManager): | ||
| 1429 | + obj_cls = ProjectNotificationSettings | ||
| 1430 | + | ||
| 1431 | + | ||
| 1388 | 1432 | class ProjectTagRelease(GitlabObject): | |
| 1389 | 1433 | _url = '/projects/%(project_id)s/repository/tags/%(tag_name)/release' | |
| 1390 | 1434 | canDelete = False | |
@@ -1987,6 +2031,8 @@ class Project(GitlabObject): | |||
| 1987 | 2031 | ('mergerequests', ProjectMergeRequestManager, [('project_id', 'id')]), | |
| 1988 | 2032 | ('milestones', ProjectMilestoneManager, [('project_id', 'id')]), | |
| 1989 | 2033 | ('notes', ProjectNoteManager, [('project_id', 'id')]), | |
| 2034 | + ('notificationsettings', ProjectNotificationSettingsManager, | ||
| 2035 | + [('project_id', 'id')]), | ||
| 1990 | 2036 | ('pipelines', ProjectPipelineManager, [('project_id', 'id')]), | |
| 1991 | 2037 | ('services', ProjectServiceManager, [('project_id', 'id')]), | |
| 1992 | 2038 | ('snippets', ProjectSnippetManager, [('project_id', 'id')]), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -282,3 +282,10 @@ | |||
| 282 | 282 | assert(msg.color == '#444444') | |
| 283 | 283 | msg.delete() | |
| 284 | 284 | assert(len(gl.broadcastmessages.list()) == 0) | |
| 285 | + | ||
| 286 | + # notification settings | ||
| 287 | + settings = gl.notificationsettings.get() | ||
| 288 | + settings.level = gitlab.NOTIFICATION_LEVEL_WATCH | ||
| 289 | + settings.save() | ||
| 290 | + settings = gl.notificationsettings.get() | ||
| 291 | + assert(settings.level == gitlab.NOTIFICATION_LEVEL_WATCH) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments