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

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

124 lines
3 KiB
Markdown
Raw Normal View History

2021-01-29 00:20:46 +05:30
---
2022-10-11 01:57:18 +05:30
stage: Plan
group: Project Management
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
2021-01-29 00:20:46 +05:30
---
2021-11-11 11:23:49 +05:30
# Custom Attributes API **(FREE SELF)**
2018-03-17 18:26:18 +05:30
Every API call to custom attributes must be authenticated as administrator.
Custom attributes are currently available on users, groups, and projects,
2021-02-22 17:27:13 +05:30
which is referred to as "resource" in this documentation.
2018-03-17 18:26:18 +05:30
## List custom attributes
Get all custom attributes on a resource.
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
GET /users/:id/custom_attributes
GET /groups/:id/custom_attributes
GET /projects/:id/custom_attributes
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a resource |
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/users/42/custom_attributes"
2018-03-17 18:26:18 +05:30
```
Example response:
```json
[
{
"key": "location",
"value": "Antarctica"
},
{
"key": "role",
"value": "Developer"
}
]
```
## Single custom attribute
Get a single custom attribute on a resource.
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
GET /users/:id/custom_attributes/:key
GET /groups/:id/custom_attributes/:key
GET /projects/:id/custom_attributes/:key
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a resource |
| `key` | string | yes | The key of the custom attribute |
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/users/42/custom_attributes/location"
2018-03-17 18:26:18 +05:30
```
Example response:
```json
{
"key": "location",
"value": "Antarctica"
}
```
## Set custom attribute
2021-02-22 17:27:13 +05:30
Set a custom attribute on a resource. The attribute is updated if it already exists,
2018-03-17 18:26:18 +05:30
or newly created otherwise.
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
PUT /users/:id/custom_attributes/:key
PUT /groups/:id/custom_attributes/:key
PUT /projects/:id/custom_attributes/:key
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a resource |
| `key` | string | yes | The key of the custom attribute |
| `value` | string | yes | The value of the custom attribute |
2020-03-13 15:44:24 +05:30
```shell
2021-09-04 01:27:46 +05:30
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" \
--data "value=Greenland" "https://gitlab.example.com/api/v4/users/42/custom_attributes/location"
2018-03-17 18:26:18 +05:30
```
Example response:
```json
{
"key": "location",
"value": "Greenland"
}
```
## Delete custom attribute
Delete a custom attribute on a resource.
2020-04-08 14:13:33 +05:30
```plaintext
2018-03-17 18:26:18 +05:30
DELETE /users/:id/custom_attributes/:key
DELETE /groups/:id/custom_attributes/:key
DELETE /projects/:id/custom_attributes/:key
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a resource |
| `key` | string | yes | The key of the custom attribute |
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/users/42/custom_attributes/location"
2018-03-17 18:26:18 +05:30
```