Skip to content

Commit b125f79

Browse files
committed
Add health API call
1 parent f31f0d7 commit b125f79

File tree

6 files changed

+154
-4
lines changed

6 files changed

+154
-4
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ build/
55
!**/src/test/**/build/
66

77
### IntelliJ IDEA ###
8-
.idea/modules.xml
9-
.idea/jarRepositories.xml
10-
.idea/compiler.xml
11-
.idea/libraries/
8+
.idea/
129
*.iws
1310
*.iml
1411
*.ipr

src/main/java/net/luckperms/rest/LuckPermsClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import net.luckperms.rest.service.ActionService;
2929
import net.luckperms.rest.service.GroupService;
30+
import net.luckperms.rest.service.MiscService;
3031
import net.luckperms.rest.service.UserService;
3132

3233
/**
@@ -66,6 +67,13 @@ static Builder builder() {
6667
*/
6768
ActionService actions();
6869

70+
/**
71+
* Gets the misc service.
72+
*
73+
* @return the misc service.
74+
*/
75+
MiscService misc();
76+
6977
/**
7078
* A builder for {@link LuckPermsClient}
7179
*/

src/main/java/net/luckperms/rest/LuckPermsClientImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import net.luckperms.rest.service.ActionService;
2929
import net.luckperms.rest.service.GroupService;
30+
import net.luckperms.rest.service.MiscService;
3031
import net.luckperms.rest.service.UserService;
3132
import okhttp3.Interceptor;
3233
import okhttp3.OkHttpClient;
@@ -42,6 +43,7 @@ class LuckPermsClientImpl implements LuckPermsClient {
4243
private final UserService userService;
4344
private final GroupService groupService;
4445
private final ActionService actionService;
46+
private final MiscService miscService;
4547

4648
LuckPermsClientImpl(String baseUrl, String apiKey) {
4749
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
@@ -59,6 +61,7 @@ class LuckPermsClientImpl implements LuckPermsClient {
5961
this.userService = retrofit.create(UserService.class);
6062
this.groupService = retrofit.create(GroupService.class);
6163
this.actionService = retrofit.create(ActionService.class);
64+
this.miscService = retrofit.create(MiscService.class);
6265
}
6366

6467
@Override
@@ -76,6 +79,11 @@ public ActionService actions() {
7679
return this.actionService;
7780
}
7881

82+
@Override
83+
public MiscService misc() {
84+
return this.miscService;
85+
}
86+
7987
static final class BuilderImpl implements Builder {
8088
private String baseUrl = null;
8189
private String apiKey = null;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* This file is part of LuckPerms, licensed under the MIT License.
3+
*
4+
* Copyright (c) lucko (Luck) <[email protected]>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
26+
package net.luckperms.rest.model;
27+
28+
import java.util.Map;
29+
30+
public class Health extends AbstractModel {
31+
private final boolean healthy;
32+
private final Map<String, Object> details;
33+
34+
public Health(boolean healthy, Map<String, Object> details) {
35+
this.healthy = healthy;
36+
this.details = details;
37+
}
38+
39+
public boolean healthy() {
40+
return this.healthy;
41+
}
42+
43+
public Map<String, Object> details() {
44+
return this.details;
45+
}
46+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is part of LuckPerms, licensed under the MIT License.
3+
*
4+
* Copyright (c) lucko (Luck) <[email protected]>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
26+
package net.luckperms.rest.service;
27+
28+
import net.luckperms.rest.model.Health;
29+
import retrofit2.Call;
30+
import retrofit2.http.GET;
31+
32+
public interface MiscService {
33+
34+
@GET("/health")
35+
Call<Health> health();
36+
37+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of LuckPerms, licensed under the MIT License.
3+
*
4+
* Copyright (c) lucko (Luck) <[email protected]>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
26+
package me.lucko.luckperms.rest;
27+
28+
import net.luckperms.rest.LuckPermsClient;
29+
import net.luckperms.rest.model.Action;
30+
import net.luckperms.rest.model.Health;
31+
import org.junit.jupiter.api.Test;
32+
import retrofit2.Response;
33+
34+
import java.io.IOException;
35+
import java.util.UUID;
36+
37+
import static org.junit.jupiter.api.Assertions.assertNotNull;
38+
import static org.junit.jupiter.api.Assertions.assertTrue;
39+
40+
public class MiscServiceTest extends AbstractIntegrationTest {
41+
42+
@Test
43+
public void testHealth() throws IOException {
44+
LuckPermsClient client = createClient();
45+
46+
Response<Health> resp = client.misc().health().execute();
47+
assertTrue(resp.isSuccessful());
48+
49+
Health health = resp.body();
50+
assertNotNull(health);
51+
assertTrue(health.healthy());
52+
}
53+
54+
}

0 commit comments

Comments
 (0)