機能フラグAPI
GitLab Premium12.5で導入されました。
注意このAPIは機能フラグの背後にあります。 このフラグが環境で有効になっていない場合は、従来の機能フラグAPIを使用できます。
GitLab Feature FlagsのリソースにアクセスするためのAPIです。
開発者以上の権限を持つユーザーは、Feature Flag APIにアクセスできます。
特集 フラグ ページネーション
デフォルトでは、APIの結果はページ分割されているため、GET
リクエストは一度に20件の結果を返します。
プロジェクトの機能フラグ一覧
要求されたプロジェクトのすべての機能フラグを取得します。
GET /projects/:id/feature_flags
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
id
| 整数/文字列 | はい | プロジェクトのIDまたはURLエンコードされたパス。 |
scope
| 列 | いいえ | 特徴フラグの状態。enabled ,disabled のいずれか。
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/feature_flags"
回答例
[
{
"name":"merge_train",
"description":"This feature is about merge train",
"version": "new_version_flag",
"created_at":"2019-11-04T08:13:51.423Z",
"updated_at":"2019-11-04T08:13:51.423Z",
"scopes":[],
"strategies": [
{
"id": 1,
"name": "userWithId",
"parameters": {
"userIds": "user1"
},
"scopes": [
{
"id": 1,
"environment_scope": "production"
}
]
}
]
},
{
"name":"new_live_trace",
"description":"This is a new live trace feature",
"version": "new_version_flag",
"created_at":"2019-11-04T08:13:10.507Z",
"updated_at":"2019-11-04T08:13:10.507Z",
"scopes":[]
"strategies": [
{
"id": 2,
"name": "default",
"parameters": {},
"scopes": [
{
"id": 2,
"environment_scope": "staging"
}
]
}
]
}
]
単一の機能フラグを取得
単一の特徴フラグを取得します。
GET /projects/:id/feature_flags/:name
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
id
| 整数/文字列 | はい | プロジェクトのIDまたはURLエンコードされたパス。 |
name
| 列 | はい | 機能フラグの名前。 |
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/feature_flags/awesome_feature
回答例
{
"name": "awesome_feature",
"description": null,
"version": "new_version_flag",
"created_at": "2020-05-13T19:56:33.119Z",
"updated_at": "2020-05-13T19:56:33.119Z",
"scopes": [],
"strategies": [
{
"id": 36,
"name": "default",
"parameters": {},
"scopes": [
{
"id": 37,
"environment_scope": "production"
}
]
}
]
}
特集フラグの作成
新しい機能フラグを作成します。
POST /projects/:id/feature_flags
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
id
| 整数/文字列 | はい | プロジェクトのIDまたはURLエンコードされたパス。 |
name
| 列 | はい | 機能フラグの名前。 |
version
| 列 | はい |
new_version_flag レガシー機能フラグを作成する場合は、省略するか、legacy_flag に設定します。
|
description
| 列 | いいえ | 機能フラグの説明。 |
strategies
| JSON | いいえ | 特徴的なフラグ戦略。 |
strategies:name
| JSON | いいえ | 戦略名。 |
strategies:parameters
| JSON | いいえ | 戦略パラメータ。 |
strategies:scopes
| JSON | いいえ | 戦略のスコープ。 |
strategies:scopes:environment_scope
| 列 | いいえ | スコープの環境仕様。 |
curl "https://gitlab.example.com/api/v4/projects/1/feature_flags" \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-type: application/json" \
--data @- << EOF
{
"name": "awesome_feature",
"version": "new_version_flag",
"strategies": [{ "name": "default", "parameters": {}, "scopes": [{ "environment_scope": "production" }] }]
}
EOF
回答例
{
"name": "awesome_feature",
"description": null,
"version": "new_version_flag",
"created_at": "2020-05-13T19:56:33.119Z",
"updated_at": "2020-05-13T19:56:33.119Z",
"scopes": [],
"strategies": [
{
"id": 36,
"name": "default",
"parameters": {},
"scopes": [
{
"id": 37,
"environment_scope": "production"
}
]
}
]
}
機能フラグの更新
機能フラグを更新します。
PUT /projects/:id/feature_flags/:name
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
id
| 整数/文字列 | はい | プロジェクトのIDまたはURLエンコードされたパス。 |
name
| 列 | はい | 機能フラグの名前。 |
description
| 列 | いいえ | 機能フラグの説明。 |
strategies
| JSON | いいえ | 特徴的なフラグ戦略。 |
strategies:id
| JSON | いいえ | 特徴フラグ戦略ID。 |
strategies:name
| JSON | いいえ | 戦略名。 |
strategies:parameters
| JSON | いいえ | 戦略パラメータ。 |
strategies:scopes
| JSON | いいえ | 戦略のスコープ。 |
strategies:scopes:id
| JSON | いいえ | スコープID。 |
strategies:scopes:environment_scope
| 列 | いいえ | スコープの環境仕様。 |
curl "https://gitlab.example.com/api/v4/projects/1/feature_flags/awesome_feature" \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-type: application/json" \
--data @- << EOF
{
"strategies": [{ "name": "gradualRolloutUserId", "parameters": { "groupId": "default", "percentage": "25" }, "scopes": [{ "environment_scope": "staging" }] }]
}
EOF
回答例
{
"name": "awesome_feature",
"description": null,
"version": "new_version_flag",
"created_at": "2020-05-13T20:10:32.891Z",
"updated_at": "2020-05-13T20:10:32.891Z",
"scopes": [],
"strategies": [
{
"id": 38,
"name": "gradualRolloutUserId",
"parameters": {
"groupId": "default",
"percentage": "25"
},
"scopes": [
{
"id": 40,
"environment_scope": "staging"
}
]
},
{
"id": 37,
"name": "default",
"parameters": {},
"scopes": [
{
"id": 39,
"environment_scope": "production"
}
]
}
]
}
機能フラグの削除
機能フラグを削除します。
DELETE /projects/:id/feature_flags/:name
属性 | タイプ | 必須 | 説明 |
---|---|---|---|
id
| 整数/文字列 | はい | プロジェクトのIDまたはURLエンコードされたパス。 |
name
| 列 | はい | 機能フラグの名前。 |
curl --header "PRIVATE-TOKEN: <your_access_token>" --request DELETE "https://gitlab.example.com/api/v4/projects/1/feature_flags/awesome_feature"