极狐GitLab 待办事项列表 API
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
使用此 API 与待办事项进行交互。
获取待办事项列表
返回待办事项列表。当未应用任何过滤器时,它返回当前用户的所有待处理待办事项。不同的过滤器允许用户优化请求。
plaintextGET /todos
参数:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| action | string | no | 要过滤的动作。可以是 assigned、mentioned、build_failed、marked、approval_required、unmergeable、directly_addressed、merge_train_removed 或 member_access_requested。 |
| author_id | integer | no | 作者的 ID |
| project_id | integer | no | 项目的 ID |
| group_id | integer | no | 群组的 ID |
| state | string | no | 待办事项的状态。可以是 pending 或 done |
| type | string | no | 待办事项的类型。可以是 Issue、MergeRequest、Commit、Epic、DesignManagement::Design、AlertManagement::Alert、Project、Namespace、Vulnerability 或 WikiPage::Meta |
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/todos"
示例响应:
json1[ 2 { 3 "id": 102, 4 "project": { 5 "id": 2, 6 "name": "Gitlab Ce", 7 "name_with_namespace": "Gitlab Org / Gitlab Ce", 8 "path": "gitlab-foss", 9 "path_with_namespace": "gitlab-org/gitlab-foss" 10 }, 11 "author": { 12 "name": "Administrator", 13 "username": "root", 14 "id": 1, 15 "state": "active", 16 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 17 "web_url": "https://gitlab.example.com/root" 18 }, 19 "action_name": "marked", 20 "target_type": "MergeRequest", 21 "target": { 22 "id": 34, 23 "iid": 7, 24 "project_id": 2, 25 "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", 26 "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.", 27 "state": "opened", 28 "created_at": "2016-06-17T07:49:24.419Z", 29 "updated_at": "2016-06-17T07:52:43.484Z", 30 "target_branch": "tutorials_git_tricks", 31 "source_branch": "DNSBL_docs", 32 "upvotes": 0, 33 "downvotes": 0, 34 "author": { 35 "name": "Maxie Medhurst", 36 "username": "craig_rutherford", 37 "id": 12, 38 "state": "active", 39 "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", 40 "web_url": "https://gitlab.example.com/craig_rutherford" 41 }, 42 "assignee": { 43 "name": "Administrator", 44 "username": "root", 45 "id": 1, 46 "state": "active", 47 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 48 "web_url": "https://gitlab.example.com/root" 49 }, 50 "source_project_id": 2, 51 "target_project_id": 2, 52 "labels": [], 53 "draft": false, 54 "work_in_progress": false, 55 "milestone": { 56 "id": 32, 57 "iid": 2, 58 "project_id": 2, 59 "title": "v1.0", 60 "description": "Assumenda placeat ea voluptatem voluptate qui.", 61 "state": "active", 62 "created_at": "2016-06-17T07:47:34.163Z", 63 "updated_at": "2016-06-17T07:47:34.163Z", 64 "due_date": null 65 }, 66 "merge_when_pipeline_succeeds": false, 67 "merge_status": "cannot_be_merged", 68 "user_notes_count": 7 69 }, 70 "target_url": "https://gitlab.example.com/gitlab-org/gitlab-foss/-/merge_requests/7", 71 "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", 72 "state": "pending", 73 "created_at": "2016-06-17T07:52:35.225Z", 74 "updated_at": "2016-06-17T07:52:35.225Z" 75 }, 76 { 77 "id": 98, 78 "project": { 79 "id": 2, 80 "name": "Gitlab Ce", 81 "name_with_namespace": "Gitlab Org / Gitlab Ce", 82 "path": "gitlab-foss", 83 "path_with_namespace": "gitlab-org/gitlab-foss" 84 }, 85 "author": { 86 "name": "Maxie Medhurst", 87 "username": "craig_rutherford", 88 "id": 12, 89 "state": "active", 90 "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", 91 "web_url": "https://gitlab.example.com/craig_rutherford" 92 }, 93 "action_name": "assigned", 94 "target_type": "MergeRequest", 95 "target": { 96 "id": 34, 97 "iid": 7, 98 "project_id": 2, 99 "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", 100 "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.", 101 "state": "opened", 102 "created_at": "2016-06-17T07:49:24.419Z", 103 "updated_at": "2016-06-17T07:52:43.484Z", 104 "target_branch": "tutorials_git_tricks", 105 "source_branch": "DNSBL_docs", 106 "upvotes": 0, 107 "downvotes": 0, 108 "author": { 109 "name": "Maxie Medhurst", 110 "username": "craig_rutherford", 111 "id": 12, 112 "state": "active", 113 "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", 114 "web_url": "https://gitlab.example.com/craig_rutherford" 115 }, 116 "assignee": { 117 "name": "Administrator", 118 "username": "root", 119 "id": 1, 120 "state": "active", 121 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 122 "web_url": "https://gitlab.example.com/root" 123 }, 124 "source_project_id": 2, 125 "target_project_id": 2, 126 "labels": [], 127 "draft": false, 128 "work_in_progress": false, 129 "milestone": { 130 "id": 32, 131 "iid": 2, 132 "project_id": 2, 133 "title": "v1.0", 134 "description": "Assumenda placeat ea voluptatem voluptate qui.", 135 "state": "active", 136 "created_at": "2016-06-17T07:47:34.163Z", 137 "updated_at": "2016-06-17T07:47:34.163Z", 138 "due_date": null 139 }, 140 "merge_when_pipeline_succeeds": false, 141 "merge_status": "cannot_be_merged", 142 "user_notes_count": 7 143 }, 144 "target_url": "https://gitlab.example.com/gitlab-org/gitlab-foss/-/merge_requests/7", 145 "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", 146 "state": "pending", 147 "created_at": "2016-06-17T07:49:24.624Z", 148 "updated_at": "2016-06-17T07:49:24.624Z" 149 } 150]
将待办事项标记为已完成
将当前用户给定 ID 的单个待处理待办事项标记为已完成。标记为已完成的待办事项在响应中返回。
plaintextPOST /todos/:id/mark_as_done
参数:
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer | yes | 待办事项的 ID |
shellcurl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/todos/130/mark_as_done"
示例响应:
json1{ 2 "id": 102, 3 "project": { 4 "id": 2, 5 "name": "Gitlab Ce", 6 "name_with_namespace": "Gitlab Org / Gitlab Ce", 7 "path": "gitlab-foss", 8 "path_with_namespace": "gitlab-org/gitlab-foss" 9 }, 10 "author": { 11 "name": "Administrator", 12 "username": "root", 13 "id": 1, 14 "state": "active", 15 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 16 "web_url": "https://gitlab.example.com/root" 17 }, 18 "action_name": "marked", 19 "target_type": "MergeRequest", 20 "target": { 21 "id": 34, 22 "iid": 7, 23 "project_id": 2, 24 "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", 25 "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.", 26 "state": "opened", 27 "created_at": "2016-06-17T07:49:24.419Z", 28 "updated_at": "2016-06-17T07:52:43.484Z", 29 "target_branch": "tutorials_git_tricks", 30 "source_branch": "DNSBL_docs", 31 "upvotes": 0, 32 "downvotes": 0, 33 "author": { 34 "name": "Maxie Medhurst", 35 "username": "craig_rutherford", 36 "id": 12, 37 "state": "active", 38 "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", 39 "web_url": "https://gitlab.example.com/craig_rutherford" 40 }, 41 "assignee": { 42 "name": "Administrator", 43 "username": "root", 44 "id": 1, 45 "state": "active", 46 "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", 47 "web_url": "https://gitlab.example.com/root" 48 }, 49 "source_project_id": 2, 50 "target_project_id": 2, 51 "labels": [], 52 "draft": false, 53 "work_in_progress": false, 54 "milestone": { 55 "id": 32, 56 "iid": 2, 57 "project_id": 2, 58 "title": "v1.0", 59 "description": "Assumenda placeat ea voluptatem voluptate qui.", 60 "state": "active", 61 "created_at": "2016-06-17T07:47:34.163Z", 62 "updated_at": "2016-06-17T07:47:34.163Z", 63 "due_date": null 64 }, 65 "merge_when_pipeline_succeeds": false, 66 "merge_status": "cannot_be_merged", 67 "subscribed": true, 68 "user_notes_count": 7 69 }, 70 "target_url": "https://gitlab.example.com/gitlab-org/gitlab-foss/-/merge_requests/7", 71 "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.", 72 "state": "done", 73 "created_at": "2016-06-17T07:52:35.225Z", 74 "updated_at": "2016-06-17T07:52:35.225Z" 75}
将所有待办事项标记为已完成
将当前用户的所有待处理待办事项标记为已完成。它返回 HTTP 状态码 204 和一个空响应。
plaintextPOST /todos/mark_as_done
shellcurl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/todos/mark_as_done"