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
Jérome Perrin
gitlab-ce
Commits
34b9cc96
Commit
34b9cc96
authored
Jan 05, 2018
by
Brent Greeff
Committed by
Rémy Coutable
Jan 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: get participants from merge_requests & issues
parent
6eeb69fc
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
149 additions
and
0 deletions
+149
-0
changelogs/unreleased/issues-40986-get-participants-from-issues-mr-api.yml
...ased/issues-40986-get-participants-from-issues-mr-api.yml
+5
-0
doc/api/issues.md
doc/api/issues.md
+39
-0
doc/api/merge_requests.md
doc/api/merge_requests.md
+35
-0
lib/api/issues.rb
lib/api/issues.rb
+13
-0
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+10
-0
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+12
-0
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+6
-0
spec/support/shared_examples/requests/api/issuable_participants_examples.rb
...d_examples/requests/api/issuable_participants_examples.rb
+29
-0
No files found.
changelogs/unreleased/issues-40986-get-participants-from-issues-mr-api.yml
0 → 100644
View file @
34b9cc96
---
title
:
'
API:
get
participants
from
merge_requests
&
issues'
merge_request
:
16187
author
:
Brent Greeff
type
:
added
doc/api/issues.md
View file @
34b9cc96
...
@@ -1124,6 +1124,45 @@ Example response:
...
@@ -1124,6 +1124,45 @@ Example response:
```
```
## Participants on issues
```
GET /projects/:id/issues/:issue_iid/participants
```
| Attribute | Type | Required | Description |
|-------------|---------|----------|--------------------------------------|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`issue_iid`
| integer | yes | The internal ID of a project's issue |
```
bash
curl
--request
GET
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/projects/5/issues/93/participants
```
Example response:
```
json
[
{
"id"
:
1
,
"name"
:
"John Doe1"
,
"username"
:
"user1"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon"
,
"web_url"
:
"http://localhost/user1"
},
{
"id"
:
5
,
"name"
:
"John Doe5"
,
"username"
:
"user5"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/4aea8cf834ed91844a2da4ff7ae6b491?s=80&d=identicon"
,
"web_url"
:
"http://localhost/user5"
}
]
```
## Comments on issues
## Comments on issues
Comments are done via the
[
notes
](
notes.md
)
resource.
Comments are done via the
[
notes
](
notes.md
)
resource.
...
...
doc/api/merge_requests.md
View file @
34b9cc96
...
@@ -308,6 +308,41 @@ Parameters:
...
@@ -308,6 +308,41 @@ Parameters:
}
}
```
```
## Get single MR participants
Get a list of merge request participants.
```
GET /projects/:id/merge_requests/:merge_request_iid/participants
```
Parameters:
-
`id`
(required) - The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user
-
`merge_request_iid`
(required) - The internal ID of the merge request
```
json
[
{
"id"
:
1
,
"name"
:
"John Doe1"
,
"username"
:
"user1"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon"
,
"web_url"
:
"http://localhost/user1"
},
{
"id"
:
2
,
"name"
:
"John Doe2"
,
"username"
:
"user2"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/10fc7f102be8de7657fb4d80898bbfe3?s=80&d=identicon"
,
"web_url"
:
"http://localhost/user2"
},
]
```
## Get single MR commits
## Get single MR commits
Get a list of merge request commits.
Get a list of merge request commits.
...
...
lib/api/issues.rb
View file @
34b9cc96
...
@@ -277,6 +277,19 @@ module API
...
@@ -277,6 +277,19 @@ module API
present
paginate
(
merge_requests
),
with:
Entities
::
MergeRequestBasic
,
current_user:
current_user
,
project:
user_project
present
paginate
(
merge_requests
),
with:
Entities
::
MergeRequestBasic
,
current_user:
current_user
,
project:
user_project
end
end
desc
'List participants for an issue'
do
success
Entities
::
UserBasic
end
params
do
requires
:issue_iid
,
type:
Integer
,
desc:
'The internal ID of a project issue'
end
get
':id/issues/:issue_iid/participants'
do
issue
=
find_project_issue
(
params
[
:issue_iid
])
participants
=
::
Kaminari
.
paginate_array
(
issue
.
participants
)
present
paginate
(
participants
),
with:
Entities
::
UserBasic
,
current_user:
current_user
,
project:
user_project
end
desc
'Get the user agent details for an issue'
do
desc
'Get the user agent details for an issue'
do
success
Entities
::
UserAgentDetail
success
Entities
::
UserAgentDetail
end
end
...
...
lib/api/merge_requests.rb
View file @
34b9cc96
...
@@ -185,6 +185,16 @@ module API
...
@@ -185,6 +185,16 @@ module API
present
merge_request
,
with:
Entities
::
MergeRequest
,
current_user:
current_user
,
project:
user_project
present
merge_request
,
with:
Entities
::
MergeRequest
,
current_user:
current_user
,
project:
user_project
end
end
desc
'Get the participants of a merge request'
do
success
Entities
::
UserBasic
end
get
':id/merge_requests/:merge_request_iid/participants'
do
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
participants
=
::
Kaminari
.
paginate_array
(
merge_request
.
participants
)
present
paginate
(
participants
),
with:
Entities
::
UserBasic
end
desc
'Get the commits of a merge request'
do
desc
'Get the commits of a merge request'
do
success
Entities
::
Commit
success
Entities
::
Commit
end
end
...
...
spec/requests/api/issues_spec.rb
View file @
34b9cc96
...
@@ -1582,4 +1582,16 @@ describe API::Issues, :mailer do
...
@@ -1582,4 +1582,16 @@ describe API::Issues, :mailer do
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
size
)
if
size
expect
(
json_response
.
length
).
to
eq
(
size
)
if
size
end
end
describe
'GET projects/:id/issues/:issue_iid/participants'
do
it_behaves_like
'issuable participants endpoint'
do
let
(
:entity
)
{
issue
}
end
it
'returns 404 if the issue is confidential'
do
post
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
confidential_issue
.
iid
}
/participants"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
end
spec/requests/api/merge_requests_spec.rb
View file @
34b9cc96
...
@@ -500,6 +500,12 @@ describe API::MergeRequests do
...
@@ -500,6 +500,12 @@ describe API::MergeRequests do
end
end
end
end
describe
'GET /projects/:id/merge_requests/:merge_request_iid/participants'
do
it_behaves_like
'issuable participants endpoint'
do
let
(
:entity
)
{
merge_request
}
end
end
describe
'GET /projects/:id/merge_requests/:merge_request_iid/commits'
do
describe
'GET /projects/:id/merge_requests/:merge_request_iid/commits'
do
it
'returns a 200 when merge request is valid'
do
it
'returns a 200 when merge request is valid'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/commits"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/commits"
,
user
)
...
...
spec/support/shared_examples/requests/api/issuable_participants_examples.rb
0 → 100644
View file @
34b9cc96
shared_examples
'issuable participants endpoint'
do
let
(
:area
)
{
entity
.
class
.
name
.
underscore
.
pluralize
}
it
'returns participants'
do
get
api
(
"/projects/
#{
project
.
id
}
/
#{
area
}
/
#{
entity
.
iid
}
/participants"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
entity
.
participants
.
size
)
last_participant
=
entity
.
participants
.
last
expect
(
json_response
.
last
[
'id'
]).
to
eq
(
last_participant
.
id
)
expect
(
json_response
.
last
[
'name'
]).
to
eq
(
last_participant
.
name
)
expect
(
json_response
.
last
[
'username'
]).
to
eq
(
last_participant
.
username
)
end
it
'returns a 404 when iid does not exist'
do
get
api
(
"/projects/
#{
project
.
id
}
/
#{
area
}
/999/participants"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'returns a 404 when id is used instead of iid'
do
get
api
(
"/projects/
#{
project
.
id
}
/
#{
area
}
/
#{
entity
.
id
}
/participants"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
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