-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
201 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.gitlab4j.api; | ||
|
||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.Response.Status; | ||
import org.gitlab4j.api.models.Metadata; | ||
|
||
/** | ||
* This class implements the client side API for the Gitlab metadata call. | ||
* | ||
* @see <a href="https://https://docs.gitlab.com/ee/api/metadata.html">Metadata API at Gitlab</a> | ||
*/ | ||
public class MetadataApi extends AbstractApi { | ||
|
||
public MetadataApi(GitLabApi gitLabApi) { | ||
super(gitLabApi); | ||
} | ||
|
||
/** | ||
* Get Gitlab metadata | ||
* | ||
* <pre><code>Gitlab Endpoint: GET /metadata</code></pre> | ||
* | ||
* @return Gitlab metadata | ||
* @throws GitLabApiException if any exception occurs | ||
*/ | ||
public Metadata getMetadata() throws GitLabApiException { | ||
Response response = get(Status.OK, null, "metadata"); | ||
return (response.readEntity(Metadata.class)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package org.gitlab4j.api.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.gitlab4j.api.utils.JacksonJson; | ||
|
||
public class Metadata { | ||
|
||
private String version; | ||
private String revision; | ||
private Kas kas; | ||
private Boolean enterprise; | ||
|
||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
public void setVersion(String version) { | ||
this.version = version; | ||
} | ||
|
||
public String getRevision() { | ||
return revision; | ||
} | ||
|
||
public void setRevision(String revision) { | ||
this.revision = revision; | ||
} | ||
|
||
public Kas getKas() { | ||
return kas; | ||
} | ||
|
||
public void setKas(Kas kas) { | ||
this.kas = kas; | ||
} | ||
|
||
public Boolean getEnterprise() { | ||
return enterprise; | ||
} | ||
|
||
public void setEnterprise(Boolean enterprise) { | ||
this.enterprise = enterprise; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return (JacksonJson.toJsonString(this)); | ||
} | ||
|
||
private static class Kas { | ||
|
||
private Boolean enabled; | ||
@JsonProperty("externalUrl") | ||
private String externalUrl; | ||
private String version; | ||
|
||
public Boolean getEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(Boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public String getExternalUrl() { | ||
return externalUrl; | ||
} | ||
|
||
public void setExternalUrl(String externalUrl) { | ||
this.externalUrl = externalUrl; | ||
} | ||
|
||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
public void setVersion(String version) { | ||
this.version = version; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return (JacksonJson.toJsonString(this)); | ||
} | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.gitlab4j.api; | ||
|
||
import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||
|
||
import org.gitlab4j.api.models.Metadata; | ||
import org.gitlab4j.api.models.Project; | ||
import org.gitlab4j.api.models.User; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@Tag("integration") | ||
@ExtendWith(SetupIntegrationTestExtension.class) | ||
@Disabled("Required Gitlab version not less then 15.6") | ||
public class TestMetadataApi extends AbstractIntegrationTest { | ||
|
||
private static GitLabApi gitLabApi; | ||
private static Project testProject; | ||
private static User currentUser; | ||
|
||
public TestMetadataApi() { | ||
super(); | ||
} | ||
|
||
@BeforeAll | ||
public static void setup() { | ||
gitLabApi = baseTestSetup(); | ||
testProject = getTestProject(); | ||
currentUser = getCurrentUser(); | ||
} | ||
|
||
@BeforeEach | ||
public void beforeMethod() { | ||
assumeTrue(gitLabApi != null); | ||
} | ||
|
||
@Test | ||
public void testGetMetadata() throws GitLabApiException { | ||
Metadata metadata = gitLabApi.getMetadataApi().getMetadata(); | ||
System.out.println("METADATA +\n" + metadata); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"version": "15.11.13", | ||
"revision": "cc3748fcd2d", | ||
"kas": { | ||
"enabled": true, | ||
"externalUrl": "ws://820bd8a8b4f6/-/kubernetes-agent/", | ||
"version": "v15.11.0" | ||
}, | ||
"enterprise": false | ||
} |