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

Method list_devices

chirpstack/src/api/device_profile.rs:823–864  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::ListDeviceProfileDevicesRequest>,
    )

Source from the content-addressed store, hash-verified

821 }
822
823 async fn list_devices(
824 &self,
825 request: Request<api::ListDeviceProfileDevicesRequest>,
826 ) -> Result<Response<api::ListDeviceProfileDevicesResponse>, Status> {
827 let req = request.get_ref();
828
829 let vendor_id = if req.vendor_id.is_empty() {
830 None
831 } else {
832 Some(Uuid::from_str(&req.vendor_id).map_err(|e| e.status())?)
833 };
834
835 self.validator
836 .validate(
837 request.extensions(),
838 validator::ValidateDeviceProfileDevicesAccess::new(validator::Flag::List),
839 )
840 .await?;
841
842 let filters = device_profile::DeviceFilters { vendor_id };
843
844 let count = device_profile::get_device_count(&filters)
845 .await
846 .map_err(|e| e.status())?;
847
848 let items = device_profile::list_devices(req.limit as i64, req.offset as i64, &filters)
849 .await
850 .map_err(|e| e.status())?;
851
852 Ok(Response::new(api::ListDeviceProfileDevicesResponse {
853 total_count: count as u32,
854 result: items
855 .iter()
856 .map(|v| api::DeviceProfileDeviceListItem {
857 id: v.id.to_string(),
858 created_at: Some(helpers::datetime_to_prost_timestamp(&v.created_at)),
859 updated_at: Some(helpers::datetime_to_prost_timestamp(&v.updated_at)),
860 name: v.name.clone(),
861 })
862 .collect(),
863 }))
864 }
865
866 async fn delete_device(
867 &self,

Callers 1

test_device_profileFunction · 0.45

Calls 7

statusMethod · 0.80
iterMethod · 0.80
to_stringMethod · 0.80
get_device_countFunction · 0.50
list_devicesFunction · 0.50
validateMethod · 0.45

Tested by 1

test_device_profileFunction · 0.36