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

Method create

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

Source from the content-addressed store, hash-verified

25#[tonic::async_trait]
26impl ApplicationService for Application {
27 async fn create(
28 &self,
29 request: Request<api::CreateApplicationRequest>,
30 ) -> Result<Response<api::CreateApplicationResponse>, Status> {
31 let req_app = match &request.get_ref().application {
32 Some(v) => v,
33 None => {
34 return Err(Status::invalid_argument("application is missing"));
35 }
36 };
37 let tenant_id = Uuid::from_str(&req_app.tenant_id).map_err(|e| e.status())?;
38
39 self.validator
40 .validate(
41 request.extensions(),
42 validator::ValidateApplicationsAccess::new(validator::Flag::Create, tenant_id),
43 )
44 .await?;
45
46 let a = application::Application {
47 tenant_id: tenant_id.into(),
48 name: req_app.name.clone(),
49 description: req_app.description.clone(),
50 tags: fields::KeyValue::new(req_app.tags.clone()),
51 ..Default::default()
52 };
53
54 let a = application::create(a).await.map_err(|e| e.status())?;
55
56 let mut resp = Response::new(api::CreateApplicationResponse {
57 id: a.id.to_string(),
58 });
59 resp.metadata_mut()
60 .insert("x-log-application_id", a.id.to_string().parse().unwrap());
61
62 Ok(resp)
63 }
64
65 async fn get(
66 &self,

Callers 1

test_applicationFunction · 0.45

Calls 7

statusMethod · 0.80
to_stringMethod · 0.80
insertMethod · 0.80
unwrapMethod · 0.80
createFunction · 0.50
validateMethod · 0.45
intoMethod · 0.45

Tested by 1

test_applicationFunction · 0.36