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

Function create_deployment

chirpstack/src/storage/fuota.rs:185–207  ·  view source on GitHub ↗
(d: FuotaDeployment)

Source from the content-addressed store, hash-verified

183}
184
185pub async fn create_deployment(d: FuotaDeployment) -> Result<FuotaDeployment, Error> {
186 d.validate()?;
187
188 let dp = device_profile::get(&d.device_profile_id).await?;
189
190 if let Some(tenant_id) = dp.tenant_id {
191 let app = storage::application::get(&d.application_id).await?;
192 if app.tenant_id != tenant_id {
193 return Err(Error::Validation(
194 "The application and device-profile must be under the same tenant".into(),
195 ));
196 }
197 }
198
199 let d: FuotaDeployment = diesel::insert_into(fuota_deployment::table)
200 .values(&d)
201 .get_result(&mut get_async_db_conn().await?)
202 .await
203 .map_err(|e| Error::from_diesel(e, d.id.to_string()))?;
204
205 info!(id = %d.id, "FUOTA deployment created");
206 Ok(d)
207}
208
209pub async fn get_deployment(id: Uuid) -> Result<FuotaDeployment, Error> {
210 fuota_deployment::dsl::fuota_deployment

Callers 7

test_fuotaFunction · 0.85
test_fuota_devicesFunction · 0.85
test_fuota_gatewaysFunction · 0.85
test_jobsFunction · 0.85
create_deploymentMethod · 0.85
fuota_deploymentFunction · 0.85

Calls 5

to_stringMethod · 0.80
getFunction · 0.70
get_async_db_connFunction · 0.70
validateMethod · 0.45
intoMethod · 0.45

Tested by 5

test_fuotaFunction · 0.68
test_fuota_devicesFunction · 0.68
test_fuota_gatewaysFunction · 0.68
test_jobsFunction · 0.68