Commit a50caee0 authored by Greg Messner's avatar Greg Messner
Browse files

Added getVersion() API call.

parent 50c190b3
......@@ -2,7 +2,12 @@ package org.gitlab4j.api;
import java.util.Map;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.gitlab4j.api.models.Group;
import org.gitlab4j.api.models.Session;
import org.gitlab4j.api.models.Version;
/**
* This class is provides a simplified interface to a GitLab API server, and divides the API up into
......@@ -233,6 +238,24 @@ public class GitLabApi {
GitLabApiClient getApiClient() {
return (apiClient);
}
/**
* Get the version info for the GitLab server using the GitLab Version API.
*
* @return the version info for the GitLab server
* @throws GitLabApiException if any exception occurs
*/
public Version getVersion() throws GitLabApiException {
class VersionApi extends AbstractApi {
VersionApi(GitLabApi gitlabApi) {
super(gitlabApi);
}
}
Response response = new VersionApi(this).get(Response.Status.OK, null, "version");
return (response.readEntity(Version.class));
}
/**
* Gets the CommitsApi instance owned by this GitLabApi instance. The CommitsApi is used
......
......@@ -15,6 +15,7 @@ import java.util.List;
import org.gitlab4j.api.GitLabApi.ApiVersion;
import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.Version;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
......@@ -104,6 +105,15 @@ public class TestGitLabApi {
assumeTrue(gitLabApi != null);
}
@Test
public void testGetVersion() throws GitLabApiException {
Version version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("version=%s, revision=%s%n", version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
}
@Test
public void testProjects() throws GitLabApiException {
List<Project> projects = gitLabApi.getProjectApi().getProjects();
......
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