updated Identity and managment service
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from typing import Any
|
||||
|
||||
from ApiControllers.abstracts.default_validations import CommonHeaders
|
||||
from ApiControllers.providers.token_provider import TokenProvider
|
||||
@@ -17,7 +18,7 @@ application_route = APIRouter(prefix="/application", tags=["Application Manageme
|
||||
@application_route.post(
|
||||
path="/list",
|
||||
description="List applications endpoint",
|
||||
operation_id="application-list",
|
||||
operation_id="3189a049-bdb0-49f3-83ff-feb8cb4cb57a",
|
||||
)
|
||||
def application_list_route(
|
||||
list_options: PaginateOnly,
|
||||
@@ -50,7 +51,7 @@ def application_list_route(
|
||||
@application_route.post(
|
||||
path="/create",
|
||||
description="Create application endpoint",
|
||||
operation_id="application-create",
|
||||
operation_id="5570be78-030a-438e-8674-7e751447608b",
|
||||
)
|
||||
def application_create_route(
|
||||
data: RequestApplication,
|
||||
@@ -85,7 +86,7 @@ def application_create_route(
|
||||
@application_route.post(
|
||||
path="/update/{application_uuid}",
|
||||
description="Update application endpoint",
|
||||
operation_id="application-update",
|
||||
operation_id="87cd4515-73dd-4d11-a01f-562e221d973c",
|
||||
)
|
||||
def application_update_route(
|
||||
data: RequestApplication,
|
||||
@@ -119,36 +120,42 @@ def application_update_route(
|
||||
).response
|
||||
|
||||
|
||||
@application_route.delete(
|
||||
path="/{application_uuid}",
|
||||
description="Delete application endpoint",
|
||||
operation_id="application-delete",
|
||||
@application_route.post(
|
||||
path="/bind/employee",
|
||||
description="Bind application to employee endpoint",
|
||||
operation_id="2bab94fa-becb-4d8e-80f1-f4631119a521",
|
||||
)
|
||||
def application_delete_route(
|
||||
application_uuid: str,
|
||||
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
|
||||
def application_bind_employee_route(
|
||||
data: Any,
|
||||
headers: CommonHeaders,
|
||||
):
|
||||
"""
|
||||
Delete application by ID
|
||||
Bind application to employee endpoint
|
||||
"""
|
||||
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
|
||||
with Applications.new_session() as db_session:
|
||||
found_application = Applications.filter_one(
|
||||
Applications.uu_id == application_uuid, db=db_session
|
||||
).data
|
||||
if not found_application:
|
||||
return EndpointResponse(
|
||||
message="MSG0002-FOUND",
|
||||
data=found_application,
|
||||
).response
|
||||
found_application.destroy(db_session)
|
||||
Applications.save(db_session)
|
||||
if found_application.meta_data.deleted:
|
||||
return EndpointResponse(
|
||||
message="MSG0004-DELETE",
|
||||
data=found_application,
|
||||
).response
|
||||
return EndpointResponse(
|
||||
message="MSG0004-DELETE",
|
||||
data=found_application,
|
||||
).response
|
||||
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
|
||||
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
|
||||
FoundCluster = ApplicationRouterCluster.get_event_cluster("ApplicationBindEmployee")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
|
||||
@application_route.post(
|
||||
path="/bind/occupant",
|
||||
description="Bind application to occupant endpoint",
|
||||
operation_id="fccf1a59-0650-4e5c-ba8d-f389dadce01c",
|
||||
)
|
||||
def application_bind_occupant_route(
|
||||
data: Any,
|
||||
headers: CommonHeaders,
|
||||
):
|
||||
"""
|
||||
Bind application to occupant endpoint
|
||||
"""
|
||||
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
|
||||
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
|
||||
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
|
||||
FoundCluster = ApplicationRouterCluster.get_event_cluster("ApplicationBindOccupant")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from typing import Any
|
||||
|
||||
from ApiControllers.abstracts.default_validations import CommonHeaders
|
||||
from ApiControllers.providers.token_provider import TokenProvider
|
||||
|
||||
from Controllers.Postgres.pagination import PaginateOnly, Pagination, PaginationResult
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Validations.service_endpoints.validations import Event2Employee, Event2Occupant
|
||||
@@ -26,46 +26,66 @@ def event_list_route(
|
||||
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
|
||||
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
|
||||
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
|
||||
FoundCluster = EventEndpointRouterCluster.get_event_cluster("EventList")
|
||||
FoundCluster = EventsEndpointRouterCluster.get_event_cluster("EventsList")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
|
||||
@event_endpoint_route.post(
|
||||
path="/bind/employee",
|
||||
description="Bind event to employee endpoint",
|
||||
operation_id="",
|
||||
path="/register/service",
|
||||
description="Register event to service endpoint",
|
||||
operation_id="c89a2150-db4d-4a8f-b6ec-9e0f09625f76",
|
||||
)
|
||||
def event_bind_employee_route(
|
||||
data: Event2Employee,
|
||||
def event_register_service_route(
|
||||
data: Any,
|
||||
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
|
||||
):
|
||||
"""
|
||||
Bind event to employee
|
||||
Register event to service
|
||||
"""
|
||||
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
|
||||
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
|
||||
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
|
||||
FoundCluster = EventEndpointRouterCluster.get_event_cluster("EventBindEmployee")
|
||||
FoundCluster = EventEndpointRouterCluster.get_event_cluster("EventRegisterService")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
|
||||
@event_endpoint_route.post(
|
||||
path="/bind/occupant",
|
||||
description="Bind event to occupant endpoint",
|
||||
operation_id="",
|
||||
path="/bind/extra/employee",
|
||||
description="Bind event to employee extra endpoint",
|
||||
operation_id="58ef3640-04ec-43f9-8f3e-f86be3ce4a24",
|
||||
)
|
||||
def event_bind_occupant_route(
|
||||
data: Event2Occupant,
|
||||
def event_bind_employee_extra_route(
|
||||
data: Any,
|
||||
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
|
||||
):
|
||||
"""
|
||||
Bind event to occupant
|
||||
Bind event to employee extra
|
||||
"""
|
||||
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
|
||||
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
|
||||
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
|
||||
FoundCluster = EventEndpointRouterCluster.get_event_cluster("EventBindOccupant")
|
||||
FoundCluster = EventEndpointRouterCluster.get_event_cluster("EventBindEmployeeExtra")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
|
||||
@event_endpoint_route.post(
|
||||
path="/bind/extra/occupant",
|
||||
description="Bind event to occupant extra endpoint",
|
||||
operation_id="7794a550-3073-43e3-b0c5-80128f8d3e4b",
|
||||
)
|
||||
def event_bind_occupant_extra_route(
|
||||
data: Any,
|
||||
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
|
||||
):
|
||||
"""
|
||||
Bind event to occupant extra
|
||||
"""
|
||||
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
|
||||
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
|
||||
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
|
||||
FoundCluster = EventEndpointRouterCluster.get_event_cluster("EventBindOccupantExtra")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
@@ -3,8 +3,11 @@ from fastapi import APIRouter
|
||||
|
||||
def get_routes() -> list[APIRouter]:
|
||||
from .application.route import application_route
|
||||
from .service_endpoints.route import service_endpoint_route
|
||||
from .service_managements.route import service_management_route
|
||||
from .event_endpoints.route import event_endpoint_route
|
||||
|
||||
return [application_route]
|
||||
return [application_route, service_endpoint_route, service_management_route, event_endpoint_route]
|
||||
|
||||
|
||||
def get_safe_endpoint_urls() -> list[tuple[str, str]]:
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
__all__ = []
|
||||
from .service_endpoints.cluster import ServiceEndpointRouterCluster
|
||||
from .event_endpoints.cluster import EventsEndpointRouterCluster
|
||||
from .application.cluster import ApplicationRouterCluster
|
||||
|
||||
__all__ = ["ServiceEndpointRouterCluster", "EventsEndpointRouterCluster", "ApplicationRouterCluster"]
|
||||
|
||||
@@ -1,27 +1,41 @@
|
||||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
SuperUsersListEvent,
|
||||
SuperUsersCreateEvent,
|
||||
SuperUsersUpdateEvent,
|
||||
ApplicationListEvent,
|
||||
ApplicationCreateEvent,
|
||||
ApplicationUpdateEvent,
|
||||
ApplicationBindEmployeeEvent,
|
||||
ApplicationBindOccupantEvent,
|
||||
)
|
||||
|
||||
UserRouterCluster = RouterCluster(name="UserRouterCluster")
|
||||
ApplicationRouterCluster = RouterCluster(name="ApplicationRouterCluster")
|
||||
|
||||
UserEventClusterList = EventCluster(
|
||||
name="UserList", endpoint_uu_id="5bc09312-d3f2-4f47-baba-17c928706da8"
|
||||
ApplicationEventClusterList = EventCluster(
|
||||
name="ApplicationList", endpoint_uu_id="3189a049-bdb0-49f3-83ff-feb8cb4cb57a"
|
||||
)
|
||||
UserEventClusterList.add_event(SuperUsersListEvent)
|
||||
ApplicationEventClusterList.add_event(ApplicationListEvent)
|
||||
|
||||
UserEventClusterCreate = EventCluster(
|
||||
name="UserCreate", endpoint_uu_id="08d4b572-1584-47bb-aa42-8d068e5514e7"
|
||||
ApplicationEventClusterCreate = EventCluster(
|
||||
name="ApplicationCreate", endpoint_uu_id="5570be78-030a-438e-8674-7e751447608b"
|
||||
)
|
||||
UserEventClusterCreate.add_event(SuperUsersCreateEvent)
|
||||
ApplicationEventClusterCreate.add_event(ApplicationCreateEvent)
|
||||
|
||||
UserEventClusterUpdate = EventCluster(
|
||||
name="UserUpdate", endpoint_uu_id="b641236a-928d-4f19-a1d2-5edf611d1e56"
|
||||
ApplicationEventClusterUpdate = EventCluster(
|
||||
name="ApplicationUpdate", endpoint_uu_id="87cd4515-73dd-4d11-a01f-562e221d973c"
|
||||
)
|
||||
UserEventClusterUpdate.add_event(SuperUsersUpdateEvent)
|
||||
ApplicationEventClusterUpdate.add_event(ApplicationUpdateEvent)
|
||||
|
||||
UserRouterCluster.set_event_cluster(UserEventClusterList)
|
||||
UserRouterCluster.set_event_cluster(UserEventClusterCreate)
|
||||
UserRouterCluster.set_event_cluster(UserEventClusterUpdate)
|
||||
ApplicationEventClusterBindEmployee = EventCluster(
|
||||
name="ApplicationBindEmployee", endpoint_uu_id="2bab94fa-becb-4d8e-80f1-f4631119a521"
|
||||
)
|
||||
ApplicationEventClusterBindEmployee.add_event(ApplicationBindEmployeeEvent)
|
||||
|
||||
ApplicationEventClusterBindOccupant = EventCluster(
|
||||
name="ApplicationBindOccupant", endpoint_uu_id="fccf1a59-0650-4e5c-ba8d-f389dadce01c"
|
||||
)
|
||||
ApplicationEventClusterBindOccupant.add_event(ApplicationBindOccupantEvent)
|
||||
|
||||
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterList)
|
||||
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterCreate)
|
||||
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterUpdate)
|
||||
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterBindEmployee)
|
||||
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterBindOccupant)
|
||||
|
||||
@@ -1,53 +1,75 @@
|
||||
from ApiControllers.abstracts.event_clusters import Event
|
||||
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Schemas import Users
|
||||
from Schemas import (
|
||||
Applications,
|
||||
Application2Employee,
|
||||
Application2Occupant,
|
||||
)
|
||||
|
||||
|
||||
# List endpoint
|
||||
SuperUsersListEvent = Event(
|
||||
name="supers_users_list",
|
||||
key="341b394f-9f11-4abb-99e7-4b27fa6bf012",
|
||||
ApplicationListEvent = Event(
|
||||
name="application_list",
|
||||
key="b4efda1e-bde7-4659-ab1a-ef74c0fd88b6",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List events of users endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
SuperUsersCreateEvent = Event(
|
||||
name="supers_users_create",
|
||||
key="4e7e189e-e015-4ff8-902d-60138cbc77a6",
|
||||
ApplicationCreateEvent = Event(
|
||||
name="application_create",
|
||||
key="f53ca9aa-5536-4d77-9129-78d67e61db4a",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Create events of users endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
SuperUsersUpdateEvent = Event(
|
||||
name="supers_users_update",
|
||||
key="efa4aa4a-d414-4391-91ee-97eb617b7755",
|
||||
ApplicationUpdateEvent = Event(
|
||||
name="application_update",
|
||||
key="0e9a855e-4e69-44b5-8ac2-825daa32840c",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Update events of users endpoint",
|
||||
)
|
||||
|
||||
#Bind Application to employee
|
||||
ApplicationBindEmployeeEvent = Event(
|
||||
name="application_bind_employee",
|
||||
key="26a96c2d-bca8-41cb-8ac1-f3ca8124434b",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Bind events of users endpoint",
|
||||
)
|
||||
|
||||
def supers_users_list_callable(list_options: PaginateOnly):
|
||||
#Bind Application to occupant
|
||||
ApplicationBindOccupantEvent = Event(
|
||||
name="application_bind_occupant",
|
||||
key="4eaf2bb0-2a42-4d21-ae65-a9259ebee189",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Bind events of users endpoint",
|
||||
)
|
||||
|
||||
|
||||
def application_list_callable(list_options: PaginateOnly):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
with Users.new_session() as db_session:
|
||||
with Applications.new_session() as db_session:
|
||||
if list_options.query:
|
||||
users_list = Users.filter_all(
|
||||
*Users.convert(list_options.query), db=db_session
|
||||
applications_list = Applications.filter_all(
|
||||
*Applications.convert(list_options.query), db=db_session
|
||||
)
|
||||
else:
|
||||
users_list = Users.filter_all(db=db_session)
|
||||
pagination = Pagination(data=users_list)
|
||||
applications_list = Applications.filter_all(db=db_session)
|
||||
pagination = Pagination(data=applications_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(
|
||||
data=users_list,
|
||||
data=applications_list,
|
||||
pagination=pagination,
|
||||
# response_model="",
|
||||
).pagination.as_dict
|
||||
@@ -57,10 +79,10 @@ def supers_users_list_callable(list_options: PaginateOnly):
|
||||
).response
|
||||
|
||||
|
||||
SuperUsersListEvent.event_callable = supers_users_list_callable
|
||||
ApplicationListEvent.event_callable = application_list_callable
|
||||
|
||||
|
||||
def supers_users_create_callable():
|
||||
def application_create_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
@@ -74,10 +96,10 @@ def supers_users_create_callable():
|
||||
}
|
||||
|
||||
|
||||
SuperUsersCreateEvent.event_callable = supers_users_create_callable
|
||||
ApplicationCreateEvent.event_callable = application_create_callable
|
||||
|
||||
|
||||
def supers_users_update_callable():
|
||||
def application_update_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
@@ -91,4 +113,36 @@ def supers_users_update_callable():
|
||||
}
|
||||
|
||||
|
||||
SuperUsersUpdateEvent.event_callable = supers_users_update_callable
|
||||
ApplicationUpdateEvent.event_callable = application_update_callable
|
||||
|
||||
|
||||
def application_bind_employee_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
ApplicationBindEmployeeEvent.event_callable = application_bind_employee_callable
|
||||
|
||||
|
||||
def application_bind_occupant_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
ApplicationBindOccupantEvent.event_callable = application_bind_occupant_callable
|
||||
|
||||
@@ -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
|
||||
@@ -5,7 +5,7 @@ from .supers_events import (
|
||||
|
||||
ServiceEndpointRouterCluster = RouterCluster(name="ServiceEndpointRouterCluster")
|
||||
ServiceEndpointEventClusterList = EventCluster(
|
||||
name="ServiceList", endpoint_uu_id="82ef3444-a26a-499d-8c77-ca2e95d6ceb9"
|
||||
name="ServiceList", endpoint_uu_id="f4e4d332-70b1-4121-9fcc-a08850b72aaa"
|
||||
)
|
||||
ServiceEndpointEventClusterList.add_event(ServiceEndpointListEvent)
|
||||
ServiceEndpointRouterCluster.set_event_cluster(ServiceEndpointEventClusterList)
|
||||
|
||||
Reference in New Issue
Block a user