From fac578c8fe086da92fcf9f3f6612925e5c715d05 Mon Sep 17 00:00:00 2001 From: Hannes Erven Date: Tue, 26 Sep 2023 09:38:34 +0200 Subject: [PATCH] Add the "internal" flag to NotesApi (#1029) --- src/main/java/org/gitlab4j/api/NotesApi.java | 20 +++++++++++++++++-- .../java/org/gitlab4j/api/models/Note.java | 11 +++++++++- src/test/resources/org/gitlab4j/api/note.json | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/NotesApi.java b/src/main/java/org/gitlab4j/api/NotesApi.java index 4b122de6..df641aac 100644 --- a/src/main/java/org/gitlab4j/api/NotesApi.java +++ b/src/main/java/org/gitlab4j/api/NotesApi.java @@ -152,7 +152,7 @@ public class NotesApi extends AbstractApi { * @throws GitLabApiException if any exception occurs */ public Note createIssueNote(Object projectIdOrPath, Long issueIid, String body) throws GitLabApiException { - return (createIssueNote(projectIdOrPath, issueIid, body, null)); + return (createIssueNote(projectIdOrPath, issueIid, body, null, null)); } /** @@ -166,10 +166,26 @@ public class NotesApi extends AbstractApi { * @throws GitLabApiException if any exception occurs */ public Note createIssueNote(Object projectIdOrPath, Long issueIid, String body, Date createdAt) throws GitLabApiException { + return (createIssueNote(projectIdOrPath, issueIid, body, null, null)); } + + /** + * Create a issues's note. + * + * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance + * @param issueIid the issue IID to create the notes for + * @param body the content of note + * @param createdAt the created time of note + * @param internal whether the note shall be marked 'internal' + * @return the created Note instance + * @throws GitLabApiException if any exception occurs + */ + public Note createIssueNote(Object projectIdOrPath, Long issueIid, String body, Date createdAt, Boolean internal) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm() .withParam("body", body, true) - .withParam("created_at", createdAt); + .withParam("created_at", createdAt) + .withParam("internal", internal); + ; Response response = post(Response.Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes"); return (response.readEntity(Note.class)); diff --git a/src/main/java/org/gitlab4j/api/models/Note.java b/src/main/java/org/gitlab4j/api/models/Note.java index e3a2e876..aad1244b 100644 --- a/src/main/java/org/gitlab4j/api/models/Note.java +++ b/src/main/java/org/gitlab4j/api/models/Note.java @@ -98,6 +98,7 @@ public class Note { private Boolean resolvable; private Participant resolvedBy; private Date resolvedAt; + private Boolean internal; private Type type; private Position position; @@ -270,7 +271,15 @@ public class Note { this.position = position; } - @Override + public Boolean getInternal() { + return internal; + } + + public void setInternal(Boolean internal) { + this.internal = internal; + } + + @Override public String toString() { return (JacksonJson.toJsonString(this)); } diff --git a/src/test/resources/org/gitlab4j/api/note.json b/src/test/resources/org/gitlab4j/api/note.json index 4f1771e2..af3f4619 100644 --- a/src/test/resources/org/gitlab4j/api/note.json +++ b/src/test/resources/org/gitlab4j/api/note.json @@ -16,6 +16,7 @@ "resolvable": true, "resolved": true, "resolved_at": "2021-09-14T09:03:50.221Z", + "internal": false, "system": false, "noteable_id": 52, "noteable_type": "Snippet", -- GitLab