Skip to content

Commit a49ba42

Browse files
committed
Added support for Issue Boards API (#316).
1 parent 0af6603 commit a49ba42

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

README.md

Lines changed: 9 additions & 2 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.9.20'
14+
compile group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.9.21'
1515
}
1616
```
1717

@@ -22,7 +22,7 @@ dependencies {
2222
<dependency>
2323
<groupId>org.gitlab4j</groupId>
2424
<artifactId>gitlab4j-api</artifactId>
25-
<version>4.9.20</version>
25+
<version>4.9.21</version>
2626
</dependency>
2727
```
2828

@@ -206,6 +206,7 @@ The API has been broken up into sub API classes to make it easier to learn and t
206206
### Available Sub APIs
207207
------------------
208208
&nbsp;&nbsp;[AwardEmojiApi](#awardemojiapi)<br/>
209+
&nbsp;&nbsp;[BoardsApi](#boardsapi)<br/>
209210
&nbsp;&nbsp;[CommitsApi](#commitsapi)<br/>
210211
&nbsp;&nbsp;[DeployKeysApi](#deploykeysapi)<br/>
211212
&nbsp;&nbsp;[DiscussionsApi](#discussionsapi)<br/>
@@ -244,6 +245,12 @@ The API has been broken up into sub API classes to make it easier to learn and t
244245
List<AwardEmoji> awardEmojis = gitLabApi.getAwardEmojiApi().getIssuAwardEmojis(1, 1);
245246
```
246247

248+
#### BoardsApi
249+
```java
250+
// Get a list of the Issue Boards belonging to the specified project
251+
List<Board> boards = gitLabApi.getBoardsApi().getBoards(projectId);
252+
```
253+
247254
#### CommitsApi
248255
```java
249256
// Get a list of commits associated with the specified branch that fall within the specified time window

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
private Session session;
5151

5252
private AwardEmojiApi awardEmojiApi;
53+
private BoardsApi boardsApi;
5354
private CommitsApi commitsApi;
5455
private DiscussionsApi discussionsApi;
5556
private DeployKeysApi deployKeysApi;
@@ -826,6 +827,25 @@ public AwardEmojiApi getAwardEmojiApi() {
826827
return (awardEmojiApi);
827828
}
828829

830+
/**
831+
* Gets the BoardsApi instance owned by this GitLabApi instance. The BoardsApi is used
832+
* to perform all Issue Boards related API calls.
833+
*
834+
* @return the BoardsApi instance owned by this GitLabApi instance
835+
*/
836+
public BoardsApi getBoardsApi() {
837+
838+
if (boardsApi == null) {
839+
synchronized (this) {
840+
if (boardsApi == null) {
841+
boardsApi = new BoardsApi(this);
842+
}
843+
}
844+
}
845+
846+
return (boardsApi);
847+
}
848+
829849
/**
830850
* Gets the CommitsApi instance owned by this GitLabApi instance. The CommitsApi is used
831851
* to perform all commit related API calls.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.gitlab4j.api;
22

33
import java.util.List;
4+
import java.util.stream.Stream;
45

56
import javax.ws.rs.core.GenericType;
67
import javax.ws.rs.core.Response;
@@ -52,6 +53,17 @@ public Pager<Label> getLabels(Object projectIdOrPath, int itemsPerPage) throws G
5253
"projects", getProjectIdOrPath(projectIdOrPath), "labels"));
5354
}
5455

56+
/**
57+
* Get a Stream of all labels of the specified project.
58+
*
59+
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
60+
* @return a Stream of project's labels
61+
* @throws GitLabApiException if any exception occurs
62+
*/
63+
public Stream<Label> getLabelsStream(Object projectIdOrPath) throws GitLabApiException {
64+
return (getLabels(projectIdOrPath, getDefaultPerPage()).stream());
65+
}
66+
5567
/**
5668
* Create a label
5769
*

src/main/java/org/gitlab4j/api/models/Label.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class Label {
1717
private Integer openIssuesCount;
1818
private Integer closedIssuesCount;
1919
private Integer openMergeRequestsCount;
20-
private boolean subscribed;
20+
private Boolean subscribed;
2121
private Integer priority;
2222

2323
public Integer getId() {
@@ -76,11 +76,11 @@ public void setOpenMergeRequestsCount(Integer openMergeRequestsCount) {
7676
this.openMergeRequestsCount = openMergeRequestsCount;
7777
}
7878

79-
public boolean isSubscribed() {
79+
public Boolean isSubscribed() {
8080
return subscribed;
8181
}
8282

83-
public void setSubscribed(boolean subscribed) {
83+
public void setSubscribed(Boolean subscribed) {
8484
this.subscribed = subscribed;
8585
}
8686

src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import org.gitlab4j.api.models.ArtifactsFile;
3636
import org.gitlab4j.api.models.AwardEmoji;
37+
import org.gitlab4j.api.models.Board;
3738
import org.gitlab4j.api.models.Branch;
3839
import org.gitlab4j.api.models.Comment;
3940
import org.gitlab4j.api.models.Commit;
@@ -94,6 +95,12 @@ public void testAwardEmoji() throws Exception {
9495
assertTrue(compareJson(awardEmoji, "award-emoji.json"));
9596
}
9697

98+
@Test
99+
public void testBoard() throws Exception {
100+
List<Board> boards = unmarshalResourceList(Board.class, "project-board.json");
101+
assertTrue(compareJson(boards, "project-board.json"));
102+
}
103+
97104
@Test
98105
public void testBranch() throws Exception {
99106

0 commit comments

Comments
 (0)