gocd/gocd — pull request #753 by arvindsv (2014-12-09 00:22:43+00:00)
Title: #739 - Feature toggle support

See #739 for details. This PR introduces support for a feature toggle list and update API, and a backend service which can be used in code to turn on and off features. The UI is coming up, but is not done yet.

The API is quite simple:

#### List values of toggles:

Without authentication:
```curl 'http://go_server/go/api/admin/feature_toggles'```

With authentication:
```curl --user username:password 'http://go_server/go/api/admin/feature_toggles'```

Example output (after formatting the JSON):
```
[
{
"has_changed":true,
"description":"desc1",
"key":"key1",
"value":false
},
{
"has_changed":false,
"description":"desc2",
"key":"key2",
"value":true
}
]
```

#### Change values of toggles:

Without authentication:
```curl -d 'toggle_value=on' 'http://go_server/go/api/admin/feature_toggles/key1'```

With authentication:
```curl --user username:password -d 'toggle_value=on' 'http://go_server/go/api/admin/feature_toggles/key1'```

Example output (for success):
```
{"message":"success"}
```

Example output (for errors):

```
{
"message":"Value of property 'toggle_value' is invalid. Valid values are: 'on' and 'off'."
}
```

```
{
"message":"Failed to change value of toggle. Message: Feature toggle: 'key_WRONG' is not valid."
}
```