feat: add remote reboot support
This commit is contained in:
@@ -10,6 +10,7 @@ import Foundation
|
||||
enum APIVersion: String, CaseIterable {
|
||||
case v2_12 = "2.12"
|
||||
case v2_13 = "2.13"
|
||||
case v2_14 = "2.14"
|
||||
|
||||
static func from(versionString: String) -> APIVersion? {
|
||||
if let version = APIVersion(rawValue: versionString) {
|
||||
@@ -24,7 +25,8 @@ enum APIVersion: String, CaseIterable {
|
||||
|
||||
switch (major, minor) {
|
||||
case (2, 12): return .v2_12
|
||||
case (2, 13...): return .v2_13
|
||||
case (2, 13): return .v2_13
|
||||
case (2, 14...): return .v2_14
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
@@ -36,6 +38,7 @@ protocol AnyServerAPI {
|
||||
func fetchMemoryData() async throws -> Any
|
||||
func fetchUtilizationData() async throws -> Any
|
||||
func fetchServerSummary(apiKey: String) async throws -> ServerInfo
|
||||
func restartServer(apiKey: String) async throws
|
||||
}
|
||||
|
||||
private struct AnyServerAPIWrapper<T: ServerAPIProtocol>: AnyServerAPI {
|
||||
@@ -64,6 +67,10 @@ private struct AnyServerAPIWrapper<T: ServerAPIProtocol>: AnyServerAPI {
|
||||
func fetchServerSummary(apiKey: String) async throws -> ServerInfo {
|
||||
return try await wrapped.fetchServerSummary(apiKey: apiKey)
|
||||
}
|
||||
|
||||
func restartServer(apiKey: String) async throws {
|
||||
try await wrapped.restartServer(apiKey: apiKey)
|
||||
}
|
||||
}
|
||||
|
||||
class APIFactory {
|
||||
@@ -73,6 +80,8 @@ class APIFactory {
|
||||
return AnyServerAPIWrapper(APIv2_12(baseURL: baseURL))
|
||||
case .v2_13:
|
||||
return AnyServerAPIWrapper(APIv2_13(baseURL: baseURL))
|
||||
case .v2_14:
|
||||
return AnyServerAPIWrapper(APIv2_14(baseURL: baseURL))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +113,7 @@ class APIFactory {
|
||||
}
|
||||
}
|
||||
|
||||
return AnyServerAPIWrapper(APIv2_13(baseURL: baseURL))
|
||||
return AnyServerAPIWrapper(APIv2_14(baseURL: baseURL))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user