debian-mirror-gitlab/doc/api/protected_tags.md

137 lines
3.6 KiB
Markdown
Raw Normal View History

2020-10-24 23:57:45 +05:30
---
stage: Create
group: Source Code
2021-02-22 17:27:13 +05:30
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments"
2020-10-24 23:57:45 +05:30
type: reference, api
---
2021-03-11 19:13:27 +05:30
# Protected tags API **(FREE)**
2018-11-20 20:47:30 +05:30
2020-10-24 23:57:45 +05:30
> Introduced in GitLab 11.3.
2018-11-20 20:47:30 +05:30
**Valid access levels**
Currently, these levels are recognized:
2019-09-30 21:07:59 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2018-11-20 20:47:30 +05:30
0 => No access
30 => Developer access
40 => Maintainer access
```
## List protected tags
Gets a list of protected tags from a project.
This function takes pagination parameters `page` and `per_page` to restrict the list of protected tags.
2020-04-08 14:13:33 +05:30
```plaintext
2018-11-20 20:47:30 +05:30
GET /projects/:id/protected_tags
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2018-11-20 20:47:30 +05:30
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags"
2018-11-20 20:47:30 +05:30
```
Example response:
```json
[
{
"name": "release-1-0",
"create_access_levels": [
{
"access_level": 40,
"access_level_description": "Maintainers"
}
]
},
...
]
```
## Get a single protected tag or wildcard protected tag
Gets a single protected tag or wildcard protected tag.
The pagination parameters `page` and `per_page` can be used to restrict the list of protected tags.
2020-04-08 14:13:33 +05:30
```plaintext
2018-11-20 20:47:30 +05:30
GET /projects/:id/protected_tags/:name
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2018-11-20 20:47:30 +05:30
| `name` | string | yes | The name of the tag or wildcard |
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags/release-1-0"
2018-11-20 20:47:30 +05:30
```
Example response:
```json
{
"name": "release-1-0",
"create_access_levels": [
{
"access_level": 40,
"access_level_description": "Maintainers"
}
]
}
```
## Protect repository tags
Protects a single repository tag or several project repository
tags using a wildcard protected tag.
2020-04-08 14:13:33 +05:30
```plaintext
2018-11-20 20:47:30 +05:30
POST /projects/:id/protected_tags
```
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
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"
2018-11-20 20:47:30 +05:30
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2018-11-20 20:47:30 +05:30
| `name` | string | yes | The name of the tag or wildcard |
2021-09-04 01:27:46 +05:30
| `create_access_level` | string | no | Access levels allowed to create (defaults: `40`, Maintainer role) |
2018-11-20 20:47:30 +05:30
Example response:
```json
{
"name": "*-stable",
"create_access_levels": [
{
"access_level": 30,
"access_level_description": "Developers + Maintainers"
}
]
}
```
## Unprotect repository tags
Unprotects the given protected tag or wildcard protected tag.
2020-04-08 14:13:33 +05:30
```plaintext
2018-11-20 20:47:30 +05:30
DELETE /projects/:id/protected_tags/:name
```
2020-03-13 15:44:24 +05:30
```shell
2020-06-23 00:09:42 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/protected_tags/*-stable"
2018-11-20 20:47:30 +05:30
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
2021-09-30 23:02:18 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
2018-11-20 20:47:30 +05:30
| `name` | string | yes | The name of the tag |