1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/docs/api-v1.md

396 lines
7.9 KiB
Markdown
Raw Normal View History

2016-09-06 21:23:56 +02:00
# API
## Feature Toggles
### Fetching Feature Toggles
2016-11-13 20:57:04 +01:00
**GET: http://unleash.host.com/api/features**
2016-09-06 21:23:56 +02:00
2016-11-09 12:41:11 +01:00
**HEADERS:**
* UNLEASH-APPNAME: appName
* UNLEASH-INSTANCEID: instanceId
2016-09-07 12:12:17 +02:00
This endpoint is the one all clients should use to fetch all available feature toggles
from the _unleash-server_. The response returns all active feature toggles and their
current strategy configuration. A feature toggle will have _at least_ one configured strategy.
A strategy will have a `name` and `parameters` map.
2016-09-06 21:23:56 +02:00
2016-09-07 12:12:17 +02:00
> _Note:_ Clients should perfer the `strategies` property.
> Legacy properties (`strategy` & `parameters`) will be kept until **version 2** of the format.
2016-09-06 21:23:56 +02:00
2016-09-07 12:12:17 +02:00
This endpoint should never return anything besides a valid *20X or 304-response*. It will also
2016-09-06 21:23:56 +02:00
include a `Etag`-header. The value of this header can be used by clients as the value of
the `If-None-Match`-header in the request to prevent a data transfer if the clients already
2016-09-07 12:12:17 +02:00
has the latest response locally.
2016-09-06 21:23:56 +02:00
**Example response:**
```json
{
"version": 1,
"features": [
{
"name": "Feature.A",
"description": "lorem ipsum",
"enabled": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"strategy": "default",
"parameters": {}
},
{
"name": "Feature.B",
"description": "lorem ipsum",
"enabled": true,
"strategies": [
{
"name": "ActiveForUserWithId",
"parameters": {
"userIdList": "123,221,998"
}
},
{
"name": "GradualRolloutRandom",
"parameters": {
"percentage": "10"
}
}
],
"strategy": "ActiveForUserWithId",
"parameters": {
"userIdList": "123,221,998"
}
}
]
}
```
2016-11-13 20:57:04 +01:00
**GET: http://unleash.host.com/api/features/:featureName**
2016-09-06 21:23:56 +02:00
2016-09-07 12:12:17 +02:00
Used to fetch details about a specific featureToggle. This is mostly provded to make it easy to
debug the API and should not be used by the client implementations.
2016-09-06 21:23:56 +02:00
2016-09-07 12:12:17 +02:00
> _Notice_: You will not get a version property when fetching a specific feature toggle by name.
2016-09-06 21:23:56 +02:00
```json
{
"name": "Feature.A",
"description": "lorem ipsum..",
"enabled": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"strategy": "default",
"parameters": {}
}
```
### Create a new Feature Toggle
2016-11-13 20:57:04 +01:00
**POST: http://unleash.host.com/api/features/**
2016-09-06 21:23:56 +02:00
**Body:**
```json
{
"name": "Feature.A",
"description": "lorem ipsum..",
"enabled": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
]
}
```
2016-09-07 12:12:17 +02:00
Used by the admin-dashboard to create a new feature toggles. The name **must be unique**,
2016-09-06 21:23:56 +02:00
otherwise you will get a _403-response_.
Returns 200-respose if the feature toggle was created successfully.
2016-09-07 12:12:17 +02:00
### Update a Feature Toggle
2016-09-06 21:23:56 +02:00
2016-11-13 20:57:04 +01:00
**PUT: http://unleash.host.com/api/features/:toggleName**
2016-09-06 21:23:56 +02:00
**Body:**
```json
{
"name": "Feature.A",
"description": "lorem ipsum..",
"enabled": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
]
}
```
2016-09-07 12:12:17 +02:00
Used by the admin dashboard to update a feature toggles. The name has to match an
existing features toggle.
2016-09-06 21:23:56 +02:00
Returns 200-respose if the feature toggle was updated successfully.
2016-09-07 12:12:17 +02:00
### Archive a Feature Toggle
2016-11-13 20:57:04 +01:00
**DELETE: http://unleash.host.com/api/features/:toggleName**
2016-09-07 12:12:17 +02:00
Used to archive a feature toggle. A feature toggle can never be totally be deleted,
but can be archived. This is a design decision to make sure that a old feature
toggle suddnely reapear by some one else reusing the same name.
## Archive
### Fetch archived toggles
2016-11-13 20:57:04 +01:00
**GET http://unleash.host.com/api/archive/features**
2016-09-07 12:12:17 +02:00
Used to fetch list of archived feature toggles
**Example response:**
```json
{
"version": 1,
"features": [
{
"name": "Feature.A",
"description": "lorem ipsum",
"enabled": false,
"strategies": [
{
"name": "default",
"parameters": {}
}
],
"strategy": "default",
"parameters": {}
}
]
}
```
### Revive feature toggle
2016-11-13 20:57:04 +01:00
**POST http://unleash.host.com/api/archive/revive**
2016-09-07 12:12:17 +02:00
**Body:**
```json
{
"name": "Feature.A"
}
```
Used to revive a feature toggle.
2016-09-06 21:23:56 +02:00
## Strategies
### Fetch Strategies
2016-11-13 20:57:04 +01:00
**GET: http://unleash.host.com/api/strategies**
2016-09-06 21:23:56 +02:00
Used to fetch all defined strategies and their defined paramters.
**Response**
```json
{
2016-11-02 12:55:14 +01:00
"version": 1,
"strategies": [
2016-09-06 21:23:56 +02:00
{
2016-11-02 12:55:14 +01:00
"name": "default",
"description": "Default on/off strategy.",
"parametersTemplate": null
2016-09-06 21:23:56 +02:00
},
{
2016-11-02 12:55:14 +01:00
"name": "ActiveForUserWithEmail",
"description": "A comma separated list of email adresses this feature should be active for.",
"parametersTemplate": {
"emails": "string"
2016-09-06 21:23:56 +02:00
}
},
{
2016-11-02 12:55:14 +01:00
"name": "Accounts",
"description": "Enable for user accounts",
"parametersTemplate": {
"Accountname": "string"
2016-09-06 21:23:56 +02:00
}
}
]}
```
### Create strategy
2016-11-13 20:57:04 +01:00
**POST: http://unleash.host.com/api/strategies**
2016-09-06 21:23:56 +02:00
**Body**
```json
{
2016-11-02 12:55:14 +01:00
"name": "ActiveForUserWithEmail",
"description": "A comma separated list of email adresses this feature should be active for.",
"parametersTemplate": {
"emails": "string"
2016-09-06 21:23:56 +02:00
}
}
```
Used to create a new Strategy. Name must be unique.
# Events
2016-11-13 20:57:04 +01:00
**GET: http://unleash.host.com/api/events**
2016-09-06 21:23:56 +02:00
2016-09-07 12:12:17 +02:00
Used to fetch all changes in the unleash system.
Event types:
- feature-created
- feature-updated
- feature-archived
- feature-revived
- strategy-created
- strategy-deleted
2016-09-06 21:23:56 +02:00
**Response**
```json
{
"version": 1,
"events":[
{
"id":454,
"type":"feature-updated",
"createdBy":"unknown",
"createdAt":"2016-08-24T11:22:01.354Z",
"data": {
"name":"eid.bankid.mobile",
"description":"",
"strategy":"default",
"enabled":true,
"parameters":{}
},
"diffs": [
{"kind":"E","path":["enabled"],"lhs":false,"rhs":true}
]
}
]
}
```
2016-11-04 16:13:58 +01:00
# Metrics
2016-11-13 20:57:04 +01:00
**GET: http://unleash.host.com/api/metrics**
2016-11-04 16:13:58 +01:00
Get aggregated state of metrics
2016-11-13 20:57:04 +01:00
```json
2016-11-04 16:13:58 +01:00
{
2016-11-13 20:57:04 +01:00
"globalCount": 1420,
"apps": {
"app-name": {
"count": 1420,
"clients": [
"instance-id"
]
}
},
"clients": {
"instance-id": {
"appName": "app-name",
"count": 1420,
"started": "2016-11-13T19:50:54.395Z",
"init": "2016-11-13T19:50:54.395Z",
"ping": "2016-11-13T19:51:14.403Z"
}
}
2016-11-04 16:13:58 +01:00
}
```
2016-11-13 20:57:04 +01:00
**GET: http://unleash.host.com/api/metrics/features**
2016-11-04 16:13:58 +01:00
2016-11-13 20:57:04 +01:00
Get metrics per toggle
2016-11-04 16:13:58 +01:00
2016-11-13 20:57:04 +01:00
```json
2016-11-04 16:13:58 +01:00
{
2016-11-13 20:57:04 +01:00
"lastHour": {
"toggle-name-1": {
"yes": 0,
"no": 720
},
"toggle-name-2": {
"yes": 0,
"no": 463
},
"toggle-name-3": {
"yes": 237,
"no": 0
}
},
"lastMinute": {
"toggle-name-1": {
"yes": 0,
"no": 0
},
"toggle-name-2": {
"yes": 0,
"no": 0
},
"toggle-name-3": {
"yes": 0,
"no": 0
}
}
2016-11-04 16:13:58 +01:00
}
```
2016-11-13 20:57:04 +01:00
**POST: http://unleash.host.com/api/client/register**
2016-11-04 16:13:58 +01:00
Register a client instance with the unleash server
```json
{
"appName": "appName",
"instanceId": "instanceId",
"strategies": ["default", "some-strategy-1"],
"started": "2016-11-03T07:16:43.572Z",
"interval": 10000,
}
```
2016-11-13 20:57:04 +01:00
**POST: http://unleash.host.com/api/client/metrics**
2016-11-04 16:13:58 +01:00
Register a metrics payload with a timed bucket
```json
{
"appName": "appName",
"instanceId": "instanceId",
"bucket": {
"start": "2016-11-03T07:16:43.572Z",
"stop": "2016-11-03T07:16:53.572Z",
"toggles": {
"toggle-name-1": {
"yes": 123,
"no": 321
}
}
},
}
```