108 lines
3.3 KiB
Python
108 lines
3.3 KiB
Python
from ApiControllers.abstracts.event_clusters import Event
|
|
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
|
from Controllers.Postgres.response import EndpointResponse
|
|
from typing import Any
|
|
from Schemas import (
|
|
Events,
|
|
Event2Employee,
|
|
Event2Occupant,
|
|
Event2EmployeeExtra,
|
|
Event2OccupantExtra,
|
|
Service2Events,
|
|
)
|
|
|
|
|
|
# List endpoint
|
|
EventsListEvent = Event(
|
|
name="service_endpoint_list",
|
|
key="0a08c64b-ce20-4791-b1e9-014db6b75ea7",
|
|
request_validator=None, # TODO: Add request validator
|
|
response_validator=None, # TODO: Add response validator
|
|
description="Super Users List services endpoint",
|
|
)
|
|
|
|
|
|
# Event Register endpoint
|
|
EventRegisterServiceEvent = Event(
|
|
name="service_endpoint_register_service",
|
|
key="e18e7f89-5708-4a15-9258-99b0903ed43d",
|
|
request_validator=None, # TODO: Add request validator
|
|
response_validator=None, # TODO: Add response validator
|
|
description="Super Users Register service endpoint",
|
|
)
|
|
|
|
# Bind employee extra endpoint
|
|
EventBindEmployeeExtraEvent = Event(
|
|
name="service_endpoint_bind_employee_extra",
|
|
key="cd452928-4256-4fb4-b81e-0ca41d723616",
|
|
request_validator=None, # TODO: Add request validator
|
|
response_validator=None, # TODO: Add response validator
|
|
description="Super Users Bind service to employee extra endpoint",
|
|
)
|
|
|
|
# Bind occupant extra endpoint
|
|
EventBindOccupantExtraEvent = Event(
|
|
name="service_endpoint_bind_occupant_extra",
|
|
key="cb11a150-8049-45c9-8cf3-d5290ffd2e4a",
|
|
request_validator=None, # TODO: Add request validator
|
|
response_validator=None, # TODO: Add response validator
|
|
description="Super Users Bind service to occupant extra endpoint",
|
|
)
|
|
|
|
|
|
def events_list_callable(list_options: PaginateOnly):
|
|
"""
|
|
Example callable method
|
|
"""
|
|
list_options = PaginateOnly(**list_options.model_dump())
|
|
with Services.new_session() as db_session:
|
|
if list_options.query:
|
|
services_list = Services.filter_all(
|
|
*Services.convert(list_options.query), db=db_session
|
|
)
|
|
else:
|
|
services_list = Services.filter_all(db=db_session)
|
|
pagination = Pagination(data=services_list)
|
|
pagination.change(**list_options.model_dump())
|
|
pagination_result = PaginationResult(
|
|
data=services_list,
|
|
pagination=pagination,
|
|
# response_model="",
|
|
).pagination.as_dict
|
|
return EndpointResponse(
|
|
message="MSG0003-LIST",
|
|
pagination_result=pagination_result,
|
|
).response
|
|
|
|
EventsListEvent.event_callable = events_list_callable
|
|
|
|
def event_register_service_callable(data: Any):
|
|
"""
|
|
Example callable method
|
|
"""
|
|
return EndpointResponse(
|
|
message="MSG0003-REGISTER",
|
|
).response
|
|
|
|
EventRegisterServiceEvent.event_callable = event_register_service_callable
|
|
|
|
def event_bind_employee_extra_callable(data: Any):
|
|
"""
|
|
Example callable method
|
|
"""
|
|
return EndpointResponse(
|
|
message="MSG0003-BIND",
|
|
).response
|
|
|
|
EventBindEmployeeExtraEvent.event_callable = event_bind_employee_extra_callable
|
|
|
|
def event_bind_occupant_extra_callable(data: Any):
|
|
"""
|
|
Example callable method
|
|
"""
|
|
return EndpointResponse(
|
|
message="MSG0003-BIND",
|
|
).response
|
|
|
|
EventBindOccupantExtraEvent.event_callable = event_bind_occupant_extra_callable
|