Protected tags API

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

Protected tags API

注意:此功能是在 GitLab 11.3 中引入的

有效的访问级别

当前,这些级别被认可:

  1. 0 => No access
  2. 30 => Developer access
  3. 40 => Maintainer access

List protected tags

从项目中获取受保护标签的列表. 此函数使用分页参数pageper_page来限制受保护标签的列表.

  1. GET /projects/:id/protected_tags
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags"

响应示例:

  1. [ { "name": "release-1-0", "create_access_levels": [ { "access_level": 40, "access_level_description": "Maintainers" } ] }, ... ]

Get a single protected tag or wildcard protected tag

获取单个受保护标签或通配符受保护标签. 分页参数pageper_page可用于限制受保护标签的列表.

  1. GET /projects/:id/protected_tags/:name
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
name string yes 标签或通配符的名称
  1. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags/release-1-0"

响应示例:

  1. { "name": "release-1-0", "create_access_levels": [ { "access_level": 40, "access_level_description": "Maintainers" } ] }

Protect repository tags

使用通配符保护的标签保护单个存储库标签或几个项目存储库标签.

  1. POST /projects/:id/protected_tags
  1. curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags?name=*-stable&create_access_level=30"
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
name string yes 标签或通配符的名称
create_access_level string no 允许创建的访问级别(默认值: 40 ,维护者访问级别)

响应示例:

  1. { "name": "*-stable", "create_access_levels": [ { "access_level": 30, "access_level_description": "Developers + Maintainers" } ] }

Unprotect repository tags

取消保护给定的受保护标签或通配符受保护标签.

  1. DELETE /projects/:id/protected_tags/:name
  1. curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags/*-stable"
Attribute Type Required Description
id integer/string yes 经过身份验证的用户拥有的项目的 ID 或URL 编码路径
name string yes 标签名称