updated Identity and managment service
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
EventsListEvent,
|
||||
EventRegisterServiceEvent,
|
||||
EventBindEmployeeExtraEvent,
|
||||
EventBindOccupantExtraEvent,
|
||||
)
|
||||
|
||||
EventsEndpointRouterCluster = RouterCluster(name="EventsEndpointRouterCluster")
|
||||
|
||||
EventsEndpointEventClusterList = EventCluster(
|
||||
name="EventsList", endpoint_uu_id="0659d5e4-671f-466c-a84f-47a1290a6f0d"
|
||||
)
|
||||
EventsEndpointEventClusterList.add_event(EventsListEvent)
|
||||
|
||||
EventsEndpointEventClusterRegisterService = EventCluster(
|
||||
name="EventRegisterService", endpoint_uu_id="c89a2150-db4d-4a8f-b6ec-9e0f09625f76"
|
||||
)
|
||||
EventsEndpointEventClusterRegisterService.add_event(EventRegisterServiceEvent)
|
||||
|
||||
EventsEndpointEventClusterBindEmployeeExtra = EventCluster(
|
||||
name="EventBindEmployeeExtra", endpoint_uu_id="58ef3640-04ec-43f9-8f3e-f86be3ce4a24"
|
||||
)
|
||||
EventsEndpointEventClusterBindEmployeeExtra.add_event(EventBindEmployeeExtraEvent)
|
||||
|
||||
EventsEndpointEventClusterBindOccupantExtra = EventCluster(
|
||||
name="EventBindOccupantExtra", endpoint_uu_id="7794a550-3073-43e3-b0c5-80128f8d3e4b"
|
||||
)
|
||||
EventsEndpointEventClusterBindOccupantExtra.add_event(EventBindOccupantExtraEvent)
|
||||
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterList)
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterRegisterService)
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterBindEmployeeExtra)
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterBindOccupantExtra)
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
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="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="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="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="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
|
||||
Reference in New Issue
Block a user