2018-09-29 18:34:47 -04:00
# frozen_string_literal: true
2018-03-28 13:07:16 -04:00
module API
module Helpers
module ProjectsHelpers
extend ActiveSupport :: Concern
2019-05-30 17:55:17 -04:00
extend Grape :: API :: Helpers
2018-03-28 13:07:16 -04:00
2020-11-24 13:09:14 -05:00
STATISTICS_SORT_PARAMS = %w[ storage_size repository_size wiki_size packages_size ] . freeze
2020-06-19 17:08:32 -04:00
2019-05-30 17:55:17 -04:00
params :optional_project_params_ce do
optional :description , type : String , desc : 'The description of the project'
2019-05-15 08:35:55 -04:00
optional :build_git_strategy , type : String , values : %w( fetch clone ) , desc : 'The Git strategy. Defaults to `fetch`'
2019-05-15 09:32:18 -04:00
optional :build_timeout , type : Integer , desc : 'Build timeout'
2019-05-15 10:17:25 -04:00
optional :auto_cancel_pending_pipelines , type : String , values : %w( disabled enabled ) , desc : 'Auto-cancel pending pipelines'
2019-05-15 09:36:17 -04:00
optional :build_coverage_regex , type : String , desc : 'Test coverage parsing'
2019-05-30 17:55:17 -04:00
optional :ci_config_path , type : String , desc : 'The path to CI config file. Defaults to `.gitlab-ci.yml`'
2020-07-09 05:09:27 -04:00
optional :service_desk_enabled , type : Boolean , desc : 'Disable or enable the service desk'
2021-06-15 14:09:57 -04:00
optional :keep_latest_artifact , type : Boolean , desc : 'Indicates if the latest artifact should be kept for this project.'
2019-05-15 07:19:16 -04:00
# TODO: remove in API v5, replaced by *_access_level
2019-05-30 17:55:17 -04:00
optional :issues_enabled , type : Boolean , desc : 'Flag indication if the issue tracker is enabled'
optional :merge_requests_enabled , type : Boolean , desc : 'Flag indication if merge requests are enabled'
optional :wiki_enabled , type : Boolean , desc : 'Flag indication if the wiki is enabled'
optional :jobs_enabled , type : Boolean , desc : 'Flag indication if jobs are enabled'
optional :snippets_enabled , type : Boolean , desc : 'Flag indication if snippets are enabled'
2019-05-15 07:19:16 -04:00
optional :issues_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Issues access level. One of `disabled`, `private` or `enabled`'
optional :repository_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Repository access level. One of `disabled`, `private` or `enabled`'
optional :merge_requests_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Merge requests access level. One of `disabled`, `private` or `enabled`'
2020-03-19 14:09:17 -04:00
optional :forking_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Forks access level. One of `disabled`, `private` or `enabled`'
2019-05-15 07:19:16 -04:00
optional :wiki_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Wiki access level. One of `disabled`, `private` or `enabled`'
optional :builds_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Builds access level. One of `disabled`, `private` or `enabled`'
optional :snippets_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Snippets access level. One of `disabled`, `private` or `enabled`'
2020-01-23 07:08:38 -05:00
optional :pages_access_level , type : String , values : %w( disabled private enabled public ) , desc : 'Pages access level. One of `disabled`, `private`, `enabled` or `public`'
2020-12-16 10:10:18 -05:00
optional :operations_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Operations access level. One of `disabled`, `private` or `enabled`'
2020-12-16 16:09:57 -05:00
optional :analytics_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Analytics access level. One of `disabled`, `private` or `enabled`'
2021-08-02 14:08:48 -04:00
optional :container_registry_access_level , type : String , values : %w( disabled private enabled ) , desc : 'Controls visibility of the container registry. One of `disabled`, `private` or `enabled`. `private` will make the container registry accessible only to project members (reporter role and above). `enabled` will make the container registry accessible to everyone who has access to the project. `disabled` will disable the container registry'
2019-05-15 07:19:16 -04:00
2020-02-05 07:09:15 -05:00
optional :emails_disabled , type : Boolean , desc : 'Disable email notifications'
2020-05-15 11:08:04 -04:00
optional :show_default_award_emojis , type : Boolean , desc : 'Show default award emojis'
2019-05-30 17:55:17 -04:00
optional :shared_runners_enabled , type : Boolean , desc : 'Flag indication if shared runners are enabled for that project'
optional :resolve_outdated_diff_discussions , type : Boolean , desc : 'Automatically resolve merge request diffs discussions on lines changed with a push'
2019-10-23 17:06:17 -04:00
optional :remove_source_branch_after_merge , type : Boolean , desc : 'Remove the source branch by default after merge'
2021-08-02 14:08:48 -04:00
optional :container_registry_enabled , type : Boolean , desc : 'Deprecated: Use :container_registry_access_level instead. Flag indication if the container registry is enabled for that project'
2020-01-08 16:08:08 -05:00
optional :container_expiration_policy_attributes , type : Hash do
use :optional_container_expiration_policy_params
end
2019-05-30 17:55:17 -04:00
optional :lfs_enabled , type : Boolean , desc : 'Flag indication if Git LFS is enabled for that project'
optional :visibility , type : String , values : Gitlab :: VisibilityLevel . string_values , desc : 'The visibility of the project.'
optional :public_builds , type : Boolean , desc : 'Perform public builds'
optional :request_access_enabled , type : Boolean , desc : 'Allow users to request member access'
optional :only_allow_merge_if_pipeline_succeeds , type : Boolean , desc : 'Only allow to merge if builds succeed'
2020-06-10 17:09:29 -04:00
optional :allow_merge_on_skipped_pipeline , type : Boolean , desc : 'Allow to merge if pipeline is skipped'
2019-05-30 17:55:17 -04:00
optional :only_allow_merge_if_all_discussions_are_resolved , type : Boolean , desc : 'Only allow to merge if all discussions are resolved'
2021-06-07 23:10:25 -04:00
optional :tag_list , type : Array [ String ] , coerce_with : :: API :: Validations :: Types :: CommaSeparatedToArray . coerce , desc : 'Deprecated: Use :topics instead'
optional :topics , type : Array [ String ] , coerce_with : :: API :: Validations :: Types :: CommaSeparatedToArray . coerce , desc : 'The list of topics for a project'
2019-09-18 10:02:45 -04:00
# TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960
2019-09-10 12:24:10 -04:00
optional :avatar , type : File , desc : 'Avatar image for project' # rubocop:disable Scalability/FileUploads
2019-05-30 17:55:17 -04:00
optional :printing_merge_request_link_enabled , type : Boolean , desc : 'Show link to create/view merge request when pushing from the command line'
optional :merge_method , type : String , values : %w( ff rebase_merge merge ) , desc : 'The merge method used when merging merge requests'
2020-01-13 07:08:04 -05:00
optional :suggestion_commit_message , type : String , desc : 'The commit message used to apply merge request suggestions'
2019-05-30 17:55:17 -04:00
optional :initialize_with_readme , type : Boolean , desc : " Initialize a project with a README.md "
2019-06-07 07:51:42 -04:00
optional :ci_default_git_depth , type : Integer , desc : 'Default number of revisions for shallow cloning'
2019-05-15 10:27:54 -04:00
optional :auto_devops_enabled , type : Boolean , desc : 'Flag indication if Auto DevOps is enabled'
optional :auto_devops_deploy_strategy , type : String , values : %w( continuous manual timed_incremental ) , desc : 'Auto Deploy strategy'
2020-01-07 19:07:43 -05:00
optional :autoclose_referenced_issues , type : Boolean , desc : 'Flag indication if referenced issues auto-closing is enabled'
2020-03-02 16:08:01 -05:00
optional :repository_storage , type : String , desc : 'Which storage shard the repository is on. Available only to admins'
2020-07-21 08:09:30 -04:00
optional :packages_enabled , type : Boolean , desc : 'Enable project packages feature'
2021-07-19 17:08:57 -04:00
optional :squash_option , type : String , values : %w( never always default_on default_off ) , desc : 'Squash default for project. One of `never`, `always`, `default_on`, or `default_off`.'
2019-05-30 17:55:17 -04:00
end
params :optional_project_params_ee do
end
2018-03-28 13:07:16 -04:00
2019-05-30 17:55:17 -04:00
params :optional_project_params do
use :optional_project_params_ce
use :optional_project_params_ee
end
2019-09-16 20:06:11 -04:00
params :optional_create_project_params_ee do
end
params :optional_create_project_params do
use :optional_project_params
use :optional_create_project_params_ee
end
2019-05-30 17:55:17 -04:00
params :optional_filter_params_ee do
end
2019-03-21 10:52:18 -04:00
2020-10-20 02:09:03 -04:00
params :optional_update_params_ce do
optional :ci_forward_deployment_enabled , type : Boolean , desc : 'Skip older deployment jobs that are still pending'
2021-01-14 07:10:54 -05:00
optional :restrict_user_defined_variables , type : Boolean , desc : 'Restrict use of user-defined variables when triggering a pipeline'
2020-10-20 02:09:03 -04:00
end
2019-05-30 17:55:17 -04:00
params :optional_update_params_ee do
2018-03-28 13:07:16 -04:00
end
2019-03-22 11:14:22 -04:00
2020-10-20 02:09:03 -04:00
params :optional_update_params do
use :optional_update_params_ce
use :optional_update_params_ee
end
2020-01-08 16:08:08 -05:00
params :optional_container_expiration_policy_params do
optional :cadence , type : String , desc : 'Container expiration policy cadence for recurring job'
2020-12-17 07:09:57 -05:00
optional :keep_n , type : Integer , desc : 'Container expiration policy number of images to keep'
2020-01-08 16:08:08 -05:00
optional :older_than , type : String , desc : 'Container expiration policy remove images older than value'
optional :name_regex , type : String , desc : 'Container expiration policy regex for image removal'
2020-04-21 11:21:10 -04:00
optional :name_regex_keep , type : String , desc : 'Container expiration policy regex for image retention'
2020-01-08 16:08:08 -05:00
optional :enabled , type : Boolean , desc : 'Flag indication if container expiration policy is enabled'
end
2019-03-22 11:14:22 -04:00
def self . update_params_at_least_one_of
[
2020-06-10 17:09:29 -04:00
:allow_merge_on_skipped_pipeline ,
2020-02-05 07:09:15 -05:00
:autoclose_referenced_issues ,
2019-05-15 10:27:54 -04:00
:auto_devops_enabled ,
:auto_devops_deploy_strategy ,
2019-05-15 10:17:25 -04:00
:auto_cancel_pending_pipelines ,
2019-05-15 09:36:17 -04:00
:build_coverage_regex ,
2019-05-15 08:35:55 -04:00
:build_git_strategy ,
2019-05-15 09:32:18 -04:00
:build_timeout ,
2019-05-15 07:19:16 -04:00
:builds_access_level ,
2019-03-22 11:14:22 -04:00
:ci_config_path ,
2019-07-18 04:13:15 -04:00
:ci_default_git_depth ,
2020-10-20 02:09:03 -04:00
:ci_forward_deployment_enabled ,
2021-08-02 14:08:48 -04:00
:container_registry_access_level ,
2020-01-08 16:08:08 -05:00
:container_expiration_policy_attributes ,
2019-03-22 11:14:22 -04:00
:default_branch ,
:description ,
2020-02-05 07:09:15 -05:00
:emails_disabled ,
2020-03-19 14:09:17 -04:00
:forking_access_level ,
2019-05-15 07:19:16 -04:00
:issues_access_level ,
2019-03-22 11:14:22 -04:00
:lfs_enabled ,
2021-07-20 17:09:52 -04:00
:merge_pipelines_enabled ,
2019-05-15 07:19:16 -04:00
:merge_requests_access_level ,
2021-07-20 17:09:52 -04:00
:merge_requests_template ,
:merge_trains_enabled ,
2019-03-22 11:14:22 -04:00
:merge_method ,
:name ,
:only_allow_merge_if_all_discussions_are_resolved ,
:only_allow_merge_if_pipeline_succeeds ,
2020-01-23 07:08:38 -05:00
:pages_access_level ,
2019-03-22 11:14:22 -04:00
:path ,
:printing_merge_request_link_enabled ,
:public_builds ,
2019-10-23 17:06:17 -04:00
:remove_source_branch_after_merge ,
2019-05-15 07:19:16 -04:00
:repository_access_level ,
2019-03-22 11:14:22 -04:00
:request_access_enabled ,
2019-05-15 07:19:16 -04:00
:resolve_outdated_diff_discussions ,
2021-01-14 07:10:54 -05:00
:restrict_user_defined_variables ,
2021-07-19 17:08:57 -04:00
:squash_option ,
2019-03-22 11:14:22 -04:00
:shared_runners_enabled ,
2019-05-15 07:19:16 -04:00
:snippets_access_level ,
2019-03-22 11:14:22 -04:00
:tag_list ,
2021-06-07 23:10:25 -04:00
:topics ,
2019-03-22 11:14:22 -04:00
:visibility ,
2019-05-15 07:19:16 -04:00
:wiki_access_level ,
2019-04-09 11:38:58 -04:00
:avatar ,
2020-01-13 07:08:04 -05:00
:suggestion_commit_message ,
2020-03-02 16:08:01 -05:00
:repository_storage ,
2020-04-08 08:09:42 -04:00
:compliance_framework_setting ,
2020-07-21 08:09:30 -04:00
:packages_enabled ,
2020-07-09 05:09:27 -04:00
:service_desk_enabled ,
2021-06-15 14:09:57 -04:00
:keep_latest_artifact ,
2019-05-15 07:19:16 -04:00
# TODO: remove in API v5, replaced by *_access_level
:issues_enabled ,
:jobs_enabled ,
:merge_requests_enabled ,
:wiki_enabled ,
2021-08-02 14:08:48 -04:00
:snippets_enabled ,
:container_registry_enabled
2019-03-22 11:14:22 -04:00
]
end
2019-07-17 03:20:17 -04:00
def filter_attributes_using_license! ( attrs )
end
2018-03-28 13:07:16 -04:00
end
end
end
2019-09-13 09:26:31 -04:00
2021-05-11 17:10:21 -04:00
API :: Helpers :: ProjectsHelpers . prepend_mod_with ( 'API::Helpers::ProjectsHelpers' )