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

Method list

chirpstack/src/api/gateway.rs:197–290  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::ListGatewaysRequest>,
    )

Source from the content-addressed store, hash-verified

195 }
196
197 async fn list(
198 &self,
199 request: Request<api::ListGatewaysRequest>,
200 ) -> Result<Response<api::ListGatewaysResponse>, Status> {
201 let req = request.get_ref();
202 let tenant_id = if req.tenant_id.is_empty() {
203 None
204 } else {
205 Some(Uuid::from_str(&req.tenant_id).map_err(|e| e.status())?)
206 };
207 let mg_id: Option<Uuid> = if req.multicast_group_id.is_empty() {
208 None
209 } else {
210 Some(Uuid::from_str(&req.multicast_group_id).map_err(|e| e.status())?)
211 };
212
213 if let Some(mg_id) = mg_id {
214 self.validator
215 .validate(
216 request.extensions(),
217 validator::ValidateMulticastGroupAccess::new(validator::Flag::Read, mg_id),
218 )
219 .await?;
220 }
221
222 let filters = gateway::Filters {
223 tenant_id,
224 multicast_group_id: mg_id,
225 search: if req.search.is_empty() {
226 None
227 } else {
228 Some(req.search.to_string())
229 },
230 };
231
232 let count = gateway::get_count(&filters).await.map_err(|e| e.status())?;
233 let result = gateway::list(
234 req.limit as i64,
235 req.offset as i64,
236 &filters,
237 req.order_by().from_proto(),
238 req.order_by_desc,
239 )
240 .await
241 .map_err(|e| e.status())?;
242
243 let mut resp = Response::new(api::ListGatewaysResponse {
244 total_count: count as u32,
245 result: result
246 .iter()
247 .map(|gw| api::GatewayListItem {
248 tenant_id: gw.tenant_id.to_string(),
249 gateway_id: gw.gateway_id.to_string(),
250 name: gw.name.clone(),
251 description: gw.description.clone(),
252 location: Some(common::Location {
253 latitude: gw.latitude,
254 longitude: gw.longitude,

Callers 1

test_gatewayFunction · 0.45

Calls 13

statusMethod · 0.80
to_stringMethod · 0.80
from_protoMethod · 0.80
iterMethod · 0.80
as_refMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
get_countFunction · 0.50
listFunction · 0.50
validateMethod · 0.45
into_hashmapMethod · 0.45

Tested by 1

test_gatewayFunction · 0.36