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