Web service initiated
This commit is contained in:
@@ -9,30 +9,31 @@ class RouteRegisterController:
|
||||
self.app = app
|
||||
|
||||
@staticmethod
|
||||
def add_router_with_event_to_database(route: APIRouter):
|
||||
def add_router_with_event_to_database(router: APIRouter):
|
||||
from Schemas import EndpointRestriction
|
||||
|
||||
with EndpointRestriction.new_session() as db_session:
|
||||
route_path = str(getattr(route, "path"))
|
||||
route_summary = str(getattr(route, "name")) or ""
|
||||
operation_id = str(getattr(route, "operation_id")) or ""
|
||||
if not operation_id:
|
||||
return
|
||||
for route in router.routes:
|
||||
route_path = str(getattr(route, "path"))
|
||||
route_summary = str(getattr(route, "name"))
|
||||
operation_id = getattr(route, "operation_id", None)
|
||||
if not operation_id:
|
||||
continue
|
||||
|
||||
for route_method in [method.lower() for method in getattr(route, "methods")]:
|
||||
restriction = EndpointRestriction.find_or_create(
|
||||
**dict(
|
||||
for route_method in [
|
||||
method.lower() for method in getattr(route, "methods")
|
||||
]:
|
||||
restriction = EndpointRestriction.find_or_create(
|
||||
endpoint_method=route_method,
|
||||
endpoint_name=route_path,
|
||||
endpoint_desc=route_summary.replace("_", " "),
|
||||
endpoint_function=route_summary,
|
||||
operation_uu_id=operation_id, # UUID of the endpoint
|
||||
operation_uu_id=operation_id, # UUID of the endpoint
|
||||
is_confirmed=True,
|
||||
db=db_session,
|
||||
)
|
||||
)
|
||||
if not restriction.meta_data.created:
|
||||
restriction.endpoint_code = f"AR{str(restriction.id).zfill(3)}"
|
||||
restriction.save(db=db_session)
|
||||
if restriction.meta_data.created:
|
||||
restriction.save(db=db_session)
|
||||
|
||||
def register_routes(self):
|
||||
for router in self.router_list:
|
||||
|
||||
Reference in New Issue
Block a user