Commit bab4bb6a authored by David Lam's avatar David Lam Committed by Greg Messner
Browse files

Controlled Pagination for Runners (#179)

parent 6a365b6b
...@@ -26,11 +26,11 @@ public class RunnersApi extends AbstractApi { ...@@ -26,11 +26,11 @@ public class RunnersApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<Runner> getRunners() throws GitLabApiException { public List<Runner> getRunners() throws GitLabApiException {
return getRunners(null); return getRunners(null, null, null);
} }
/** /**
* Get a list of specific runners available to the user. * Get a list of all available runners available to the user with pagination support.
* *
* GET /runners * GET /runners
* *
...@@ -39,8 +39,39 @@ public class RunnersApi extends AbstractApi { ...@@ -39,8 +39,39 @@ public class RunnersApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<Runner> getRunners(Runner.RunnerStatus scope) throws GitLabApiException { public List<Runner> getRunners(Runner.RunnerStatus scope) throws GitLabApiException {
return getRunners(scope, null, null);
}
/**
* Get a list of all available runners available to the user with pagination support.
*
* GET /runners
*
* @param page The page offset of runners
* @param perPage The number of runners to get after the page offset
* @return List of Runners
* @throws GitLabApiException if any exception occurs
*/
public List<Runner> getRunners(int page, int perPage) throws GitLabApiException {
return getRunners(null, page, perPage);
}
/**
* Get a list of specific runners available to the user.
*
* GET /runners
*
* @param scope The scope of specific runners to show, one of: active, paused, online; showing all runners null
* @param page The page offset of runners
* @param perPage The number of runners to get after the page offset
* @return List of Runners
* @throws GitLabApiException if any exception occurs
*/
public List<Runner> getRunners(Runner.RunnerStatus scope, Integer page, Integer perPage) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("scope", scope, false); .withParam("scope", scope, false)
.withParam("page", page, false)
.withParam("per_page", perPage, false);
Response response = get(Response.Status.OK, formData.asMap(), "runners"); Response response = get(Response.Status.OK, formData.asMap(), "runners");
return (response.readEntity(new GenericType<List<Runner>>() { return (response.readEntity(new GenericType<List<Runner>>() {
})); }));
...@@ -84,7 +115,7 @@ public class RunnersApi extends AbstractApi { ...@@ -84,7 +115,7 @@ public class RunnersApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<Runner> getAllRunners() throws GitLabApiException { public List<Runner> getAllRunners() throws GitLabApiException {
return getAllRunners(null); return getAllRunners(null, null, null);
} }
/** /**
...@@ -97,8 +128,38 @@ public class RunnersApi extends AbstractApi { ...@@ -97,8 +128,38 @@ public class RunnersApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public List<Runner> getAllRunners(Runner.RunnerStatus scope) throws GitLabApiException { public List<Runner> getAllRunners(Runner.RunnerStatus scope) throws GitLabApiException {
return getAllRunners(scope, null, null);
}
/**
* Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
*
* GET /runners/all
*
* @param page The page offset of runners
* @param perPage The number of runners to get after the page offset * @return List of Runners
* @throws GitLabApiException if any exception occurs
*/
public List<Runner> getAllRunners(int page, int perPage) throws GitLabApiException {
return getAllRunners(null, page, perPage);
}
/**
* Get a list of all runners in the GitLab instance (specific and shared). Access is restricted to users with admin privileges.
*
* GET /runners/all
*
* @param scope The scope of specific runners to show, one of: active, paused, online; showing all runners null
* @param page The page offset of runners
* @param perPage The number of runners to get after the page offset
* @return List of Runners
* @throws GitLabApiException if any exception occurs
*/
public List<Runner> getAllRunners(Runner.RunnerStatus scope, Integer page, Integer perPage) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("scope", scope, false); .withParam("scope", scope, false)
.withParam("page", page, false)
.withParam("per_page", perPage, false);
Response response = get(Response.Status.OK, formData.asMap(), "runners", "all"); Response response = get(Response.Status.OK, formData.asMap(), "runners", "all");
return (response.readEntity(new GenericType<List<Runner>>() { return (response.readEntity(new GenericType<List<Runner>>() {
})); }));
...@@ -133,6 +194,7 @@ public class RunnersApi extends AbstractApi { ...@@ -133,6 +194,7 @@ public class RunnersApi extends AbstractApi {
return (new Pager<>(this, Runner.class, itemsPerPage, formData.asMap(), "runners")); return (new Pager<>(this, Runner.class, itemsPerPage, formData.asMap(), "runners"));
} }
/** /**
* Get details of a runner. * Get details of a runner.
* *
...@@ -296,7 +358,7 @@ public class RunnersApi extends AbstractApi { ...@@ -296,7 +358,7 @@ public class RunnersApi extends AbstractApi {
* *
* GET /projects/:id/runners * GET /projects/:id/runners
* *
* @param projectId The ID of the project owned by the authenticated user * @param projectId The ID of the project owned by the authenticated user
* @param itemsPerPage the number of Project instances that will be fetched per page * @param itemsPerPage the number of Project instances that will be fetched per page
* @return Pager of all Runner available in the project * @return Pager of all Runner available in the project
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment