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

機能フラグAPI

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

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

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

このAPIは、ブール値と時間ゲートの割合の値のみをサポートしていることに注意してください。

すべての機能をリスト表示

すべての永続化された機能のリストを、そのゲートの値とともに取得します。

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
  }
]

機能を設定または作成

機能のゲート値を設定します。指定された名前の機能がまだ存在しない場合は、作成されます。値は、ブール値、または時間の割合を示す整数にすることができます。

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

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など)。カンマを使用して、複数のリポジトリパスを区切ります
forceブール値いいえYAML定義などの機能フラグ検証チェックをスキップします

1回のAPIコールで、feature_groupusergroupnamespaceproject、およびrepositoryの機能を有効または無効にできます。

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