summaryrefslogtreecommitdiff
path: root/lib/api/users.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-22 15:08:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-22 15:08:48 +0000
commit180cd023a11c0eb413ad0de124d9758ea25672bd (patch)
tree63d77be00a22dc637daa0b6d5b644e230f5f4890 /lib/api/users.rb
parentbe3e24ea3c9f497efde85900df298ce9bc42fce8 (diff)
downloadgitlab-ce-180cd023a11c0eb413ad0de124d9758ea25672bd.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r--lib/api/users.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 120f66b6a71..eba7c50435c 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -533,6 +533,32 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
+ desc 'Get memberships' do
+ success Entities::Membership
+ end
+ params do
+ requires :user_id, type: Integer, desc: 'The ID of the user'
+ optional :type, type: String, values: %w[Project Namespace]
+ use :pagination
+ end
+ get ":user_id/memberships" do
+ authenticated_as_admin!
+ user = find_user_by_id(params)
+
+ members = case params[:type]
+ when 'Project'
+ user.project_members
+ when 'Namespace'
+ user.group_members
+ else
+ user.members
+ end
+
+ members = members.including_source
+
+ present paginate(members), with: Entities::Membership
+ end
+
params do
requires :user_id, type: Integer, desc: 'The ID of the user'
end