Release links API

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

Release links API

在 GitLab 11.7 中引入 .

使用此 API,您可以操纵 GitLab 的Release链接. 有关操纵其他 Release 资产的信息,请参见Release API . GitLab 支持指向httphttpsftp资产的链接.

Get links

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

  1. GET /projects/:id/releases/:tag_name/assets/links
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径 .
tag_name string yes 与发行版关联的标签.

请求示例:

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

响应示例:

  1. [ { "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

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

  1. GET /projects/:id/releases/:tag_name/assets/links/:link_id
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径 .
tag_name string yes 与发行版关联的标签.
link_id integer yes 链接的 ID.

请求示例:

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

响应示例:

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

Create a link

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

  1. POST /projects/:id/releases/:tag_name/assets/links
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径 .
tag_name string yes 与发行版关联的标签.
name string yes 链接的名称.
url string yes 链接的 URL.
link_type string no 链接的类型: otherrunbookimagepackage . 默认为other .

请求示例:

  1. curl --request POST \
  2. --header "PRIVATE-TOKEN: n671WNGecHugsdEDPsyo" \
  3. --data name="awesome-v0.2.dmg" \
  4. --data url="http://192.168.10.15:3000" \
  5. "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" }

Update a link

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

  1. PUT /projects/:id/releases/:tag_name/assets/links/:link_id
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径 .
tag_name string yes 与发行版关联的标签.
link_id integer yes 链接的 ID.
name string no 链接的名称.
url string no 链接的 URL.
link_type string no 链接的类型: otherrunbookimagepackage . 默认为other .

注意您必须至少指定nameurl

请求示例:

  1. 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"

响应示例:

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

Delete a link

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

  1. DELETE /projects/:id/releases/:tag_name/assets/links/:link_id
Attribute Type Required Description
id integer/string yes 项目的 ID 或URL 编码的路径 .
tag_name string yes 与发行版关联的标签.
link_id integer yes 链接的 ID.

请求示例:

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

响应示例:

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