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

Method list

chirpstack/src/api/application.rs:161–215  ·  view source on GitHub ↗
(
        &self,
        request: Request<api::ListApplicationsRequest>,
    )

Source from the content-addressed store, hash-verified

159 }
160
161 async fn list(
162 &self,
163 request: Request<api::ListApplicationsRequest>,
164 ) -> Result<Response<api::ListApplicationsResponse>, Status> {
165 let req = request.get_ref();
166 let user_id: Option<Uuid> =
167 if let Some(AuthID::User(v)) = request.extensions().get::<AuthID>() {
168 Some(*v)
169 } else {
170 None
171 };
172 let tenant_id = Uuid::from_str(&req.tenant_id).map_err(|e| e.status())?;
173
174 self.validator
175 .validate(
176 request.extensions(),
177 validator::ValidateApplicationsAccess::new(validator::Flag::List, tenant_id),
178 )
179 .await?;
180
181 let filters = application::Filters {
182 user_id,
183 tenant_id: Some(tenant_id),
184 search: if req.search.is_empty() {
185 None
186 } else {
187 Some(req.search.to_string())
188 },
189 };
190
191 let count = application::get_count(&filters)
192 .await
193 .map_err(|e| e.status())?;
194 let results = application::list(req.limit as i64, req.offset as i64, &filters)
195 .await
196 .map_err(|e| e.status())?;
197
198 let mut resp = Response::new(api::ListApplicationsResponse {
199 total_count: count as u32,
200 result: results
201 .iter()
202 .map(|a| api::ApplicationListItem {
203 id: a.id.to_string(),
204 created_at: Some(helpers::datetime_to_prost_timestamp(&a.created_at)),
205 updated_at: Some(helpers::datetime_to_prost_timestamp(&a.updated_at)),
206 name: a.name.clone(),
207 description: a.description.clone(),
208 })
209 .collect(),
210 });
211 resp.metadata_mut()
212 .insert("x-log-tenant_id", req.tenant_id.parse().unwrap());
213
214 Ok(resp)
215 }
216
217 async fn list_integrations(
218 &self,

Callers 1

test_applicationFunction · 0.45

Calls 9

statusMethod · 0.80
to_stringMethod · 0.80
iterMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
get_countFunction · 0.50
listFunction · 0.50
validateMethod · 0.45

Tested by 1

test_applicationFunction · 0.36