summaryrefslogtreecommitdiff
path: root/lib/api/features.rb
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-06-01 07:25:48 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-06-01 07:25:48 +0000
commit3cc138d824df039af2d7dae2ae04c30e98b51af1 (patch)
treee7b16ba807cad3231b69457bcc71ccbb1b74c4ce /lib/api/features.rb
parent17c926313a242c6ad988a7ffd55aa6330c8aacfd (diff)
parentdd0f8b8ccc3b5f61e31703f7391a919b702934a5 (diff)
downloadgitlab-ce-3cc138d824df039af2d7dae2ae04c30e98b51af1.tar.gz
Merge branch 'master' into '24196-protected-variables'
# Conflicts: # db/schema.rb
Diffstat (limited to 'lib/api/features.rb')
-rw-r--r--lib/api/features.rb36
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