|
11 | 11 | import org.gitlab4j.api.models.Discussion; |
12 | 12 | import org.gitlab4j.api.models.Note; |
13 | 13 | import org.gitlab4j.api.models.Position; |
| 14 | +import org.gitlab4j.api.utils.ISO8601; |
14 | 15 |
|
15 | 16 | /** |
16 | 17 | * This class implements the client side API for the GitLab Discussions API. |
@@ -657,6 +658,39 @@ public Discussion createCommitDiscussion( |
657 | 658 | return (response.readEntity(Discussion.class)); |
658 | 659 | } |
659 | 660 |
|
| 661 | + /** |
| 662 | + * Creates a new discussion to a single project commit. This is similar to creating |
| 663 | + * a note but other comments (replies) can be added to it later. |
| 664 | + * |
| 665 | + * <pre><code>GitLab Endpoint: POST /projects/:id/repository/commits/:commit_sha/discussions</code></pre> |
| 666 | + * |
| 667 | + * @param projectIdOrPath projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance |
| 668 | + * @param commitSha the commit SHA to create the discussion for |
| 669 | + * @param body the content of a discussion |
| 670 | + * @param createdAt date the discussion was created (requires admin or project/group owner rights) (Optional) |
| 671 | + * @return a Discussion instance containing the newly created discussion |
| 672 | + * @throws GitLabApiException if any exception occurs during execution |
| 673 | + */ |
| 674 | + public Discussion createCommitDiscussion(Object projectIdOrPath, String commitSha, String body, Date createdAt) |
| 675 | + throws GitLabApiException { |
| 676 | + |
| 677 | + GitLabApiForm formData = new GitLabApiForm().withParam("body", body, true); |
| 678 | + if (createdAt != null) { |
| 679 | + formData.withParam("created_at", ISO8601.toString(createdAt)); |
| 680 | + } |
| 681 | + |
| 682 | + Response response = post( |
| 683 | + Response.Status.CREATED, |
| 684 | + formData, |
| 685 | + "projects", |
| 686 | + getProjectIdOrPath(projectIdOrPath), |
| 687 | + "repository", |
| 688 | + "commits", |
| 689 | + commitSha, |
| 690 | + "discussions"); |
| 691 | + return (response.readEntity(Discussion.class)); |
| 692 | + } |
| 693 | + |
660 | 694 | /** |
661 | 695 | * Adds a note to an existing commit discussion. |
662 | 696 | * |
|
0 commit comments