-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfastapi_endpoint.py
More file actions
37 lines (28 loc) · 1.18 KB
/
fastapi_endpoint.py
File metadata and controls
37 lines (28 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
"""Extend FastAPI endpoint to include simulation and aggregation routers."""
import logging
from odoo import models
from fastapi import APIRouter
_logger = logging.getLogger(__name__)
class SppApiV2SimulationEndpoint(models.Model):
"""Extend FastAPI endpoint for Simulation and Aggregation API."""
_inherit = "fastapi.endpoint"
def _get_fastapi_routers(self) -> list[APIRouter]:
"""Add simulation and aggregation routers to API V2."""
routers = super()._get_fastapi_routers()
if self.app == "api_v2":
from ..routers.aggregation import aggregation_router
from ..routers.comparison import comparison_router
from ..routers.run import run_router
from ..routers.scenario import scenario_router
from ..routers.simulation import simulation_router
routers.extend(
[
scenario_router,
run_router,
comparison_router,
simulation_router,
aggregation_router,
]
)
return routers