320.md 13.4 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
# Issue Boards API

> 原文:[https://docs.gitlab.com/ee/api/boards.html](https://docs.gitlab.com/ee/api/boards.html)

*   [Project Board](#project-board)
*   [Single board](#single-board)
*   [Create a board](#create-a-board-starter)
*   [Update a board](#update-a-board-starter)
*   [Delete a board](#delete-a-board-starter)
*   [List board lists](#list-board-lists)
*   [Single board list](#single-board-list)
*   [New board list](#new-board-list)
*   [Edit board list](#edit-board-list)
*   [Delete a board list](#delete-a-board-list)

# Issue Boards API[](#issue-boards-api "Permalink")

对板的每个 API 调用都必须经过验证.

如果用户不是项目成员,并且该项目是私有项目,则对该项目的`GET`请求将导致`404`状态代码.

## Project Board[](#project-board "Permalink")

列出给定项目中的发行板.

```
GET /projects/:id/boards 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards" 
```

响应示例:

```
[  {  "id"  :  1,  "project":  {  "id":  5,  "name":  "Diaspora Project Site",  "name_with_namespace":  "Diaspora / Diaspora Project Site",  "path":  "diaspora-project-site",  "path_with_namespace":  "diaspora/diaspora-project-site",  "http_url_to_repo":  "http://example.com/diaspora/diaspora-project-site.git",  "web_url":  "http://example.com/diaspora/diaspora-project-site"  },  "milestone":  {  "id":  12,  "title":  "10.0"  },  "lists"  :  [  {  "id"  :  1,  "label"  :  {  "name"  :  "Testing",  "color"  :  "#F0AD4E",  "description"  :  null  },  "position"  :  1,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  },  {  "id"  :  2,  "label"  :  {  "name"  :  "Ready",  "color"  :  "#FF0000",  "description"  :  null  },  "position"  :  2,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  },  {  "id"  :  3,  "label"  :  {  "name"  :  "Production",  "color"  :  "#FF5F00",  "description"  :  null  },  "position"  :  3,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  }  ]  }  ] 
```

## Single board[](#single-board "Permalink")

拿一块板.

```
GET /projects/:id/boards/:board_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `board_id` | integer | yes | 单板编号 |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards/1" 
```

响应示例:

```
 {  "id":  1,  "name":  "project issue board",  "project":  {  "id":  5,  "name":  "Diaspora Project Site",  "name_with_namespace":  "Diaspora / Diaspora Project Site",  "path":  "diaspora-project-site",  "path_with_namespace":  "diaspora/diaspora-project-site",  "http_url_to_repo":  "http://example.com/diaspora/diaspora-project-site.git",  "web_url":  "http://example.com/diaspora/diaspora-project-site"  },  "milestone":  {  "id":  12,  "title":  "10.0"  },  "lists"  :  [  {  "id"  :  1,  "label"  :  {  "name"  :  "Testing",  "color"  :  "#F0AD4E",  "description"  :  null  },  "position"  :  1,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  },  {  "id"  :  2,  "label"  :  {  "name"  :  "Ready",  "color"  :  "#FF0000",  "description"  :  null  },  "position"  :  2,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  },  {  "id"  :  3,  "label"  :  {  "name"  :  "Production",  "color"  :  "#FF5F00",  "description"  :  null  },  "position"  :  3,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  }  ]  } 
```

## Create a board[](#create-a-board-starter "Permalink")

创建一个木板.

```
POST /projects/:id/boards 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `name` | string | yes | 新板的名称 |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards?name=newboard" 
```

响应示例:

```
 {  "id":  1,  "project":  {  "id":  5,  "name":  "Diaspora Project Site",  "name_with_namespace":  "Diaspora / Diaspora Project Site",  "path":  "diaspora-project-site",  "path_with_namespace":  "diaspora/diaspora-project-site",  "http_url_to_repo":  "http://example.com/diaspora/diaspora-project-site.git",  "web_url":  "http://example.com/diaspora/diaspora-project-site"  },  "name":  "newboard",  "milestone":  {  "id":  12  "title":  "10.0"  },  "lists"  :  [  {  "id"  :  1,  "label"  :  {  "name"  :  "Testing",  "color"  :  "#F0AD4E",  "description"  :  null  },  "position"  :  1,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  },  {  "id"  :  2,  "label"  :  {  "name"  :  "Ready",  "color"  :  "#FF0000",  "description"  :  null  },  "position"  :  2,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  },  {  "id"  :  3,  "label"  :  {  "name"  :  "Production",  "color"  :  "#FF5F00",  "description"  :  null  },  "position"  :  3,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  }  ]  } 
```

## Update a board[](#update-a-board-starter "Permalink")

[Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/5954) in [GitLab Starter](https://about.gitlab.com/pricing/) 11.1.

更新板.

```
PUT /projects/:id/boards/:board_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `board_id` | integer | yes | 单板编号 |
| `name` | string | no | 董事会的新名称 |
| `assignee_id` | integer | no | 董事会受让人的范围应为 |
| `milestone_id` | integer | no | 董事会应达到的里程碑 |
| `labels` | string | no | 以逗号分隔的标签名称列表,该范围应适用于板 |
| `weight` | integer | no | 重量范围从 0 到 9,该板的范围应为 |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards/1?name=new_name&milestone_id=43&assignee_id=1&labels=Doing&weight=4" 
```

响应示例:

```
 {  "id":  1,  "project":  {  "id":  5,  "name":  "Diaspora Project Site",  "name_with_namespace":  "Diaspora / Diaspora Project Site",  "path":  "diaspora-project-site",  "path_with_namespace":  "diaspora/diaspora-project-site",  "created_at":  "2018-07-03T05:48:49.982Z",  "default_branch":  null,  "tag_list":  [],  "ssh_url_to_repo":  "ssh://user@example.com/diaspora/diaspora-project-site.git",  "http_url_to_repo":  "http://example.com/diaspora/diaspora-project-site.git",  "web_url":  "http://example.com/diaspora/diaspora-project-site",  "readme_url":  null,  "avatar_url":  null,  "star_count":  0,  "forks_count":  0,  "last_activity_at":  "2018-07-03T05:48:49.982Z"  },  "lists":  [],  "name":  "new_name",  "group":  null,  "milestone":  {  "id":  43,  "iid":  1,  "project_id":  15,  "title":  "Milestone 1",  "description":  "Milestone 1 desc",  "state":  "active",  "created_at":  "2018-07-03T06:36:42.618Z",  "updated_at":  "2018-07-03T06:36:42.618Z",  "due_date":  null,  "start_date":  null,  "web_url":  "http://example.com/root/board1/milestones/1"  },  "assignee":  {  "id":  1,  "name":  "Administrator",  "username":  "root",  "state":  "active",  "avatar_url":  "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",  "web_url":  "http://example.com/root"  },  "labels":  [{  "id":  10,  "name":  "Doing",  "color":  "#5CB85C",  "description":  null  }],  "weight":  4  } 
```

## Delete a board[](#delete-a-board-starter "Permalink")

删除板.

```
DELETE /projects/:id/boards/:board_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `board_id` | integer | yes | 单板编号 |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards/1" 
```

## List board lists[](#list-board-lists "Permalink")

获取董事会名单的清单. 不包括`open``closed`列表

```
GET /projects/:id/boards/:board_id/lists 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `board_id` | integer | yes | 单板编号 |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards/1/lists" 
```

响应示例:

```
[  {  "id"  :  1,  "label"  :  {  "name"  :  "Testing",  "color"  :  "#F0AD4E",  "description"  :  null  },  "position"  :  1,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  },  {  "id"  :  2,  "label"  :  {  "name"  :  "Ready",  "color"  :  "#FF0000",  "description"  :  null  },  "position"  :  2,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  },  {  "id"  :  3,  "label"  :  {  "name"  :  "Production",  "color"  :  "#FF5F00",  "description"  :  null  },  "position"  :  3,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  }  ] 
```

## Single board list[](#single-board-list "Permalink")

获取单板列表.

```
GET /projects/:id/boards/:board_id/lists/:list_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `board_id` | integer | yes | 单板编号 |
| `list_id` | integer | yes | 单板编号 |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards/1/lists/1" 
```

响应示例:

```
{  "id"  :  1,  "label"  :  {  "name"  :  "Testing",  "color"  :  "#F0AD4E",  "description"  :  null  },  "position"  :  1,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  } 
```

## New board list[](#new-board-list "Permalink")

创建一个新的发行委员会列表.

```
POST /projects/:id/boards/:board_id/lists 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `board_id` | integer | yes | 单板编号 |
| `label_id` | integer | no | 标签的 ID |
| `assignee_id` | integer | no | 用户的 ID |
| `milestone_id` | integer | no | 里程碑的 ID |

**注意:**标签,受让人和里程碑参数是互斥的,也就是说,请求中仅接受其中一个. 查看[发行委员会文档](../user/project/issue_board.html#summary-of-features-per-tier) ,以获取有关每种列表类型所需许可证的更多信息.

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards/1/lists?label_id=5" 
```

响应示例:

```
{  "id"  :  1,  "label"  :  {  "name"  :  "Testing",  "color"  :  "#F0AD4E",  "description"  :  null  },  "position"  :  1,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  } 
```

## Edit board list[](#edit-board-list "Permalink")

更新现有的发行委员会列表. 此调用用于更改列表位置.

```
PUT /projects/:id/boards/:board_id/lists/:list_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `board_id` | integer | yes | 单板编号 |
| `list_id` | integer | yes | 单板编号 |
| `position` | integer | yes | The position of the list |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards/1/lists/1?position=2" 
```

响应示例:

```
{  "id"  :  1,  "label"  :  {  "name"  :  "Testing",  "color"  :  "#F0AD4E",  "description"  :  null  },  "position"  :  1,  "max_issue_count":  0,  "max_issue_weight":  0,  "limit_metric":  null  } 
```

## Delete a board list[](#delete-a-board-list "Permalink")

仅适用于管理员和项目所有者. 删除相关的单板列表.

```
DELETE /projects/:id/boards/:board_id/lists/:list_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `board_id` | integer | yes | 单板编号 |
| `list_id` | integer | yes | 单板编号 |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/boards/1/lists/1" 
```