|
1 | | -/* |
2 | | - * The MIT License (MIT) |
3 | | - * |
4 | | - * Copyright (c) 2017 Greg Messner <greg@messners.com> |
5 | | - * |
6 | | - * Permission is hereby granted, free of charge, to any person obtaining a copy of |
7 | | - * this software and associated documentation files (the "Software"), to deal in |
8 | | - * the Software without restriction, including without limitation the rights to |
9 | | - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
10 | | - * the Software, and to permit persons to whom the Software is furnished to do so, |
11 | | - * subject to the following conditions: |
12 | | - * |
13 | | - * The above copyright notice and this permission notice shall be included in all |
14 | | - * copies or substantial portions of the Software. |
15 | | - * |
16 | | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
18 | | - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
19 | | - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
20 | | - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
21 | | - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | | - */ |
23 | | - |
24 | 1 | package org.gitlab4j.api; |
25 | 2 |
|
26 | 3 | import java.util.Date; |
|
37 | 14 | import org.gitlab4j.api.models.IssueFilter; |
38 | 15 | import org.gitlab4j.api.models.IssueLink; |
39 | 16 | import org.gitlab4j.api.models.MergeRequest; |
| 17 | +import org.gitlab4j.api.models.Participant; |
40 | 18 | import org.gitlab4j.api.models.TimeStats; |
41 | 19 | import org.gitlab4j.api.utils.DurationUtils; |
42 | 20 |
|
@@ -799,4 +777,66 @@ public IssueLink deleteIssueLink(Object projectIdOrPath, Integer issueIid, Integ |
799 | 777 | "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "links", issueLinkId); |
800 | 778 | return (response.readEntity(IssueLink.class)); |
801 | 779 | } |
| 780 | + |
| 781 | + /** |
| 782 | + * Get list of participants for an issue. |
| 783 | + * |
| 784 | + * <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/participants</code></pre> |
| 785 | + * |
| 786 | + * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance |
| 787 | + * @param issueIid the IID of the issue to get the participants for |
| 788 | + * @return a List containing all participants for the specified issue |
| 789 | + * @throws GitLabApiException if any exception occurs |
| 790 | + */ |
| 791 | + public List<Participant> getParticipants(Object projectIdOrPath, Integer issueIid) throws GitLabApiException { |
| 792 | + return (getParticipants(projectIdOrPath, issueIid, getDefaultPerPage()).all()); |
| 793 | + } |
| 794 | + |
| 795 | + /** |
| 796 | + * Get list of participants for an issue and in the specified page range. |
| 797 | + * |
| 798 | + * <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/participants</code></pre> |
| 799 | + * |
| 800 | + * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance |
| 801 | + * @param issueIid the IID of the issue to get the participants for |
| 802 | + * @param page the page to get |
| 803 | + * @param perPage the number of projects per page |
| 804 | + * @return a List containing all participants for the specified issue |
| 805 | + * @throws GitLabApiException if any exception occurs |
| 806 | + */ |
| 807 | + public List<Participant> getParticipants(Object projectIdOrPath, Integer issueIid, int page, int perPage) throws GitLabApiException { |
| 808 | + Response response = get(Response.Status.OK, getPageQueryParams(page, perPage), |
| 809 | + "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "participants"); |
| 810 | + return (response.readEntity(new GenericType<List<Participant>>() { })); |
| 811 | + } |
| 812 | + |
| 813 | + /** |
| 814 | + * Get a Pager of the participants for an issue. |
| 815 | + * |
| 816 | + * <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/participants</code></pre> |
| 817 | + * |
| 818 | + * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance |
| 819 | + * @param issueIid the IID of the issue to get the participants for |
| 820 | + * @param itemsPerPage the number of Participant instances that will be fetched per page |
| 821 | + * @return a Pager containing all participants for the specified issue |
| 822 | + * @throws GitLabApiException if any exception occurs |
| 823 | + */ |
| 824 | + public Pager<Participant> getParticipants(Object projectIdOrPath, Integer issueIid, int itemsPerPage) throws GitLabApiException { |
| 825 | + return new Pager<Participant>(this, Participant.class, itemsPerPage, null, |
| 826 | + "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "participants"); |
| 827 | + } |
| 828 | + |
| 829 | + /** |
| 830 | + * Get Stream of participants for an issue. |
| 831 | + * |
| 832 | + * <pre><code>GitLab Endpoint: GET /projects/:id/issues/:issue_iid/participants</code></pre> |
| 833 | + * |
| 834 | + * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance |
| 835 | + * @param issueIid the IID of the issue to get the participants for |
| 836 | + * @return a Stream containing all participants for the specified issue |
| 837 | + * @throws GitLabApiException if any exception occurs |
| 838 | + */ |
| 839 | + public Stream<Participant> getParticipantsStream(Object projectIdOrPath, Integer issueIid) throws GitLabApiException { |
| 840 | + return (getParticipants(projectIdOrPath, issueIid, getDefaultPerPage()).stream()); |
| 841 | + } |
802 | 842 | } |
0 commit comments