| 115 | } |
| 116 | |
| 117 | async fn get_deployment( |
| 118 | &self, |
| 119 | request: Request<api::GetFuotaDeploymentRequest>, |
| 120 | ) -> Result<Response<api::GetFuotaDeploymentResponse>, Status> { |
| 121 | let req = request.get_ref(); |
| 122 | let dp_id = Uuid::from_str(&req.id).map_err(|e| e.status())?; |
| 123 | |
| 124 | self.validator |
| 125 | .validate( |
| 126 | request.extensions(), |
| 127 | validator::ValidateFuotaDeploymentAccess::new(validator::Flag::Read, dp_id), |
| 128 | ) |
| 129 | .await?; |
| 130 | |
| 131 | let dp = fuota::get_deployment(dp_id).await.map_err(|e| e.status())?; |
| 132 | |
| 133 | let mut resp = Response::new(api::GetFuotaDeploymentResponse { |
| 134 | deployment: Some(api::FuotaDeployment { |
| 135 | id: dp.id.to_string(), |
| 136 | application_id: dp.application_id.to_string(), |
| 137 | device_profile_id: dp.device_profile_id.to_string(), |
| 138 | name: dp.name.clone(), |
| 139 | multicast_group_type: match dp.multicast_group_type.as_ref() { |
| 140 | "B" => api::MulticastGroupType::ClassB, |
| 141 | "C" => api::MulticastGroupType::ClassC, |
| 142 | _ => return Err(Status::invalid_argument("Invalid multicast_group_type")), |
| 143 | } |
| 144 | .into(), |
| 145 | multicast_class_c_scheduling_type: dp |
| 146 | .multicast_class_c_scheduling_type |
| 147 | .to_proto() |
| 148 | .into(), |
| 149 | multicast_dr: dp.multicast_dr as u32, |
| 150 | multicast_class_b_ping_slot_periodicity: dp.multicast_class_b_ping_slot_periodicity |
| 151 | as u32, |
| 152 | multicast_frequency: dp.multicast_frequency as u32, |
| 153 | multicast_timeout: dp.multicast_timeout as u32, |
| 154 | unicast_max_retry_count: dp.unicast_max_retry_count as u32, |
| 155 | fragmentation_fragment_size: dp.fragmentation_fragment_size as u32, |
| 156 | fragmentation_redundancy_percentage: dp.fragmentation_redundancy_percentage as u32, |
| 157 | fragmentation_session_index: dp.fragmentation_session_index as u32, |
| 158 | fragmentation_matrix: dp.fragmentation_matrix as u32, |
| 159 | fragmentation_block_ack_delay: dp.fragmentation_block_ack_delay as u32, |
| 160 | fragmentation_descriptor: dp.fragmentation_descriptor.clone(), |
| 161 | request_fragmentation_session_status: dp |
| 162 | .request_fragmentation_session_status |
| 163 | .to_proto() |
| 164 | .into(), |
| 165 | payload: dp.payload.clone(), |
| 166 | calculate_multicast_timeout: false, |
| 167 | calculate_fragmentation_fragment_size: false, |
| 168 | on_complete_set_device_tags: dp.on_complete_set_device_tags.into_hashmap(), |
| 169 | }), |
| 170 | created_at: Some(helpers::datetime_to_prost_timestamp(&dp.created_at)), |
| 171 | updated_at: Some(helpers::datetime_to_prost_timestamp(&dp.updated_at)), |
| 172 | started_at: dp |
| 173 | .started_at |
| 174 | .as_ref() |