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

Method get

chirpstack/src/api/tenant.rs:78–119  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::GetTenantRequest>,
    )

Source from the content-addressed store, hash-verified

76 }
77
78 async fn get(
79 &self,
80 request: Request<api::GetTenantRequest>,
81 ) -> Result<Response<api::GetTenantResponse>, Status> {
82 let req = request.get_ref();
83 let tenant_id = Uuid::from_str(&req.id).map_err(|e| e.status())?;
84
85 self.validator
86 .validate(
87 request.extensions(),
88 validator::ValidateTenantAccess::new(validator::Flag::Read, tenant_id),
89 )
90 .await?;
91
92 let t = tenant::get(&tenant_id).await.map_err(|e| e.status())?;
93
94 let mut resp = Response::new(api::GetTenantResponse {
95 tenant: Some(api::Tenant {
96 id: t.id.to_string(),
97 name: t.name,
98 description: t.description,
99 can_have_gateways: t.can_have_gateways,
100 max_gateway_count: t.max_gateway_count as u32,
101 max_device_count: t.max_device_count as u32,
102 private_gateways_up: t.private_gateways_up,
103 private_gateways_down: t.private_gateways_down,
104 tags: t.tags.into_hashmap(),
105 dev_addr_prefixes: t
106 .dev_addr_prefixes
107 .deref()
108 .iter()
109 .filter_map(|v| v.map(|v| v.to_string()))
110 .collect(),
111 }),
112 created_at: Some(helpers::datetime_to_prost_timestamp(&t.created_at)),
113 updated_at: Some(helpers::datetime_to_prost_timestamp(&t.updated_at)),
114 });
115 resp.metadata_mut()
116 .insert("x-log-tenant_id", req.id.parse().unwrap());
117
118 Ok(resp)
119 }
120
121 async fn update(
122 &self,

Callers 1

test_tenantFunction · 0.45

Calls 10

statusMethod · 0.80
to_stringMethod · 0.80
iterMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
getFunction · 0.50
validateMethod · 0.45
into_hashmapMethod · 0.45
derefMethod · 0.45

Tested by 1

test_tenantFunction · 0.36