Commit 53244026 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'move-ff-entities-to-core' into 'master'

Move Feature Flag API Entities to Core RUN AS-IF-FOSS

See merge request gitlab-org/gitlab!43345
parents b1d293d9 dd64a3b7
......@@ -18,13 +18,13 @@ module API
resource :feature_flag_scopes do
desc 'Get all effective feature flags under the environment' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag::DetailedLegacyScope
success ::API::Entities::FeatureFlag::DetailedLegacyScope
end
params do
requires :environment, type: String, desc: 'The environment name'
end
get do
present scopes_for_environment, with: EE::API::Entities::FeatureFlag::DetailedLegacyScope
present scopes_for_environment, with: ::API::Entities::FeatureFlag::DetailedLegacyScope
end
end
......@@ -35,18 +35,18 @@ module API
resource :scopes do
desc 'Get all scopes of a feature flag' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag::LegacyScope
success ::API::Entities::FeatureFlag::LegacyScope
end
params do
use :pagination
end
get do
present paginate(feature_flag.scopes), with: EE::API::Entities::FeatureFlag::LegacyScope
present paginate(feature_flag.scopes), with: ::API::Entities::FeatureFlag::LegacyScope
end
desc 'Create a scope of a feature flag' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag::LegacyScope
success ::API::Entities::FeatureFlag::LegacyScope
end
params do
requires :environment_scope, type: String, desc: 'The environment scope of the scope'
......@@ -61,7 +61,7 @@ module API
.execute(feature_flag)
if result[:status] == :success
present scope, with: EE::API::Entities::FeatureFlag::LegacyScope
present scope, with: ::API::Entities::FeatureFlag::LegacyScope
else
render_api_error!(result[:message], result[:http_status])
end
......@@ -73,15 +73,15 @@ module API
resource ':environment_scope', requirements: ENVIRONMENT_SCOPE_ENDPOINT_REQUIREMENTS do
desc 'Get a scope of a feature flag' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag::LegacyScope
success ::API::Entities::FeatureFlag::LegacyScope
end
get do
present scope, with: EE::API::Entities::FeatureFlag::LegacyScope
present scope, with: ::API::Entities::FeatureFlag::LegacyScope
end
desc 'Update a scope of a feature flag' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag::LegacyScope
success ::API::Entities::FeatureFlag::LegacyScope
end
params do
optional :active, type: Boolean, desc: 'Whether the scope is active'
......@@ -100,7 +100,7 @@ module API
updated_scope = result[:feature_flag].scopes
.find { |scope| scope.environment_scope == params[:environment_scope] }
present updated_scope, with: EE::API::Entities::FeatureFlag::LegacyScope
present updated_scope, with: ::API::Entities::FeatureFlag::LegacyScope
else
render_api_error!(result[:message], result[:http_status])
end
......@@ -108,7 +108,7 @@ module API
desc 'Delete a scope from a feature flag' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag::LegacyScope
success ::API::Entities::FeatureFlag::LegacyScope
end
delete do
authorize_update_feature_flag!
......
......@@ -18,7 +18,7 @@ module API
resource :feature_flags do
desc 'Get all feature flags of a project' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag
success ::API::Entities::FeatureFlag
end
params do
optional :scope, type: String, desc: 'The scope of feature flags',
......@@ -35,7 +35,7 @@ module API
desc 'Create a new feature flag' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag
success ::API::Entities::FeatureFlag
end
params do
requires :name, type: String, desc: 'The name of feature flag'
......@@ -86,7 +86,7 @@ module API
resource 'feature_flags/:feature_flag_name', requirements: FEATURE_FLAG_ENDPOINT_REQUIREMENTS do
desc 'Get a feature flag of a project' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag
success ::API::Entities::FeatureFlag
end
get do
authorize_read_feature_flag!
......@@ -96,7 +96,7 @@ module API
desc 'Enable a strategy for a feature flag on an environment' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag
success ::API::Entities::FeatureFlag
end
params do
requires :environment_scope, type: String, desc: 'The environment scope of the feature flag'
......@@ -119,7 +119,7 @@ module API
desc 'Disable a strategy for a feature flag on an environment' do
detail 'This feature is going to be introduced in GitLab 12.5 if `feature_flag_api` feature flag is removed'
success EE::API::Entities::FeatureFlag
success ::API::Entities::FeatureFlag
end
params do
requires :environment_scope, type: String, desc: 'The environment scope of the feature flag'
......@@ -142,7 +142,7 @@ module API
desc 'Update a feature flag' do
detail 'This feature will be introduced in GitLab 13.1 if feature_flags_new_version feature flag is removed'
success EE::API::Entities::FeatureFlag
success ::API::Entities::FeatureFlag
end
params do
optional :name, type: String, desc: 'The name of the feature flag'
......@@ -185,7 +185,7 @@ module API
desc 'Delete a feature flag' do
detail 'This feature was introduced in GitLab 12.5'
success EE::API::Entities::FeatureFlag
success ::API::Entities::FeatureFlag
end
delete do
authorize_destroy_feature_flag!
......@@ -226,7 +226,7 @@ module API
def present_entity(result)
present result,
with: EE::API::Entities::FeatureFlag,
with: ::API::Entities::FeatureFlag,
feature_flags_new_version_enabled: feature_flags_new_version_enabled?
end
......
......@@ -19,19 +19,19 @@ module API
resource :feature_flags_user_lists do
desc 'Get all feature flags user lists of a project' do
detail 'This feature was introduced in GitLab 12.10'
success EE::API::Entities::FeatureFlag::UserList
success ::API::Entities::FeatureFlag::UserList
end
params do
use :pagination
end
get do
present paginate(user_project.operations_feature_flags_user_lists),
with: EE::API::Entities::FeatureFlag::UserList
with: ::API::Entities::FeatureFlag::UserList
end
desc 'Create a feature flags user list for a project' do
detail 'This feature was introduced in GitLab 12.10'
success EE::API::Entities::FeatureFlag::UserList
success ::API::Entities::FeatureFlag::UserList
end
params do
requires :name, type: String, desc: 'The name of the list'
......@@ -41,7 +41,7 @@ module API
list = user_project.operations_feature_flags_user_lists.create(declared_params)
if list.save
present list, with: EE::API::Entities::FeatureFlag::UserList
present list, with: ::API::Entities::FeatureFlag::UserList
else
render_api_error!(list.errors.full_messages, :bad_request)
end
......@@ -54,16 +54,16 @@ module API
resource 'feature_flags_user_lists/:iid' do
desc 'Get a single feature flag user list belonging to a project' do
detail 'This feature was introduced in GitLab 12.10'
success EE::API::Entities::FeatureFlag::UserList
success ::API::Entities::FeatureFlag::UserList
end
get do
present user_project.operations_feature_flags_user_lists.find_by_iid!(params[:iid]),
with: EE::API::Entities::FeatureFlag::UserList
with: ::API::Entities::FeatureFlag::UserList
end
desc 'Update a feature flag user list' do
detail 'This feature was introduced in GitLab 12.10'
success EE::API::Entities::FeatureFlag::UserList
success ::API::Entities::FeatureFlag::UserList
end
params do
optional :name, type: String, desc: 'The name of the list'
......@@ -73,7 +73,7 @@ module API
list = user_project.operations_feature_flags_user_lists.find_by_iid!(params[:iid])
if list.update(declared_params(include_missing: false))
present list, with: EE::API::Entities::FeatureFlag::UserList
present list, with: ::API::Entities::FeatureFlag::UserList
else
render_api_error!(list.errors.full_messages, :bad_request)
end
......
# frozen_string_literal: true
module EE
module API
module Entities
class FeatureFlag < Grape::Entity
expose :name
expose :description
expose :active
expose :version, if: :feature_flags_new_version_enabled
expose :created_at
expose :updated_at
expose :scopes, using: FeatureFlag::LegacyScope
expose :strategies, using: FeatureFlag::Strategy, if: :feature_flags_new_version_enabled
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class FeatureFlag < Grape::Entity
class DetailedLegacyScope < LegacyScope
expose :name
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class FeatureFlag < Grape::Entity
class LegacyScope < Grape::Entity
expose :id
expose :active
expose :environment_scope
expose :strategies
expose :created_at
expose :updated_at
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class FeatureFlag < Grape::Entity
class Scope < Grape::Entity
expose :id
expose :environment_scope
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class FeatureFlag < Grape::Entity
class Strategy < Grape::Entity
expose :id
expose :name
expose :parameters
expose :scopes, using: FeatureFlag::Scope
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class FeatureFlag < Grape::Entity
class UserList < Grape::Entity
include RequestAwareEntity
expose :id
expose :iid
expose :project_id
expose :created_at
expose :updated_at
expose :name
expose :user_xids
expose :path do |list|
project_feature_flags_user_list_path(list.project, list)
end
expose :edit_path do |list|
edit_project_feature_flags_user_list_path(list.project, list)
end
end
end
end
end
end
# frozen_string_literal: true
module API
module Entities
class FeatureFlag < Grape::Entity
expose :name
expose :description
expose :active
expose :version, if: :feature_flags_new_version_enabled
expose :created_at
expose :updated_at
expose :scopes, using: FeatureFlag::LegacyScope
expose :strategies, using: FeatureFlag::Strategy, if: :feature_flags_new_version_enabled
end
end
end
# frozen_string_literal: true
module API
module Entities
class FeatureFlag < Grape::Entity
class DetailedLegacyScope < LegacyScope
expose :name
end
end
end
end
# frozen_string_literal: true
module API
module Entities
class FeatureFlag < Grape::Entity
class LegacyScope < Grape::Entity
expose :id
expose :active
expose :environment_scope
expose :strategies
expose :created_at
expose :updated_at
end
end
end
end
# frozen_string_literal: true
module API
module Entities
class FeatureFlag < Grape::Entity
class Scope < Grape::Entity
expose :id
expose :environment_scope
end
end
end
end
# frozen_string_literal: true
module API
module Entities
class FeatureFlag < Grape::Entity
class Strategy < Grape::Entity
expose :id
expose :name
expose :parameters
expose :scopes, using: FeatureFlag::Scope
end
end
end
end
# frozen_string_literal: true
module API
module Entities
class FeatureFlag < Grape::Entity
class UserList < Grape::Entity
include RequestAwareEntity
expose :id
expose :iid
expose :project_id
expose :created_at
expose :updated_at
expose :name
expose :user_xids
expose :path do |list|
project_feature_flags_user_list_path(list.project, list)
end
expose :edit_path do |list|
edit_project_feature_flags_user_list_path(list.project, list)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment