add command endpoints

minor bump
This commit is contained in:
2026-04-06 21:50:54 +01:00
parent fb1c48c862
commit 1182146691
6 changed files with 67 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
[project]
name = "vmr-http"
version = "0.7.2"
version = "0.8.0"
description = "HTTP API for controlling Voicemeeter"
readme = "README.md"
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]

View File

@@ -7,7 +7,7 @@ from fastapi import Depends, FastAPI, HTTPException
from voicemeeterlib.error import CAPIError
from .dependencies import get_voicemeeter_client
from .web import bus, strip
from .web import bus, command, strip
@asynccontextmanager
@@ -29,6 +29,7 @@ app = FastAPI(
)
app.include_router(strip.router, prefix='/strip/{index}')
app.include_router(bus.router, prefix='/bus/{index}')
app.include_router(command.router, prefix='/command')
@app.get('/health')

View File

@@ -1,5 +1,5 @@
"""API endpoints for controlling various Voicemeeter components."""
from . import bus, strip
from . import bus, command, strip
__all__ = ['bus', 'strip']
__all__ = ['bus', 'command', 'strip']

View File

@@ -0,0 +1,5 @@
"""module for command-related endpoints."""
from .command import router
__all__ = ['router']

View File

@@ -0,0 +1,56 @@
"""module for command related endpoints."""
from fastapi import APIRouter, Depends
from vmr_http.dependencies import get_voicemeeter_client
router = APIRouter(tags=['command'])
###
# Although these endpoints are technically modifying the state of the Voicemeeter application,
# they are commands that trigger an action rather than resource updates.
# Therefore, they are implemented as POST.
###
@router.post('/show')
async def show_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Show the Voicemeeter application."""
voicemeeter.command.show()
return {'status': 'Voicemeeter shown'}
@router.post('/hide')
async def hide_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Hide the Voicemeeter application."""
voicemeeter.command.hide()
return {'status': 'Voicemeeter hidden'}
@router.post('/shutdown')
async def shutdown_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Shutdown the Voicemeeter application."""
voicemeeter.command.shutdown()
return {'status': 'Voicemeeter shutdown'}
@router.post('/restart')
async def restart_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Restart the Voicemeeter application."""
voicemeeter.command.restart()
return {'status': 'Voicemeeter restarted'}
@router.post('/lock')
async def lock_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Lock the Voicemeeter application."""
voicemeeter.command.lock = True
return {'status': 'Voicemeeter locked'}
@router.post('/unlock')
async def unlock_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Unlock the Voicemeeter application."""
voicemeeter.command.lock = False
return {'status': 'Voicemeeter unlocked'}

2
uv.lock generated
View File

@@ -1151,7 +1151,7 @@ wheels = [
[[package]]
name = "vmr-http"
version = "0.7.2"
version = "0.8.0"
source = { editable = "." }
dependencies = [
{ name = "fastapi" },