Skip to content

Commit 60259a6

Browse files
MadnessIRLDavide Santonocito
and
Davide Santonocito
authored
Add attributes "created_at", "internal" for NotesApi commits and DiscussionApi merge requests (#1194)
Co-authored-by: Davide Santonocito <[email protected]>
1 parent c3d3a17 commit 60259a6

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

Diff for: src/main/java/org/gitlab4j/api/DiscussionsApi.java

+34
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.gitlab4j.api.models.Discussion;
1212
import org.gitlab4j.api.models.Note;
1313
import org.gitlab4j.api.models.Position;
14+
import org.gitlab4j.api.utils.ISO8601;
1415

1516
/**
1617
* This class implements the client side API for the GitLab Discussions API.
@@ -657,6 +658,39 @@ public Discussion createCommitDiscussion(
657658
return (response.readEntity(Discussion.class));
658659
}
659660

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+
660694
/**
661695
* Adds a note to an existing commit discussion.
662696
*

Diff for: src/main/java/org/gitlab4j/api/NotesApi.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import javax.ws.rs.core.Response;
99

1010
import org.gitlab4j.api.models.Note;
11+
import org.gitlab4j.api.utils.ISO8601;
1112

1213
public class NotesApi extends AbstractApi {
1314

@@ -500,12 +501,18 @@ public Note getMergeRequestNote(Object projectIdOrPath, Long mergeRequestIid, Lo
500501
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
501502
* @param mergeRequestIid the merge request IID to create the notes for
502503
* @param body the content of note
504+
* @param createdAt date the discussion was created (requires admin or project/group owner rights) (Optional)
503505
* @return the created Note instance
504506
* @throws GitLabApiException if any exception occurs
505507
*/
506-
public Note createMergeRequestNote(Object projectIdOrPath, Long mergeRequestIid, String body)
508+
public Note createMergeRequestNote(
509+
Object projectIdOrPath, Long mergeRequestIid, String body, Date createdAt, boolean internal)
507510
throws GitLabApiException {
508-
GitLabApiForm formData = new GitLabApiForm().withParam("body", body, true);
511+
GitLabApiForm formData =
512+
new GitLabApiForm().withParam("body", body, true).withParam("internal", internal);
513+
if (createdAt != null) {
514+
formData.withParam("created_at", ISO8601.toString(createdAt));
515+
}
509516
Response response = post(
510517
Response.Status.CREATED,
511518
formData,

Diff for: src/main/java/org/gitlab4j/api/models/Setting.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ public enum Setting {
488488
/**
489489
* Gitaly fast operation timeout, in seconds. Some Gitaly operations are
490490
* expected to be fast. If they exceed this threshold, there may be a problem
491-
* with a storage shard and failing fast can help maintain the stability of
491+
* with a storage shard and 'failing fast' can help maintain the stability of
492492
* the GitLab instance. Set to 0 to disable timeouts.
493493
*/
494494
GITALY_TIMEOUT_FAST(Integer.class),
@@ -1534,7 +1534,7 @@ public enum Setting {
15341534

15351535
/**
15361536
* When rate limiting is enabled via the throttle_* settings, send this plain text response
1537-
* when a rate limit is exceeded. Retry later is sent if this is blank.
1537+
* when a rate limit is exceeded. 'Retry later' is sent if this is blank.
15381538
*/
15391539
RATE_LIMITING_RESPONSE_TEXT(String.class),
15401540

@@ -1575,7 +1575,7 @@ public enum Setting {
15751575
USER_DEACTIVATION_EMAILS_ENABLED(Boolean.class),
15761576

15771577
/**
1578-
* track or compress. Sets the behavior for Sidekiq job size limits. Default: compress.
1578+
* track or compress. Sets the behavior for Sidekiq job size limits. Default: 'compress'.
15791579
*/
15801580
SIDEKIQ_JOB_LIMITER_MODE(String.class),
15811581

0 commit comments

Comments
 (0)