|
1 | 1 | package app.simplecloud.controller.api |
2 | 2 |
|
3 | 3 | import app.simplecloud.controller.shared.group.Group |
4 | | -import build.buf.gen.simplecloud.controller.v1.ServerType |
5 | 4 | import app.simplecloud.controller.shared.server.Server |
6 | 5 | import build.buf.gen.simplecloud.controller.v1.ServerStartCause |
7 | 6 | import build.buf.gen.simplecloud.controller.v1.ServerState |
8 | 7 | import build.buf.gen.simplecloud.controller.v1.ServerStopCause |
| 8 | +import build.buf.gen.simplecloud.controller.v1.ServerType |
9 | 9 | import java.util.concurrent.CompletableFuture |
10 | 10 |
|
11 | 11 | interface ServerApi { |
@@ -52,21 +52,54 @@ interface ServerApi { |
52 | 52 | * @param groupName the group name of the group the new server should be of. |
53 | 53 | * @return a [CompletableFuture] with a [Server] or null. |
54 | 54 | */ |
55 | | - fun startServer(groupName: String, startCause: ServerStartCause = ServerStartCause.API_START): CompletableFuture<Server?> |
| 55 | + fun startServer( |
| 56 | + groupName: String, |
| 57 | + startCause: ServerStartCause = ServerStartCause.API_START |
| 58 | + ): CompletableFuture<Server?> |
56 | 59 |
|
57 | 60 | /** |
58 | 61 | * @param groupName the group name of the servers group. |
59 | 62 | * @param numericalId the numerical id of the server. |
60 | 63 | * @return a [CompletableFuture] with the stopped [Server]. |
61 | 64 | */ |
62 | | - fun stopServer(groupName: String, numericalId: Long, stopCause: ServerStopCause = ServerStopCause.API_STOP): CompletableFuture<Server> |
| 65 | + fun stopServer( |
| 66 | + groupName: String, |
| 67 | + numericalId: Long, |
| 68 | + stopCause: ServerStopCause = ServerStopCause.API_STOP |
| 69 | + ): CompletableFuture<Server> |
63 | 70 |
|
64 | 71 | /** |
65 | 72 | * @param id the id of the server. |
66 | 73 | * @return a [CompletableFuture] with the stopped [Server]. |
67 | 74 | */ |
68 | 75 | fun stopServer(id: String, stopCause: ServerStopCause = ServerStopCause.API_STOP): CompletableFuture<Server> |
69 | 76 |
|
| 77 | + /** |
| 78 | + * Stops all servers within a specified group. |
| 79 | + * |
| 80 | + * @param groupName The name of the server group to stop. |
| 81 | + * @param stopCause The reason for stopping the servers. Defaults to [ServerStopCause.API_STOP]. |
| 82 | + * @return A [CompletableFuture] containing a list of stopped [Server] instances. |
| 83 | + */ |
| 84 | + fun stopServers( |
| 85 | + groupName: String, |
| 86 | + stopCause: ServerStopCause = ServerStopCause.API_STOP |
| 87 | + ): CompletableFuture<List<Server>> |
| 88 | + |
| 89 | + /** |
| 90 | + * Stops all servers within a specified group and sets a timeout to prevent new server starts for the group. |
| 91 | + * |
| 92 | + * @param groupName The name of the server group to stop. |
| 93 | + * @param timeoutSeconds The duration (in seconds) for which new server starts will be prevented. |
| 94 | + * @param stopCause The reason for stopping the servers. Defaults to [ServerStopCause.API_STOP]. |
| 95 | + * @return A [CompletableFuture] containing a list of stopped [Server] instances. |
| 96 | + */ |
| 97 | + fun stopServers( |
| 98 | + groupName: String, |
| 99 | + timeoutSeconds: Int, |
| 100 | + stopCause: ServerStopCause = ServerStopCause.API_STOP |
| 101 | + ): CompletableFuture<List<Server>> |
| 102 | + |
70 | 103 | /** |
71 | 104 | * @param id the id of the server. |
72 | 105 | * @param state the new state of the server. |
@@ -145,6 +178,32 @@ interface ServerApi { |
145 | 178 | */ |
146 | 179 | suspend fun stopServer(id: String, stopCause: ServerStopCause = ServerStopCause.API_STOP): Server |
147 | 180 |
|
| 181 | + /** |
| 182 | + * Stops all servers within a specified group. |
| 183 | + * |
| 184 | + * @param groupName The name of the server group to stop. |
| 185 | + * @param stopCause The reason for stopping the servers. Defaults to [ServerStopCause.API_STOP]. |
| 186 | + * @return A list of stopped [Server] instances. |
| 187 | + */ |
| 188 | + suspend fun stopServers( |
| 189 | + groupName: String, |
| 190 | + stopCause: ServerStopCause = ServerStopCause.API_STOP |
| 191 | + ): List<Server> |
| 192 | + |
| 193 | + /** |
| 194 | + * Stops all servers within a specified group and sets a timeout to prevent new server starts for the group. |
| 195 | + * |
| 196 | + * @param groupName The name of the server group to stop. |
| 197 | + * @param timeoutSeconds The duration (in seconds) for which new server starts will be prevented. |
| 198 | + * @param stopCause The reason for stopping the servers. Defaults to [ServerStopCause.API_STOP]. |
| 199 | + * @return A list of stopped [Server] instances. |
| 200 | + */ |
| 201 | + suspend fun stopServers( |
| 202 | + groupName: String, |
| 203 | + timeoutSeconds: Int, |
| 204 | + stopCause: ServerStopCause = ServerStopCause.API_STOP |
| 205 | + ): List<Server> |
| 206 | + |
148 | 207 | /** |
149 | 208 | * @param id the id of the server. |
150 | 209 | * @param state the new state of the server. |
|
0 commit comments