Skip to content

Commit bab4bb6

Browse files
lamdavgmessner
authored andcommitted
Controlled Pagination for Runners (#179)
1 parent 6a365b6 commit bab4bb6

File tree

1 file changed

+68
-6
lines changed

1 file changed

+68
-6
lines changed

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

+68-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public RunnersApi(GitLabApi gitLabApi) {
2626
* @throws GitLabApiException if any exception occurs
2727
*/
2828
public List<Runner> getRunners() throws GitLabApiException {
29-
return getRunners(null);
29+
return getRunners(null, null, null);
3030
}
3131

3232
/**
33-
* Get a list of specific runners available to the user.
33+
* Get a list of all available runners available to the user with pagination support.
3434
*
3535
* GET /runners
3636
*
@@ -39,8 +39,39 @@ public List<Runner> getRunners() throws GitLabApiException {
3939
* @throws GitLabApiException if any exception occurs
4040
*/
4141
public List<Runner> getRunners(Runner.RunnerStatus scope) throws GitLabApiException {
42+
return getRunners(scope, null, null);
43+
}
44+
45+
/**
46+
* Get a list of all available runners available to the user with pagination support.
47+
*
48+
* GET /runners
49+
*
50+
* @param page The page offset of runners
51+
* @param perPage The number of runners to get after the page offset
52+
* @return List of Runners
53+
* @throws GitLabApiException if any exception occurs
54+
*/
55+
public List<Runner> getRunners(int page, int perPage) throws GitLabApiException {
56+
return getRunners(null, page, perPage);
57+
}
58+
59+
/**
60+
* Get a list of specific runners available to the user.
61+
*
62+
* GET /runners
63+
*
64+
* @param scope The scope of specific runners to show, one of: active, paused, online; showing all runners null
65+
* @param page The page offset of runners
66+
* @param perPage The number of runners to get after the page offset
67+
* @return List of Runners
68+
* @throws GitLabApiException if any exception occurs
69+
*/
70+
public List<Runner> getRunners(Runner.RunnerStatus scope, Integer page, Integer perPage) throws GitLabApiException {
4271
GitLabApiForm formData = new GitLabApiForm()
43-
.withParam("scope", scope, false);
72+
.withParam("scope", scope, false)
73+
.withParam("page", page, false)
74+
.withParam("per_page", perPage, false);
4475
Response response = get(Response.Status.OK, formData.asMap(), "runners");
4576
return (response.readEntity(new GenericType<List<Runner>>() {
4677
}));
@@ -84,7 +115,7 @@ public Pager<Runner> getRunners(Runner.RunnerStatus scope, int itemsPerPage) thr
84115
* @throws GitLabApiException if any exception occurs
85116
*/
86117
public List<Runner> getAllRunners() throws GitLabApiException {
87-
return getAllRunners(null);
118+
return getAllRunners(null, null, null);
88119
}
89120

90121
/**
@@ -97,8 +128,38 @@ public List<Runner> getAllRunners() throws GitLabApiException {
97128
* @throws GitLabApiException if any exception occurs
98129
*/
99130
public List<Runner> getAllRunners(Runner.RunnerStatus scope) throws GitLabApiException {
131+
return getAllRunners(scope, null, null);
132+
}
133+
134+
/**
135+
* Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
136+
*
137+
* GET /runners/all
138+
*
139+
* @param page The page offset of runners
140+
* @param perPage The number of runners to get after the page offset * @return List of Runners
141+
* @throws GitLabApiException if any exception occurs
142+
*/
143+
public List<Runner> getAllRunners(int page, int perPage) throws GitLabApiException {
144+
return getAllRunners(null, page, perPage);
145+
}
146+
147+
/**
148+
* Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
149+
*
150+
* GET /runners/all
151+
*
152+
* @param scope The scope of specific runners to show, one of: active, paused, online; showing all runners null
153+
* @param page The page offset of runners
154+
* @param perPage The number of runners to get after the page offset
155+
* @return List of Runners
156+
* @throws GitLabApiException if any exception occurs
157+
*/
158+
public List<Runner> getAllRunners(Runner.RunnerStatus scope, Integer page, Integer perPage) throws GitLabApiException {
100159
GitLabApiForm formData = new GitLabApiForm()
101-
.withParam("scope", scope, false);
160+
.withParam("scope", scope, false)
161+
.withParam("page", page, false)
162+
.withParam("per_page", perPage, false);
102163
Response response = get(Response.Status.OK, formData.asMap(), "runners", "all");
103164
return (response.readEntity(new GenericType<List<Runner>>() {
104165
}));
@@ -133,6 +194,7 @@ public Pager<Runner> getAllRunners(Runner.RunnerStatus scope, int itemsPerPage)
133194
return (new Pager<>(this, Runner.class, itemsPerPage, formData.asMap(), "runners"));
134195
}
135196

197+
136198
/**
137199
* Get details of a runner.
138200
*
@@ -296,7 +358,7 @@ public List<Runner> getProjectRunners(Integer projectId) throws GitLabApiExcepti
296358
*
297359
* GET /projects/:id/runners
298360
*
299-
* @param projectId The ID of the project owned by the authenticated user
361+
* @param projectId The ID of the project owned by the authenticated user
300362
* @param itemsPerPage the number of Project instances that will be fetched per page
301363
* @return Pager of all Runner available in the project
302364
* @throws GitLabApiException if any exception occurs

0 commit comments

Comments
 (0)