| 437 | } |
| 438 | |
| 439 | void mitk::MonaiLabelTool::FetchOverallInfo(const std::string &hostName, const int &port) |
| 440 | { |
| 441 | m_InfoParameters.reset(); |
| 442 | if (!IsMonaiServerOn(hostName, port)) |
| 443 | { |
| 444 | Tool::ErrorMessage.Send(m_SERVER_503_ERROR_TEXT); |
| 445 | mitkThrow() << m_SERVER_503_ERROR_TEXT; |
| 446 | } |
| 447 | httplib::SSLClient cli(hostName, port); |
| 448 | cli.enable_server_certificate_verification(false); |
| 449 | if (auto response = cli.Get("/info/")) |
| 450 | { |
| 451 | if (response->status == 200) |
| 452 | { |
| 453 | auto jsonObj = nlohmann::json::parse(response->body); |
| 454 | if (jsonObj.is_discarded() || !jsonObj.is_object()) |
| 455 | { |
| 456 | MITK_ERROR << "Could not parse response from MONAILabel server as JSON object!"; |
| 457 | return; |
| 458 | } |
| 459 | auto appData = jsonObj.template get<mitk::MonaiAppMetadata>(); |
| 460 | m_InfoParameters = std::make_unique<mitk::MonaiAppMetadata>(appData); |
| 461 | if (nullptr != m_InfoParameters) |
| 462 | { |
| 463 | m_InfoParameters->hostName = hostName; |
| 464 | m_InfoParameters->port = port; |
| 465 | } |
| 466 | } |
| 467 | } |
| 468 | else |
| 469 | { |
| 470 | Tool::ErrorMessage.Send(httplib::to_string(response.error()) + " error occurred."); |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | void mitk::MonaiLabelTool::PostInferRequest(const std::string &hostName, |
| 475 | const int &port, |
no test coverage detected