new: pve ctrl (#307)

This commit is contained in:
lollipopkit
2024-03-19 01:00:28 -06:00
parent 2597f99571
commit 48fdf4cc84
4 changed files with 331 additions and 123 deletions

View File

@@ -135,4 +135,36 @@ final class PveProvider extends ChangeNotifier {
data.value = res;
return res;
}
Future<bool> reboot(String node, String id) async {
await connected.future;
final resp =
await session.post('$addr/api2/json/nodes/$node/$id/status/reboot');
return _isCtrlSuc(resp);
}
Future<bool> start(String node, String id) async {
await connected.future;
final resp =
await session.post('$addr/api2/json/nodes/$node/$id/status/start');
return _isCtrlSuc(resp);
}
Future<bool> stop(String node, String id) async {
await connected.future;
final resp =
await session.post('$addr/api2/json/nodes/$node/$id/status/stop');
return _isCtrlSuc(resp);
}
Future<bool> shutdown(String node, String id) async {
await connected.future;
final resp =
await session.post('$addr/api2/json/nodes/$node/$id/status/shutdown');
return _isCtrlSuc(resp);
}
bool _isCtrlSuc(Response resp) {
return resp.statusCode == 200;
}
}