exec method
Future<Map<String, dynamic>>
exec(
{ - required String name,
- required String image,
- required String? command,
- required String? pullSecret,
- String? participantName,
- String? role,
- Map<String, String>? env,
- String? roomStoragePath,
})
Implementation
Future<Map<String, dynamic>> exec({
required String name,
required String image,
required String? command,
required String? pullSecret,
String? participantName,
String? role,
Map<String, String>? env,
String? roomStoragePath,
}) async {
final ws = (protocol.channel as WebSocketProtocolChannel);
final baseUrl = ws.url.toString();
final uri = Uri.parse('$baseUrl/exec').replace(scheme: ws.url.scheme.replaceAll("ws", "http"));
final response = await post(
uri,
headers: {"Authorization": "Bearer ${ws.jwt}"},
body: jsonEncode({
"image": image,
"name": name,
"command": command,
"pull_secret": pullSecret,
"env": env,
"room_storage_path": roomStoragePath,
"participant_name": participantName,
"role": role,
}),
);
if (response.statusCode >= 400) {
throw Exception(
'Failed to execute. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
return jsonDecode(response.body) as Map<String, dynamic>;
}