Skip to content

Commit 4b72785

Browse files
authored
Add Epic and Epic Issues API support (#218)
1 parent 2263d76 commit 4b72785

File tree

11 files changed

+836
-3
lines changed

11 files changed

+836
-3
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ To utilize the GitLab API for Java in your project, simply add the following dep
1111
```java
1212
dependencies {
1313
...
14-
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.8.29'
14+
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.8.30'
1515
}
1616
```
1717

@@ -20,7 +20,7 @@ dependencies {
2020
<dependency>
2121
<groupId>org.gitlab4j</groupId>
2222
<artifactId>gitlab4j-api</artifactId>
23-
<version>4.8.29</version>
23+
<version>4.8.30</version>
2424
</dependency>
2525
```
2626

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

183+
#### EpicsApi
184+
```java
185+
// Get a list epics of the requested group and its subgroups.
186+
List<Epic> epics = gitLabApi.getEpicsApi().getEpics(1);
187+
```
188+
182189
#### EventsApi
183190
```java
184191
// Get a list of Events for the authenticated user
185-
Date after = new Date(0); // After Eposc
192+
Date after = new Date(0); // After Epoch
186193
Date before = new Date(); // Before now
187194
List<Event> events = gitLabApi.getEventsApi().getAuthenticatedUserEvents(null, null, before, after, DESC);
188195
```

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,30 @@ public String toString() {
5959
}
6060
}
6161

62+
63+
/** Enum to use for ordering the results of getEpics(). */
64+
public enum EpicOrderBy {
65+
66+
CREATED_AT, UPDATED_AT;
67+
68+
private static JacksonJsonEnumHelper<EpicOrderBy> enumHelper = new JacksonJsonEnumHelper<>(EpicOrderBy.class);
69+
70+
@JsonCreator
71+
public static EpicOrderBy forValue(String value) {
72+
return enumHelper.forValue(value);
73+
}
74+
75+
@JsonValue
76+
public String toValue() {
77+
return (enumHelper.toString(this));
78+
}
79+
80+
@Override
81+
public String toString() {
82+
return (enumHelper.toString(this));
83+
}
84+
}
85+
6286
/** Enum to use for ordering the results of getProjects(). */
6387
public enum ProjectOrderBy {
6488

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

Lines changed: 413 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public String getApiNamespace() {
5050

5151
private CommitsApi commitsApi;
5252
private DeployKeysApi deployKeysApi;
53+
private EpicsApi epicsApi;
5354
private EventsApi eventsApi;
5455
private GroupApi groupApi;
5556
private HealthCheckApi healthCheckApi;
@@ -846,6 +847,25 @@ public DeployKeysApi getDeployKeysApi() {
846847
return (deployKeysApi);
847848
}
848849

850+
/**
851+
* Gets the EpicsApi instance owned by this GitLabApi instance. The EpicsApi is used
852+
* to perform all Epics and Epic Issues related API calls.
853+
*
854+
* @return the EpicsApi instance owned by this GitLabApi instance
855+
*/
856+
public EpicsApi getEpicsApi() {
857+
858+
if (epicsApi == null) {
859+
synchronized (this) {
860+
if (epicsApi == null) {
861+
epicsApi = new EpicsApi(this);
862+
}
863+
}
864+
}
865+
866+
return (epicsApi);
867+
}
868+
849869
/**
850870
* Gets the EventsApi instance owned by this GitLabApi instance. The EventsApi is used
851871
* to perform all events related API calls.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ public GitLabApiForm(MultivaluedHashMap<String, String> map) {
2121
super(map);
2222
}
2323

24+
/**
25+
* Create a GitLabApiForm instance with the "page", and "per_page" parameters preset.
26+
*
27+
* @param page the value for the "page" parameter
28+
* @param perPage the value for the "per_page" parameter
29+
*/
30+
public GitLabApiForm(int page, int perPage) {
31+
super();
32+
withParam(AbstractApi.PAGE_PARAM, page);
33+
withParam(AbstractApi.PER_PAGE_PARAM, (Integer)perPage);
34+
}
35+
2436
/**
2537
* Fluent method for adding query and form parameters to a get() or post() call.
2638
*
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
package org.gitlab4j.api.models;
2+
3+
import java.util.Date;
4+
import java.util.List;
5+
6+
import javax.xml.bind.annotation.XmlAccessType;
7+
import javax.xml.bind.annotation.XmlAccessorType;
8+
import javax.xml.bind.annotation.XmlRootElement;
9+
10+
@XmlRootElement
11+
@XmlAccessorType(XmlAccessType.FIELD)
12+
public class Epic {
13+
14+
private Integer id;
15+
private Integer iid;
16+
private Integer groupId;
17+
private String title;
18+
private String description;
19+
private Author author;
20+
private List<String> labels;
21+
private Date startDate;
22+
private Date endDate;
23+
private Date createdAt;
24+
private Date updatedAt;
25+
26+
public Integer getId() {
27+
return id;
28+
}
29+
30+
public void setId(Integer id) {
31+
this.id = id;
32+
}
33+
34+
public Integer getIid() {
35+
return iid;
36+
}
37+
38+
public void setIid(Integer iid) {
39+
this.iid = iid;
40+
}
41+
42+
public Integer getGroupId() {
43+
return groupId;
44+
}
45+
46+
public void setGroupId(Integer groupId) {
47+
this.groupId = groupId;
48+
}
49+
50+
public String getTitle() {
51+
return title;
52+
}
53+
54+
public void setTitle(String title) {
55+
this.title = title;
56+
}
57+
58+
public Epic withTitle(String title) {
59+
this.title = title;
60+
return (this);
61+
}
62+
63+
public String getDescription() {
64+
return description;
65+
}
66+
67+
public void setDescription(String description) {
68+
this.description = description;
69+
}
70+
71+
public Epic withDescription(String description) {
72+
this.description = description;
73+
return (this);
74+
}
75+
76+
public Author getAuthor() {
77+
return author;
78+
}
79+
80+
public void setAuthor(Author author) {
81+
this.author = author;
82+
}
83+
84+
public Epic withAuthor(Author author) {
85+
this.author = author;
86+
return (this);
87+
}
88+
89+
public List<String> getLabels() {
90+
return labels;
91+
}
92+
93+
public void setLabels(List<String> labels) {
94+
this.labels = labels;
95+
}
96+
97+
public Epic withLabels(List<String> labels) {
98+
this.labels = labels;
99+
return (this);
100+
}
101+
102+
public Date getStartDate() {
103+
return startDate;
104+
}
105+
106+
public void setStartDate(Date startDate) {
107+
this.startDate = startDate;
108+
}
109+
110+
public Epic withStartDate(Date startDate) {
111+
this.startDate = startDate;
112+
return (this);
113+
}
114+
115+
public Date getEndDate() {
116+
return endDate;
117+
}
118+
119+
public void setEndDate(Date endDate) {
120+
this.endDate = endDate;
121+
}
122+
123+
public Epic withEndDate(Date endDate) {
124+
this.endDate = endDate;
125+
return (this);
126+
}
127+
128+
public Date getCreatedAt() {
129+
return createdAt;
130+
}
131+
132+
public void setCreatedAt(Date createdAt) {
133+
this.createdAt = createdAt;
134+
}
135+
136+
public Date getUpdatedAt() {
137+
return updatedAt;
138+
}
139+
140+
public void setUpdatedAt(Date updatedAt) {
141+
this.updatedAt = updatedAt;
142+
}
143+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
package org.gitlab4j.api.models;
3+
4+
import java.util.Map;
5+
6+
import javax.xml.bind.annotation.XmlAccessType;
7+
import javax.xml.bind.annotation.XmlAccessorType;
8+
9+
import com.fasterxml.jackson.annotation.JsonIgnore;
10+
import com.fasterxml.jackson.annotation.JsonProperty;
11+
12+
@XmlAccessorType(XmlAccessType.FIELD)
13+
public class EpicIssue extends Issue {
14+
15+
private Integer downvotes;
16+
private Integer upvotes;
17+
18+
@JsonProperty("_links")
19+
private Map<String, String> links;
20+
21+
private Boolean subscribed;
22+
private Integer epicIssueId;
23+
private Integer relativePosition;
24+
25+
public Integer getDownvotes() {
26+
return downvotes;
27+
}
28+
29+
public void setDownvotes(Integer downvotes) {
30+
this.downvotes = downvotes;
31+
}
32+
33+
public Integer getUpvotes() {
34+
return upvotes;
35+
}
36+
37+
public void setUpvotes(Integer upvotes) {
38+
this.upvotes = upvotes;
39+
}
40+
41+
public Map<String, String> getLinks() {
42+
return links;
43+
}
44+
45+
public void setLinks(Map<String, String> links) {
46+
this.links = links;
47+
}
48+
49+
@JsonIgnore
50+
public String getLinkByName(String name) {
51+
if (links == null || links.isEmpty()) {
52+
return (null);
53+
}
54+
55+
return (links.get(name));
56+
}
57+
58+
public Boolean getSubscribed() {
59+
return subscribed;
60+
}
61+
62+
public void setSubscribed(Boolean subscribed) {
63+
this.subscribed = subscribed;
64+
}
65+
66+
public Integer getEpicIssueId() {
67+
return epicIssueId;
68+
}
69+
70+
public void setEpicIssueId(Integer epicIssueId) {
71+
this.epicIssueId = epicIssueId;
72+
}
73+
74+
public Integer getRelativePosition() {
75+
return relativePosition;
76+
}
77+
78+
public void setRelativePosition(Integer relativePosition) {
79+
this.relativePosition = relativePosition;
80+
}
81+
}

0 commit comments

Comments
 (0)