| 1728 | } |
| 1729 | |
| 1730 | async fn update_blynk_integration( |
| 1731 | &self, |
| 1732 | request: Request<api::UpdateBlynkIntegrationRequest>, |
| 1733 | ) -> Result<Response<()>, Status> { |
| 1734 | let req_int = match &request.get_ref().integration { |
| 1735 | Some(v) => v, |
| 1736 | None => { |
| 1737 | return Err(Status::invalid_argument("integration is missing")); |
| 1738 | } |
| 1739 | }; |
| 1740 | let app_id = Uuid::from_str(&req_int.application_id).map_err(|e| e.status())?; |
| 1741 | |
| 1742 | self.validator |
| 1743 | .validate( |
| 1744 | request.extensions(), |
| 1745 | validator::ValidateApplicationAccess::new(validator::Flag::Update, app_id), |
| 1746 | ) |
| 1747 | .await?; |
| 1748 | |
| 1749 | let _ = application::update_integration(application::Integration { |
| 1750 | application_id: app_id.into(), |
| 1751 | kind: application::IntegrationKind::Blynk, |
| 1752 | configuration: application::IntegrationConfiguration::Blynk( |
| 1753 | application::BlynkConfiguration { |
| 1754 | token: req_int.token.clone(), |
| 1755 | }, |
| 1756 | ), |
| 1757 | ..Default::default() |
| 1758 | }) |
| 1759 | .await |
| 1760 | .map_err(|e| e.status())?; |
| 1761 | |
| 1762 | let mut resp = Response::new(()); |
| 1763 | resp.metadata_mut().insert( |
| 1764 | "x-log-application_id", |
| 1765 | req_int.application_id.parse().unwrap(), |
| 1766 | ); |
| 1767 | |
| 1768 | Ok(resp) |
| 1769 | } |
| 1770 | |
| 1771 | async fn delete_blynk_integration( |
| 1772 | &self, |