특징 플래그 API
Tier: Free, Premium, Ultimate
Offering: GitLab.com, Self-managed, GitLab Dedicated
- GitLab Premium 12.5에서 소개되었습니다.
- GitLab Free 13.5로 이동되었습니다.
GitLab feature flags의 리소스에 액세스하기 위한 API입니다.
최소한 Developer role을 가진 사용자는 특징 플래그 API에 액세스할 수 있습니다.
특징 플래그 페이징
기본적으로 GET
요청은 API 결과가 페이징되기 때문에 한 번에 20개의 결과를 반환합니다.
프로젝트의 특징 플래그 디렉터리
요청된 프로젝트의 모든 특징 플래그를 가져옵니다.
GET /projects/:id/feature_flags
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id
| 정수/문자열 | 예 | 프로젝트의 ID 또는 URL-encoded path. |
scope
| 문자열 | 아니오 | 특징 플래그의 조건 중 하나, enabled , disabled .
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/feature_flags"
예시 응답:
[
{
"name":"merge_train",
"description":"Merge Train에 관한 기능",
"active": true,
"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"
}
],
"user_list": null
}
]
},
{
"name":"new_live_trace",
"description":"새로운 라이브 추적 기능",
"active": true,
"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"
}
],
"user_list": null
}
]
},
{
"name":"user_list",
"description":"사용자 디렉터리에 관한 기능",
"active": true,
"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": "gitlabUserList",
"parameters": {},
"scopes": [
{
"id": 2,
"environment_scope": "staging"
}
],
"user_list": {
"id": 1,
"iid": 1,
"name": "내 사용자 디렉터리",
"user_xids": "user1,user2,user3"
}
}
]
}
]
단일 특징 플래그 가져오기
단일 특징 플래그를 가져옵니다.
GET /projects/:id/feature_flags/:feature_flag_name
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id
| 정수/문자열 | 예 | 프로젝트의 ID 또는 URL-encoded path. |
feature_flag_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,
"active": true,
"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"
}
],
"user_list": null
}
]
}
새로운 특징 플래그 생성
새로운 특징 플래그를 생성합니다.
POST /projects/:id/feature_flags
속성 | 유형 | 필수 | 설명 |
---|---|---|---|
id
| 정수/문자열 | 예 | 프로젝트의 ID 또는 URL-encoded path. |
name
| 문자열 | 예 | 특징 플래그의 이름. |
version
| 문자열 | 예 |
사용 중단 특징 플래그의 버전. new_version_flag 여야 합니다. Legacy 특징 플래그를 생성하려면 생략하십시오.
|
description
| 문자열 | 아니오 | 특징 플래그에 대한 설명. |
active
| 부울 | 아니오 | 플래그의 활성 상태. 기본값은 true입니다. 지원 버전 13.3 이상에서 지원됩니다. |
strategies
| 전략 JSON 객체의 배열 | 아니오 | 특징 플래그 전략들. |
strategies:name
| JSON | 아니오 | 전략 이름. default , gradualRolloutUserId , userWithId , 또는 gitlabUserList 가 될 수 있습니다. GitLab 13.5 및 이후 버전에서는 flexibleRollout 일 수 있습니다.
|
strategies:parameters
| JSON | 아니오 | 전략 매개변수. |
strategies:scopes
| JSON | 아니오 | 전략의 범위. |
strategies:scopes:environment_scope
| 문자열 | 아니오 | 범위의 환경 범위. |
strategies:user_list_id
| 정수/문자열 | 아니오 | 특징 플래그 사용자 디렉터리의 ID. 전략이 gitlabUserList 인 경우.
|
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,
"active": true,
"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/:feature_flag_name
속성 | 유형 | 필수여부 | 설명 |
---|---|---|---|
id
| integer/string | yes | 프로젝트의 ID 또는 URL-encoded path. |
feature_flag_name
| string | yes | 현재 피처 플래그의 이름. |
description
| string | no | 피처 플래그의 설명. |
active
| boolean | no | 플래그의 활성 상태. GitLab 13.3 및 이후 버전에서 지원. |
name
| string | no | 피처 플래그의 새 이름. GitLab 13.3 및 이후 버전에서 지원. |
strategies
| 전략 JSON 객체들의 배열 | no | 피처 플래그 전략. |
strategies:id
| JSON | no | 피처 플래그 전략 ID. |
strategies:name
| JSON | no | 전략 이름. |
strategies:_destroy
| boolean | no | 참일 경우 전략 삭제. |
strategies:parameters
| JSON | no | 전략 매개변수. |
strategies:scopes
| JSON | no | 전략의 범위. |
strategies:scopes:id
| JSON | no | 환경 범위 ID. |
strategies:scopes:environment_scope
| string | no | 범위의 환경 범위. |
strategies:scopes:_destroy
| boolean | no | 참일 경우 범위 삭제. |
strategies:user_list_id
| integer/string | no | 피처 플래그 사용자 디렉터리 ID. 전략이 gitlabUserList 인 경우에 사용됨.
|
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,
"active": true,
"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/:feature_flag_name
속성 | 유형 | 필수여부 | 설명 |
---|---|---|---|
id
| integer/string | yes | 프로젝트의 ID 또는 URL-encoded path. |
feature_flag_name
| string | yes | 피처 플래그의 이름. |
curl --header "PRIVATE-TOKEN: <your_access_token>" --request DELETE "https://gitlab.example.com/api/v4/projects/1/feature_flags/awesome_feature"