2017-06-29 12:53:57 -04:00
|
|
|
# Features flags API
|
2017-05-31 17:06:01 -04:00
|
|
|
|
2020-05-15 14:07:52 -04:00
|
|
|
This API is for managing Flipper-based [feature flags used in development of GitLab](../development/feature_flags/index.md).
|
|
|
|
|
2017-05-31 17:06:01 -04:00
|
|
|
All methods require administrator authorization.
|
|
|
|
|
|
|
|
Notice that currently the API only supports boolean and percentage-of-time gate
|
|
|
|
values.
|
|
|
|
|
|
|
|
## List all features
|
|
|
|
|
|
|
|
Get a list of all persisted features, with its gate values.
|
|
|
|
|
2020-02-27 04:09:01 -05:00
|
|
|
```plaintext
|
2017-05-31 17:06:01 -04:00
|
|
|
GET /features
|
|
|
|
```
|
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2020-05-27 20:08:37 -04:00
|
|
|
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/features"
|
2017-05-31 17:06:01 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "experimental_feature",
|
|
|
|
"state": "off",
|
|
|
|
"gates": [
|
|
|
|
{
|
|
|
|
"key": "boolean",
|
|
|
|
"value": false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2020-05-13 20:07:47 -04:00
|
|
|
{
|
|
|
|
"name": "my_user_feature",
|
|
|
|
"state": "on",
|
|
|
|
"gates": [
|
|
|
|
{
|
|
|
|
"key": "percentage_of_actors",
|
|
|
|
"value": 34
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2017-05-31 17:06:01 -04:00
|
|
|
{
|
|
|
|
"name": "new_library",
|
|
|
|
"state": "on",
|
|
|
|
"gates": [
|
|
|
|
{
|
|
|
|
"key": "boolean",
|
|
|
|
"value": true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Set or create a feature
|
|
|
|
|
|
|
|
Set a feature's gate value. If a feature with the given name doesn't exist yet
|
|
|
|
it will be created. The value can be a boolean, or an integer to indicate
|
|
|
|
percentage of time.
|
|
|
|
|
2020-02-27 04:09:01 -05:00
|
|
|
```plaintext
|
2017-05-31 17:06:01 -04:00
|
|
|
POST /features/:name
|
|
|
|
```
|
|
|
|
|
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
|
|
|
| `name` | string | yes | Name of the feature to create or update |
|
|
|
|
| `value` | integer/string | yes | `true` or `false` to enable/disable, or an integer for percentage of time |
|
2020-05-13 20:07:47 -04:00
|
|
|
| `key` | string | no | `percentage_of_actors` or `percentage_of_time` (default) |
|
2017-06-28 13:29:56 -04:00
|
|
|
| `feature_group` | string | no | A Feature group name |
|
2017-06-21 10:49:51 -04:00
|
|
|
| `user` | string | no | A GitLab username |
|
2019-08-23 04:50:24 -04:00
|
|
|
| `group` | string | no | A GitLab group's path, for example `gitlab-org` |
|
2019-09-18 14:06:14 -04:00
|
|
|
| `project` | string | no | A projects path, for example `gitlab-org/gitlab-foss` |
|
2017-05-31 17:06:01 -04:00
|
|
|
|
2019-01-07 05:07:14 -05:00
|
|
|
Note that you can enable or disable a feature for a `feature_group`, a `user`,
|
2019-02-07 15:27:03 -05:00
|
|
|
a `group`, and a `project` in a single API call.
|
2017-06-27 12:58:56 -04:00
|
|
|
|
2020-01-30 10:09:15 -05:00
|
|
|
```shell
|
2020-05-27 20:08:37 -04:00
|
|
|
curl --data "value=30" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/features/new_library"
|
2017-05-31 17:06:01 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"name": "new_library",
|
|
|
|
"state": "conditional",
|
|
|
|
"gates": [
|
|
|
|
{
|
|
|
|
"key": "boolean",
|
|
|
|
"value": false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"key": "percentage_of_time",
|
|
|
|
"value": 30
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
2018-04-03 07:35:26 -04:00
|
|
|
|
2020-05-13 20:07:47 -04:00
|
|
|
### Set percentage of actors rollout
|
|
|
|
|
2020-05-14 23:08:10 -04:00
|
|
|
Rollout to percentage of actors.
|
2020-05-13 20:07:47 -04:00
|
|
|
|
|
|
|
```plaintext
|
|
|
|
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&
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"name": "my_user_feature",
|
|
|
|
"state": "conditional",
|
|
|
|
"gates": [
|
|
|
|
{
|
|
|
|
"key": "boolean",
|
|
|
|
"value": false
|
|
|
|
},
|
|
|
|
{
|
2020-05-14 23:08:10 -04:00
|
|
|
"key": "percentage_of_actors",
|
2020-05-13 20:07:47 -04:00
|
|
|
"value": 42
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-05-14 23:08:10 -04:00
|
|
|
Rolls out the `my_user_feature` to `42%` of actors.
|
2020-05-13 20:07:47 -04:00
|
|
|
|
2018-04-03 07:35:26 -04:00
|
|
|
## Delete a feature
|
|
|
|
|
|
|
|
Removes a feature gate. Response is equal when the gate exists, or doesn't.
|
|
|
|
|
2020-02-27 04:09:01 -05:00
|
|
|
```plaintext
|
2018-04-03 07:35:26 -04:00
|
|
|
DELETE /features/:name
|
|
|
|
```
|