diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2016-10-23 21:46:28 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2016-10-23 21:46:28 +0200 |
commit | b15f17b6d2008ee658cf9206aa37faaf966a521b (patch) | |
tree | 0ea09ee088d28770c7bc6d0e34382ca1cb142a9f /gitlab | |
parent | 6d3450c4fe4a2e592b9000be309819278f519e11 (diff) | |
download | gitlab-b15f17b6d2008ee658cf9206aa37faaf966a521b.tar.gz |
Add support for the notification settings API
Diffstat (limited to 'gitlab')
-rw-r--r-- | gitlab/__init__.py | 3 | ||||
-rw-r--r-- | gitlab/const.py | 7 | ||||
-rw-r--r-- | gitlab/objects.py | 46 |
3 files changed, 56 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index a022cb4..14b642d 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -82,6 +82,8 @@ class Gitlab(object): issues (IssueManager): Manager for GitLab issues licenses (LicenseManager): Manager for licenses namespaces (NamespaceManager): Manager for namespaces + notificationsettings (NotificationSettingsManager): Manager for global + notification settings project_accessrequests (ProjectAccessRequestManager): Manager for GitLab projects access requests project_boards (ProjectBoardManager): Manager for GitLab projects @@ -181,6 +183,7 @@ class Gitlab(object): self.issues = IssueManager(self) self.licenses = LicenseManager(self) self.namespaces = NamespaceManager(self) + self.notificationsettings = NotificationSettingsManager(self) self.project_accessrequests = ProjectAccessRequestManager(self) self.project_boards = ProjectBoardManager(self) self.project_board_listss = ProjectBoardListManager(self) diff --git a/gitlab/const.py b/gitlab/const.py index 7930c0b..99a1745 100644 --- a/gitlab/const.py +++ b/gitlab/const.py @@ -24,3 +24,10 @@ OWNER_ACCESS = 50 VISIBILITY_PRIVATE = 0 VISIBILITY_INTERNAL = 10 VISIBILITY_PUBLIC = 20 + +NOTIFICATION_LEVEL_DISABLED = 'disabled' +NOTIFICATION_LEVEL_PARTICIPATING = 'participating' +NOTIFICATION_LEVEL_WATCH = 'watch' +NOTIFICATION_LEVEL_GLOBAL = 'global' +NOTIFICATION_LEVEL_MENTION = 'mention' +NOTIFICATION_LEVEL_CUSTOM = 'custom' diff --git a/gitlab/objects.py b/gitlab/objects.py index 0897c68..e95a894 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -752,6 +752,30 @@ class KeyManager(BaseManager): obj_cls = Key +class NotificationSettings(GitlabObject): + _url = '/notification_settings' + _id_in_update_url = False + optionalUpdateAttrs = ['level', + 'notification_email', + 'new_note', + 'new_issue', + 'reopen_issue', + 'close_issue', + 'reassign_issue', + 'new_merge_request', + 'reopen_merge_request', + 'close_merge_request', + 'reassign_merge_request', + 'merge_merge_request'] + canList = False + canCreate = False + canDelete = False + + +class NotificationSettingsManager(BaseManager): + obj_cls = NotificationSettings + + class GroupIssue(GitlabObject): _url = '/groups/%(group_id)s/issues' canGet = 'from_list' @@ -783,6 +807,15 @@ class GroupMemberManager(BaseManager): obj_cls = GroupMember +class GroupNotificationSettings(NotificationSettings): + _url = '/groups/%(group_id)s/notification_settings' + requiredUrlAttrs = ['group_id'] + + +class GroupNotificationSettingsManager(BaseManager): + obj_cls = GroupNotificationSettings + + class GroupProject(GitlabObject): _url = '/groups/%(group_id)s/projects' canGet = 'from_list' @@ -835,6 +868,8 @@ class Group(GitlabObject): managers = [ ('accessrequests', GroupAccessRequestManager, [('group_id', 'id')]), ('members', GroupMemberManager, [('group_id', 'id')]), + ('notificationsettings', GroupNotificationSettingsManager, + [('group_id', 'id')]), ('projects', GroupProjectManager, [('group_id', 'id')]), ('issues', GroupIssueManager, [('group_id', 'id')]) ] @@ -1385,6 +1420,15 @@ class ProjectNoteManager(BaseManager): obj_cls = ProjectNote +class ProjectNotificationSettings(NotificationSettings): + _url = '/projects/%(project_id)s/notification_settings' + requiredUrlAttrs = ['project_id'] + + +class ProjectNotificationSettingsManager(BaseManager): + obj_cls = ProjectNotificationSettings + + class ProjectTagRelease(GitlabObject): _url = '/projects/%(project_id)s/repository/tags/%(tag_name)/release' canDelete = False @@ -1987,6 +2031,8 @@ class Project(GitlabObject): ('mergerequests', ProjectMergeRequestManager, [('project_id', 'id')]), ('milestones', ProjectMilestoneManager, [('project_id', 'id')]), ('notes', ProjectNoteManager, [('project_id', 'id')]), + ('notificationsettings', ProjectNotificationSettingsManager, + [('project_id', 'id')]), ('pipelines', ProjectPipelineManager, [('project_id', 'id')]), ('services', ProjectServiceManager, [('project_id', 'id')]), ('snippets', ProjectSnippetManager, [('project_id', 'id')]), |