Commit 2b3f0724 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'backport-api-parameters' into 'master'

Backport EE API parameters in lib/api

See merge request gitlab-org/gitlab-ce!26369
parents 637dc389 cbe21d78
......@@ -20,8 +20,19 @@ module API
optional :share_with_group_lock, type: Boolean, desc: 'Prevent sharing a project with another group within this group'
end
if Gitlab.ee?
params :optional_params_ee do
optional :membership_lock, type: Boolean, desc: 'Prevent adding new members to project membership within this group'
optional :ldap_cn, type: String, desc: 'LDAP Common Name'
optional :ldap_access, type: Integer, desc: 'A valid access level'
optional :shared_runners_minutes_limit, type: Integer, desc: '(admin-only) Pipeline minutes quota for this group'
all_or_none_of :ldap_cn, :ldap_access
end
end
params :optional_params do
use :optional_params_ce
use :optional_params_ee if Gitlab.ee?
end
params :statistics_params do
......@@ -164,6 +175,10 @@ module API
optional :name, type: String, desc: 'The name of the group'
optional :path, type: String, desc: 'The path of the group'
use :optional_params
if Gitlab.ee?
optional :file_template_project_id, type: Integer, desc: 'The ID of a project to use for custom templates in this group'
end
end
put ':id' do
group = find_group!(params[:id])
......
# frozen_string_literal: true
module API
module Helpers
module IssuesHelpers
def self.update_params_at_least_one_of
[
:assignee_id,
:assignee_ids,
:confidential,
:created_at,
:description,
:discussion_locked,
:due_date,
:labels,
:milestone_id,
:state_event,
:title
]
end
end
end
end
......@@ -31,11 +31,50 @@ module API
optional :initialize_with_readme, type: Boolean, desc: "Initialize a project with a README.md"
end
if Gitlab.ee?
params :optional_project_params_ee do
optional :repository_storage, type: String, desc: 'Which storage shard the repository is on. Available only to admins'
optional :approvals_before_merge, type: Integer, desc: 'How many approvers should approve merge request by default'
optional :external_authorization_classification_label, type: String, desc: 'The classification label for the project'
optional :mirror, type: Boolean, desc: 'Enables pull mirroring in a project'
optional :mirror_trigger_builds, type: Boolean, desc: 'Pull mirroring triggers builds'
end
end
params :optional_project_params do
use :optional_project_params_ce
use :optional_project_params_ee if Gitlab.ee?
end
end
end
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
end
end
end
......@@ -8,15 +8,6 @@ module API
helpers ::Gitlab::IssuableMetadata
# EE::API::Issues would override the following helpers
helpers do
params :issues_params_ee do
end
params :issue_params_ee do
end
end
helpers do
# rubocop: disable CodeReuse/ActiveRecord
def find_issues(args = {})
......@@ -33,6 +24,16 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
if Gitlab.ee?
params :issues_params_ee do
optional :weight, types: [Integer, String], integer_none_any: true, desc: 'The weight of the issue'
end
params :issue_params_ee do
optional :weight, type: Integer, desc: 'The weight of the issue'
end
end
params :issues_params do
optional :labels, type: Array[String], coerce_with: Validations::Types::LabelsList.coerce, desc: 'Comma-separated list of label names'
optional :milestone, type: String, desc: 'Milestone title'
......@@ -57,7 +58,7 @@ module API
optional :confidential, type: Boolean, desc: 'Filter confidential or public issues'
use :pagination
use :issues_params_ee
use :issues_params_ee if Gitlab.ee?
end
params :issue_params do
......@@ -70,7 +71,7 @@ module API
optional :confidential, type: Boolean, desc: 'Boolean parameter if the issue should be confidential'
optional :discussion_locked, type: Boolean, desc: " Boolean parameter indicating if the issue's discussion is locked"
use :issue_params_ee
use :issue_params_ee if Gitlab.ee?
end
end
......@@ -219,8 +220,8 @@ module API
desc: 'Date time when the issue was updated. Available only for admins and project owners.'
optional :state_event, type: String, values: %w[reopen close], desc: 'State of the issue'
use :issue_params
at_least_one_of :title, :description, :assignee_ids, :assignee_id, :milestone_id, :discussion_locked,
:labels, :created_at, :due_date, :confidential, :state_event
at_least_one_of(*Helpers::IssuesHelpers.update_params_at_least_one_of)
end
# rubocop: disable CodeReuse/ActiveRecord
put ':id/issues/:issue_iid' do
......
......@@ -11,12 +11,20 @@ module API
before { authenticate_non_get! }
helpers do
params :optional_filter_params_ee do
# EE::API::Projects would override this helper
end
if Gitlab.ee?
params :optional_filter_params_ee do
optional :wiki_checksum_failed, type: Grape::API::Boolean, default: false, desc: 'Limit by projects where wiki checksum is failed'
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
# EE::API::Projects would override this helper
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'
optional :packages_enabled, type: Grape::API::Boolean, desc: 'Enable project packages feature'
optional :fallback_approvals_required, type: Integer, desc: 'Overall approvals required when no rule is present'
end
end
# EE::API::Projects would override this method
......@@ -35,34 +43,6 @@ module API
end
end
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'
......@@ -97,7 +77,7 @@ module API
optional :with_programming_language, type: String, desc: 'Limit to repositories which use the given programming language'
optional :min_access_level, type: Integer, values: Gitlab::Access.all_values, desc: 'Limit by minimum access level of authenticated user'
use :optional_filter_params_ee
use :optional_filter_params_ee if Gitlab.ee?
end
params :create_params do
......@@ -316,8 +296,9 @@ module API
optional :path, type: String, desc: 'The path of the repository'
use :optional_project_params
use :optional_update_params_ee if Gitlab.ee?
at_least_one_of(*::API::Projects.update_params_at_least_one_of)
at_least_one_of(*Helpers::ProjectsHelpers.update_params_at_least_one_of)
end
put ':id' do
authorize_admin_project
......
......@@ -51,6 +51,30 @@ module API
optional :merge_access_level, type: Integer,
values: ProtectedBranch::MergeAccessLevel.allowed_access_levels,
desc: 'Access levels allowed to merge (defaults: `40`, maintainer access level)'
if Gitlab.ee?
optional :unprotect_access_level, type: Integer,
values: ProtectedBranch::UnprotectAccessLevel.allowed_access_levels,
desc: 'Access levels allowed to unprotect (defaults: `40`, maintainer access level)'
optional :allowed_to_push, type: Array, desc: 'An array of users/groups allowed to push' do
optional :access_level, type: Integer, values: ProtectedBranch::PushAccessLevel.allowed_access_levels
optional :user_id, type: Integer
optional :group_id, type: Integer
end
optional :allowed_to_merge, type: Array, desc: 'An array of users/groups allowed to merge' do
optional :access_level, type: Integer, values: ProtectedBranch::MergeAccessLevel.allowed_access_levels
optional :user_id, type: Integer
optional :group_id, type: Integer
end
optional :allowed_to_unprotect, type: Array, desc: 'An array of users/groups allowed to unprotect' do
optional :access_level, type: Integer, values: ProtectedBranch::UnprotectAccessLevel.allowed_access_levels
optional :user_id, type: Integer
optional :group_id, type: Integer
end
end
end
# rubocop: disable CodeReuse/ActiveRecord
post ':id/protected_branches' do
......
......@@ -135,8 +135,44 @@ module API
desc: "Restrictions on the complexity of uploaded #{type.upcase} keys. A value of #{ApplicationSetting::FORBIDDEN_KEY_VALUE} disables all #{type.upcase} keys."
end
if Gitlab.ee?
optional :elasticsearch_aws, type: Boolean, desc: 'Enable support for AWS hosted elasticsearch'
given elasticsearch_aws: ->(val) { val } do
optional :elasticsearch_aws_access_key, type: String, desc: 'AWS IAM access key'
requires :elasticsearch_aws_region, type: String, desc: 'The AWS region the elasticsearch domain is configured'
optional :elasticsearch_aws_secret_access_key, type: String, desc: 'AWS IAM secret access key'
end
optional :elasticsearch_indexing, type: Boolean, desc: 'Enable Elasticsearch indexing'
given elasticsearch_indexing: ->(val) { val } do
optional :elasticsearch_search, type: Boolean, desc: 'Enable Elasticsearch search'
requires :elasticsearch_url, type: String, desc: 'The url to use for connecting to Elasticsearch. Use a comma-separated list to support clustering (e.g., "http://localhost:9200, http://localhost:9201")'
end
optional :email_additional_text, type: String, desc: 'Additional text added to the bottom of every email for legal/auditing/compliance reasons'
optional :help_text, type: String, desc: 'GitLab server administrator information'
optional :repository_size_limit, type: Integer, desc: 'Size limit per repository (MB)'
optional :file_template_project_id, type: Integer, desc: 'ID of project where instance-level file templates are stored.'
optional :repository_storages, type: Array[String], desc: 'A list of names of enabled storage paths, taken from `gitlab.yml`. New projects will be created in one of these stores, chosen at random.'
optional :snowplow_enabled, type: Boolean, desc: 'Enable Snowplow'
given snowplow_enabled: ->(val) { val } do
requires :snowplow_collector_uri, type: String, desc: 'Snowplow Collector URI'
optional :snowplow_cookie_domain, type: String, desc: 'Snowplow cookie domain'
optional :snowplow_site_id, type: String, desc: 'Snowplow Site/Application ID'
end
optional :usage_ping_enabled, type: Boolean, desc: 'Every week GitLab will report license usage back to GitLab, Inc.'
end
optional_attributes = ::ApplicationSettingsHelper.visible_attributes << :performance_bar_allowed_group_id
if Gitlab.ee?
optional_attributes += EE::ApplicationSettingsHelper.possible_licensed_attributes
end
optional(*optional_attributes)
at_least_one_of(*optional_attributes)
end
......
......@@ -51,6 +51,10 @@ module API
optional :avatar, type: File, desc: 'Avatar image for user'
optional :private_profile, type: Boolean, desc: 'Flag indicating the user has a private profile'
all_or_none_of :extern_uid, :provider
if Gitlab.ee?
optional :shared_runners_minutes_limit, type: Integer, desc: 'Pipeline minutes quota for this user'
end
end
params :sort_params do
......@@ -80,6 +84,10 @@ module API
use :sort_params
use :pagination
use :with_custom_attributes
if Gitlab.ee?
optional :skip_ldap, type: Boolean, default: false, desc: 'Skip LDAP users'
end
end
# rubocop: disable CodeReuse/ActiveRecord
get do
......
......@@ -55,6 +55,10 @@ module API
requires :key, type: String, desc: 'The key of the variable'
requires :value, type: String, desc: 'The value of the variable'
optional :protected, type: String, desc: 'Whether the variable is protected'
if Gitlab.ee?
optional :environment_scope, type: String, desc: 'The environment_scope of the variable'
end
end
post ':id/variables' do
variable_params = declared_params(include_missing: false)
......@@ -76,6 +80,10 @@ module API
optional :key, type: String, desc: 'The key of the variable'
optional :value, type: String, desc: 'The value of the variable'
optional :protected, type: String, desc: 'Whether the variable is protected'
if Gitlab.ee?
optional :environment_scope, type: String, desc: 'The environment_scope of the variable'
end
end
# rubocop: disable CodeReuse/ActiveRecord
put ':id/variables/:key' do
......
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