| 784 | } |
| 785 | |
| 786 | async fn get_my_devices_integration( |
| 787 | &self, |
| 788 | request: Request<api::GetMyDevicesIntegrationRequest>, |
| 789 | ) -> Result<Response<api::GetMyDevicesIntegrationResponse>, Status> { |
| 790 | let req = request.get_ref(); |
| 791 | let app_id = Uuid::from_str(&req.application_id).map_err(|e| e.status())?; |
| 792 | |
| 793 | self.validator |
| 794 | .validate( |
| 795 | request.extensions(), |
| 796 | validator::ValidateApplicationAccess::new(validator::Flag::Read, app_id), |
| 797 | ) |
| 798 | .await?; |
| 799 | |
| 800 | let i = application::get_integration(&app_id, application::IntegrationKind::MyDevices) |
| 801 | .await |
| 802 | .map_err(|e| e.status())?; |
| 803 | |
| 804 | if let application::IntegrationConfiguration::MyDevices(conf) = &i.configuration { |
| 805 | let mut resp = Response::new(api::GetMyDevicesIntegrationResponse { |
| 806 | integration: Some(api::MyDevicesIntegration { |
| 807 | application_id: app_id.to_string(), |
| 808 | endpoint: conf.endpoint.clone(), |
| 809 | }), |
| 810 | }); |
| 811 | resp.metadata_mut() |
| 812 | .insert("x-log-application_id", req.application_id.parse().unwrap()); |
| 813 | |
| 814 | Ok(resp) |
| 815 | } else { |
| 816 | Err(Status::internal( |
| 817 | "Integration has no MyDevices configuration", |
| 818 | )) |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | async fn update_my_devices_integration( |
| 823 | &self, |