|
9 | 9 | import javax.ws.rs.core.GenericType;
|
10 | 10 | import javax.ws.rs.core.Response;
|
11 | 11 |
|
| 12 | +import org.gitlab4j.api.models.ChildEpic; |
| 13 | +import org.gitlab4j.api.models.CreatedChildEpic; |
12 | 14 | import org.gitlab4j.api.models.Epic;
|
13 | 15 | import org.gitlab4j.api.models.EpicIssue;
|
14 | 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; |
15 | 20 |
|
16 | 21 | /**
|
17 | 22 | * This class implements the client side API for the GitLab Epics and Epic Issues API calls.
|
@@ -458,4 +463,208 @@ public List<EpicIssue> updateIssue(Object groupIdOrPath, Long epicIid, Long epic
|
458 | 463 | "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "issues", epicIssueId);
|
459 | 464 | return response.readEntity(new GenericType<List<EpicIssue>>() {});
|
460 | 465 | }
|
| 466 | + |
| 467 | + /** |
| 468 | + * Gets all child epics of an epic and the authenticated user has access to. |
| 469 | + * |
| 470 | + * <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/epics</code></pre> |
| 471 | + * |
| 472 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 473 | + * @param epicIid the IID of the epic to get child epics for |
| 474 | + * @return a list of all child epics of the specified epic |
| 475 | + * @throws GitLabApiException if any exception occurs |
| 476 | + */ |
| 477 | + public List<ChildEpic> getChildEpics(Object groupIdOrPath, Long epicIid) throws GitLabApiException { |
| 478 | + return (getChildEpics(groupIdOrPath, epicIid, getDefaultPerPage()).all()); |
| 479 | + } |
| 480 | + |
| 481 | + /** |
| 482 | + * Get a Pager of all child epics of an epic and the authenticated user has access to. |
| 483 | + * |
| 484 | + * <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/epics</code></pre> |
| 485 | + * |
| 486 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 487 | + * @param epicIid the IID of the epic to get child epics for |
| 488 | + * @param itemsPerPage the number of child epics per page |
| 489 | + * @return the Pager of all child epics of the specified epic |
| 490 | + * @throws GitLabApiException if any exception occurs |
| 491 | + */ |
| 492 | + public Pager<ChildEpic> getChildEpics(Object groupIdOrPath, Long epicIid, int itemsPerPage) throws GitLabApiException { |
| 493 | + return (new Pager<ChildEpic>(this, ChildEpic.class, itemsPerPage, null, "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics")); |
| 494 | + } |
| 495 | + |
| 496 | + /** |
| 497 | + * Gets all child epics of an epic and the authenticated user has access to as a Stream. |
| 498 | + * |
| 499 | + * <pre><code>GitLab Endpoint: GET /groups/:id/epics/:epic_iid/epics</code></pre> |
| 500 | + * |
| 501 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 502 | + * @param epicIid the IID of the epic to get child epics for |
| 503 | + * @return a Stream of all child epics of the specified epic |
| 504 | + * @throws GitLabApiException if any exception occurs |
| 505 | + */ |
| 506 | + public Stream<ChildEpic> getChildEpicsStream(Object groupIdOrPath, Long epicIid) throws GitLabApiException { |
| 507 | + return (getChildEpics(groupIdOrPath, epicIid, getDefaultPerPage()).stream()); |
| 508 | + } |
| 509 | + |
| 510 | + /** |
| 511 | + * Creates an association between two epics, designating one as the parent epic and the other as the child epic. A parent epic can have multiple child epics. If the new child epic already belonged to another epic, it is unassigned from that previous parent. |
| 512 | + * |
| 513 | + * <pre><code>GitLab Endpoint: POST /groups/:id/epics/:epic_iid/epics/:child_epic_id</code></pre> |
| 514 | + * |
| 515 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 516 | + * @param epicIid the Epic IID to assign the child epic to |
| 517 | + * @param childEpicId the global ID of the child epic. Epic IID can’t be used because they can conflict with epics from other groups. |
| 518 | + * @return an ChildEpic instance containing info on the newly assigned child epic |
| 519 | + * @throws GitLabApiException if any exception occurs |
| 520 | + */ |
| 521 | + public ChildEpic assignChildEpic(Object groupIdOrPath, Long epicIid, Long childEpicId) throws GitLabApiException { |
| 522 | + Response response = post(Response.Status.CREATED, (Form)null, |
| 523 | + "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics", childEpicId); |
| 524 | + return (response.readEntity(ChildEpic.class)); |
| 525 | + } |
| 526 | + |
| 527 | + /** |
| 528 | + * Creates a new epic and associates it with provided parent epic. |
| 529 | + * |
| 530 | + * <pre><code>GitLab Endpoint: POST /groups/:id/epics/:epic_iid/epics</code></pre> |
| 531 | + * |
| 532 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 533 | + * @param epicIid the Epic IID to assign the child epic to (of the future parent epic) |
| 534 | + * @param title the title of a newly created epic |
| 535 | + * @param confidential whether the epic should be confidential (optional) |
| 536 | + * @return an ChildEpic instance containing info on the newly created and assigned child epic |
| 537 | + * @throws GitLabApiException if any exception occurs |
| 538 | + */ |
| 539 | + public CreatedChildEpic createAndAssignChildEpic(Object groupIdOrPath, Long epicIid, String title, Boolean confidential) throws GitLabApiException { |
| 540 | + Form formData = new GitLabApiForm() |
| 541 | + .withParam("title", title, true) |
| 542 | + .withParam("confidential", confidential); |
| 543 | + Response response = post(Response.Status.CREATED, formData.asMap(), |
| 544 | + "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics"); |
| 545 | + return (response.readEntity(CreatedChildEpic.class)); |
| 546 | + } |
| 547 | + |
| 548 | + /** |
| 549 | + * Re-order a child epic |
| 550 | + * |
| 551 | + * <pre><code>GitLab Endpoint: PUT /groups/:id/epics/:epic_iid/epics/:child_epic_id</code></pre> |
| 552 | + * |
| 553 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 554 | + * @param epicIid the Epic IID that the child epic is assigned to |
| 555 | + * @param childEpicId the ID of the child epic. Epic IID can’t be used because they can conflict with epics from other groups. |
| 556 | + * @param moveBeforeId the ID of a sibling epic that should be placed before the child epic (optional) |
| 557 | + * @param moveAfterId the ID of a sibling epic that should be placed after the child epic (optional) |
| 558 | + * @return a list of all child epics of the specified epic |
| 559 | + * @throws GitLabApiException if any exception occurs |
| 560 | + */ |
| 561 | + public List<ChildEpic> reOrderChildEpic(Object groupIdOrPath, Long epicIid, Long childEpicId, Long moveBeforeId, Long moveAfterId) throws GitLabApiException { |
| 562 | + GitLabApiForm form = new GitLabApiForm() |
| 563 | + .withParam("move_before_id", moveBeforeId) |
| 564 | + .withParam("move_after_id", moveAfterId); |
| 565 | + Response response = put(Response.Status.OK, form.asMap(), |
| 566 | + "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics", childEpicId); |
| 567 | + return response.readEntity(new GenericType<List<ChildEpic>>() {}); |
| 568 | + } |
| 569 | + |
| 570 | + /** |
| 571 | + * Unassigns a child epic from a parent epic. |
| 572 | + * |
| 573 | + * <pre><code>GitLab Endpoint: DELETE /groups/:id/epics/:epic_iid/epics/:child_epic_id</code></pre> |
| 574 | + * |
| 575 | + * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path |
| 576 | + * @param epicIid the Epic IID to remove the child epic from |
| 577 | + * @param childEpicId the ID of the child epic. Epic IID can’t be used because they can conflict with epics from other groups. |
| 578 | + * @return an ChildEpic instance containing info on the removed child epic |
| 579 | + * @throws GitLabApiException if any exception occurs |
| 580 | + */ |
| 581 | + public ChildEpic unassignChildEpic(Object groupIdOrPath, Long epicIid, Long childEpicId) throws GitLabApiException { |
| 582 | + Response response = delete(Response.Status.OK, null, |
| 583 | + "groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid, "epics", childEpicId); |
| 584 | + return (response.readEntity(ChildEpic.class)); |
| 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 | + |
461 | 670 | }
|
0 commit comments