355.md 3.9 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
# 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 | 标签名称 |