|
14 | 14 | import org.gitlab4j.api.models.Epic;
|
15 | 15 | import org.gitlab4j.api.models.EpicIssue;
|
16 | 16 | import org.gitlab4j.api.models.EpicIssueLink;
|
| 17 | +import org.gitlab4j.api.models.LinkType; |
| 18 | +import org.gitlab4j.api.models.RelatedEpic; |
| 19 | +import org.gitlab4j.api.models.RelatedEpicLink; |
17 | 20 |
|
18 | 21 | /**
|
19 | 22 | * This class implements the client side API for the GitLab Epics and Epic Issues API calls.
|
@@ -461,7 +464,6 @@ public List<EpicIssue> updateIssue(Object groupIdOrPath, Long epicIid, Long epic
|
461 | 464 | return response.readEntity(new GenericType<List<EpicIssue>>() {});
|
462 | 465 | }
|
463 | 466 |
|
464 |
| - |
465 | 467 | /**
|
466 | 468 | * Gets all child epics of an epic and the authenticated user has access to.
|
467 | 469 | *
|
@@ -581,4 +583,88 @@ public ChildEpic unassignChildEpic(Object groupIdOrPath, Long epicIid, Long chil
|
581 | 583 | "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics", childEpicId);
|
582 | 584 | return (response.readEntity(ChildEpic.class));
|
583 | 585 | }
|
| 586 | + |
| 587 | + /** |
| 588 | + * Gets all linked epics of an epic filtered according to the user authorizations. |
| 589 | + * |
| 590 | + * <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/related_epics</code></pre> |
| 591 | + * |
| 592 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 593 | + * @param epicIid the IID of the epic to get child epics for |
| 594 | + * @return a list of all related epics of the specified epic |
| 595 | + * @throws GitLabApiException if any exception occurs |
| 596 | + */ |
| 597 | + public List<RelatedEpic> getRelatedEpics(Object groupIdOrPath, Long epicIid) throws GitLabApiException { |
| 598 | + return (getRelatedEpics(groupIdOrPath, epicIid, getDefaultPerPage()).all()); |
| 599 | + } |
| 600 | + |
| 601 | + /** |
| 602 | + * Get a Pager of all linked epics of an epic filtered according to the user authorizations. |
| 603 | + * |
| 604 | + * <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/related_epics</code></pre> |
| 605 | + * |
| 606 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 607 | + * @param epicIid the IID of the epic to get child epics for |
| 608 | + * @param itemsPerPage the number of child epics per page |
| 609 | + * @return the Pager of all related epics of the specified epic |
| 610 | + * @throws GitLabApiException if any exception occurs |
| 611 | + */ |
| 612 | + public Pager<RelatedEpic> getRelatedEpics(Object groupIdOrPath, Long epicIid, int itemsPerPage) throws GitLabApiException { |
| 613 | + return (new Pager<RelatedEpic>(this, RelatedEpic.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "related_epics")); |
| 614 | + } |
| 615 | + |
| 616 | + /** |
| 617 | + * Gets all linked epics of an epic filtered according to the user authorizations to as a Stream. |
| 618 | + * |
| 619 | + * <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/related_epics</code></pre> |
| 620 | + * |
| 621 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 622 | + * @param epicIid the IID of the epic to get child epics for |
| 623 | + * @return a Stream of all related epics of the specified epic |
| 624 | + * @throws GitLabApiException if any exception occurs |
| 625 | + */ |
| 626 | + public Stream<RelatedEpic> getRelatedEpicsStream(Object groupIdOrPath, Long epicIid) throws GitLabApiException { |
| 627 | + return (getRelatedEpics(groupIdOrPath, epicIid, getDefaultPerPage()).stream()); |
| 628 | + } |
| 629 | + |
| 630 | + /** |
| 631 | + * Create a two-way relation between two epics. The user must have at least the Guest role for both groups. |
| 632 | + * |
| 633 | + * <pre><code>GitLab Endpoint: POST /groups/:id/epics/:epic_iid/related_epics</code></pre> |
| 634 | + * |
| 635 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 636 | + * @param epicIid the Epic IID to assign the child epic to |
| 637 | + * @param targetGroupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path of the target group’s epic |
| 638 | + * @param targetEpicIid the Epic IID of the target group’s epic. |
| 639 | + * @param linkType the type of the relation (optional), defaults to {@link LinkType#RELATES_TO}. |
| 640 | + * @return an RelatedEpic instance containing info on the newly assigned child epic |
| 641 | + * @throws GitLabApiException if any exception occurs |
| 642 | + */ |
| 643 | + public RelatedEpicLink createRelatedEpicLink(Object groupIdOrPath, Long epicIid, Object targetGroupIdOrPath, Long targetEpicIid, LinkType linkType) throws GitLabApiException { |
| 644 | + Form formData = new GitLabApiForm() |
| 645 | + .withParam("target_group_id", getGroupIdOrPath(targetGroupIdOrPath), true) |
| 646 | + .withParam("target_epic_iid", targetEpicIid, true) |
| 647 | + .withParam("link_type", linkType); |
| 648 | + Response response = post(Response.Status.CREATED, formData.asMap(), |
| 649 | + "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "related_epics"); |
| 650 | + return (response.readEntity(RelatedEpicLink.class)); |
| 651 | + } |
| 652 | + |
| 653 | + /** |
| 654 | + * Delete a two-way relation between two epics. The user must have at least the Guest role for both groups. |
| 655 | + * |
| 656 | + * <pre><code>GitLab Endpoint: DELETE /groups/:id/epics/:epic_iid/related_epics/:related_epic_link_id</code></pre> |
| 657 | + * |
| 658 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 659 | + * @param epicIid the Epic IID to remove the child epic from |
| 660 | + * @param relatedEpicLinkId the ID a related epic link. |
| 661 | + * @return an RelatedEpicLink instance containing info on the removed related epic |
| 662 | + * @throws GitLabApiException if any exception occurs |
| 663 | + */ |
| 664 | + public RelatedEpicLink deleteRelatedEpicLink(Object groupIdOrPath, Long epicIid, Long relatedEpicLinkId) throws GitLabApiException { |
| 665 | + Response response = delete(Response.Status.OK, null, |
| 666 | + "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "related_epics", relatedEpicLinkId); |
| 667 | + return (response.readEntity(RelatedEpicLink.class)); |
| 668 | + } |
| 669 | + |
584 | 670 | }
|
0 commit comments