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

Method get_keys

chirpstack/src/api/device.rs:378–408  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::GetDeviceKeysRequest>,
    )

Source from the content-addressed store, hash-verified

376 }
377
378 async fn get_keys(
379 &self,
380 request: Request<api::GetDeviceKeysRequest>,
381 ) -> Result<Response<api::GetDeviceKeysResponse>, Status> {
382 let req = request.get_ref();
383 let dev_eui = EUI64::from_str(&req.dev_eui).map_err(|e| e.status())?;
384
385 self.validator
386 .validate(
387 request.extensions(),
388 validator::ValidateDeviceAccess::new(validator::Flag::Read, dev_eui),
389 )
390 .await?;
391
392 let dk = device_keys::get(&dev_eui).await.map_err(|e| e.status())?;
393
394 let mut resp = Response::new(api::GetDeviceKeysResponse {
395 device_keys: Some(api::DeviceKeys {
396 dev_eui: dk.dev_eui.to_string(),
397 nwk_key: dk.nwk_key.to_string(),
398 app_key: dk.app_key.to_string(),
399 gen_app_key: dk.gen_app_key.to_string(),
400 }),
401 created_at: Some(helpers::datetime_to_prost_timestamp(&dk.created_at)),
402 updated_at: Some(helpers::datetime_to_prost_timestamp(&dk.updated_at)),
403 });
404 resp.metadata_mut()
405 .insert("x-log-dev_eui", req.dev_eui.parse().unwrap());
406
407 Ok(resp)
408 }
409
410 async fn update_keys(
411 &self,

Callers 1

test_deviceFunction · 0.80

Calls 7

statusMethod · 0.80
to_stringMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
getFunction · 0.50
validateMethod · 0.45

Tested by 1

test_deviceFunction · 0.64