357.md 5.0 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
# Release links API

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

*   [Get links](#get-links)
*   [Get a link](#get-a-link)
*   [Create a link](#create-a-link)
*   [Update a link](#update-a-link)
*   [Delete a link](#delete-a-link)

# Release links API[](#release-links-api "Permalink")

在 GitLab 11.7 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/41766) .

使用此 API,您可以操纵 GitLab 的[Release](../../user/project/releases/index.html)链接. 有关操纵其他 Release 资产的信息,请参见[Release API](index.html) . GitLab 支持指向`http``https``ftp`资产的链接.

## Get links[](#get-links "Permalink")

从发布中获取资产作为链接.

```
GET /projects/:id/releases/:tag_name/assets/links 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](../README.html#namespaced-path-encoding) . |
| `tag_name` | string | yes | 与发行版关联的标签. |

请求示例:

```
curl --header "PRIVATE-TOKEN: n671WNGecHugsdEDPsyo" "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links" 
```

响应示例:

```
[  {  "id":2,  "name":"awesome-v0.2.msi",  "url":"http://192.168.10.15:3000/msi",  "external":true,  "link_type":"other"  },  {  "id":1,  "name":"awesome-v0.2.dmg",  "url":"http://192.168.10.15:3000",  "external":true,  "link_type":"other"  }  ] 
```

## Get a link[](#get-a-link "Permalink")

从发布中获取资产作为链接.

```
GET /projects/:id/releases/:tag_name/assets/links/:link_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](../README.html#namespaced-path-encoding) . |
| `tag_name` | string | yes | 与发行版关联的标签. |
| `link_id` | integer | yes | 链接的 ID. |

请求示例:

```
curl --header "PRIVATE-TOKEN: n671WNGecHugsdEDPsyo" "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links/1" 
```

响应示例:

```
{  "id":1,  "name":"awesome-v0.2.dmg",  "url":"http://192.168.10.15:3000",  "external":true,  "link_type":"other"  } 
```

## Create a link[](#create-a-link "Permalink")

从发布创建资产作为链接.

```
POST /projects/:id/releases/:tag_name/assets/links 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](../README.html#namespaced-path-encoding) . |
| `tag_name` | string | yes | 与发行版关联的标签. |
| `name` | string | yes | 链接的名称. |
| `url` | string | yes | 链接的 URL. |
| `link_type` | string | no | 链接的类型: `other``runbook``image``package` . 默认为`other` . |

请求示例:

```
curl --request POST \
     --header "PRIVATE-TOKEN: n671WNGecHugsdEDPsyo" \
     --data name="awesome-v0.2.dmg" \
     --data url="http://192.168.10.15:3000" \
     "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links" 
```

响应示例:

```
{  "id":1,  "name":"awesome-v0.2.dmg",  "url":"http://192.168.10.15:3000",  "external":true,  "link_type":"other"  } 
```

## Update a link[](#update-a-link "Permalink")

将资产更新为发布中的链接.

```
PUT /projects/:id/releases/:tag_name/assets/links/:link_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](../README.html#namespaced-path-encoding) . |
| `tag_name` | string | yes | 与发行版关联的标签. |
| `link_id` | integer | yes | 链接的 ID. |
| `name` | string | no | 链接的名称. |
| `url` | string | no | 链接的 URL. |
| `link_type` | string | no | 链接的类型: `other``runbook``image``package` . 默认为`other` . |

**注意**您必须至少指定`name``url`

请求示例:

```
curl --request PUT --data name="new name" --data link_type="runbook" --header "PRIVATE-TOKEN: n671WNGecHugsdEDPsyo" "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links/1" 
```

响应示例:

```
{  "id":1,  "name":"new name",  "url":"http://192.168.10.15:3000",  "external":true,  "link_type":"runbook"  } 
```

## Delete a link[](#delete-a-link "Permalink")

从发布中删除资产作为链接.

```
DELETE /projects/:id/releases/:tag_name/assets/links/:link_id 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](../README.html#namespaced-path-encoding) . |
| `tag_name` | string | yes | 与发行版关联的标签. |
| `link_id` | integer | yes | 链接的 ID. |

请求示例:

```
curl --request DELETE --header "PRIVATE-TOKEN: n671WNGecHugsdEDPsyo" "https://gitlab.example.com/api/v4/projects/24/releases/v0.1/assets/links/1" 
```

响应示例:

```
{  "id":1,  "name":"new name",  "url":"http://192.168.10.15:3000",  "external":true,  "link_type":"other"  } 
```