Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ interface ServerApi {
stopCause: ServerStopCause = ServerStopCause.API_STOP
): CompletableFuture<List<Server>>

/**
* @param server the [Server] to update.
* @return the updated [Server].
*/
fun updateServer(server: Server): CompletableFuture<Server>

/**
* @param id the id of the server.
* @param state the new state of the server.
Expand Down Expand Up @@ -218,6 +224,12 @@ interface ServerApi {
stopCause: ServerStopCause = ServerStopCause.API_STOP
): List<Server>

/**
* @param server the [Server] to update.
* @return the updated [Server].
*/
suspend fun updateServer(server: Server): Server

/**
* @param id the id of the server.
* @param state the new state of the server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ class ServerApiCoroutineImpl(
}
}

override suspend fun updateServer(server: Server): Server {
return Server.fromDefinition(
serverServiceStub.updateServer(updateServerRequest {
this.server = server.toDefinition()
})
)
}

override suspend fun updateServerState(id: String, state: ServerState): Server {
return Server.fromDefinition(
serverServiceStub.updateServerState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ class ServerApiFutureImpl(
}
}

override fun updateServer(server: Server): CompletableFuture<Server> {
return serverServiceStub.updateServer(
UpdateServerRequest.newBuilder()
.setServer(server.toDefinition())
.build()
).toCompletable().thenApply {
return@thenApply Server.fromDefinition(it)
}
}

override fun updateServerState(id: String, state: ServerState): CompletableFuture<Server> {
return serverServiceStub.updateServerState(
UpdateServerStateRequest.newBuilder()
Expand Down