| 1420 | } |
| 1421 | |
| 1422 | async fn update_pilot_things_integration( |
| 1423 | &self, |
| 1424 | request: Request<api::UpdatePilotThingsIntegrationRequest>, |
| 1425 | ) -> Result<Response<()>, Status> { |
| 1426 | let req_int = match &request.get_ref().integration { |
| 1427 | Some(v) => v, |
| 1428 | None => { |
| 1429 | return Err(Status::invalid_argument("integration is missing")); |
| 1430 | } |
| 1431 | }; |
| 1432 | let app_id = Uuid::from_str(&req_int.application_id).map_err(|e| e.status())?; |
| 1433 | |
| 1434 | self.validator |
| 1435 | .validate( |
| 1436 | request.extensions(), |
| 1437 | validator::ValidateApplicationAccess::new(validator::Flag::Update, app_id), |
| 1438 | ) |
| 1439 | .await?; |
| 1440 | |
| 1441 | let _ = application::update_integration(application::Integration { |
| 1442 | application_id: app_id.into(), |
| 1443 | kind: application::IntegrationKind::PilotThings, |
| 1444 | configuration: application::IntegrationConfiguration::PilotThings( |
| 1445 | application::PilotThingsConfiguration { |
| 1446 | server: req_int.server.clone(), |
| 1447 | token: req_int.token.clone(), |
| 1448 | }, |
| 1449 | ), |
| 1450 | ..Default::default() |
| 1451 | }) |
| 1452 | .await |
| 1453 | .map_err(|e| e.status())?; |
| 1454 | |
| 1455 | let mut resp = Response::new(()); |
| 1456 | resp.metadata_mut().insert( |
| 1457 | "x-log-application_id", |
| 1458 | req_int.application_id.parse().unwrap(), |
| 1459 | ); |
| 1460 | |
| 1461 | Ok(resp) |
| 1462 | } |
| 1463 | |
| 1464 | async fn delete_pilot_things_integration( |
| 1465 | &self, |