Skip to content

Commit 04561b0

Browse files
committed
Added support for creating, updating, and deleting an issue board (#316).
1 parent 97f4572 commit 04561b0

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

src/main/java/org/gitlab4j/api/BoardsApi.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,69 @@ public Optional<Board> getOptionalBoard(Object projectIdOrPath, Integer boardId)
115115
}
116116
}
117117

118+
/**
119+
* Creates a new Issue Board.
120+
*
121+
* <p>NOTE: This is only available in GitLab EE</p>
122+
*
123+
* <pre><code>GitLab Endpoint: POST /projects/:id/boards</code></pre>
124+
*
125+
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
126+
* @param name the name for the new board
127+
* @return the created Board instance
128+
* @throws GitLabApiException if any exception occurs
129+
*/
130+
public Board createBoard(Object projectIdOrPath, String name) throws GitLabApiException {
131+
GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true);
132+
Response response = post(Response.Status.CREATED, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "boards");
133+
return (response.readEntity(Board.class));
134+
}
135+
136+
/**
137+
* Updates an existing Issue Board.
138+
*
139+
* <p>NOTE: This is only available in GitLab EE</p>
140+
*
141+
* <pre><code>GitLab Endpoint: PUT /projects/:id/boards/:board_id</code></pre>
142+
*
143+
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance, required
144+
* @param boardId the ID of the board, required
145+
* @param name the new name of the board, optional (can be null)
146+
* @param assigneeId the assignee the board should be scoped to, optional (can be null)
147+
* @param milestoneId the milestone the board should be scoped to, optional (can be null)
148+
* @param labels a comma-separated list of label names which the board should be scoped to, optional (can be null)
149+
* @param weight the weight range from 0 to 9, to which the board should be scoped to, optional (can be null)
150+
* @return the updated Board instance
151+
* @throws GitLabApiException if any exception occurs
152+
*/
153+
public BoardList updateBoard(Object projectIdOrPath, Integer boardId, String name,
154+
Integer assigneeId, Integer milestoneId, String labels, Integer weight) throws GitLabApiException {
155+
GitLabApiForm formData = new GitLabApiForm()
156+
.withParam("name", name)
157+
.withParam("assignee_id", assigneeId)
158+
.withParam("milestone_id", milestoneId)
159+
.withParam("labels", labels)
160+
.withParam("weight", weight);
161+
Response response = put(Response.Status.OK, formData.asMap(),
162+
"projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId);
163+
return (response.readEntity(BoardList.class));
164+
}
165+
166+
/**
167+
* Soft deletes an existing Issue Board.
168+
*
169+
* <p>NOTE: This is only available in GitLab EE</p>
170+
*
171+
* <pre><code>GitLab Endpoint: DELETE /projects/:id/boards/:board_id</code></pre>
172+
*
173+
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
174+
* @param boardId the ID of the board
175+
* @throws GitLabApiException if any exception occurs
176+
*/
177+
public void deleteBoard(Object projectIdOrPath, Integer boardId) throws GitLabApiException {
178+
delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "boards", boardId);
179+
}
180+
118181
/**
119182
* Get a list of the board’s lists. Does not include open and closed lists.
120183
*

0 commit comments

Comments
 (0)