피처 플래그s API

Tier: Free, Premium, Ultimate Offering: Self-managed

이 API는 GitLab 개발에 사용되는 Flipper 기반 피처 플래그를 관리하기 위한 것입니다.

모든 방법은 관리자 승인이 필요합니다.

현재 해당 API는 불리언과 시간의 백분율 게이트 값을 지원합니다.

모든 기능 디렉터리

모든 유지된 기능 디렉터리을 가져옵니다. 게이트 값을 포함합니다.

GET /features
curl --header "PRIVATE-TOKEN: <your_access_token>" "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 --header "PRIVATE-TOKEN: <your_access_token>" "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
  }
]

기능 설정 또는 생성

기능의 게이트 값을 설정합니다. 주어진 이름의 기능이 아직 존재하지 않은 경우 생성됩니다. 값은 불리언 또는 시간의 백분율을 나타내는 정수일 수 있습니다.

caution
아직 개발 중인 기능을 활성화하기 전에 보안 및 안정성 리스크를 이해해야 합니다.
POST /features/:name
속성 형식 필수 설명
name string yes 생성하거나 업데이트할 기능의 이름
value integer/string yes 활성화/비활성화를 나타내는 true 또는 false, 또는 시간의 백분율을 나타내는 정수
key string no percentage_of_actors 또는 percentage_of_time (기본값)
feature_group string no 기능 그룹 이름
user string no GitLab 사용자 또는 쉼표로 구분된 여러 사용자 이름
group string no GitLab 그룹 경로, 예: gitlab-org, 또는 쉼표로 구분된 여러 그룹 경로
namespace string no GitLab 그룹 또는 사용자 네임스페이스 경로, 예: john-doe, 또는 쉼표로 구분된 여러 네임스페이스 경로. GitLab 15.0에서 도입됨. Introduced in GitLab 15.0.
project string no 프로젝트 경로, 예: gitlab-org/gitlab-foss, 또는 쉼표로 구분된 여러 프로젝트 경로
repository string no 리포지터리 경로, 예: gitlab-org/gitlab-test.git, gitlab-org/gitlab-test.wiki.git, snippets/21.git 등. 여러 리포지터리 경로를 구분하려면 쉼표를 사용하세요.
force boolean no YAML 정의와 같은 피처 플래그 유효성 검사를 건너뛰기

단일 API 호출로 feature_group, user, group, namespace, project, repository에 대해 기능을 활성화 또는 비활성화할 수 있습니다.

curl --data "value=30" --header "PRIVATE-TOKEN: <your_access_token>" "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