summaryrefslogtreecommitdiff
path: root/lib/api/features.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 11:33:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 11:33:21 +0000
commit7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch)
tree5bdc2229f5198d516781f8d24eace62fc7e589e9 /lib/api/features.rb
parent185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff)
downloadgitlab-ce-7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0.tar.gz
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'lib/api/features.rb')
-rw-r--r--lib/api/features.rb45
1 files changed, 35 insertions, 10 deletions
diff --git a/lib/api/features.rb b/lib/api/features.rb
index 9d4e6eee82c..6b6f5cbfb3f 100644
--- a/lib/api/features.rb
+++ b/lib/api/features.rb
@@ -4,6 +4,8 @@ module API
class Features < ::API::Base
before { authenticated_as_admin! }
+ features_tags = %w[features]
+
feature_category :feature_flags
urgency :low
@@ -44,8 +46,11 @@ module API
end
resource :features do
- desc 'Get a list of all features' do
+ desc 'List all features' do
+ detail 'Get a list of all persisted features, with its gate values.'
success Entities::Feature
+ is_array true
+ tags features_tags
end
get do
features = Feature.all
@@ -53,8 +58,11 @@ module API
present features, with: Entities::Feature, current_user: current_user
end
- desc 'Get a list of all feature definitions' do
+ desc 'List all feature definitions' do
+ detail 'Get a list of all feature definitions.'
success Entities::Feature::Definition
+ is_array true
+ tags features_tags
end
get :definitions do
definitions = ::Feature::Definition.definitions.values.map(&:to_h)
@@ -62,30 +70,44 @@ module API
present definitions, with: Entities::Feature::Definition, current_user: current_user
end
- desc 'Set the gate value for the given feature' do
+ desc 'Set or create a feature' do
+ detail "Set a feature's gate value. If a feature with the given name doesn't exist yet, it's created. " \
+ "The value can be a boolean, or an integer to indicate percentage of time."
success Entities::Feature
+ failure [
+ { code: 400, message: 'Bad request' }
+ ]
+ tags features_tags
end
params do
- requires :value, type: String, desc: '`true` or `false` to enable/disable, a float for percentage of time'
- optional :key, type: String, desc: '`percentage_of_actors` or the default `percentage_of_time`'
+ requires :value,
+ types: [String, Integer],
+ desc: '`true` or `false` to enable/disable, or an integer for percentage of time'
+ optional :key, type: String, desc: '`percentage_of_actors` or `percentage_of_time` (default)'
optional :feature_group, type: String, desc: 'A Feature group name'
optional :user, type: String, desc: 'A GitLab username or comma-separated multiple usernames'
optional :group,
type: String,
- desc: "A GitLab group's path, such as 'gitlab-org', or comma-separated multiple group paths"
+ desc: "A GitLab group's path, for example `gitlab-org`, or comma-separated multiple group paths"
optional :namespace,
type: String,
- desc: "A GitLab group or user namespace path, such as 'john-doe', or comma-separated multiple namespace paths"
+ desc: "A GitLab group or user namespace's path, for example `john-doe`, or comma-separated " \
+ "multiple namespace paths. Introduced in GitLab 15.0."
optional :project,
type: String,
- desc: "A projects path, such as `gitlab-org/gitlab-ce`, or comma-separated multiple project paths"
- optional :force, type: Boolean, desc: 'Skip feature flag validation checks, ie. YAML definition'
+ desc: "A projects path, for example `gitlab-org/gitlab-foss`, or comma-separated multiple project paths"
+ optional :repository,
+ type: String,
+ desc: "A repository path, for example `gitlab-org/gitlab-test.git`, `gitlab-org/gitlab-test.wiki.git`, " \
+ "`snippets/21.git`, to name a few. Use comma to separate multiple repository paths"
+ optional :force, type: Boolean, desc: 'Skip feature flag validation checks, such as a YAML definition'
mutually_exclusive :key, :feature_group
mutually_exclusive :key, :user
mutually_exclusive :key, :group
mutually_exclusive :key, :namespace
mutually_exclusive :key, :project
+ mutually_exclusive :key, :repository
end
post ':name' do
if Feature.enabled?(:set_feature_flag_service)
@@ -135,7 +157,10 @@ module API
bad_request!(e.message)
end
- desc 'Remove the gate value for the given feature'
+ desc 'Delete a feature' do
+ detail "Removes a feature gate. Response is equal when the gate exists, or doesn't."
+ tags features_tags
+ end
delete ':name' do
Feature.remove(params[:name])