diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2017-06-09 14:28:28 -0500 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2017-06-09 14:28:28 -0500 |
commit | 5bed8ac730f3849f550590ae9906166dd031dc87 (patch) | |
tree | bab3febb5105a9720e29abc2898ac440875c58c5 /lib/api/features.rb | |
parent | 66bbf30ed8bb006d9a968693fef266c86ec2325f (diff) | |
parent | abc61f260074663e5711d3814d9b7d301d07a259 (diff) | |
download | gitlab-ce-merge-master-9-3-stable.tar.gz |
Merge commit 'abc61f260074663e5711d3814d9b7d301d07a259' into merge-master-9-3-stablemerge-master-9-3-stable
Diffstat (limited to 'lib/api/features.rb')
-rw-r--r-- | lib/api/features.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/api/features.rb b/lib/api/features.rb new file mode 100644 index 00000000000..cff0ba2ddff --- /dev/null +++ b/lib/api/features.rb @@ -0,0 +1,36 @@ +module API + class Features < Grape::API + before { authenticated_as_admin! } + + resource :features do + desc 'Get a list of all features' do + success Entities::Feature + end + get do + features = Feature.all + + present features, with: Entities::Feature, current_user: current_user + end + + desc 'Set the gate value for the given feature' do + success Entities::Feature + end + params do + requires :value, type: String, desc: '`true` or `false` to enable/disable, an integer for percentage of time' + end + post ':name' do + feature = Feature.get(params[:name]) + + if %w(0 false).include?(params[:value]) + feature.disable + elsif params[:value] == 'true' + feature.enable + else + feature.enable_percentage_of_time(params[:value].to_i) + end + + present feature, with: Entities::Feature, current_user: current_user + end + end + end +end |