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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

119 lines
2.8 KiB
Markdown
Raw Normal View History

2020-10-24 23:57:45 +05:30
---
stage: Create
group: Source Code
2022-11-25 23:54:43 +05:30
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/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
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 |
|-----------|--------|----------|-----------------------|
2022-11-25 23:54:43 +05:30
| `name` | string | **{check-circle}** Yes | The name of the alias. |
2019-09-30 21:07:59 +05:30
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
2021-09-04 01:27:46 +05:30
Add a new alias for a project. When successful, responds with `201 Created`.
When there are validation errors, for example, when the alias already exists, responds with `400 Bad Request`:
2019-09-30 21:07:59 +05:30
2020-04-08 14:13:33 +05:30
```plaintext
2019-09-30 21:07:59 +05:30
POST /project_aliases
```
| Attribute | Type | Required | Description |
|--------------|----------------|----------|----------------------------------------|
2022-11-25 23:54:43 +05:30
| `name` | string | **{check-circle}** Yes | The name of the alias. Must be unique. |
| `project_id` | integer or string | **{check-circle}** Yes | The ID or path of the project. |
2019-09-30 21:07:59 +05:30
2020-04-08 14:13:33 +05:30
```shell
2021-09-04 01:27:46 +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
2021-09-04 01:27:46 +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 |
|-----------|--------|----------|-----------------------|
2022-11-25 23:54:43 +05:30
| `name` | string | **{check-circle}** Yes | The name of the alias. |
2019-09-30 21:07:59 +05:30
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
```