正式なドキュメントは英語版であり、この日本語訳は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"