|
7 | 7 | import java.net.URL; |
8 | 8 |
|
9 | 9 | public class HealthCheckApi extends AbstractApi { |
| 10 | + |
10 | 11 | public HealthCheckApi(GitLabApi gitLabApi) { |
11 | 12 | super(gitLabApi); |
12 | 13 | } |
13 | 14 |
|
14 | 15 | /** |
15 | 16 | * Get Health Checks from the liveness endpoint. |
16 | 17 | * |
17 | | - * Requires ip_whitelist |
18 | | - * https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html |
| 18 | + * Requires ip_whitelist, see the following link for more info: |
| 19 | + * See <a href="https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html">https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html</a> |
19 | 20 | * |
20 | 21 | * GET /-/liveness |
21 | 22 | * |
22 | 23 | * @return HealthCheckInfo instance |
23 | 24 | * @throws GitLabApiException if any exception occurs |
24 | 25 | */ |
25 | | - public HealthCheckInfo getLiveness() throws GitLabApiException, IOException { |
26 | | - URL livenessUrl = getApiClient().getUrlWithBase("-", "liveness"); |
27 | | - Response response = get(Response.Status.OK, null, livenessUrl); |
28 | | - return (response.readEntity(HealthCheckInfo.class)); |
| 26 | + public HealthCheckInfo getLiveness() throws GitLabApiException { |
| 27 | + return (getLiveness(null)); |
29 | 28 | } |
30 | 29 |
|
31 | 30 | /** |
32 | 31 | * Get Health Checks from the liveness endpoint. |
33 | 32 | * |
34 | | - * Requires ip_whitelist |
35 | | - * https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html |
36 | | - * |
37 | 33 | * GET /-/liveness |
38 | 34 | * |
39 | 35 | * @param token Health Status token |
40 | 36 | * @return HealthCheckInfo instance |
41 | 37 | * @throws GitLabApiException if any exception occurs |
42 | 38 | * @deprecated |
43 | 39 | */ |
44 | | - public HealthCheckInfo getLiveness(String token) throws GitLabApiException, IOException { |
45 | | - URL livenessUrl = getApiClient().getUrlWithBase("-", "liveness"); |
46 | | - GitLabApiForm formData = new GitLabApiForm() |
47 | | - .withParam("token", token, false); |
48 | | - Response response = get(Response.Status.OK, formData.asMap(), livenessUrl); |
49 | | - return (response.readEntity(HealthCheckInfo.class)); |
| 40 | + public HealthCheckInfo getLiveness(String token) throws GitLabApiException { |
| 41 | + try { |
| 42 | + URL livenessUrl = getApiClient().getUrlWithBase("-", "liveness"); |
| 43 | + GitLabApiForm formData = new GitLabApiForm().withParam("token", token, false); |
| 44 | + Response response = get(Response.Status.OK, formData.asMap(), livenessUrl); |
| 45 | + return (response.readEntity(HealthCheckInfo.class)); |
| 46 | + } catch (IOException ioe) { |
| 47 | + throw (new GitLabApiException(ioe)); |
| 48 | + } |
50 | 49 | } |
51 | 50 |
|
52 | 51 | /** |
53 | 52 | * Get Health Checks from the readiness endpoint. |
54 | 53 | * |
55 | | - * Requires ip_whitelist |
56 | | - * https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html |
| 54 | + * Requires ip_whitelist, see the following link for more info: |
| 55 | + * See <a href="https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html">https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html</a> |
57 | 56 | * |
58 | 57 | * GET /-/readiness |
59 | 58 | * |
60 | 59 | * @return HealthCheckInfo instance |
61 | 60 | * @throws GitLabApiException if any exception occurs |
62 | 61 | */ |
63 | | - public HealthCheckInfo getReadiness() throws GitLabApiException, IOException { |
64 | | - URL readinessUrl = getApiClient().getUrlWithBase("-", "readiness"); |
65 | | - Response response = get(Response.Status.OK, null, readinessUrl); |
66 | | - return (response.readEntity(HealthCheckInfo.class)); |
| 62 | + public HealthCheckInfo getReadiness() throws GitLabApiException { |
| 63 | + return (getReadiness(null)); |
67 | 64 | } |
68 | 65 |
|
69 | 66 | /** |
70 | 67 | * Get Health Checks from the readiness endpoint. |
71 | 68 | * |
72 | | - * Requires ip_whitelist |
73 | | - * https://docs.gitlab.com/ee/administration/monitoring/ip_whitelist.html |
74 | | - * |
75 | 69 | * GET /-/readiness |
76 | 70 | * |
77 | 71 | * @param token Health Status token |
78 | 72 | * @return HealthCheckInfo instance |
79 | 73 | * @throws GitLabApiException if any exception occurs |
80 | 74 | * @deprecated |
81 | 75 | */ |
82 | | - public HealthCheckInfo getReadiness(String token) throws GitLabApiException, IOException { |
83 | | - URL readinessUrl = getApiClient().getUrlWithBase("-", "readiness"); |
84 | | - GitLabApiForm formData = new GitLabApiForm() |
85 | | - .withParam("token", token, false); |
86 | | - Response response = get(Response.Status.OK, formData.asMap(), readinessUrl); |
87 | | - return (response.readEntity(HealthCheckInfo.class)); |
| 76 | + public HealthCheckInfo getReadiness(String token) throws GitLabApiException { |
| 77 | + try { |
| 78 | + URL readinessUrl = getApiClient().getUrlWithBase("-", "readiness"); |
| 79 | + GitLabApiForm formData = new GitLabApiForm().withParam("token", token, false); |
| 80 | + Response response = get(Response.Status.OK, formData.asMap(), readinessUrl); |
| 81 | + return (response.readEntity(HealthCheckInfo.class)); |
| 82 | + } catch (IOException ioe) { |
| 83 | + throw (new GitLabApiException(ioe)); |
| 84 | + } |
88 | 85 | } |
89 | 86 | } |
0 commit comments