正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。

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"