| 641 | } |
| 642 | |
| 643 | async fn get_things_board_integration( |
| 644 | &self, |
| 645 | request: Request<api::GetThingsBoardIntegrationRequest>, |
| 646 | ) -> Result<Response<api::GetThingsBoardIntegrationResponse>, Status> { |
| 647 | let req = request.get_ref(); |
| 648 | let app_id = Uuid::from_str(&req.application_id).map_err(|e| e.status())?; |
| 649 | |
| 650 | self.validator |
| 651 | .validate( |
| 652 | request.extensions(), |
| 653 | validator::ValidateApplicationAccess::new(validator::Flag::Read, app_id), |
| 654 | ) |
| 655 | .await?; |
| 656 | |
| 657 | let i = application::get_integration(&app_id, application::IntegrationKind::ThingsBoard) |
| 658 | .await |
| 659 | .map_err(|e| e.status())?; |
| 660 | |
| 661 | if let application::IntegrationConfiguration::ThingsBoard(conf) = &i.configuration { |
| 662 | let mut resp = Response::new(api::GetThingsBoardIntegrationResponse { |
| 663 | integration: Some(api::ThingsBoardIntegration { |
| 664 | application_id: app_id.to_string(), |
| 665 | server: conf.server.clone(), |
| 666 | }), |
| 667 | }); |
| 668 | resp.metadata_mut() |
| 669 | .insert("x-log-application_id", req.application_id.parse().unwrap()); |
| 670 | |
| 671 | Ok(resp) |
| 672 | } else { |
| 673 | Err(Status::internal( |
| 674 | "Integration has no ThingsBoard configuration", |
| 675 | )) |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | async fn update_things_board_integration( |
| 680 | &self, |