"""REST bindings; operations also serve the MCP interface.""" from fastapi import APIRouter, Depends from application import services as operations app = APIRouter(dependencies=[Depends(operations._counters_written)]) startup = operations.startup shutdown = operations.shutdown reset = operations.reset # Keep existing imports working while there is only one owner of managers and state. def __getattr__(name): return getattr(operations, name) app.get('', response_model=list[operations.ServiceModel])(operations.get_services) app.get('/pyfilter-api', response_model=operations.PyFilterApiModel)(operations.get_pyfilter_api) app.get('/{service_id}', response_model=operations.ServiceModel)(operations.get_service) app.post('', response_model=operations.ServiceAddResponse)(operations.add_service) app.put('/{service_id}', response_model=operations.StatusMessageModel)(operations.edit_service) app.get('/{service_id}/addresses', response_model=list[operations.AddressModel])(operations.get_addresses) app.post('/{service_id}/addresses', response_model=operations.StatusMessageModel)(operations.add_address) app.put('/{service_id}/addresses/{address_id}', response_model=operations.StatusMessageModel)(operations.edit_address) app.delete('/{service_id}/addresses/{address_id}', response_model=operations.StatusMessageModel)(operations.delete_address) app.delete('/{service_id}', response_model=operations.StatusMessageModel)(operations.delete_service) app.post('/{service_id}/start', response_model=operations.StatusMessageModel)(operations.start_service) app.post('/{service_id}/stop', response_model=operations.StatusMessageModel)(operations.stop_service) app.get('/{service_id}/filters', response_model=list[operations.FilterModel])(operations.get_filters) app.post('/{service_id}/filters', response_model=operations.StatusMessageModel)(operations.add_filter) app.put('/{service_id}/filters/{filter_id}', response_model=operations.StatusMessageModel)(operations.edit_filter) app.delete('/{service_id}/filters/{filter_id}', response_model=operations.StatusMessageModel)(operations.delete_filter) app.post('/{service_id}/filters/order', response_model=operations.StatusMessageModel)(operations.reorder_filters) app.post('/{service_id}/filters/{filter_id}/check', response_model=operations.CodeCheckResult)(operations.check_filter_code) app.get('/{service_id}/filters/{filter_id}/code', response_class=operations.PlainTextResponse)(operations.get_filter_code) app.put('/{service_id}/filters/{filter_id}/code', response_model=operations.StatusMessageModel)(operations.set_filter_code) app.get('/{service_id}/filters/{filter_id}/functions', response_model=list[operations.PyFunctionModel])(operations.get_functions) app.put('/{service_id}/filters/{filter_id}/functions/{name}', response_model=operations.StatusMessageModel)(operations.edit_function) app.get('/{service_id}/filters/{filter_id}/regexes', response_model=list[operations.RegexModel])(operations.get_regexes) app.post('/{service_id}/filters/{filter_id}/regexes', response_model=operations.StatusMessageModel)(operations.add_regex) app.put('/{service_id}/filters/{filter_id}/regexes/{regex_id}', response_model=operations.StatusMessageModel)(operations.edit_regex) app.delete('/{service_id}/filters/{filter_id}/regexes/{regex_id}', response_model=operations.StatusMessageModel)(operations.delete_regex) app.get('/{service_id}/stats', response_model=operations.StatsModel)(operations.get_stats) app.get('/{service_id}/logs', response_model=list[operations.LogEntryModel])(operations.get_logs) app.delete('/{service_id}/logs', response_model=operations.StatusMessageModel)(operations.clear_logs) app.post('/debug-regex', response_model=operations.DebugResponse)(operations.debug_regexes)