Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing attributes for NotesApi and DiscussionApi (#1193) #1194

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/main/java/org/gitlab4j/api/DiscussionsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.gitlab4j.api.models.Discussion;
import org.gitlab4j.api.models.Note;
import org.gitlab4j.api.models.Position;
import org.gitlab4j.api.utils.ISO8601;

/**
* This class implements the client side API for the GitLab Discussions API.
Expand Down Expand Up @@ -657,6 +658,40 @@ public Discussion createCommitDiscussion(
return (response.readEntity(Discussion.class));
}

/**
* Creates a new discussion to a single project commit. This is similar to creating
* a note but other comments (replies) can be added to it later.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/repository/commits/:commit_sha/discussions</code></pre>
*
* @param projectIdOrPath projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param commitSha the commit SHA to create the discussion for
* @param body the content of a discussion
* @param createdAt date the discussion was created (requires admin or project/group owner rights) (Optional)
* @return a Discussion instance containing the newly created discussion
* @throws GitLabApiException if any exception occurs during execution
*/
public Discussion createCommitDiscussion(Object projectIdOrPath, String commitSha, String body, Date createdAt)
MadnessIRL marked this conversation as resolved.
Show resolved Hide resolved
throws GitLabApiException {

GitLabApiForm formData =
new GitLabApiForm().withParam("body", body, true);
if (createdAt != null) {
formData.withParam("created_at", ISO8601.toString(createdAt));
MadnessIRL marked this conversation as resolved.
Show resolved Hide resolved
}

Response response = post(
Response.Status.CREATED,
formData,
"projects",
getProjectIdOrPath(projectIdOrPath),
"repository",
"commits",
commitSha,
"discussions");
return (response.readEntity(Discussion.class));
}

/**
* Adds a note to an existing commit discussion.
*
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/gitlab4j/api/NotesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.ws.rs.core.Response;

import org.gitlab4j.api.models.Note;
import org.gitlab4j.api.utils.ISO8601;

public class NotesApi extends AbstractApi {

Expand Down Expand Up @@ -500,12 +501,19 @@ public Note getMergeRequestNote(Object projectIdOrPath, Long mergeRequestIid, Lo
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param mergeRequestIid the merge request IID to create the notes for
* @param body the content of note
* @param createdAt date the discussion was created (requires admin or project/group owner rights) (Optional)
* @return the created Note instance
* @throws GitLabApiException if any exception occurs
*/
public Note createMergeRequestNote(Object projectIdOrPath, Long mergeRequestIid, String body)
public Note createMergeRequestNote(Object projectIdOrPath, Long mergeRequestIid, String body,
Date createdAt, boolean internal)
throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm().withParam("body", body, true);
GitLabApiForm formData = new GitLabApiForm()
.withParam("body", body, true)
.withParam("internal", internal);
if (createdAt != null) {
formData.withParam("created_at", ISO8601.toString(createdAt));
}
Response response = post(
Response.Status.CREATED,
formData,
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/gitlab4j/api/models/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public enum Setting {
/**
* Gitaly fast operation timeout, in seconds. Some Gitaly operations are
* expected to be fast. If they exceed this threshold, there may be a problem
* with a storage shard and failing fast can help maintain the stability of
* with a storage shard and 'failing fast' can help maintain the stability of
* the GitLab instance. Set to 0 to disable timeouts.
*/
GITALY_TIMEOUT_FAST(Integer.class),
Expand Down Expand Up @@ -1534,7 +1534,7 @@ public enum Setting {

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

Expand Down Expand Up @@ -1575,7 +1575,7 @@ public enum Setting {
USER_DEACTIVATION_EMAILS_ENABLED(Boolean.class),

/**
* track or compress. Sets the behavior for Sidekiq job size limits. Default: compress.
* track or compress. Sets the behavior for Sidekiq job size limits. Default: 'compress'.
*/
SIDEKIQ_JOB_LIMITER_MODE(String.class),

Expand Down
Loading