ашчуы

This commit is contained in:
xds
2026-02-20 10:28:56 +03:00
parent e1d941a2cd
commit 9e0c522b5f
3 changed files with 17 additions and 2 deletions

View File

@@ -91,6 +91,18 @@ async def update_environment(
update_data = env_update.model_dump(exclude_unset=True)
if not update_data:
return env
# Verify assets exist if provided
if "asset_ids" in update_data:
if update_data["asset_ids"] is None:
del update_data["asset_ids"]
elif update_data["asset_ids"]:
# Verify all assets exist using batch check
assets = await dao.assets.get_assets_by_ids(update_data["asset_ids"])
if len(assets) != len(update_data["asset_ids"]):
found_ids = {a.id for a in assets}
missing_ids = [aid for aid in update_data["asset_ids"] if aid not in found_ids]
raise HTTPException(status_code=400, detail=f"Some assets not found: {missing_ids}")
success = await dao.environments.update_env(env_id, update_data)
if not success:

View File

@@ -12,6 +12,7 @@ class EnvironmentCreate(BaseModel):
class EnvironmentUpdate(BaseModel):
name: Optional[str] = Field(None, min_length=1)
description: Optional[str] = None
asset_ids: Optional[List[str]] = None
class AssetToEnvironment(BaseModel):