| 1383 | } |
| 1384 | |
| 1385 | async fn get_pilot_things_integration( |
| 1386 | &self, |
| 1387 | request: Request<api::GetPilotThingsIntegrationRequest>, |
| 1388 | ) -> Result<Response<api::GetPilotThingsIntegrationResponse>, Status> { |
| 1389 | let req = request.get_ref(); |
| 1390 | let app_id = Uuid::from_str(&req.application_id).map_err(|e| e.status())?; |
| 1391 | |
| 1392 | self.validator |
| 1393 | .validate( |
| 1394 | request.extensions(), |
| 1395 | validator::ValidateApplicationAccess::new(validator::Flag::Read, app_id), |
| 1396 | ) |
| 1397 | .await?; |
| 1398 | |
| 1399 | let i = application::get_integration(&app_id, application::IntegrationKind::PilotThings) |
| 1400 | .await |
| 1401 | .map_err(|e| e.status())?; |
| 1402 | |
| 1403 | if let application::IntegrationConfiguration::PilotThings(conf) = &i.configuration { |
| 1404 | let mut resp = Response::new(api::GetPilotThingsIntegrationResponse { |
| 1405 | integration: Some(api::PilotThingsIntegration { |
| 1406 | application_id: app_id.to_string(), |
| 1407 | server: conf.server.clone(), |
| 1408 | token: conf.token.clone(), |
| 1409 | }), |
| 1410 | }); |
| 1411 | resp.metadata_mut() |
| 1412 | .insert("x-log-application_id", req.application_id.parse().unwrap()); |
| 1413 | |
| 1414 | Ok(resp) |
| 1415 | } else { |
| 1416 | Err(Status::internal( |
| 1417 | "Integration has no PilotThings configuration", |
| 1418 | )) |
| 1419 | } |
| 1420 | } |
| 1421 | |
| 1422 | async fn update_pilot_things_integration( |
| 1423 | &self, |