59 lines
2.1 KiB
Python
59 lines
2.1 KiB
Python
from fastapi.routing import APIRouter
|
|
from fastapi.requests import Request
|
|
|
|
from api_validations.validations_request import (
|
|
DepartmentsPydantic,
|
|
PatchRecord,
|
|
ListOptions,
|
|
)
|
|
|
|
from api_services.redis.auth_actions.token import parse_token_object_to_dict
|
|
|
|
|
|
services_route = APIRouter(prefix="/services", tags=["Services"])
|
|
services_route.include_router(services_route, include_in_schema=True)
|
|
|
|
|
|
@services_route.post(path="/list", summary="List Active/Delete/Confirm Modules")
|
|
def services_list(request: Request, list_options: ListOptions):
|
|
from events.events_services import ServicesEvents
|
|
|
|
token_dict = parse_token_object_to_dict(request=request)
|
|
active_function = getattr(ServicesEvents, "services_list")
|
|
return active_function(list_options=list_options, token_dict=token_dict)
|
|
|
|
|
|
@services_route.post(path="/create", summary="Create Modules with given auth levels")
|
|
def services_create(request: Request, data: DepartmentsPydantic):
|
|
from events.events_services import ServicesEvents
|
|
|
|
token_dict = parse_token_object_to_dict(request=request)
|
|
active_function = getattr(ServicesEvents, "services_create")
|
|
return active_function(data=data, token_dict=token_dict)
|
|
|
|
|
|
@services_route.post(
|
|
path="/update/{service_uu_id}", summary="Update Modules with given auth levels"
|
|
)
|
|
def services_update(request: Request, service_uu_id: str, data: DepartmentsPydantic):
|
|
from events.events_services import ServicesEvents
|
|
|
|
token_dict = parse_token_object_to_dict(request=request)
|
|
active_function = getattr(ServicesEvents, "services_update")
|
|
return active_function(
|
|
data=data, service_uu_id=service_uu_id, token_dict=token_dict
|
|
)
|
|
|
|
|
|
@services_route.patch(
|
|
path="/patch/{service_uu_id}", summary="Patch Modules with given auth levels"
|
|
)
|
|
def services_patch(request: Request, service_uu_id: str, data: PatchRecord):
|
|
from events.events_services import ServicesEvents
|
|
|
|
token_dict = parse_token_object_to_dict(request=request)
|
|
active_function = getattr(ServicesEvents, "services_patch")
|
|
return active_function(
|
|
data=data, service_uu_id=service_uu_id, token_dict=token_dict
|
|
)
|