2017-06-29 12:53:57 -04:00
|
|
|
# Features flags API
|
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.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /features
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/features
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "experimental_feature",
|
|
|
|
"state": "off",
|
|
|
|
"gates": [
|
|
|
|
{
|
|
|
|
"key": "boolean",
|
|
|
|
"value": false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"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.
|
|
|
|
|
|
|
|
```
|
|
|
|
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 |
|
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 |
|
2017-05-31 17:06:01 -04:00
|
|
|
|
2017-07-05 15:55:27 -04:00
|
|
|
Note that you can enable or disable a feature for both a `feature_group` and a
|
|
|
|
`user` with a single API call.
|
2017-06-27 12:58:56 -04:00
|
|
|
|
2017-05-31 17:06:01 -04:00
|
|
|
```bash
|
|
|
|
curl --data "value=30" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/features/new_library
|
|
|
|
```
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
## Delete a feature
|
|
|
|
|
|
|
|
Removes a feature gate. Response is equal when the gate exists, or doesn't.
|
|
|
|
|
|
|
|
```
|
|
|
|
DELETE /features/:name
|
|
|
|
```
|