summaryrefslogtreecommitdiff
path: root/docs/gl_objects
diff options
context:
space:
mode:
Diffstat (limited to 'docs/gl_objects')
-rw-r--r--docs/gl_objects/notifications.py21
-rw-r--r--docs/gl_objects/notifications.rst38
2 files changed, 59 insertions, 0 deletions
diff --git a/docs/gl_objects/notifications.py b/docs/gl_objects/notifications.py
new file mode 100644
index 0000000..c46e36e
--- /dev/null
+++ b/docs/gl_objects/notifications.py
@@ -0,0 +1,21 @@
+# get
+# global settings
+settings = gl.notificationsettings.get()
+# for a group
+settings = gl.groups.get(group_id).notificationsettings.get()
+# for a project
+settings = gl.projects.get(project_id).notificationsettings.get()
+# end get
+
+# update
+# use a predefined level
+settings.level = gitlab.NOTIFICATION_LEVEL_WATCH
+# create a custom setup
+settings.level = gitlab.NOTIFICATION_LEVEL_CUSTOM
+settings.save() # will create additional attributes, but not mandatory
+
+settings.new_merge_request = True
+settings.new_issue = True
+settings.new_note = True
+settings.save()
+# end update
diff --git a/docs/gl_objects/notifications.rst b/docs/gl_objects/notifications.rst
new file mode 100644
index 0000000..472f710
--- /dev/null
+++ b/docs/gl_objects/notifications.rst
@@ -0,0 +1,38 @@
+#####################
+Notification settings
+#####################
+
+You can define notification settings globally, for groups and for projects.
+Valid levels are defined as constants:
+
+* ``NOTIFICATION_LEVEL_DISABLED``
+* ``NOTIFICATION_LEVEL_PARTICIPATING``
+* ``NOTIFICATION_LEVEL_WATCH``
+* ``NOTIFICATION_LEVEL_GLOBAL``
+* ``NOTIFICATION_LEVEL_MENTION``
+* ``NOTIFICATION_LEVEL_CUSTOM``
+
+You get access to fine-grained settings if you use the
+``NOTIFICATION_LEVEL_CUSTOM`` level.
+
+* Object classes: :class:`gitlab.objects.NotificationSettings` (global),
+ :class:`gitlab.objects.GroupNotificationSettings` (groups) and
+ :class:`gitlab.objects.ProjectNotificationSettings` (projects)
+* Manager objects: :attr:`gitlab.Gitlab.notificationsettings` (global),
+ :attr:`gitlab.objects.Group.notificationsettings` (groups) and
+ :attr:`gitlab.objects.Project.notificationsettings` (projects)
+
+Examples
+--------
+
+Get the settings:
+
+.. literalinclude:: notifications.py
+ :start-after: # get
+ :end-before: # end get
+
+Update the settings:
+
+.. literalinclude:: notifications.py
+ :start-after: # update
+ :end-before: # end update