mirror of
https://github.com/Av0idD4rk/firegex.git
synced 2026-10-23 16:31:00 +00:00
Expose 28 tools with shared REST operations, role-scoped bearer authentication, revisions, durable retries, snapshots, jobs and timed rollback. Add Docker verification harnesses and setup/workflow documentation in docs/mcp.md and inst.md. Validated with 330 unit tests, two consecutive 25-case MCP/import runs, and restart recovery; the full upstream regression run remains incomplete.
44 lines
3.7 KiB
Python
44 lines
3.7 KiB
Python
"""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)
|