Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
a50caee0
Commit
a50caee0
authored
Jun 20, 2017
by
Greg Messner
Browse files
Added getVersion() API call.
parent
50c190b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GitLabApi.java
View file @
a50caee0
...
...
@@ -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
...
...
src/test/java/org/gitlab4j/api/TestGitLabApi.java
View file @
a50caee0
...
...
@@ -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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment