MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / list_devices

Method list_devices

chirpstack/src/api/fuota.rs:471–530  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::ListFuotaDeploymentDevicesRequest>,
    )

Source from the content-addressed store, hash-verified

469 }
470
471 async fn list_devices(
472 &self,
473 request: Request<api::ListFuotaDeploymentDevicesRequest>,
474 ) -> Result<Response<api::ListFuotaDeploymentDevicesResponse>, Status> {
475 let req = request.get_ref();
476 let dp_id = Uuid::from_str(&req.fuota_deployment_id).map_err(|e| e.status())?;
477
478 self.validator
479 .validate(
480 request.extensions(),
481 validator::ValidateFuotaDeploymentAccess::new(validator::Flag::Read, dp_id),
482 )
483 .await?;
484
485 let count = fuota::get_device_count(dp_id)
486 .await
487 .map_err(|e| e.status())?;
488 let items = fuota::get_devices(dp_id, req.limit as i64, req.offset as i64)
489 .await
490 .map_err(|e| e.status())?;
491
492 let mut resp = Response::new(api::ListFuotaDeploymentDevicesResponse {
493 total_count: count as u32,
494 result: items
495 .iter()
496 .map(|d| api::FuotaDeploymentDeviceListItem {
497 fuota_deployment_id: d.fuota_deployment_id.to_string(),
498 dev_eui: d.dev_eui.to_string(),
499 created_at: Some(helpers::datetime_to_prost_timestamp(&d.created_at)),
500 completed_at: d
501 .completed_at
502 .as_ref()
503 .map(helpers::datetime_to_prost_timestamp),
504 mc_group_setup_completed_at: d
505 .mc_group_setup_completed_at
506 .as_ref()
507 .map(helpers::datetime_to_prost_timestamp),
508 mc_session_completed_at: d
509 .mc_session_completed_at
510 .as_ref()
511 .map(helpers::datetime_to_prost_timestamp),
512 frag_session_setup_completed_at: d
513 .frag_session_setup_completed_at
514 .as_ref()
515 .map(helpers::datetime_to_prost_timestamp),
516 frag_status_completed_at: d
517 .frag_status_completed_at
518 .as_ref()
519 .map(helpers::datetime_to_prost_timestamp),
520 error_msg: d.error_msg.clone(),
521 })
522 .collect(),
523 });
524 resp.metadata_mut().insert(
525 "x-log-fuota_deployment_id",
526 req.fuota_deployment_id.parse().unwrap(),
527 );
528

Callers 1

test_fuotaFunction · 0.45

Calls 10

get_devicesFunction · 0.85
statusMethod · 0.80
iterMethod · 0.80
to_stringMethod · 0.80
as_refMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
get_device_countFunction · 0.50
validateMethod · 0.45

Tested by 1

test_fuotaFunction · 0.36