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

Method get_gateways_summary

chirpstack/src/api/internal.rs:667–704  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::GetGatewaysSummaryRequest>,
    )

Source from the content-addressed store, hash-verified

665 }
666
667 async fn get_gateways_summary(
668 &self,
669 request: Request<api::GetGatewaysSummaryRequest>,
670 ) -> Result<Response<api::GetGatewaysSummaryResponse>, Status> {
671 let req = request.get_ref();
672
673 let tenant_id = if req.tenant_id.is_empty() {
674 None
675 } else {
676 Some(Uuid::from_str(&req.tenant_id).map_err(|e| e.status())?)
677 };
678
679 if tenant_id.is_none() {
680 self.validator
681 .validate(request.extensions(), validator::ValidateIsAdmin::new())
682 .await?;
683 } else {
684 self.validator
685 .validate(
686 request.extensions(),
687 validator::ValidateTenantAccess::new(
688 validator::Flag::Read,
689 *tenant_id.as_ref().unwrap(),
690 ),
691 )
692 .await?;
693 }
694
695 let counts = gateway::get_counts_by_state(&tenant_id)
696 .await
697 .map_err(|e| e.status())?;
698
699 Ok(Response::new(api::GetGatewaysSummaryResponse {
700 online_count: counts.online_count as u32,
701 offline_count: counts.offline_count as u32,
702 never_seen_count: counts.never_seen_count as u32,
703 }))
704 }
705
706 type StreamGatewayFramesStream = DropReceiver<Result<api::LogItem, Status>>;
707

Callers

nothing calls this directly

Calls 5

get_counts_by_stateFunction · 0.85
statusMethod · 0.80
unwrapMethod · 0.80
as_refMethod · 0.80
validateMethod · 0.45

Tested by

no test coverage detected