| 599 | } |
| 600 | |
| 601 | async fn list_gateways( |
| 602 | &self, |
| 603 | request: Request<api::ListFuotaDeploymentGatewaysRequest>, |
| 604 | ) -> Result<Response<api::ListFuotaDeploymentGatewaysResponse>, Status> { |
| 605 | let req = request.get_ref(); |
| 606 | let dp_id = Uuid::from_str(&req.fuota_deployment_id).map_err(|e| e.status())?; |
| 607 | |
| 608 | self.validator |
| 609 | .validate( |
| 610 | request.extensions(), |
| 611 | validator::ValidateFuotaDeploymentAccess::new(validator::Flag::Read, dp_id), |
| 612 | ) |
| 613 | .await?; |
| 614 | |
| 615 | let count = fuota::get_gateway_count(dp_id) |
| 616 | .await |
| 617 | .map_err(|e| e.status())?; |
| 618 | let items = fuota::get_gateways(dp_id, req.limit as i64, req.offset as i64) |
| 619 | .await |
| 620 | .map_err(|e| e.status())?; |
| 621 | |
| 622 | let mut resp = Response::new(api::ListFuotaDeploymentGatewaysResponse { |
| 623 | total_count: count as u32, |
| 624 | result: items |
| 625 | .iter() |
| 626 | .map(|gw| api::FuotaDeploymentGatewayListItem { |
| 627 | fuota_deployment_id: gw.fuota_deployment_id.to_string(), |
| 628 | gateway_id: gw.gateway_id.to_string(), |
| 629 | created_at: Some(helpers::datetime_to_prost_timestamp(&gw.created_at)), |
| 630 | }) |
| 631 | .collect(), |
| 632 | }); |
| 633 | resp.metadata_mut().insert( |
| 634 | "x-log-fuota_deployment_id", |
| 635 | req.fuota_deployment_id.parse().unwrap(), |
| 636 | ); |
| 637 | Ok(resp) |
| 638 | } |
| 639 | |
| 640 | async fn list_jobs( |
| 641 | &self, |