diff options
Diffstat (limited to 'lib/api/groups.rb')
-rw-r--r-- | lib/api/groups.rb | 103 |
1 files changed, 52 insertions, 51 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 64958ff982a..c8042326cab 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -9,15 +9,16 @@ module API helpers do params :optional_params_ce do - optional :description, type: String, desc: 'The description of the group' + optional :description, type: String, desc: "The description of the group" optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, default: Gitlab::VisibilityLevel.string_level( - Gitlab::CurrentSettings.current_application_settings.default_group_visibility), - desc: 'The visibility of the group' - optional :lfs_enabled, type: Boolean, desc: 'Enable/disable LFS for the projects in this group' - optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access' - optional :share_with_group_lock, type: Boolean, desc: 'Prevent sharing a project with another group within this group' + Gitlab::CurrentSettings.current_application_settings.default_group_visibility + ), + desc: "The visibility of the group" + optional :lfs_enabled, type: Boolean, desc: "Enable/disable LFS for the projects in this group" + optional :request_access_enabled, type: Boolean, desc: "Allow users to request member access" + optional :share_with_group_lock, type: Boolean, desc: "Prevent sharing a project with another group within this group" end params :optional_params do @@ -25,18 +26,18 @@ module API end params :statistics_params do - optional :statistics, type: Boolean, default: false, desc: 'Include project statistics' + optional :statistics, type: Boolean, default: false, desc: "Include project statistics" end params :group_list_params do use :statistics_params - optional :skip_groups, type: Array[Integer], desc: 'Array of group ids to exclude from list' - optional :all_available, type: Boolean, desc: 'Show all group that you have access to' - optional :search, type: String, desc: 'Search for a specific group' - optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user' - optional :order_by, type: String, values: %w[name path id], default: 'name', desc: 'Order by name, path or id' - optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)' - optional :min_access_level, type: Integer, values: Gitlab::Access.all_values, desc: 'Minimum access level of authenticated user' + optional :skip_groups, type: Array[Integer], desc: "Array of group ids to exclude from list" + optional :all_available, type: Boolean, desc: "Show all group that you have access to" + optional :search, type: String, desc: "Search for a specific group" + optional :owned, type: Boolean, default: false, desc: "Limit by owned by authenticated user" + optional :order_by, type: String, values: %w[name path id], default: "name", desc: "Order by name, path or id" + optional :sort, type: String, values: %w[asc desc], default: "asc", desc: "Sort by asc (ascending) or desc (descending)" + optional :min_access_level, type: Integer, values: Gitlab::Access.all_values, desc: "Minimum access level of authenticated user" use :pagination end @@ -50,7 +51,7 @@ module API groups = GroupsFinder.new(current_user, find_params).execute groups = groups.search(params[:search]) if params[:search].present? groups = groups.where.not(id: params[:skip_groups]) if params[:skip_groups].present? - order_options = { params[:order_by] => params[:sort] } + order_options = {params[:order_by] => params[:sort]} order_options["id"] ||= "asc" groups = groups.reorder(order_options) @@ -62,7 +63,7 @@ module API group = find_group!(params[:id]) options = { only_owned: !params[:with_shared], - include_subgroups: params[:include_subgroups] + include_subgroups: params[:include_subgroups], } projects = GroupProjectsFinder.new( @@ -81,7 +82,7 @@ module API options = { with: Entities::Group, current_user: current_user, - statistics: params[:statistics] && current_user.admin? + statistics: params[:statistics] && current_user.admin?, } groups = groups.with_statistics if options[:statistics] @@ -94,7 +95,7 @@ module API resource :groups do include CustomAttributesEndpoints - desc 'Get a groups list' do + desc "Get a groups list" do success Entities::Group end params do @@ -106,15 +107,15 @@ module API present_groups params, groups end - desc 'Create a group. Available only for users who can create groups.' do + desc "Create a group. Available only for users who can create groups." do success Entities::Group end params do - requires :name, type: String, desc: 'The name of the group' - requires :path, type: String, desc: 'The path of the group' + requires :name, type: String, desc: "The name of the group" + requires :path, type: String, desc: "The path of the group" if ::Group.supports_nested_objects? - optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group' + optional :parent_id, type: Integer, desc: "The parent group id for creating nested group" end use :optional_params @@ -138,18 +139,18 @@ module API end params do - requires :id, type: String, desc: 'The ID of a group' + requires :id, type: String, desc: "The ID of a group" end resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do - desc 'Update a group. Available only for users who can administrate groups.' do + desc "Update a group. Available only for users who can administrate groups." do success Entities::Group end params do - optional :name, type: String, desc: 'The name of the group' - optional :path, type: String, desc: 'The path of the group' + optional :name, type: String, desc: "The name of the group" + optional :path, type: String, desc: "The path of the group" use :optional_params end - put ':id' do + put ":id" do group = find_group!(params[:id]) authorize! :admin_group, group @@ -160,19 +161,19 @@ module API end end - desc 'Get a single group, with containing projects.' do + desc "Get a single group, with containing projects." do success Entities::GroupDetail end params do use :with_custom_attributes - optional :with_projects, type: Boolean, default: true, desc: 'Omit project details' + optional :with_projects, type: Boolean, default: true, desc: "Omit project details" end get ":id" do group = find_group!(params[:id]) options = { with: params[:with_projects] ? Entities::GroupDetail : Entities::Group, - current_user: current_user + current_user: current_user, } group, options = with_custom_attributes(group, options) @@ -180,12 +181,12 @@ module API present group, options end - desc 'Remove a group.' + desc "Remove a group." delete ":id" do group = find_group!(params[:id]) authorize! :admin_group, group - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/46285') + Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/46285") destroy_conditionally!(group) do |group| ::Groups::DestroyService.new(group, current_user).async_execute end @@ -193,26 +194,26 @@ module API accepted! end - desc 'Get a list of projects in this group.' do + desc "Get a list of projects in this group." do success Entities::Project end params do - optional :archived, type: Boolean, default: false, desc: 'Limit by archived status' + optional :archived, type: Boolean, default: false, desc: "Limit by archived status" 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' + desc: "Limit by visibility" + optional :search, type: String, desc: "Return list of authorized projects matching the search criteria" optional :order_by, type: String, values: %w[id name path created_at updated_at last_activity_at], - default: 'created_at', desc: 'Return projects ordered by field' - optional :sort, type: String, values: %w[asc desc], default: 'desc', - desc: 'Return projects sorted in ascending and descending order' + default: "created_at", desc: "Return projects ordered by field" + optional :sort, type: String, values: %w[asc desc], default: "desc", + desc: "Return projects sorted in ascending and descending order" optional :simple, type: Boolean, default: false, - desc: 'Return only the ID, URL, name, and path of each project' - optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user' - optional :starred, type: Boolean, default: false, desc: 'Limit by starred status' - optional :with_issues_enabled, type: Boolean, default: false, desc: 'Limit by enabled issues feature' - optional :with_merge_requests_enabled, type: Boolean, default: false, desc: 'Limit by enabled merge requests feature' - optional :with_shared, type: Boolean, default: true, desc: 'Include projects shared to this group' - optional :include_subgroups, type: Boolean, default: false, desc: 'Includes projects in subgroups of this group' + desc: "Return only the ID, URL, name, and path of each project" + optional :owned, type: Boolean, default: false, desc: "Limit by owned by authenticated user" + optional :starred, type: Boolean, default: false, desc: "Limit by starred status" + optional :with_issues_enabled, type: Boolean, default: false, desc: "Limit by enabled issues feature" + optional :with_merge_requests_enabled, type: Boolean, default: false, desc: "Limit by enabled merge requests feature" + optional :with_shared, type: Boolean, default: true, desc: "Include projects shared to this group" + optional :include_subgroups, type: Boolean, default: false, desc: "Includes projects in subgroups of this group" use :pagination use :with_custom_attributes @@ -222,7 +223,7 @@ module API options = { with: params[:simple] ? Entities::BasicProjectDetails : Entities::Project, - current_user: current_user + current_user: current_user, } projects, options = with_custom_attributes(projects, options) @@ -230,7 +231,7 @@ module API present options[:with].prepare_relation(projects), options end - desc 'Get a list of subgroups in this group.' do + desc "Get a list of subgroups in this group." do success Entities::Group end params do @@ -242,13 +243,13 @@ module API present_groups params, groups end - desc 'Transfer a project to the group namespace. Available only for admin.' do + desc "Transfer a project to the group namespace. Available only for admin." do success Entities::GroupDetail end params do - requires :project_id, type: String, desc: 'The ID or path of the project' + requires :project_id, type: String, desc: "The ID or path of the project" end - post ":id/projects/:project_id", requirements: { project_id: /.+/ } do + post ":id/projects/:project_id", requirements: {project_id: /.+/} do authenticated_as_admin! group = find_group!(params[:id]) project = find_project!(params[:project_id]) |