mirror of
https://github.com/onyx-and-iris/vmr-http.git
synced 2026-04-07 02:13:31 +00:00
add command endpoints
minor bump
This commit is contained in:
@@ -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" }]
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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']
|
||||
|
||||
5
src/vmr_http/web/command/__init__.py
Normal file
5
src/vmr_http/web/command/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
"""module for command-related endpoints."""
|
||||
|
||||
from .command import router
|
||||
|
||||
__all__ = ['router']
|
||||
56
src/vmr_http/web/command/command.py
Normal file
56
src/vmr_http/web/command/command.py
Normal 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'}
|
||||
Reference in New Issue
Block a user