Skip to content

Add Epic and Epic Issues API support #218

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

Merged
merged 5 commits into from
Jul 7, 2018
Merged
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
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To utilize the GitLab API for Java in your project, simply add the following dep
```java
dependencies {
...
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.8.29'
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.8.30'
}
```

Expand All @@ -20,7 +20,7 @@ dependencies {
<dependency>
<groupId>org.gitlab4j</groupId>
<artifactId>gitlab4j-api</artifactId>
<version>4.8.29</version>
<version>4.8.30</version>
</dependency>
```

Expand Down Expand Up @@ -137,6 +137,7 @@ The API has been broken up into sub APIs classes to make it easier to learn and
------------------
&nbsp;&nbsp;[CommitsApi](#commitsapi)<br/>
&nbsp;&nbsp;[DeployKeysApi](#deploykeysapi)<br/>
&nbsp;&nbsp;[EpicsApi](#epicsapi)<br/>
&nbsp;&nbsp;[EventsApi](#eventsapi)<br/>
&nbsp;&nbsp;[GroupApi](#groupapi)<br/>
&nbsp;&nbsp;[HealthCheckApi](#healthcheckapi)<br/>
Expand Down Expand Up @@ -179,10 +180,16 @@ List<Commit> commits = gitLabApi.getCommitsApi().getCommits(1234, "new-feature",
List<DeployKey> deployKeys = gitLabApi.getDeployKeysApi().getDeployKeys();
```

#### EpicsApi
```java
// Get a list epics of the requested group and its subgroups.
List<Epic> epics = gitLabApi.getEpicsApi().getEpics(1);
```

#### EventsApi
```java
// Get a list of Events for the authenticated user
Date after = new Date(0); // After Eposc
Date after = new Date(0); // After Epoch
Date before = new Date(); // Before now
List<Event> events = gitLabApi.getEventsApi().getAuthenticatedUserEvents(null, null, before, after, DESC);
```
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/gitlab4j/api/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,30 @@ public String toString() {
}
}


/** Enum to use for ordering the results of getEpics(). */
public enum EpicOrderBy {

CREATED_AT, UPDATED_AT;

private static JacksonJsonEnumHelper<EpicOrderBy> enumHelper = new JacksonJsonEnumHelper<>(EpicOrderBy.class);

@JsonCreator
public static EpicOrderBy forValue(String value) {
return enumHelper.forValue(value);
}

@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}

@Override
public String toString() {
return (enumHelper.toString(this));
}
}

/** Enum to use for ordering the results of getProjects(). */
public enum ProjectOrderBy {

Expand Down
413 changes: 413 additions & 0 deletions src/main/java/org/gitlab4j/api/EpicsApi.java

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions src/main/java/org/gitlab4j/api/GitLabApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public String getApiNamespace() {

private CommitsApi commitsApi;
private DeployKeysApi deployKeysApi;
private EpicsApi epicsApi;
private EventsApi eventsApi;
private GroupApi groupApi;
private HealthCheckApi healthCheckApi;
Expand Down Expand Up @@ -846,6 +847,25 @@ public DeployKeysApi getDeployKeysApi() {
return (deployKeysApi);
}

/**
* Gets the EpicsApi instance owned by this GitLabApi instance. The EpicsApi is used
* to perform all Epics and Epic Issues related API calls.
*
* @return the EpicsApi instance owned by this GitLabApi instance
*/
public EpicsApi getEpicsApi() {

if (epicsApi == null) {
synchronized (this) {
if (epicsApi == null) {
epicsApi = new EpicsApi(this);
}
}
}

return (epicsApi);
}

/**
* Gets the EventsApi instance owned by this GitLabApi instance. The EventsApi is used
* to perform all events related API calls.
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/gitlab4j/api/GitLabApiForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ public GitLabApiForm(MultivaluedHashMap<String, String> map) {
super(map);
}

/**
* Create a GitLabApiForm instance with the "page", and "per_page" parameters preset.
*
* @param page the value for the "page" parameter
* @param perPage the value for the "per_page" parameter
*/
public GitLabApiForm(int page, int perPage) {
super();
withParam(AbstractApi.PAGE_PARAM, page);
withParam(AbstractApi.PER_PAGE_PARAM, (Integer)perPage);
}

/**
* Fluent method for adding query and form parameters to a get() or post() call.
*
Expand Down
143 changes: 143 additions & 0 deletions src/main/java/org/gitlab4j/api/models/Epic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package org.gitlab4j.api.models;

import java.util.Date;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Epic {

private Integer id;
private Integer iid;
private Integer groupId;
private String title;
private String description;
private Author author;
private List<String> labels;
private Date startDate;
private Date endDate;
private Date createdAt;
private Date updatedAt;

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public Integer getIid() {
return iid;
}

public void setIid(Integer iid) {
this.iid = iid;
}

public Integer getGroupId() {
return groupId;
}

public void setGroupId(Integer groupId) {
this.groupId = groupId;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public Epic withTitle(String title) {
this.title = title;
return (this);
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public Epic withDescription(String description) {
this.description = description;
return (this);
}

public Author getAuthor() {
return author;
}

public void setAuthor(Author author) {
this.author = author;
}

public Epic withAuthor(Author author) {
this.author = author;
return (this);
}

public List<String> getLabels() {
return labels;
}

public void setLabels(List<String> labels) {
this.labels = labels;
}

public Epic withLabels(List<String> labels) {
this.labels = labels;
return (this);
}

public Date getStartDate() {
return startDate;
}

public void setStartDate(Date startDate) {
this.startDate = startDate;
}

public Epic withStartDate(Date startDate) {
this.startDate = startDate;
return (this);
}

public Date getEndDate() {
return endDate;
}

public void setEndDate(Date endDate) {
this.endDate = endDate;
}

public Epic withEndDate(Date endDate) {
this.endDate = endDate;
return (this);
}

public Date getCreatedAt() {
return createdAt;
}

public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}

public Date getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}
81 changes: 81 additions & 0 deletions src/main/java/org/gitlab4j/api/models/EpicIssue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

package org.gitlab4j.api.models;

import java.util.Map;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

@XmlAccessorType(XmlAccessType.FIELD)
public class EpicIssue extends Issue {

private Integer downvotes;
private Integer upvotes;

@JsonProperty("_links")
private Map<String, String> links;

private Boolean subscribed;
private Integer epicIssueId;
private Integer relativePosition;

public Integer getDownvotes() {
return downvotes;
}

public void setDownvotes(Integer downvotes) {
this.downvotes = downvotes;
}

public Integer getUpvotes() {
return upvotes;
}

public void setUpvotes(Integer upvotes) {
this.upvotes = upvotes;
}

public Map<String, String> getLinks() {
return links;
}

public void setLinks(Map<String, String> links) {
this.links = links;
}

@JsonIgnore
public String getLinkByName(String name) {
if (links == null || links.isEmpty()) {
return (null);
}

return (links.get(name));
}

public Boolean getSubscribed() {
return subscribed;
}

public void setSubscribed(Boolean subscribed) {
this.subscribed = subscribed;
}

public Integer getEpicIssueId() {
return epicIssueId;
}

public void setEpicIssueId(Integer epicIssueId) {
this.epicIssueId = epicIssueId;
}

public Integer getRelativePosition() {
return relativePosition;
}

public void setRelativePosition(Integer relativePosition) {
this.relativePosition = relativePosition;
}
}
Loading