in server/lib/controllers/WorkstationsController.dart [178:220]
Future<Response> _createWorkstationHandler(Request request) async {
try {
String clusterName = request.params['clusterName']!;
String configName = request.params['configName']!;
String workstationName = request.params['workstationName']!;
String projectId = request.url.queryParameters['projectId']!;
String region = request.url.queryParameters['region']!;
final body = await request.readAsString();
Map<String, dynamic> requestMap = jsonDecode(body);
String email = requestMap["email"];
http.Response response = await _workstationsService.createWorkstation(projectId, clusterName, configName, workstationName, region);
if (response.statusCode != HttpStatus.ok) {
print(response);
return Response.internalServerError(
body: jsonResponseEncode({"msg": "Failed to create workstation"}),
);
}
response = await _workstationsService.grantAccessForUser(projectId, clusterName, configName, workstationName, region, email);
if (response.statusCode == HttpStatus.ok) {
return Response.ok(
jsonResponseEncode({"msg": "Workstation created"}),
);
} else {
print(response);
return Response.internalServerError(
body: jsonResponseEncode({"msg": "Failed to grant workstation access"}),
);
}
} on Exception catch (e, stacktrace) {
print("Exception occurred: $e stackTrace: $stacktrace");
return Response.internalServerError(
body: jsonResponseEncode({"msg": "Internal Server Error"}),
);
}
}