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

Method get

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

Source from the content-addressed store, hash-verified

79 }
80
81 async fn get(
82 &self,
83 request: Request<api::GetGatewayRequest>,
84 ) -> Result<Response<api::GetGatewayResponse>, Status> {
85 let req = request.get_ref();
86 let gw_id = EUI64::from_str(&req.gateway_id).map_err(|e| e.status())?;
87
88 self.validator
89 .validate(
90 request.extensions(),
91 validator::ValidateGatewayAccess::new(validator::Flag::Read, gw_id),
92 )
93 .await?;
94
95 let gw = gateway::get(&gw_id).await.map_err(|e| e.status())?;
96
97 let mut resp = Response::new(api::GetGatewayResponse {
98 gateway: Some(api::Gateway {
99 gateway_id: gw.gateway_id.to_string(),
100 name: gw.name,
101 description: gw.description,
102 location: Some(common::Location {
103 latitude: gw.latitude,
104 longitude: gw.longitude,
105 altitude: gw.altitude as f64,
106 ..Default::default()
107 }),
108 tenant_id: gw.tenant_id.to_string(),
109 tags: gw.tags.into_hashmap(),
110 metadata: gw.properties.into_hashmap(),
111 stats_interval: gw.stats_interval_secs as u32,
112 downlink_priority: gw.downlink_priority as u32,
113 }),
114 created_at: Some(helpers::datetime_to_prost_timestamp(&gw.created_at)),
115 updated_at: Some(helpers::datetime_to_prost_timestamp(&gw.updated_at)),
116 last_seen_at: gw
117 .last_seen_at
118 .as_ref()
119 .map(helpers::datetime_to_prost_timestamp),
120 });
121 resp.metadata_mut()
122 .insert("x-log-gateway_id", req.gateway_id.parse().unwrap());
123
124 Ok(resp)
125 }
126
127 async fn update(
128 &self,

Callers 3

get_metricsMethod · 0.45
test_gatewayFunction · 0.45

Calls 9

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

Tested by 1

test_gatewayFunction · 0.36