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

機能フラグAPI

  • プラン: Free、Premium、Ultimate
  • 提供形態: GitLab Self-Managed

このAPIは、GitLabの開発で使用されるFlipperベースの機能フラグを管理するためのものです。

すべてのメソッドには管理者の認可が必要です。

このAPIは、booleanとpercentage-of-timeゲート値のみをサポートしていることに注意してください。

すべての機能フラグをリストする

永続化されたすべての機能フラグと、そのゲート値を一覧表示します。

GET /features
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/features"

レスポンス例:

[
  {
    "name": "experimental_feature",
    "state": "off",
    "gates": [
      {
        "key": "boolean",
        "value": false
      }
    ],
    "definition": null
  },
  {
    "name": "my_user_feature",
    "state": "on",
    "gates": [
      {
        "key": "percentage_of_actors",
        "value": 34
      }
    ],
    "definition": {
      "name": "my_user_feature",
      "introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40880",
      "rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/244905",
      "group": "group::ci",
      "type": "development",
      "default_enabled": false
    }
  },
  {
    "name": "new_library",
    "state": "on",
    "gates": [
      {
        "key": "boolean",
        "value": true
      }
    ],
    "definition": null
  }
]

すべての機能フラグ定義をリストする

すべての機能フラグ定義を一覧表示します。

GET /features/definitions
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/features/definitions"

レスポンス例:

[
  {
    "name": "geo_pages_deployment_replication",
    "introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68662",
    "rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/337676",
    "milestone": "14.3",
    "log_state_changes": null,
    "type": "development",
    "group": "group::geo",
    "default_enabled": true
  }
]

機能フラグを作成または更新する

機能フラグのゲート値を作成または更新します。指定された名前の機能フラグがまだ存在しない場合、それは作成されます。値はboolean、または時間のパーセンテージを示す整数にすることができます。

開発中の機能を有効にする前に、セキュリティと安定性のリスクを理解しておく必要があります。

POST /features/:name
属性必須説明
name文字列はい作成または更新する機能フラグの名前
value整数または文字列はいtrueまたはfalseで有効/無効を設定するか、時間の割合を示す整数
key文字列いいえpercentage_of_actorsまたはpercentage_of_time (デフォルト)
feature_group文字列いいえ機能フラググループ名
user文字列いいえGitLabのユーザー名、またはカンマ区切りの複数のユーザー名
group文字列いいえGitLabグループのパス。例: gitlab-org、またはカンマ区切りの複数のグループパス
namespace文字列いいえGitLabグループまたはユーザーネームスペースのパス。例: john-doe、またはカンマ区切りの複数のネームスペースパス。GitLab 15.0で導入されました。
project文字列いいえプロジェクトパス。例: gitlab-org/gitlab-foss、またはカンマ区切りの複数のプロジェクトパス
repository文字列いいえリポジトリパス。例: gitlab-org/gitlab-test.gitgitlab-org/gitlab-test.wiki.gitsnippets/21.gitなど。複数のリポジトリパスはカンマで区切ります
runner文字列いいえRunner ID、またはカンマ区切りの複数のRunner ID
forceブール値いいえYAML定義などの機能フラグ検証チェックをスキップします

単一のAPIコールで、feature_groupusergroupnamespaceprojectrepositoryrunnerの機能を有効または無効にできます。

curl --request POST \
  --data "value=30" \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/features/new_library"

レスポンス例:

{
  "name": "new_library",
  "state": "conditional",
  "gates": [
    {
      "key": "boolean",
      "value": false
    },
    {
      "key": "percentage_of_time",
      "value": 30
    }
  ],
  "definition": {
    "name": "my_user_feature",
    "introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40880",
    "rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/244905",
    "group": "group::ci",
    "type": "development",
    "default_enabled": false
  }
}

アクターのロールアウトの割合を設定する

アクターのパーセンテージへのロールアウト。

POST https://gitlab.example.com/api/v4/features/my_user_feature?private_token=<your_access_token>
Content-Type: application/x-www-form-urlencoded
value=42&key=percentage_of_actors&

レスポンス例:

{
  "name": "my_user_feature",
  "state": "conditional",
  "gates": [
    {
      "key": "boolean",
      "value": false
    },
    {
      "key": "percentage_of_actors",
      "value": 42
    }
  ],
  "definition": {
    "name": "my_user_feature",
    "introduced_by_url": "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40880",
    "rollout_issue_url": "https://gitlab.com/gitlab-org/gitlab/-/issues/244905",
    "group": "group::ci",
    "type": "development",
    "default_enabled": false
  }
}

my_user_featureをアクターの42%にロールアウトします。

機能を削除する

機能フラグゲートを削除します。機能フラグが存在するかどうかにかかわらず、同じレスポンスを返します。

DELETE /features/:name