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

Method get_device

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

Source from the content-addressed store, hash-verified

786 }
787
788 async fn get_device(
789 &self,
790 request: Request<api::GetDeviceProfileDeviceRequest>,
791 ) -> Result<Response<api::GetDeviceProfileDeviceResponse>, Status> {
792 let req = request.get_ref();
793 let device_id = Uuid::from_str(&req.id).map_err(|e| e.status())?;
794
795 self.validator
796 .validate(
797 request.extensions(),
798 validator::ValidateDeviceProfileDeviceAccess::new(validator::Flag::Read),
799 )
800 .await?;
801
802 let d = device_profile::get_device(device_id)
803 .await
804 .map_err(|e| e.status())?;
805
806 let mut resp = Response::new(api::GetDeviceProfileDeviceResponse {
807 device: Some(api::DeviceProfileDevice {
808 id: d.id.to_string(),
809 vendor_id: d.vendor_id.to_string(),
810 name: d.name.clone(),
811 description: d.description.clone(),
812 metadata: d.metadata.into_hashmap(),
813 }),
814 created_at: Some(helpers::datetime_to_prost_timestamp(&d.created_at)),
815 updated_at: Some(helpers::datetime_to_prost_timestamp(&d.updated_at)),
816 });
817
818 resp.metadata_mut()
819 .insert("x-log-device_id", req.id.parse().unwrap());
820 Ok(resp)
821 }
822
823 async fn list_devices(
824 &self,

Callers 1

test_device_profileFunction · 0.80

Calls 8

get_deviceFunction · 0.85
statusMethod · 0.80
to_stringMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
validateMethod · 0.45
into_hashmapMethod · 0.45

Tested by 1

test_device_profileFunction · 0.64