summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-09-29 13:04:16 +0000
committerRémy Coutable <remy@rymai.me>2016-09-29 13:04:16 +0000
commitf6a1a21f6f808738b3caccca1b1233303649f898 (patch)
tree9c9a7da0c507ec4bdf3e0111e3a34f0d98a7a3fe /lib
parentc6a73b99df34e0a18d99e98bfc430f69327583e7 (diff)
parent93d849beaebb00dc4dcb6cb5ffa4721883e0da51 (diff)
downloadgitlab-ce-f6a1a21f6f808738b3caccca1b1233303649f898.tar.gz
Merge branch 'issue_22382' into 'master'
Expose project share expiration_date field on API closes #22382 See merge request !6484
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities.rb2
-rw-r--r--lib/api/projects.rb11
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 409a4c7cc07..c5dc8b22f60 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -343,7 +343,7 @@ module API
end
class ProjectGroupLink < Grape::Entity
- expose :id, :project_id, :group_id, :group_access
+ expose :id, :project_id, :group_id, :group_access, :expires_at
end
class Todo < Grape::Entity
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 6d99617b56f..680055c95eb 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -393,23 +393,24 @@ module API
# Share project with group
#
# Parameters:
- # id (required) - The ID of a project
- # group_id (required) - The ID of a group
+ # id (required) - The ID of a project
+ # group_id (required) - The ID of a group
# group_access (required) - Level of permissions for sharing
+ # expires_at (optional) - Share expiration date
#
# Example Request:
# POST /projects/:id/share
post ":id/share" do
authorize! :admin_project, user_project
required_attributes! [:group_id, :group_access]
+ attrs = attributes_for_keys [:group_id, :group_access, :expires_at]
unless user_project.allowed_to_share_with_group?
return render_api_error!("The project sharing with group is disabled", 400)
end
- link = user_project.project_group_links.new
- link.group_id = params[:group_id]
- link.group_access = params[:group_access]
+ link = user_project.project_group_links.new(attrs)
+
if link.save
present link, with: Entities::ProjectGroupLink
else