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

119 lines
2.8 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
# Project Aliases API **(PREMIUM SELF)**
2019-09-30 21:07:59 +05:30
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/3264) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.1.
2019-09-30 21:07:59 +05:30
All methods require administrator authorization.
## List all project aliases
Get a list of all project aliases:
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-30 21:07:59 +05:30
GET /project_aliases
```
2020-04-08 14:13:33 +05:30
```shell
2019-09-30 21:07:59 +05:30
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases"
```
Example response:
```json
[
{
"id": 1,
"project_id": 1,
2019-12-21 20:55:43 +05:30
"name": "gitlab-foss"
2019-09-30 21:07:59 +05:30
},
{
"id": 2,
"project_id": 2,
2019-12-21 20:55:43 +05:30
"name": "gitlab"
2019-09-30 21:07:59 +05:30
}
]
```
## Get project alias' details
Get details of a project alias:
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-30 21:07:59 +05:30
GET /project_aliases/:name
```
| Attribute | Type | Required | Description |
|-----------|--------|----------|-----------------------|
| `name` | string | yes | The name of the alias |
2020-04-08 14:13:33 +05:30
```shell
2019-12-21 20:55:43 +05:30
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab"
2019-09-30 21:07:59 +05:30
```
Example response:
```json
{
"id": 1,
"project_id": 1,
2019-12-21 20:55:43 +05:30
"name": "gitlab"
2019-09-30 21:07:59 +05:30
}
```
## Create a project alias
Add a new alias for a project. Responds with a 201 when successful,
400 when there are validation errors (e.g. alias already exists):
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-30 21:07:59 +05:30
POST /project_aliases
```
| Attribute | Type | Required | Description |
|--------------|----------------|----------|----------------------------------------|
| `project_id` | integer/string | yes | The ID or path of the project. |
| `name` | string | yes | The name of the alias. Must be unique. |
2020-04-08 14:13:33 +05:30
```shell
2019-12-21 20:55:43 +05:30
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases" --form "project_id=1" --form "name=gitlab"
2019-09-30 21:07:59 +05:30
```
or
2020-04-08 14:13:33 +05:30
```shell
2019-12-21 20:55:43 +05:30
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases" --form "project_id=gitlab-org/gitlab" --form "name=gitlab"
2019-09-30 21:07:59 +05:30
```
Example response:
```json
{
"id": 1,
"project_id": 1,
2019-12-21 20:55:43 +05:30
"name": "gitlab"
2019-09-30 21:07:59 +05:30
}
```
## Delete a project alias
Removes a project aliases. Responds with a 204 when project alias
exists, 404 when it doesn't:
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-30 21:07:59 +05:30
DELETE /project_aliases/:name
```
| Attribute | Type | Required | Description |
|-----------|--------|----------|-----------------------|
| `name` | string | yes | The name of the alias |
2020-04-08 14:13:33 +05:30
```shell
2019-12-21 20:55:43 +05:30
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/project_aliases/gitlab"
2019-09-30 21:07:59 +05:30
```