Skip to content

Commit 743d1a7

Browse files
committed
simplified HealthCheck classes
1 parent 2e15348 commit 743d1a7

File tree

8 files changed

+151
-204
lines changed

8 files changed

+151
-204
lines changed
Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.gitlab4j.api;
22

3-
import org.gitlab4j.api.models.LivenessHealthCheck;
4-
import org.gitlab4j.api.models.ReadinessHealthCheck;
3+
import org.gitlab4j.api.models.HealthCheckInfo;
54

65
import javax.ws.rs.core.Response;
76
import java.io.IOException;
@@ -14,67 +13,77 @@ public HealthCheckApi(GitLabApi gitLabApi) {
1413

1514
/**
1615
* Get Health Checks from the liveness endpoint.
16+
*
1717
* Requires ip_whitelist
18+
* https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html
1819
*
1920
* GET /-/liveness
2021
*
21-
* @return LivenessHealthCheck instance
22+
* @return HealthCheckInfo instance
2223
* @throws GitLabApiException if any exception occurs
2324
*/
24-
public LivenessHealthCheck getLiveness() throws GitLabApiException, IOException {
25+
public HealthCheckInfo getLiveness() throws GitLabApiException, IOException {
2526
URL livenessUrl = getApiClient().getUrlWithBase("-", "liveness");
2627
Response response = get(Response.Status.OK, null, livenessUrl);
27-
return (response.readEntity(LivenessHealthCheck.class));
28+
return (response.readEntity(HealthCheckInfo.class));
2829
}
2930

3031
/**
3132
* Get Health Checks from the liveness endpoint.
3233
*
34+
* Requires ip_whitelist
35+
* https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html
36+
*
3337
* GET /-/liveness
3438
*
3539
* @param token Health Status token
36-
* @return LivenessHealthCheck instance
40+
* @return HealthCheckInfo instance
3741
* @throws GitLabApiException if any exception occurs
3842
* @deprecated
3943
*/
40-
public LivenessHealthCheck getLiveness(String token) throws GitLabApiException, IOException {
44+
public HealthCheckInfo getLiveness(String token) throws GitLabApiException, IOException {
4145
URL livenessUrl = getApiClient().getUrlWithBase("-", "liveness");
4246
GitLabApiForm formData = new GitLabApiForm()
4347
.withParam("token", token, false);
4448
Response response = get(Response.Status.OK, formData.asMap(), livenessUrl);
45-
return (response.readEntity(LivenessHealthCheck.class));
49+
return (response.readEntity(HealthCheckInfo.class));
4650
}
4751

4852
/**
4953
* Get Health Checks from the readiness endpoint.
54+
*
5055
* Requires ip_whitelist
56+
* https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html
5157
*
5258
* GET /-/readiness
5359
*
54-
* @return ReadinessHealthCheck instance
60+
* @return HealthCheckInfo instance
5561
* @throws GitLabApiException if any exception occurs
5662
*/
57-
public ReadinessHealthCheck getReadiness() throws GitLabApiException, IOException {
63+
public HealthCheckInfo getReadiness() throws GitLabApiException, IOException {
5864
URL readinessUrl = getApiClient().getUrlWithBase("-", "readiness");
5965
Response response = get(Response.Status.OK, null, readinessUrl);
60-
return (response.readEntity(ReadinessHealthCheck.class));
66+
return (response.readEntity(HealthCheckInfo.class));
6167
}
6268

6369
/**
6470
* Get Health Checks from the readiness endpoint.
6571
*
72+
* Requires ip_whitelist
73+
* https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html
74+
*
6675
* GET /-/readiness
6776
*
6877
* @param token Health Status token
69-
* @return LivenessHealthCheck instance
78+
* @return HealthCheckInfo instance
7079
* @throws GitLabApiException if any exception occurs
7180
* @deprecated
7281
*/
73-
public ReadinessHealthCheck getReadiness(String token) throws GitLabApiException, IOException {
82+
public HealthCheckInfo getReadiness(String token) throws GitLabApiException, IOException {
7483
URL readinessUrl = getApiClient().getUrlWithBase("-", "readiness");
7584
GitLabApiForm formData = new GitLabApiForm()
7685
.withParam("token", token, false);
7786
Response response = get(Response.Status.OK, formData.asMap(), readinessUrl);
78-
return (response.readEntity(ReadinessHealthCheck.class));
87+
return (response.readEntity(HealthCheckInfo.class));
7988
}
8089
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.gitlab4j.api.models;
2+
3+
import javax.xml.bind.annotation.XmlAccessType;
4+
import javax.xml.bind.annotation.XmlAccessorType;
5+
import javax.xml.bind.annotation.XmlRootElement;
6+
7+
@XmlRootElement
8+
@XmlAccessorType(XmlAccessType.FIELD)
9+
public class HealthCheckInfo {
10+
private HealthCheckItem dbCheck;
11+
private HealthCheckItem redisCheck;
12+
private HealthCheckItem cacheCheck;
13+
private HealthCheckItem queuesCheck;
14+
private HealthCheckItem sharedStateCheck;
15+
private HealthCheckItem fsShardsCheck;
16+
private HealthCheckItem gitalyCheck;
17+
18+
public HealthCheckItem getDbCheck() {
19+
return this.dbCheck;
20+
}
21+
22+
public void setDbCheck(HealthCheckItem dbCheck) {
23+
this.dbCheck = dbCheck;
24+
}
25+
26+
public HealthCheckItem getRedisCheck() {
27+
return this.redisCheck;
28+
}
29+
30+
public void setRedisCheck(HealthCheckItem redisCheck) {
31+
this.redisCheck = redisCheck;
32+
}
33+
34+
public HealthCheckItem getCacheCheck() {
35+
return this.cacheCheck;
36+
}
37+
38+
public void setCacheCheck(HealthCheckItem cacheCheck) {
39+
this.cacheCheck = cacheCheck;
40+
}
41+
42+
public HealthCheckItem getQueuesCheck() {
43+
return this.queuesCheck;
44+
}
45+
46+
public void setQueuesCheck(HealthCheckItem queuesCheck) {
47+
this.queuesCheck = queuesCheck;
48+
}
49+
50+
public HealthCheckItem getSharedStateCheck() {
51+
return this.sharedStateCheck;
52+
}
53+
54+
public void setSharedStateCheck(HealthCheckItem sharedStateCheck) {
55+
this.sharedStateCheck = sharedStateCheck;
56+
}
57+
58+
public HealthCheckItem getFsShardsCheck() {
59+
return this.fsShardsCheck;
60+
}
61+
62+
public void setFsShardsCheck(HealthCheckItem fsShardsCheck) {
63+
this.fsShardsCheck = fsShardsCheck;
64+
}
65+
66+
public HealthCheckItem getGitalyCheck() {
67+
return this.gitalyCheck;
68+
}
69+
70+
public void setGitalyCheck(HealthCheckItem gitalyCheck) {
71+
this.gitalyCheck = gitalyCheck;
72+
}
73+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.gitlab4j.api.models;
2+
3+
import javax.xml.bind.annotation.XmlAccessType;
4+
import javax.xml.bind.annotation.XmlAccessorType;
5+
import java.util.Map;
6+
7+
@XmlAccessorType(XmlAccessType.FIELD)
8+
public class HealthCheckItem {
9+
private HealthCheckStatus status;
10+
private Map<String, String> labels;
11+
private String message;
12+
13+
public HealthCheckStatus getStatus() {
14+
return this.status;
15+
}
16+
17+
public void setStatus(HealthCheckStatus status) {
18+
this.status = status;
19+
}
20+
21+
public Map<String, String> getLabels() {
22+
return labels;
23+
}
24+
25+
public void setLabels(Map<String, String> labels) {
26+
this.labels = labels;
27+
}
28+
29+
public String getMessage() {
30+
return message;
31+
}
32+
33+
public void setMessage(String message) {
34+
this.message = message;
35+
}
36+
37+
}
Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
package org.gitlab4j.api.models;
22

3-
import javax.xml.bind.annotation.XmlAccessType;
4-
import javax.xml.bind.annotation.XmlAccessorType;
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonValue;
5+
import org.gitlab4j.api.utils.JacksonJsonEnumHelper;
56

6-
@XmlAccessorType(XmlAccessType.FIELD)
7-
public class HealthCheckStatus {
8-
private String status;
7+
public enum HealthCheckStatus {
8+
OK, FAILED;
99

10-
public String getStatus() {
11-
return this.status;
10+
private static JacksonJsonEnumHelper<HealthCheckStatus> enumHelper = new JacksonJsonEnumHelper<>(HealthCheckStatus.class);
11+
12+
@JsonCreator
13+
public static HealthCheckStatus forValue(String value) {
14+
return enumHelper.forValue(value);
15+
}
16+
17+
@JsonValue
18+
public String toValue() {
19+
return enumHelper.toString(this);
1220
}
1321

14-
public void setStatus(String status) {
15-
this.status = status;
22+
@Override
23+
public String toString() {
24+
return enumHelper.toString(this);
1625
}
1726
}

src/main/java/org/gitlab4j/api/models/HealthCheckStatusDetail.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/main/java/org/gitlab4j/api/models/HealthCheckStatusLabel.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/main/java/org/gitlab4j/api/models/LivenessHealthCheck.java

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)