update routes now support PATCH and PUT operations

remove the individual parameter PUT endpoints

minor bump
This commit is contained in:
2026-04-05 01:19:22 +01:00
parent cd80c7b763
commit 2ebf926b22
9 changed files with 56 additions and 242 deletions

View File

@@ -1,6 +1,6 @@
"""module for strip gate related endpoints."""
from fastapi import APIRouter, Body, Depends
from fastapi import APIRouter, Depends
from vmr_http.dependencies import get_voicemeeter_client
from vmr_http.models.strip import StripGateParams
@@ -8,14 +8,16 @@ from vmr_http.models.strip import StripGateParams
router = APIRouter()
@router.patch('/{index}/gate')
@router.put('/{index}/gate')
async def set_strip_gate_params(index: int, request: StripGateParams, voicemeeter=Depends(get_voicemeeter_client)):
"""Set the gate parameters for the specified strip index."""
async def update_strip_gate_params(index: int, params: StripGateParams, voicemeeter=Depends(get_voicemeeter_client)):
"""Update one or more gate parameters for the specified strip index."""
strip_gate = voicemeeter.strip[index].gate
for key, value in request.model_dump(exclude_unset=True).items():
updated = {}
for key, value in params.model_dump(exclude_unset=True).items():
setattr(strip_gate, key, value)
return {key: getattr(strip_gate, key) for key in request.model_dump(exclude_unset=True)}
updated[key] = getattr(strip_gate, key)
return updated
@router.get('/{index}/gate/knob')
@@ -23,15 +25,3 @@ async def get_strip_gate_knob(index: int, voicemeeter=Depends(get_voicemeeter_cl
"""Get the current gate knob value for the specified strip index."""
strip_gate = voicemeeter.strip[index].gate
return {'knob': strip_gate.knob}
@router.put('/{index}/gate/knob')
async def set_strip_gate_knob(
index: int,
knob: float = Body(..., embed=True),
voicemeeter=Depends(get_voicemeeter_client),
):
"""Set the gate knob value for the specified strip index."""
strip_gate = voicemeeter.strip[index].gate
strip_gate.knob = knob
return {'knob': strip_gate.knob}