Notes API

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

Notes API

注释是对以下内容的评论:

  • Snippets
  • Issues
  • 合并要求
  • Epics

这包括系统注释,这些注释是有关对象更改的注释(例如,当里程碑更改时,将有相应的系统注释). 标签注释不是此 API 的一部分,而是在资源标签事件中记录为单独的事件 .

Notes pagination

默认情况下,因为 API 结果是分页的,所以GET请求一次返回 20 个结果.

阅读有关分页的更多信息.

Issues

List project issue notes

获取单个问题的所有注释的列表.

  1. GET /projects/:id/issues/:issue_iid/notes
  2. GET /projects/:id/issues/:issue_iid/notes?sort=asc&order_by=updated_at
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
issue_iid integer yes 问题的 IID
sort string no 返回按ascdesc排列的发行说明. 默认为desc
order_by string no 返回按created_atupdated_at字段排序的发行说明. 默认为created_at
  1. [ { "id": 302, "body": "closed", "attachment": null, "author": { "id": 1, "username": "pipin", "email": "admin@example.com", "name": "Pip", "state": "active", "created_at": "2013-09-30T13:46:01Z" }, "created_at": "2013-10-02T09:22:45Z", "updated_at": "2013-10-02T10:22:45Z", "system": true, "noteable_id": 377, "noteable_type": "Issue", "noteable_iid": 377, "resolvable": false, "confidential": false }, { "id": 305, "body": "Text of the comment\r\n", "attachment": null, "author": { "id": 1, "username": "pipin", "email": "admin@example.com", "name": "Pip", "state": "active", "created_at": "2013-09-30T13:46:01Z" }, "created_at": "2013-10-02T09:56:03Z", "updated_at": "2013-10-02T09:56:03Z", "system": true, "noteable_id": 121, "noteable_type": "Issue", "noteable_iid": 121, "resolvable": false, "confidential": true } ]
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes"

Get single issue note

返回有关特定项目问题的单个注释

  1. GET /projects/:id/issues/:issue_iid/notes/:note_id

Parameters:

  • id (必填)-项目的 ID 或URL 编码的路径
  • issue_iid (必填)-项目问题的 IID
  • note_id (必填)-问题注释的 ID
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes/1"

Create new issue note

为单个项目问题创建新的注释.

  1. POST /projects/:id/issues/:issue_iid/notes

Parameters:

  • id (必填)-项目的 ID 或URL 编码的路径
  • issue_iid (必填)-问题的 IID
  • body (必填)-注释的内容. 限制为 1,000,000 个字符.
  • confidential (可选)-便笺的机密标志. 默认为 false.
  • created_at (可选)-日期时间字符串,ISO 8601 格式,例如 2016-03-11T03:45:40Z(需要管理员或项目/组所有者权限)
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes?body=note"

Modify existing issue note

修改问题的现有注释.

  1. PUT /projects/:id/issues/:issue_iid/notes/:note_id

Parameters:

  • id (必填)-项目的 ID 或URL 编码的路径
  • issue_iid (必填)-问题的 IID
  • note_id (必填)-注释的 ID
  • body (必填)-注释的内容. 限制为 1,000,000 个字符.
  1. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes?body=note"

Delete an issue note

删除问题的现有注释.

  1. DELETE /projects/:id/issues/:issue_iid/notes/:note_id

Parameters:

Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
issue_iid integer yes 问题的 IID
note_id integer yes 笔记的 ID
  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes/636"

Snippets

List all snippet notes

获取单个代码段的所有注释的列表. 片段注释是用户可以发布到片段的注释.

  1. GET /projects/:id/snippets/:snippet_id/notes
  2. GET /projects/:id/snippets/:snippet_id/notes?sort=asc&order_by=updated_at
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
snippet_id integer yes 项目代码段的 ID
sort string no 返回按ascdesc顺序排序的asc注释. 默认为desc
order_by string no 返回按created_atupdated_at字段排序的created_at注释. 默认为created_at
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/notes"

Get single snippet note

返回给定片段的单个音符.

  1. GET /projects/:id/snippets/:snippet_id/notes/:note_id

Parameters:

  • id (必填)-项目的 ID 或URL 编码的路径
  • snippet_id (必填)-项目代码段的 ID
  • note_id (必填)- note_id的 ID
  1. { "id": 52, "title": "Snippet", "file_name": "snippet.rb", "author": { "id": 1, "username": "pipin", "email": "admin@example.com", "name": "Pip", "state": "active", "created_at": "2013-09-30T13:46:01Z" }, "expires_at": null, "updated_at": "2013-10-02T07:34:20Z", "created_at": "2013-10-02T07:34:20Z" }
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/notes/11"

Create new snippet note

为单个代码段创建新的音符. 片段注释是用户可以发布到片段的注释. 如果您在主体仅包含奖励表情符号的位置创建注释,则会收到该对象的回信.

  1. POST /projects/:id/snippets/:snippet_id/notes

Parameters:

  • id (必填)-项目的 ID 或URL 编码的路径
  • snippet_id (必填)-代码段的 ID
  • body (必填)-注释的内容. 限制为 1,000,000 个字符.
  • created_at (可选)-日期时间字符串,ISO 8601 格式,例如 2016-03-11T03:45:40Z
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippet/11/notes?body=note"

Modify existing snippet note

修改代码段的现有注释.

  1. PUT /projects/:id/snippets/:snippet_id/notes/:note_id

Parameters:

  • id (required) - The ID or URL-encoded path of the project
  • snippet_id (必填)-代码段的 ID
  • note_id (必填)-注释的 ID
  • body (必填)-注释的内容. 限制为 1,000,000 个字符.
  1. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/notes?body=note"

Delete a snippet note

删除片段的现有注释.

  1. DELETE /projects/:id/snippets/:snippet_id/notes/:note_id

Parameters:

Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
snippet_id integer yes 片段的 ID
note_id integer yes 笔记的 ID
  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/52/notes/1659"

Merge Requests

List all merge request notes

获取单个合并请求的所有注释的列表.

  1. GET /projects/:id/merge_requests/:merge_request_iid/notes
  2. GET /projects/:id/merge_requests/:merge_request_iid/notes?sort=asc&order_by=updated_at
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
merge_request_iid integer yes 项目合并请求的 IID
sort string no 返回以ascdesc顺序排序的合并请求注释. 默认为desc
order_by string no 返回由created_atupdated_at字段排序的合并请求注释. 默认为created_at
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/notes"

Get single merge request note

返回给定合并请求的单个注释.

  1. GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id

Parameters:

  • id (必填)-项目的 ID 或URL 编码的路径
  • merge_request_iid (必填)-项目合并请求的 IID
  • note_id (必需)-合并请求注释的 ID
  1. { "id": 301, "body": "Comment for MR", "attachment": null, "author": { "id": 1, "username": "pipin", "email": "admin@example.com", "name": "Pip", "state": "active", "created_at": "2013-09-30T13:46:01Z" }, "created_at": "2013-10-02T08:57:14Z", "updated_at": "2013-10-02T08:57:14Z", "system": false, "noteable_id": 2, "noteable_type": "MergeRequest", "noteable_iid": 2, "resolvable": false, "confidential": false }
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/notes/1"

Create new merge request note

为单个合并请求创建一个新注释. 如果您在主体仅包含奖励表情符号的位置创建注释,则会收到该对象的回信.

  1. POST /projects/:id/merge_requests/:merge_request_iid/notes

Parameters:

  • id (必填)-项目的 ID 或URL 编码的路径
  • merge_request_iid (必填)-合并请求的 IID
  • body (必填)-注释的内容. 限制为 1,000,000 个字符.
  • created_at (可选)-日期时间字符串,ISO 8601 格式,例如 2016-03-11T03:45:40Z

Modify existing merge request note

修改合并请求的现有注释.

  1. PUT /projects/:id/merge_requests/:merge_request_iid/notes/:note_id

Parameters:

  • id (必填)-项目的 ID 或URL 编码的路径
  • merge_request_iid (必填)-合并请求的 IID
  • note_id (必填)-注释的 ID
  • body (必填)-注释的内容. 限制为 1,000,000 个字符.
  1. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/notes?body=note"

Delete a merge request note

删除合并请求的现有注释.

  1. DELETE /projects/:id/merge_requests/:merge_request_iid/notes/:note_id

Parameters:

Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径
merge_request_iid integer yes 合并请求的 IID
note_id integer yes 笔记的 ID
  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/7/notes/1602"

Epics

List all epic notes

获取单个史诗的所有注释的列表. 史诗笔记是用户可以发布到史诗中的评论.

  1. GET /groups/:id/epics/:epic_id/notes
  2. GET /groups/:id/epics/:epic_id/notes?sort=asc&order_by=updated_at
Attribute Type Required Description
id integer/string yes 组的 ID 或URL 编码的路径
epic_id integer yes 小组史诗的 ID
sort string no 返回按ascdesc排列的史诗笔记. 默认为desc
order_by string no 返回按created_atupdated_at字段排序的史诗笔记. 默认为created_at
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/notes"

Get single epic note

返回给定史诗的单个音符.

  1. GET /groups/:id/epics/:epic_id/notes/:note_id

Parameters:

Attribute Type Required Description
id integer/string yes 组的 ID 或URL 编码的路径
epic_id integer yes 史诗的 ID
note_id integer yes 笔记的 ID
  1. { "id": 52, "title": "Epic", "file_name": "epic.rb", "author": { "id": 1, "username": "pipin", "email": "admin@example.com", "name": "Pip", "state": "active", "created_at": "2013-09-30T13:46:01Z" }, "expires_at": null, "updated_at": "2013-10-02T07:34:20Z", "created_at": "2013-10-02T07:34:20Z", "confidential": false }
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/notes/1"

Create new epic note

为单个史诗创建新的音符. 史诗笔记是用户可以发布到史诗中的评论. 如果您在主体仅包含奖励表情符号的位置创建注释,则会收到该对象的回信.

  1. POST /groups/:id/epics/:epic_id/notes

Parameters:

Attribute Type Required Description
id integer/string yes 组的 ID 或URL 编码的路径
epic_id integer yes 史诗的 ID
body string yes 注释的内容. 限制为 1,000,000 个字符.
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippet/11/notes?body=note"

Modify existing epic note

修改史诗的现有注释.

  1. PUT /groups/:id/epics/:epic_id/notes/:note_id

Parameters:

Attribute Type Required Description
id integer/string yes 组的 ID 或URL 编码的路径
epic_id integer yes 史诗的 ID
note_id integer yes 笔记的 ID
body string yes 注释的内容. 限制为 1,000,000 个字符.
  1. curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippet/11/notes?body=note"

Delete an epic note

删除史诗的现有音符.

  1. DELETE /groups/:id/epics/:epic_id/notes/:note_id

Parameters:

Attribute Type Required Description
id integer/string yes 组的 ID 或URL 编码的路径
epic_id integer yes 史诗的 ID
note_id integer yes 笔记的 ID
  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/52/notes/1659"