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

Method list

chirpstack/src/api/relay.rs:27–66  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::ListRelaysRequest>,
    )

Source from the content-addressed store, hash-verified

25#[tonic::async_trait]
26impl RelayService for Relay {
27 async fn list(
28 &self,
29 request: Request<api::ListRelaysRequest>,
30 ) -> Result<Response<api::ListRelaysResponse>, Status> {
31 let req = request.get_ref();
32 let app_id = Uuid::from_str(&req.application_id).map_err(|e| e.status())?;
33
34 self.validator
35 .validate(
36 request.extensions(),
37 validator::ValidateDevicesAccess::new(validator::Flag::List, app_id),
38 )
39 .await?;
40
41 let filters = relay::RelayFilters {
42 application_id: Some(app_id),
43 };
44
45 let count = relay::get_relay_count(&filters)
46 .await
47 .map_err(|e| e.status())?;
48 let items = relay::list_relays(req.limit as i64, req.offset as i64, &filters)
49 .await
50 .map_err(|e| e.status())?;
51
52 let mut resp = Response::new(api::ListRelaysResponse {
53 total_count: count as u32,
54 result: items
55 .iter()
56 .map(|r| api::RelayListItem {
57 dev_eui: r.dev_eui.to_string(),
58 name: r.name.clone(),
59 })
60 .collect(),
61 });
62
63 resp.metadata_mut()
64 .insert("x-log-application_id", req.application_id.parse().unwrap());
65 Ok(resp)
66 }
67
68 async fn add_device(
69 &self,

Callers 1

test_relayFunction · 0.45

Calls 8

get_relay_countFunction · 0.85
list_relaysFunction · 0.85
statusMethod · 0.80
iterMethod · 0.80
to_stringMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
validateMethod · 0.45

Tested by 1

test_relayFunction · 0.36