31 lines
891 B
Swift
31 lines
891 B
Swift
//
|
|
// APIv2_14.swift
|
|
// iKeyMon
|
|
//
|
|
// Created by tracer on 19.04.26.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class APIv2_14: APIv2_13 {
|
|
private enum Endpoint: String {
|
|
case serverReboot = "/api/v2/server/reboot"
|
|
|
|
func url(baseURL: URL) -> URL {
|
|
baseURL.appendingPathComponent(rawValue)
|
|
}
|
|
}
|
|
|
|
override func restartServer(apiKey: String) async throws {
|
|
var request = URLRequest(url: Endpoint.serverReboot.url(baseURL: baseURL))
|
|
request.httpMethod = "POST"
|
|
request.setValue(apiKey, forHTTPHeaderField: "X-API-KEY")
|
|
request.setValue("application/json", forHTTPHeaderField: "Accept")
|
|
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
|
request.timeoutInterval = 30
|
|
request.httpBody = #"{"confirm":true}"#.data(using: .utf8)
|
|
|
|
try await performRequestWithoutBody(request)
|
|
}
|
|
}
|