피처 플래그s API

Tier: Free, Premium, Ultimate Offering: GitLab.com, Self-Managed, GitLab Dedicated
History

GitLab Feature Flags에 대한 리소스에 액세스하기 위한 API입니다.

최소한 Developer 역할을 가진 사용자만 특징 플래그 API에 액세스할 수 있습니다.

피처 플래그s 페이지네이션

기본적으로 GET 요청은 API 결과가 페이징됨으로 한 번에 20개의 결과를 반환합니다.

프로젝트의 특징 플래그 디렉터리

요청된 프로젝트의 모든 특징 플래그를 가져옵니다.

GET /projects/:id/feature_flags
속성 유형 필요 설명
id integer/string yes 프로젝트의 ID 또는 URL-인코딩 된 경로.
scope string no 특징 플래그의 조건 중 하나. 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",
      "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":"This is a new live trace feature",
      "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":"This feature is about user list",
      "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": "My user list",
            "user_xids": "user1,user2,user3"
          }
        }
      ]
   }
]

단일 특징 플래그 가져오기

특정 특징 플래그를 가져옵니다.

GET /projects/:id/feature_flags/:feature_flag_name
속성 유형 필요 설명
id integer/string yes 프로젝트의 ID 또는 URL-인코딩 된 경로.
feature_flag_name string yes 특징 플래그의 이름.
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 integer/string yes 프로젝트의 ID 또는 URL-인코딩 된 경로.
name string yes 특징 플래그의 이름.
version string yes 지원 중단 특징 플래그의 버전. new_version_flag 여야 합니다. Legacy 특징 플래그를 생성하지려면 생략해야 합니다.
description string no 특징 플래그의 설명.
active boolean no 플래그의 활성 상태. 기본값은 true입니다.
strategies strategy JSON 객체 배열 no 특징 플래그의 전략.
strategies:name JSON no 전략 이름. default, gradualRolloutUserId, userWithId, 또는 gitlabUserList일 수 있습니다. GitLab 13.5 그리고 이후에는 flexibleRollout이 될 수 있습니다.
strategies:parameters JSON no 전략 매개변수.
strategies:scopes JSON no 전략의 범위.
strategies:scopes:environment_scope string no 범위의 환경 범위.
strategies:user_list_id integer/string no 특징 플래그 사용자 디렉터리의 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 정수/문자열 프로젝트의 ID 또는 URL 코딩된 경로.
feature_flag_name 문자열 피처 플래그의 현재 이름.
description 문자열 아니요 피처 플래그의 설명.
active 부울 아니요 플래그의 활성 상태.
name 문자열 아니요 피처 플래그의 새 이름.
strategies 전략 JSON 객체 배열 아니요 피처 플래그 전략.
strategies:id JSON 아니요 플래그 전략 ID.
strategies:name JSON 아니요 전략 이름.
strategies:_destroy 부울 아니요 참이면 전략 삭제.
strategies:parameters JSON 아니요 전략 파라미터.
strategies:scopes JSON 아니요 전략의 범위.
strategies:scopes:id JSON 아니요 환경 범위 ID.
strategies:scopes:environment_scope 문자열 아니요 범위의 환경 범위.
strategies:scopes:_destroy 부울 아니요 참이면 범위 삭제.
strategies:user_list_id 정수/문자열 아니요 전략이 gitlabUserList인 경우 피처 플래그 사용자 디렉터리의 ID.
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 정수/문자열 프로젝트의 ID 또는 URL-encoded path of the project.
feature_flag_name 문자열 피처 플래그의 이름.
curl --header "PRIVATE-TOKEN: <your_access_token>" --request DELETE "https://gitlab.example.com/api/v4/projects/1/feature_flags/awesome_feature"