diff options
author | Toon Claes <toon@gitlab.com> | 2017-03-01 16:16:29 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2017-03-02 09:33:24 +0100 |
commit | b2c2dfe545526a1857e9605761f6d256ef73e190 (patch) | |
tree | ba3ec9ea7ce38a4c2ca09b6d92a3d67bb492daf1 /lib/api/projects.rb | |
parent | fc287191451bb6aac80d759ab521b5834d27df43 (diff) | |
download | gitlab-ce-b2c2dfe545526a1857e9605761f6d256ef73e190.tar.gz |
Expose Project's & ProjectSnippet's VisibilityLevel as String
Instead of exposing the VisibilityLevel as Integer, expose it as
String `visibility` for Project and ProjectSnippet.
Filter queries also accept the `visibility` as String instead of
`visibility_level` as Integer.
Also remove the `public` boolean.
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r-- | lib/api/projects.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 996404e0e49..743dcac41f9 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -16,11 +16,7 @@ module API optional :shared_runners_enabled, type: Boolean, desc: 'Flag indication if shared runners are enabled for that project' optional :container_registry_enabled, type: Boolean, desc: 'Flag indication if the container registry is enabled for that project' optional :lfs_enabled, type: Boolean, desc: 'Flag indication if Git LFS is enabled for that project' - optional :visibility_level, type: Integer, values: [ - Gitlab::VisibilityLevel::PRIVATE, - Gitlab::VisibilityLevel::INTERNAL, - Gitlab::VisibilityLevel::PUBLIC - ], desc: 'Create a public project. The same as visibility_level = 20.' + 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' @@ -48,7 +44,7 @@ module API params :filter_params do optional :archived, type: Boolean, default: false, desc: 'Limit by archived status' - optional :visibility, type: String, values: %w[public internal private], + optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'Limit by visibility' optional :search, type: String, desc: 'Return list of authorized projects matching the search criteria' optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user' @@ -101,7 +97,7 @@ module API use :create_params end post do - attrs = declared_params(include_missing: false) + attrs = map_visibility_level(declared_params(include_missing: false)) project = ::Projects::CreateService.new(current_user, attrs).execute if project.saved? @@ -130,7 +126,7 @@ module API user = User.find_by(id: params.delete(:user_id)) not_found!('User') unless user - attrs = declared_params(include_missing: false) + attrs = map_visibility_level(declared_params(include_missing: false)) project = ::Projects::CreateService.new(user, attrs).execute if project.saved? @@ -208,14 +204,14 @@ module API at_least_one_of :name, :description, :issues_enabled, :merge_requests_enabled, :wiki_enabled, :builds_enabled, :snippets_enabled, :shared_runners_enabled, :container_registry_enabled, - :lfs_enabled, :visibility_level, :public_builds, + :lfs_enabled, :visibility, :public_builds, :request_access_enabled, :only_allow_merge_if_pipeline_succeeds, :only_allow_merge_if_all_discussions_are_resolved, :path, :default_branch end put ':id' do authorize_admin_project - attrs = declared_params(include_missing: false) + attrs = map_visibility_level(declared_params(include_missing: false)) authorize! :rename_project, user_project if attrs[:name].present? authorize! :change_visibility_level, user_project if attrs[:visibility_level].present? |