Browse Source

Settings API PATCH Method
- Added PATCH support to `/api/settings` for Home Assistant rest_command compatibility

Closes #152

maziggy 4 months ago
parent
commit
3a3f6a1845
2 changed files with 11 additions and 0 deletions
  1. 1 0
      CHANGELOG.md
  2. 10 0
      backend/app/api/routes/settings.py

+ 1 - 0
CHANGELOG.md

@@ -34,6 +34,7 @@ All notable changes to Bambuddy will be documented in this file.
   - Bulk delete for multiple files at once
   - Bulk delete for multiple files at once
 
 
 ### Fixes
 ### Fixes
+- **Settings API PATCH Method** - Added PATCH support to `/api/settings` for Home Assistant rest_command compatibility (Issue #152)
 - **P2S Empty Archive Tiles** - Fixed FTP file search for printers without SD card (Issue #146):
 - **P2S Empty Archive Tiles** - Fixed FTP file search for printers without SD card (Issue #146):
   - Added root folder `/` to search paths when looking for 3MF files
   - Added root folder `/` to search paths when looking for 3MF files
   - Printers without SD card store files in root instead of `/cache`
   - Printers without SD card store files in root instead of `/cache`

+ 10 - 0
backend/app/api/routes/settings.py

@@ -164,6 +164,16 @@ async def update_settings(
     return await get_settings(db)
     return await get_settings(db)
 
 
 
 
+@router.patch("/", response_model=AppSettings)
+@router.patch("", response_model=AppSettings)
+async def patch_settings(
+    settings_update: AppSettingsUpdate,
+    db: AsyncSession = Depends(get_db),
+):
+    """Partially update application settings (same as PUT, for REST compatibility)."""
+    return await update_settings(settings_update, db)
+
+
 @router.post("/reset", response_model=AppSettings)
 @router.post("/reset", response_model=AppSettings)
 async def reset_settings(db: AsyncSession = Depends(get_db)):
 async def reset_settings(db: AsyncSession = Depends(get_db)):
     """Reset all settings to defaults."""
     """Reset all settings to defaults."""