Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
eff1b05a
Commit
eff1b05a
authored
Nov 22, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Add endpoint to delete a group share
parent
35d6ea4f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
0 deletions
+66
-0
changelogs/unreleased/api-delete-group-share.yml
changelogs/unreleased/api-delete-group-share.yml
+4
-0
doc/api/projects.md
doc/api/projects.md
+19
-0
lib/api/projects.rb
lib/api/projects.rb
+13
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+30
-0
No files found.
changelogs/unreleased/api-delete-group-share.yml
0 → 100644
View file @
eff1b05a
---
title
:
'
API:
Add
ability
to
unshare
a
project
from
a
group'
merge_request
:
7662
author
:
Robert Schilling
doc/api/projects.md
View file @
eff1b05a
...
...
@@ -1074,6 +1074,25 @@ Parameters:
|
`group_access`
| integer | yes | The permissions level to grant the group |
|
`expires_at`
| string | no | Share expiration date in ISO 8601 format: 2016-09-26 |
### Delete a shared project link within a group
Unshare the project from the group. Returns
`204`
and no content on success.
```
DELETE /projects/:id/share/:group_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME |
|
`group_id`
| integer | yes | The ID of the group |
```
bash
curl
--request
DELETE
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v3/projects/5/share/17
```
## Hooks
Also called Project Hooks and Webhooks.
...
...
lib/api/projects.rb
View file @
eff1b05a
...
...
@@ -438,6 +438,19 @@ module API
end
end
params
do
requires
:group_id
,
type:
Integer
,
desc:
'The ID of the group'
end
delete
":id/share/:group_id"
do
authorize!
:admin_project
,
user_project
link
=
user_project
.
project_group_links
.
find_by
(
group_id:
params
[
:group_id
])
not_found!
(
'Group Link'
)
unless
link
link
.
destroy
no_content!
end
# Upload a file
#
# Parameters:
...
...
spec/requests/api/projects_spec.rb
View file @
eff1b05a
...
...
@@ -908,6 +908,36 @@ describe API::API, api: true do
end
end
describe
'DELETE /projects/:id/share/:group_id'
do
it
'returns 204 when deleting a group share'
do
group
=
create
(
:group
,
:public
)
create
(
:project_group_link
,
group:
group
,
project:
project
)
delete
api
(
"/projects/
#{
project
.
id
}
/share/
#{
group
.
id
}
"
,
user
)
expect
(
response
).
to
have_http_status
(
204
)
expect
(
project
.
project_group_links
).
to
be_empty
end
it
'returns a 400 when group id is not an integer'
do
delete
api
(
"/projects/
#{
project
.
id
}
/share/foo"
,
user
)
expect
(
response
).
to
have_http_status
(
400
)
end
it
'returns a 404 error when group link does not exist'
do
delete
api
(
"/projects/
#{
project
.
id
}
/share/1234"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
end
it
'returns a 404 error when project does not exist'
do
delete
api
(
"/projects/123/share/1234"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
end
end
describe
'GET /projects/search/:query'
do
let!
(
:query
)
{
'query'
}
let!
(
:search
)
{
create
(
:empty_project
,
name:
query
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment