Notification settings API

原文:https://docs.gitlab.com/ee/api/notification_settings.html

Notification settings API

在 GitLab 8.12 中引入 .

Valid notification levels

通知级别在NotificationSetting.level模型枚举中定义. 当前,这些级别被认可:

  1. disabled
  2. participating
  3. watch
  4. global
  5. mention
  6. custom

如果使用custom级别,则可以控制特定的电子邮件事件. 可用事件由NotificationSetting.email_events返回. 当前,这些事件被认可:

  • new_note
  • new_issue
  • reopen_issue
  • close_issue
  • reassign_issue
  • issue_due
  • new_merge_request
  • push_to_merge_request
  • reopen_merge_request
  • close_merge_request
  • reassign_merge_request
  • merge_merge_request
  • failed_pipeline
  • fixed_pipeline
  • success_pipeline
  • new_epic

Global notification settings

获取当前的通知设置和电子邮件地址.

  1. GET /notification_settings
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/notification_settings"

响应示例:

  1. { "level": "participating", "notification_email": "admin@example.com" }

Update global notification settings

更新当前的通知设置和电子邮件地址.

  1. PUT /notification_settings
  1. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/notification_settings?level=watch"
Attribute Type Required Description
level string no 全局通知级别
notification_email string no 发送通知的电子邮件地址
new_note boolean no 启用/禁用此通知
new_issue boolean no 启用/禁用此通知
reopen_issue boolean no 启用/禁用此通知
close_issue boolean no 启用/禁用此通知
reassign_issue boolean no 启用/禁用此通知
issue_due boolean no 启用/禁用此通知
new_merge_request boolean no 启用/禁用此通知
push_to_merge_request boolean no 启用/禁用此通知
reopen_merge_request boolean no 启用/禁用此通知
close_merge_request boolean no 启用/禁用此通知
reassign_merge_request boolean no 启用/禁用此通知
merge_merge_request boolean no 启用/禁用此通知
failed_pipeline boolean no 启用/禁用此通知
fixed_pipeline boolean no 启用/禁用此通知
success_pipeline boolean no 启用/禁用此通知
new_epic boolean no 启用/禁用此通知(在 11.3 中引入

响应示例:

  1. { "level": "watch", "notification_email": "admin@example.com" }

Group / project level notification settings

获取当前的组或项目通知设置.

  1. GET /groups/:id/notification_settings
  2. GET /projects/:id/notification_settings
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/notification_settings"
  2. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/8/notification_settings"
Attribute Type Required Description
id integer/string yes 组/项目 ID 或路径

响应示例:

  1. { "level": "global" }

Update group/project level notification settings

更新当前的组/项目通知设置.

  1. PUT /groups/:id/notification_settings
  2. PUT /projects/:id/notification_settings
  1. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/notification_settings?level=watch"
  2. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/8/notification_settings?level=custom&new_note=true"
Attribute Type Required Description
id integer/string yes 组/项目 ID 或路径
level string no 全局通知级别
new_note boolean no 启用/禁用此通知
new_issue boolean no 启用/禁用此通知
reopen_issue boolean no 启用/禁用此通知
close_issue boolean no 启用/禁用此通知
reassign_issue boolean no 启用/禁用此通知
issue_due boolean no 启用/禁用此通知
new_merge_request boolean no 启用/禁用此通知
push_to_merge_request boolean no 启用/禁用此通知
reopen_merge_request boolean no 启用/禁用此通知
close_merge_request boolean no 启用/禁用此通知
reassign_merge_request boolean no 启用/禁用此通知
merge_merge_request boolean no 启用/禁用此通知
failed_pipeline boolean no 启用/禁用此通知
fixed_pipeline boolean no 启用/禁用此通知
success_pipeline boolean no 启用/禁用此通知
new_epic boolean no 启用/禁用此通知(在 11.3 中引入

响应示例:

  1. { "level": "watch" } { "level": "custom", "events": { "new_note": true, "new_issue": false, "reopen_issue": false, "close_issue": false, "reassign_issue": false, "issue_due": false, "new_merge_request": false, "push_to_merge_request": false, "reopen_merge_request": false, "close_merge_request": false, "reassign_merge_request": false, "merge_merge_request": false, "failed_pipeline": false, "fixed_pipeline": false, "success_pipeline": false } }

使用 GitLab Ultimate 或 Gold 的用户还将看到new_epic参数:

  1. { "level": "custom", "events": { "new_note": true, "new_issue": false, "new_epic": false, ... } }