# Epic Links API

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

*   [List epics related to a given epic](#list-epics-related-to-a-given-epic)
*   [Assign a child epic](#assign-a-child-epic)
*   [Create and assign a child epic](#create-and-assign-a-child-epic)
*   [Re-order a child epic](#re-order-a-child-epic)
*   [Unassign a child epic](#unassign-a-child-epic)

# Epic Links API[](#epic-links-api-ultimate "Permalink")

**注意：**该端点是在 GitLab 11.8 中[引入的](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/9188) .

管理亲子[史诗般的关系](../user/group/epics/index.html#multi-level-child-epics-ultimate) .

每个对`epic_links` API 调用`epic_links`必须经过身份验证.

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

多级史诗仅在 GitLab [Ultimate / Gold](https://about.gitlab.com/pricing/)中可用. 如果"多级史诗"功能不可用，将返回`403`状态代码.

## List epics related to a given epic[](#list-epics-related-to-a-given-epic "Permalink")

获取史诗的所有子史诗.

```
GET /groups/:id/epics/:epic_iid/epics 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 认证用户拥有[的组](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `epic_iid` | integer | yes | 史诗的内部 ID. |

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

响应示例：

```
[  {  "id":  29,  "iid":  6,  "group_id":  1,  "parent_id":  5,  "title":  "Accusamus iste et ullam ratione voluptatem omnis debitis dolor est.",  "description":  "Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum.",  "author":  {  "id":  10,  "name":  "Lu Mayer",  "username":  "kam",  "state":  "active",  "avatar_url":  "http://www.gravatar.com/avatar/018729e129a6f31c80a6327a30196823?s=80&d=identicon",  "web_url":  "http://localhost:3001/kam"  },  "start_date":  null,  "start_date_is_fixed":  false,  "start_date_fixed":  null,  "start_date_from_milestones":  null,  //deprecated  in  favor  of  start_date_from_inherited_source  "start_date_from_inherited_source":  null,  "end_date":  "2018-07-31",  //deprecated  in  favor  of  due_date  "due_date":  "2018-07-31",  "due_date_is_fixed":  false,  "due_date_fixed":  null,  "due_date_from_milestones":  "2018-07-31",  //deprecated  in  favor  of  start_date_from_inherited_source  "due_date_from_inherited_source":  "2018-07-31",  "created_at":  "2018-07-17T13:36:22.770Z",  "updated_at":  "2018-07-18T12:22:05.239Z",  "labels":  []  }  ] 
```

## Assign a child epic[](#assign-a-child-epic "Permalink")

在两个史诗之间创建关联，将一个史诗指定为父史诗，将另一个史诗指定为子史诗. 父史诗可以有多个子史诗. 如果新的子史诗已经属于另一个史诗，则该子史诗不会从先前的父史诗中分配.

```
POST /groups/:id/epics/:epic_iid/epics 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.html#namespaced-path-encoding) owned by the authenticated user |
| `epic_iid` | integer | yes | 史诗的内部 ID. |
| `child_epic_id` | integer | yes | 子史诗的全局 ID. 内部 ID 无法使用，因为它们可能与其他组的史诗冲突. |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/epics/5/epics/6" 
```

响应示例：

```
{  "id":  6,  "iid":  38,  "group_id":  1,  "parent_id":  5  "title":  "Accusamus iste et ullam ratione voluptatem omnis debitis dolor est.",  "description":  "Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum.",  "author":  {  "id":  10,  "name":  "Lu Mayer",  "username":  "kam",  "state":  "active",  "avatar_url":  "http://www.gravatar.com/avatar/018729e129a6f31c80a6327a30196823?s=80&d=identicon",  "web_url":  "http://localhost:3001/kam"  },  "start_date":  null,  "start_date_is_fixed":  false,  "start_date_fixed":  null,  "start_date_from_milestones":  null,  //deprecated  in  favor  of  start_date_from_inherited_source  "start_date_from_inherited_source":  null,  "end_date":  "2018-07-31",  //deprecated  in  favor  of  due_date  "due_date":  "2018-07-31",  "due_date_is_fixed":  false,  "due_date_fixed":  null,  "due_date_from_milestones":  "2018-07-31",  //deprecated  in  favor  of  start_date_from_inherited_source  "due_date_from_inherited_source":  "2018-07-31",  "created_at":  "2018-07-17T13:36:22.770Z",  "updated_at":  "2018-07-18T12:22:05.239Z",  "labels":  []  } 
```

## Create and assign a child epic[](#create-and-assign-a-child-epic "Permalink")

创建一个新的史诗并将其与提供的父史诗相关联. 响应是 LinkedEpic 对象.

```
POST /groups/:id/epics/:epic_iid/epics 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 认证用户拥有[的组](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) |
| `epic_iid` | integer | yes | （未来父级）史诗的内部 ID. |
| `title` | string | yes | 新创建的史诗的标题. |

```
curl --request POST --header  "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/epics/5/epics?title=Newpic" 
```

响应示例：

```
{  "id":  24,  "iid":  2,  "title":  "child epic",  "group_id":  49,  "parent_id":  23,  "has_children":  false,  "has_issues":  false,  "reference":  "&2",  "url":  "http://localhost/groups/group16/-/epics/2",  "relation_url":  "http://localhost/groups/group16/-/epics/1/links/24"  } 
```

## Re-order a child epic[](#re-order-a-child-epic "Permalink")

```
PUT /groups/:id/epics/:epic_iid/epics/:child_epic_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 认证用户拥有[的组](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) . |
| `epic_iid` | integer | yes | 史诗的内部 ID. |
| `child_epic_id` | integer | yes | 子史诗的全局 ID. 内部 ID 无法使用，因为它们可能与其他组的史诗冲突. |
| `move_before_id` | integer | no | 同胞史诗的全局 ID，应放在子史诗之前. |
| `move_after_id` | integer | no | 同胞史诗的全局 ID，应放在子史诗之后. |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/epics/4/epics/5" 
```

响应示例：

```
[  {  "id":  29,  "iid":  6,  "group_id":  1,  "parent_id":  5,  "title":  "Accusamus iste et ullam ratione voluptatem omnis debitis dolor est.",  "description":  "Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum.",  "author":  {  "id":  10,  "name":  "Lu Mayer",  "username":  "kam",  "state":  "active",  "avatar_url":  "http://www.gravatar.com/avatar/018729e129a6f31c80a6327a30196823?s=80&d=identicon",  "web_url":  "http://localhost:3001/kam"  },  "start_date":  null,  "start_date_is_fixed":  false,  "start_date_fixed":  null,  "start_date_from_milestones":  null,  //deprecated  in  favor  of  start_date_from_inherited_source  "start_date_from_inherited_source":  null,  "end_date":  "2018-07-31",  //deprecated  in  favor  of  due_date  "due_date":  "2018-07-31",  "due_date_is_fixed":  false,  "due_date_fixed":  null,  "due_date_from_milestones":  "2018-07-31",  //deprecated  in  favor  of  start_date_from_inherited_source  "due_date_from_inherited_source":  "2018-07-31",  "created_at":  "2018-07-17T13:36:22.770Z",  "updated_at":  "2018-07-18T12:22:05.239Z",  "labels":  []  }  ] 
```

## Unassign a child epic[](#unassign-a-child-epic "Permalink")

从父级史诗中取消分配子级史诗.

```
DELETE /groups/:id/epics/:epic_iid/epics/:child_epic_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 认证用户拥有[的组](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) . |
| `epic_iid` | integer | yes | 史诗的内部 ID. |
| `child_epic_id` | integer | yes | 子史诗的全局 ID. 内部 ID 无法使用，因为它们可能与其他组的史诗冲突. |

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

响应示例：

```
{  "id":  5,  "iid":  38,  "group_id":  1,  "parent_id":  null,  "title":  "Accusamus iste et ullam ratione voluptatem omnis debitis dolor est.",  "description":  "Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum.",  "author":  {  "id":  10,  "name":  "Lu Mayer",  "username":  "kam",  "state":  "active",  "avatar_url":  "http://www.gravatar.com/avatar/018729e129a6f31c80a6327a30196823?s=80&d=identicon",  "web_url":  "http://localhost:3001/kam"  },  "start_date":  null,  "start_date_is_fixed":  false,  "start_date_fixed":  null,  "start_date_from_milestones":  null,  //deprecated  in  favor  of  start_date_from_inherited_source  "start_date_from_inherited_source":  null,  "end_date":  "2018-07-31",  //deprecated  in  favor  of  due_date  "due_date":  "2018-07-31",  "due_date_is_fixed":  false,  "due_date_fixed":  null,  "due_date_from_milestones":  "2018-07-31",  //deprecated  in  favor  of  start_date_from_inherited_source  "due_date_from_inherited_source":  "2018-07-31",  "created_at":  "2018-07-17T13:36:22.770Z",  "updated_at":  "2018-07-18T12:22:05.239Z",  "labels":  []  } 
```