多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# Protected tags API > 原文:[https://docs.gitlab.com/ee/api/protected_tags.html](https://docs.gitlab.com/ee/api/protected_tags.html) * [List protected tags](#list-protected-tags) * [Get a single protected tag or wildcard protected tag](#get-a-single-protected-tag-or-wildcard-protected-tag) * [Protect repository tags](#protect-repository-tags) * [Unprotect repository tags](#unprotect-repository-tags) # Protected tags API[](#protected-tags-api "Permalink") **注意:**此功能是在 GitLab 11.3 中引入的 **有效的访问级别** 当前,这些级别被认可: ``` 0 => No access 30 => Developer access 40 => Maintainer access ``` ## List protected tags[](#list-protected-tags "Permalink") 从项目中获取受保护标签的列表. 此函数使用分页参数`page`和`per_page`来限制受保护标签的列表. ``` GET /projects/:id/protected_tags ``` | 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/protected_tags" ``` 响应示例: ``` [ { "name": "release-1-0", "create_access_levels": [ { "access_level": 40, "access_level_description": "Maintainers" } ] }, ... ] ``` ## Get a single protected tag or wildcard protected tag[](#get-a-single-protected-tag-or-wildcard-protected-tag "Permalink") 获取单个受保护标签或通配符受保护标签. 分页参数`page`和`per_page`可用于限制受保护标签的列表. ``` GET /projects/:id/protected_tags/:name ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `name` | string | yes | 标签或通配符的名称 | ``` curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags/release-1-0" ``` 响应示例: ``` { "name": "release-1-0", "create_access_levels": [ { "access_level": 40, "access_level_description": "Maintainers" } ] } ``` ## Protect repository tags[](#protect-repository-tags "Permalink") 使用通配符保护的标签保护单个存储库标签或几个项目存储库标签. ``` POST /projects/:id/protected_tags ``` ``` 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 | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `name` | string | yes | 标签或通配符的名称 | | `create_access_level` | string | no | 允许创建的访问级别(默认值: `40` ,维护者访问级别) | 响应示例: ``` { "name": "*-stable", "create_access_levels": [ { "access_level": 30, "access_level_description": "Developers + Maintainers" } ] } ``` ## Unprotect repository tags[](#unprotect-repository-tags "Permalink") 取消保护给定的受保护标签或通配符受保护标签. ``` DELETE /projects/:id/protected_tags/:name ``` ``` 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 | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `name` | string | yes | 标签名称 |