Commit 2fe01c8f authored by Lin Jen-Shin's avatar Lin Jen-Shin Committed by Tiago Botelho

Move EE specific params to its own module

parent d5a86c3e
# frozen_string_literal: true
module EE
module API
module Projects
......@@ -10,6 +12,13 @@ module EE
optional :repository_checksum_failed, type: Grape::API::Boolean, default: false, desc: 'Limit by projects where repository checksum is failed'
end
params :optional_update_params_ee do
optional :mirror_user_id, type: Integer, desc: 'User responsible for all the activity surrounding a pull mirror event'
optional :only_mirror_protected_branches, type: Grape::API::Boolean, desc: 'Only mirror protected branches'
optional :mirror_overwrites_diverged_branches, type: Grape::API::Boolean, desc: 'Pull mirror overwrites diverged branches'
optional :import_url, type: String, desc: 'URL from which the project is imported'
end
def apply_filters(projects)
projects = super(projects)
projects = projects.verification_failed_wikis if params[:wiki_checksum_failed]
......@@ -19,6 +28,17 @@ module EE
end
end
end
class_methods do
def update_params_at_least_one_of
super.concat [
:approvals_before_merge,
:repository_storage,
:external_authorization_classification_label,
:import_url
]
end
end
end
end
end
......@@ -13,6 +13,9 @@ module API
# EE::API::Projects would override this helper
end
params :optional_update_params_ee do
end
# EE::API::Projects would override this method
def apply_filters(projects)
projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled]
......@@ -25,6 +28,34 @@ module API
prepend EE::API::Projects
def self.update_params_at_least_one_of
[
:jobs_enabled,
:resolve_outdated_diff_discussions,
:ci_config_path,
:container_registry_enabled,
:default_branch,
:description,
:issues_enabled,
:lfs_enabled,
:merge_requests_enabled,
:merge_method,
:name,
:only_allow_merge_if_all_discussions_are_resolved,
:only_allow_merge_if_pipeline_succeeds,
:path,
:printing_merge_request_link_enabled,
:public_builds,
:request_access_enabled,
:shared_runners_enabled,
:snippets_enabled,
:tag_list,
:visibility,
:wiki_enabled,
:avatar
]
end
helpers do
params :statistics_params do
optional :statistics, type: Boolean, default: false, desc: 'Include project statistics'
......@@ -264,51 +295,14 @@ module API
success Entities::Project
end
params do
# CE
at_least_one_of_ce =
[
:jobs_enabled,
:resolve_outdated_diff_discussions,
:ci_config_path,
:container_registry_enabled,
:default_branch,
:description,
:issues_enabled,
:lfs_enabled,
:merge_requests_enabled,
:merge_method,
:name,
:only_allow_merge_if_all_discussions_are_resolved,
:only_allow_merge_if_pipeline_succeeds,
:path,
:printing_merge_request_link_enabled,
:public_builds,
:request_access_enabled,
:shared_runners_enabled,
:snippets_enabled,
:tag_list,
:visibility,
:wiki_enabled,
:avatar
]
optional :name, type: String, desc: 'The name of the project'
optional :default_branch, type: String, desc: 'The default branch of the project'
optional :path, type: String, desc: 'The path of the repository'
optional :import_url, type: String, desc: 'URL from which the project is imported'
# EE
at_least_one_of_ee = [
:approvals_before_merge,
:repository_storage,
:external_authorization_classification_label,
:import_url
]
optional :mirror_user_id, type: Integer, desc: 'User responsible for all the activity surrounding a pull mirror event'
optional :only_mirror_protected_branches, type: Boolean, desc: 'Only mirror protected branches'
optional :mirror_overwrites_diverged_branches, type: Boolean, desc: 'Pull mirror overwrites diverged branches'
use :optional_project_params
at_least_one_of(*(at_least_one_of_ce + at_least_one_of_ee))
use :optional_update_params_ee
at_least_one_of(*::API::Projects.update_params_at_least_one_of)
end
put ':id' do
authorize_admin_project
......
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