Skip to content

Commit

Permalink
Additions in EpicsApi (#1179)
Browse files Browse the repository at this point in the history
* Add support for "created_at" in Epic creation
* Add parameters to the updateEpic(..) method
  • Loading branch information
jmini authored Oct 12, 2024
1 parent cd7d0c3 commit fb23e25
Showing 1 changed file with 58 additions and 4 deletions.
62 changes: 58 additions & 4 deletions src/main/java/org/gitlab4j/api/EpicsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;

import org.gitlab4j.api.Constants.StateEvent;
import org.gitlab4j.api.models.ChildEpic;
import org.gitlab4j.api.models.CreatedChildEpic;
import org.gitlab4j.api.models.Epic;
Expand Down Expand Up @@ -259,15 +260,38 @@ public Optional<Epic> getOptionalEpic(Object groupIdOrPath, Long epicIid) {
* @param endDate the end date of the epic (optional)
* @return an Epic instance containing info on the newly created epic
* @throws GitLabApiException if any exception occurs
* @deprecated use {@link #createEpic(Object, String, String, String, Date, Date, Date)} instead
*/
@Deprecated
public Epic createEpic(Object groupIdOrPath, String title, String labels, String description,
Date startDate, Date endDate) throws GitLabApiException {
return createEpic(groupIdOrPath, title, labels, description, startDate, endDate, null);
}

/**
* Creates a new epic.
*
* <pre><code>GitLab Endpoint: POST /groups/:id/epics</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param title the title of the epic (required)
* @param labels comma separated list of labels (optional)
* @param description the description of the epic (optional)
* @param startDate the start date of the epic (optional)
* @param endDate the end date of the epic (optional)
* @param createdAt the end date when the epic was created. Requires administrator or project/group owner privileges (optional)
* @return an Epic instance containing info on the newly created epic
* @throws GitLabApiException if any exception occurs
*/
public Epic createEpic(Object groupIdOrPath, String title, String labels, String description,
Date startDate, Date endDate, Date createdAt) throws GitLabApiException {
Form formData = new GitLabApiForm()
.withParam("title", title, true)
.withParam("labels", labels)
.withParam("description", description)
.withParam("start_date", startDate)
.withParam("end_date", endDate);
.withParam("end_date", endDate)
.withParam("created_at", createdAt);
Response response = post(Response.Status.CREATED, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "epics");
return (response.readEntity(Epic.class));
Expand Down Expand Up @@ -297,7 +321,8 @@ public Epic createEpic(Object groupIdOrPath, Epic epic) throws GitLabApiExceptio
.withParam("labels", epic.getLabels())
.withParam("description", epic.getDescription())
.withParam("start_date", epic.getStartDate())
.withParam("end_date", epic.getEndDate());
.withParam("end_date", epic.getEndDate())
.withParam("created_at", epic.getCreatedAt());
Response response = post(Response.Status.CREATED, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "epics");
return (response.readEntity(Epic.class));
Expand All @@ -317,15 +342,43 @@ public Epic createEpic(Object groupIdOrPath, Epic epic) throws GitLabApiExceptio
* @param endDate the end date of the epic (optional)
* @return an Epic instance containing info on the newly created epic
* @throws GitLabApiException if any exception occurs
* @deprecated use {@link #updateEpic(Object, Long, String, String, String, Date, Date, StateEvent, Boolean, Long)} instead
*/
@Deprecated
public Epic updateEpic(Object groupIdOrPath, Long epicIid, String title, String labels, String description,
Date startDate, Date endDate) throws GitLabApiException {
return updateEpic(groupIdOrPath, epicIid, title, labels, description, startDate, endDate, null, null, null);
}

/**
* Updates an existing epic.
*
* <pre><code>GitLab Endpoint: PUT /groups/:id/epics/:epic_iid</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param epicIid the IID of the epic to update
* @param title the title of the epic (optional)
* @param labels comma separated list of labels (optional)
* @param description the description of the epic (optional)
* @param startDate the start date of the epic (optional)
* @param endDate the end date of the epic (optional)
* @param stateEvent State event for an epic. Set close to {@link StateEvent#CLOSE}L the epic and {@link StateEvent#REOPEN} to reopen it (optional)
* @param confidential Whether the epic should be confidential (optional)
* @param parentId The ID of a parent epic (optional)
* @return an Epic instance containing info on the newly created epic
* @throws GitLabApiException if any exception occurs
*/
public Epic updateEpic(Object groupIdOrPath, Long epicIid, String title, String labels, String description,
Date startDate, Date endDate, StateEvent stateEvent, Boolean confidential, Long parentId) throws GitLabApiException {
Form formData = new GitLabApiForm()
.withParam("title", title, true)
.withParam("labels", labels)
.withParam("description", description)
.withParam("start_date", startDate)
.withParam("end_date", endDate);
.withParam("end_date", endDate)
.withParam("state_event", stateEvent)
.withParam("confidential", confidential)
.withParam("parent_id", parentId);
Response response = put(Response.Status.OK, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid);
return (response.readEntity(Epic.class));
Expand Down Expand Up @@ -355,7 +408,8 @@ public Epic updateEpic(Object groupIdOrPath, Long epicIid, Epic epic) throws Git
.withParam("labels", epic.getLabels())
.withParam("description", epic.getDescription())
.withParam("start_date", epic.getStartDate())
.withParam("end_date", epic.getEndDate());
.withParam("end_date", epic.getEndDate())
.withParam("parent_id", epic.getParentId());
Response response = put(Response.Status.OK, formData.asMap(),
"groups", getGroupIdOrPath(groupIdOrPath), "epics", epicIid);
return (response.readEntity(Epic.class));
Expand Down

0 comments on commit fb23e25

Please sign in to comment.