カスタム属性API
- プラン: Free、Premium、Ultimate
- 提供形態: GitLab Self-Managed、GitLab Dedicated
ユーザー、グループ、プロジェクトのカスタム属性を管理するために、このAPIを使用します。
前提条件:
- インスタンスの管理者である必要があります。
すべてのカスタム属性を一覧表示
指定されたリソースのすべてのカスタム属性を一覧表示します。
GET /users/:id/custom_attributes
GET /groups/:id/custom_attributes
GET /projects/:id/custom_attributes| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数 | はい | リソースのID |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/users/42/custom_attributes"レスポンス例:
[
{
"key": "location",
"value": "Antarctica"
},
{
"key": "role",
"value": "Developer"
}
]カスタム属性を取得する
指定されたリソースのカスタム属性を取得します。
GET /users/:id/custom_attributes/:key
GET /groups/:id/custom_attributes/:key
GET /projects/:id/custom_attributes/:key| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数 | はい | リソースのID |
key | 文字列 | はい | カスタム属性のキー |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/users/42/custom_attributes/location"レスポンス例:
{
"key": "location",
"value": "Antarctica"
}カスタム属性を更新する
指定されたリソースのカスタム属性を更新または作成します。属性がすでに存在する場合は更新され、そうでない場合は新規作成されます。
PUT /users/:id/custom_attributes/:key
PUT /groups/:id/custom_attributes/:key
PUT /projects/:id/custom_attributes/:key| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数 | はい | リソースのID |
key | 文字列 | はい | カスタム属性のキー |
value | 文字列 | はい | カスタム属性の値 |
curl --request PUT \
--header "PRIVATE-TOKEN: <your_access_token>" \
--data "value=Greenland" \
--url "https://gitlab.example.com/api/v4/users/42/custom_attributes/location"レスポンス例:
{
"key": "location",
"value": "Greenland"
}カスタム属性を削除する
指定されたリソースのカスタム属性を削除します。
DELETE /users/:id/custom_attributes/:key
DELETE /groups/:id/custom_attributes/:key
DELETE /projects/:id/custom_attributes/:key| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数 | はい | リソースのID |
key | 文字列 | はい | カスタム属性のキー |
curl --request DELETE \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "https://gitlab.example.com/api/v4/users/42/custom_attributes/location"