api added

This commit is contained in:
2025-05-30 21:10:44 +03:00
parent c44a724a05
commit e5829f0525
72 changed files with 5576 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
from .events.cluster import EventsEndpointRouterCluster
from .application.cluster import ApplicationRouterCluster
# from .services.cluster import ServicesEndpointRouterCluster
__all__ = ["EventsEndpointRouterCluster", "ApplicationRouterCluster"]

View File

@@ -0,0 +1,54 @@
from api_initializer.event_clusters import EventCluster, RouterCluster
from index import endpoints_index
from .supers_events import (
ApplicationListAllEvent,
ApplicationListAvailableEvent,
ApplicationListAppendedEvent,
ApplicationRegisterServiceEvent,
ApplicationUnRegisterServiceEvent,
ApplicationCreateEvent,
ApplicationUpdateEvent,
ApplicationBindEmployeeEvent,
ApplicationBindOccupantEvent,
)
ApplicationRouterCluster = RouterCluster(name="ApplicationRouterCluster")
ApplicationEventClusterListAll = EventCluster(name="ApplicationListAll", endpoint_uu_id=endpoints_index["ApplicationListAll"])
ApplicationEventClusterListAll.add_event(ApplicationListAllEvent)
ApplicationEventClusterListAvailable = EventCluster(name="ApplicationListAvailable", endpoint_uu_id=endpoints_index["ApplicationListAvailable"])
ApplicationEventClusterListAvailable.add_event(ApplicationListAvailableEvent)
ApplicationEventClusterListAppended = EventCluster(name="ApplicationListAppended", endpoint_uu_id=endpoints_index["ApplicationListAppended"])
ApplicationEventClusterListAppended.add_event(ApplicationListAppendedEvent)
ApplicationEventClusterRegisterService = EventCluster(name="ApplicationRegisterService", endpoint_uu_id=endpoints_index["ApplicationRegisterService"])
ApplicationEventClusterRegisterService.add_event(ApplicationRegisterServiceEvent)
ApplicationEventClusterUnregisterService = EventCluster(name="ApplicationUnRegisterService", endpoint_uu_id=endpoints_index["ApplicationUnRegisterService"])
ApplicationEventClusterUnregisterService.add_event(ApplicationUnRegisterServiceEvent)
ApplicationEventClusterCreate = EventCluster(name="ApplicationCreate", endpoint_uu_id=endpoints_index["ApplicationCreate"])
ApplicationEventClusterCreate.add_event(ApplicationCreateEvent)
ApplicationEventClusterUpdate = EventCluster(name="ApplicationUpdate", endpoint_uu_id=endpoints_index["ApplicationUpdate"])
ApplicationEventClusterUpdate.add_event(ApplicationUpdateEvent)
ApplicationEventClusterBindEmployee = EventCluster(name="ApplicationBindEmployee", endpoint_uu_id=endpoints_index["ApplicationBindEmployee"])
ApplicationEventClusterBindEmployee.add_event(ApplicationBindEmployeeEvent)
ApplicationEventClusterBindOccupant = EventCluster(name="ApplicationBindOccupant", endpoint_uu_id=endpoints_index["ApplicationBindOccupant"])
ApplicationEventClusterBindOccupant.add_event(ApplicationBindOccupantEvent)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterListAll)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterListAvailable)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterListAppended)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterRegisterService)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterUnregisterService)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterCreate)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterUpdate)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterBindEmployee)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterBindOccupant)

View File

@@ -0,0 +1,356 @@
from typing import Any
from api_initializer.event_clusters import Event
from api_validations.response import (
PaginateOnly,
Pagination,
PaginationResult,
PostgresResponseSingle,
PostgresResponse,
EndpointResponse
)
from schemas import (
Applications,
Application2Employee,
Application2Occupant,
Service2Application,
Services,
)
# List all endpoint
ApplicationListAllEvent = Event(
name="application_list_all",
key="1971ce4d-4f59-4aa8-83e2-ca19d7da6d11",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users List all applications endpoint",
)
# List available endpoint
ApplicationListAvailableEvent = Event(
name="application_list_available",
key="d8e733f5-b53a-4c36-9082-12579bf9cc4a",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users List available applications endpoint",
)
# List appended endpoint
ApplicationListAppendedEvent = Event(
name="application_list_appended",
key="ea7bbd58-da09-407c-a630-c324e0272385",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users List appended applications endpoint",
)
# Register application to service endpoint
ApplicationRegisterServiceEvent = Event(
name="application_register_service",
key="47d7cfc8-6004-4442-8357-16ceac5d9d18",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users Register application to service endpoint",
)
# Unregister application to service endpoint
ApplicationUnRegisterServiceEvent = Event(
name="application_unregister_service",
key="d228ab26-0b74-440f-8f1f-8f40be5a22f2",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users Unregister application to service endpoint",
)
# Create endpoint
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="Super Users Create applications endpoint",
)
# Update endpoint
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="Super Users Update applications endpoint",
)
# Bind employee endpoint
ApplicationBindEmployeeEvent = Event(
name="application_bind_employee",
key="948763ee-f221-409e-9a82-8525053505cb",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users Bind applications to employee endpoint",
)
# Bind occupant endpoint
ApplicationBindOccupantEvent = Event(
name="application_bind_occupant",
key="03c894a3-b337-4d90-a559-5fcd0dc3e2c5",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users Bind applications to occupant endpoint",
)
def application_list_all_callable(list_options: PaginateOnly):
list_options = PaginateOnly(**list_options.model_dump())
with Applications.new_session() as db_session:
Applications.set_session(db_session)
if list_options.query:
applications_list = Applications.query.filter(*Applications.convert(list_options.query))
else:
applications_list = Applications.query.filter()
pagination = Pagination(data=applications_list)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(data=applications_list, pagination=pagination)
return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response
ApplicationListAllEvent.event_callable = application_list_all_callable
def application_list_available_callable(list_options: PaginateOnly):
"""
Example callable method
"""
list_options = PaginateOnly(**list_options.model_dump())
service_uu_id = list_options.query.get("service_uu_id__ilike", None)
if not service_uu_id:
return {
"message": "MSG0003-PARAM-MISSING",
"data": list_options.query,
"completed": False,
}
list_options.query.pop("service_uu_id__ilike", None)
list_options.query.pop("service_uu_id", None)
with Applications.new_session() as db_session:
Service2Application.set_session(db_session)
service2applications = Service2Application.query.filter(*Service2Application.convert({"service_uu_id__ilike": service_uu_id})).all()
already_events = [service_to_application.application_id for service_to_application in service2applications]
if list_options.query:
applications_list = Applications.query.filter(*Applications.convert(list_options.query), Applications.id.not_in(already_events))
else:
applications_list = Applications.query.filter(Applications.id.not_in(already_events))
pagination = Pagination(data=applications_list)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(data=applications_list, pagination=pagination)
return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response
ApplicationListAvailableEvent.event_callable = application_list_available_callable
def application_list_appended_callable(list_options: PaginateOnly):
"""
Example callable method
"""
list_options = PaginateOnly(**list_options.model_dump())
service_uu_id = list_options.query.get("service_uu_id__ilike", None)
if not service_uu_id:
return {
"message": "MSG0003-PARAM-MISSING",
"data": list_options.query,
"completed": False,
}
list_options.query.pop("service_uu_id__ilike", None)
list_options.query.pop("service_uu_id", None)
with Service2Application.new_session() as db_session:
Service2Application.set_session(db_session)
Applications.set_session(db_session)
service2applications = Service2Application.query.filter(*Service2Application.convert({"service_uu_id__ilike": service_uu_id})).all()
already_events = [service_to_application.application_id for service_to_application in service2applications]
if list_options.query:
applications_list = Applications.query.filter(*Applications.convert(list_options.query), Applications.id.in_(already_events))
else:
applications_list = Applications.query.filter(Applications.id.in_(already_events))
pagination = Pagination(data=applications_list)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(data=applications_list, pagination=pagination)
return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response
ApplicationListAppendedEvent.event_callable = application_list_appended_callable
def application_create_callable(data: Any):
"""
Create a new application
"""
with Applications.new_session() as db_session:
created_application_dict = data.model_dump()
Applications.set_session(db_session)
created_application = Applications.create(**created_application_dict)
if created_application:
created_application.save()
return {
"completed": True,
"message": "MSG0001-INSERT",
"data": created_application,
}
return {
"completed": False,
"message": "MSG0002-ERROR",
"data": created_application,
}
ApplicationCreateEvent.event_callable = application_create_callable
def application_update_callable(data: Any, uu_id: str):
"""
Update an existing application
"""
with Applications.new_session() as db_session:
updated_application_dict = data.model_dump(exclude_unset=True, exclude_none=True)
found_application = Applications.query.filter(Applications.uu_id == uu_id).first()
if not found_application:
return {
"completed": False,
"message": "MSG0002-FOUND",
"data": found_application,
}
updated_application = found_application.update(**updated_application_dict)
updated_application.save()
if updated_application.meta_data.updated:
return {
"completed": True,
"message": "MSG0003-UPDATE",
"data": updated_application,
}
return {
"completed": False,
"message": "MSG0003-UPDATE",
"data": updated_application,
}
ApplicationUpdateEvent.event_callable = application_update_callable
def application_register_service_callable(data: Any):
"""
Register an application to a service
"""
with Applications.new_session() as db_session:
Applications.set_session(db_session)
event = Applications.query.filter(Applications.uu_id == data.application_uu_id).first()
if not event:
return {
"message": "MSG0003-NOT-FOUND",
"data": data.model_dump(),
"completed": False,
}
service = Services.query.filter(Services.uu_id == data.service_uu_id).first()
if not service:
return {
"message": "MSG0003-NOT-FOUND",
"data": data.model_dump(),
"completed": False,
}
service_to_application = Service2Application.query.filter(
Service2Application.service_id == service.data.id,
Service2Application.application_id == event.data.id,
).first()
if service_to_application:
return {
"message": "MSG0003-ALREADY-FOUND",
"data": data.model_dump(),
"completed": False,
}
service_to_application = Service2Application.create(
service_id=service.data.id,
service_uu_id=str(service.data.uu_id),
application_id=event.data.id,
application_uu_id=str(event.data.uu_id),
application_code=event.data.application_code,
site_url=event.data.site_url,
is_confirmed=True,
)
service_to_application.save()
return {
"message": "MSG0003-REGISTER",
"data": data.model_dump(),
"completed": True,
}
ApplicationRegisterServiceEvent.event_callable = application_register_service_callable
def application_unregister_service_callable(data: Any):
"""
Unregister an application from a service
"""
with Applications.new_session() as db_session:
Applications.set_session(db_session)
application = Applications.query.filter(Applications.uu_id == data.application_uu_id).first()
if not application:
return {
"message": "MSG0003-NOT-FOUND",
"data": data.model_dump(),
"completed": False,
}
service = Services.query.filter(Services.uu_id == data.service_uu_id).first()
if not service:
return {
"message": "MSG0003-NOT-FOUND",
"data": data.model_dump(),
"completed": False,
}
service_to_application = Service2Application.query.filter(
Service2Application.service_id == service.data.id,
Service2Application.application_id == application.data.id,
).first()
if not service_to_application:
return {
"message": "MSG0003-NOT-FOUND",
"data": data.model_dump(),
"completed": False,
}
service_to_application.query.delete()
db_session.commit()
return {
"message": "MSG0003-UNREGISTER",
"data": data.model_dump(),
"completed": True,
}
ApplicationUnRegisterServiceEvent.event_callable = application_unregister_service_callable
def application_bind_employee_callable(data: Any):
"""
Example callable method
"""
return {
"message": "MSG0003-BIND",
"data": data.model_dump(),
"completed": True,
}
ApplicationBindEmployeeEvent.event_callable = application_bind_employee_callable
def application_bind_occupant_callable(data: Any):
"""
Example callable method
"""
return {
"message": "MSG0003-BIND",
"data": data.model_dump(),
"completed": True,
}
ApplicationBindOccupantEvent.event_callable = application_bind_occupant_callable

View File

@@ -0,0 +1,37 @@
from api_initializer.event_clusters import EventCluster, RouterCluster
from index import endpoints_index
from .supers_events import (
EventsListAvailableEvent,
EventsListAppendedEvent,
EventRegisterServiceEvent,
EventUnRegisterServiceEvent,
EventBindEmployeeExtraEvent,
EventBindOccupantExtraEvent,
)
EventsEndpointRouterCluster = RouterCluster(name="EventsEndpointRouterCluster")
EventsEndpointEventClusterListAvailable = EventCluster(name="EventsListAvailable", endpoint_uu_id=endpoints_index["EventsListAvailable"])
EventsEndpointEventClusterListAvailable.add_event(EventsListAvailableEvent)
EventsEndpointEventClusterListAppended = EventCluster(name="EventsListAppended", endpoint_uu_id=endpoints_index["EventsListAppended"])
EventsEndpointEventClusterListAppended.add_event(EventsListAppendedEvent)
EventsEndpointEventClusterRegisterService = EventCluster(name="EventRegisterService", endpoint_uu_id=endpoints_index["EventRegisterService"])
EventsEndpointEventClusterRegisterService.add_event(EventRegisterServiceEvent)
EventsEndpointEventClusterUnregisterService = EventCluster(name="EventUnregisterService", endpoint_uu_id=endpoints_index["EventUnRegisterService"])
EventsEndpointEventClusterUnregisterService.add_event(EventUnRegisterServiceEvent)
EventsEndpointEventClusterBindEmployeeExtra = EventCluster(name="EventBindExtraEmployee", endpoint_uu_id=endpoints_index["EventBindExtraEmployee"])
EventsEndpointEventClusterBindEmployeeExtra.add_event(EventBindEmployeeExtraEvent)
EventsEndpointEventClusterBindOccupantExtra = EventCluster(name="EventBindExtraOccupant", endpoint_uu_id=endpoints_index["EventBindExtraOccupant"])
EventsEndpointEventClusterBindOccupantExtra.add_event(EventBindOccupantExtraEvent)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterListAvailable)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterListAppended)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterRegisterService)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterUnregisterService)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterBindEmployeeExtra)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterBindOccupantExtra)

View File

@@ -0,0 +1,186 @@
from typing import Any
from api_initializer.event_clusters import Event
from api_validations.response import (
PaginateOnly,
Pagination,
PaginationResult,
PostgresResponseSingle,
PostgresResponse,
EndpointResponse
)
from schemas import (
Events,
Event2Employee,
Event2Occupant,
Event2EmployeeExtra,
Event2OccupantExtra,
Service2Events,
Services,
)
# List available events endpoint
EventsListAvailableEvent = Event(
name="event_endpoint_list_available",
key="d39af512-ec71-4c0f-9b35-e53b0d06d3a4",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users List available events endpoint",
)
# List appended events endpoint
EventsListAppendedEvent = Event(
name="event_endpoint_list_appended",
key="bea77d6a-d99f-468b-9002-b3bda6bb6ad0",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users List appended events endpoint",
)
# Event Register endpoint
EventRegisterServiceEvent = Event(
name="event_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",
)
# Event Unregister endpoint
EventUnRegisterServiceEvent = Event(
name="service_endpoint_unregister_service",
key="4d693774-4857-435b-a63c-c39baebfe916",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users Unregister 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_available_callable(list_options: PaginateOnly):
"""List available events with pagination and filtering options"""
list_options = PaginateOnly(**list_options.model_dump())
service_uu_id = list_options.query.get("service_uu_id__ilike", None)
if not service_uu_id:
return {"message": "MSG0003-PARAM-MISSING", "data": list_options.query, "completed": False}
list_options.query.pop("service_uu_id__ilike", None)
list_options.query.pop("service_uu_id", None)
with Events.new_session() as db_session:
service2events = Service2Events.query.filter(Service2Events.service_uu_id.ilike(f'%{service_uu_id}%'),)
already_events = [service_to_event.event_id for service_to_event in service2events.all()]
if list_options.query:
events_list = Events.query.filter(*Events.convert(list_options.query), Events.id.not_in(already_events))
else:
events_list = Events.query.filter(Events.id.not_in(already_events))
events_response = PostgresResponse(data=events_list)
pagination = Pagination(data=events_response)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(data=events_response, pagination=pagination)
return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response
EventsListAvailableEvent.event_callable = events_list_available_callable
def events_list_appended_callable(list_options: PaginateOnly):
"""List appended events with pagination and filtering options"""
list_options = PaginateOnly(**list_options.model_dump())
service_uu_id = list_options.query.get("service_uu_id__ilike", None)
if not service_uu_id:
return {"message": "MSG0003-PARAM-MISSING", "data": list_options.query, "completed": False}
list_options.query.pop("service_uu_id__ilike", None)
list_options.query.pop("service_uu_id", None)
with Events.new_session() as db_session:
service2events = Service2Events.query.filter(*Service2Events.convert({"service_uu_id__ilike": service_uu_id}))
already_events = [service_to_event.event_id for service_to_event in service2events.all()]
if list_options.query:
events_list = Events.filter_all(*Events.convert(list_options.query), Events.id.in_(already_events))
else:
events_list = Events.filter_all(Events.id.in_(already_events))
events_response = PostgresResponse(data=events_list)
pagination = Pagination(data=events_response)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(data=events_response, pagination=pagination)
return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response
EventsListAppendedEvent.event_callable = events_list_appended_callable
def event_register_service_callable(data: Any):
"""Register event to service"""
with Events.new_session() as db_session:
event = Events.query.filter(Events.uu_id == data.event_uu_id).first()
if not event:
return EndpointResponse(message="MSG0003-NOT-FOUND", data=data.model_dump(), completed=False).response
service = Services.query.filter(Services.uu_id == data.service_uu_id).first()
if not service:
return {"message": "MSG0003-NOT-FOUND", "data": data.model_dump(), "completed": False,}
service_to_event = Service2Events.query.filter_by(service_id=service.data.id, event_id=event.data.id).first()
Service2Events.set_session(db_session)
if not service_to_event:
service_to_event = Service2Events.create(
service_id=service.data.id, service_uu_id=str(service.data.uu_id), event_id=event.data.id,
event_uu_id=str(event.data.uu_id), is_confirmed=True,
)
service_to_event.save()
return {"message": "MSG0003-REGISTERED", "data": data.model_dump(), "completed": True}
return {"message": "MSG0003-REGISTER-ERROR", "data": data.model_dump(), "completed": True}
EventRegisterServiceEvent.event_callable = event_register_service_callable
def event_unregister_service_callable(data: Any):
"""Unregister event from service"""
with Events.new_session() as db_session:
event = Events.query.filter(Events.uu_id == data.event_uu_id).first()
if not event:
return EndpointResponse(message="MSG0003-NOT-FOUND", data=data.model_dump(), completed=False).response
service = Services.query.filter(Services.uu_id == data.service_uu_id).first()
if not service:
return {"message": "MSG0003-NOT-FOUND", "data": data.model_dump(), "completed": False}
service_to_event = Service2Events.query.filter(
Service2Events.service_id == service.data.id, Service2Events.event_id == event.data.id,
).first()
if not service_to_event:
return {"message": "MSG0003-NOT-FOUND", "data": data.model_dump(), "completed": False}
service_to_event.query.delete()
return {"message": "MSG0003-UNREGISTER", "data": data.model_dump(), "completed": True}
EventUnRegisterServiceEvent.event_callable = event_unregister_service_callable
def event_bind_employee_extra_callable(data: Any):
"""Bind event to employee extra"""
return EndpointResponse(message="MSG0003-BIND-EMP").response
EventBindEmployeeExtraEvent.event_callable = event_bind_employee_extra_callable
def event_bind_occupant_extra_callable(data: Any):
"""Bind event to occupant extra"""
return EndpointResponse(message="MSG0003-BIND-OCUP").response
EventBindOccupantExtraEvent.event_callable = event_bind_occupant_extra_callable

View File

@@ -0,0 +1,27 @@
from api_initializer.event_clusters import EventCluster, RouterCluster
from index import endpoints_index
from .supers_events import (
SuperServiceListEvent,
SuperServiceCreateEvent,
SuperServiceUpdateEvent,
SuperServiceDeleteEvent,
)
ServicesRouterCluster = RouterCluster(name="ServicesRouterCluster")
ServicesEventClusterList = EventCluster(name="ServicesList", endpoint_uu_id=endpoints_index["ServicesList"])
ServicesEventClusterList.add_event(SuperServiceListEvent)
ServicesEventClusterCreate = EventCluster(name="ServicesCreate", endpoint_uu_id=endpoints_index["ServicesCreate"])
ServicesEventClusterCreate.add_event(SuperServiceCreateEvent)
ServicesEventClusterUpdate = EventCluster(name="ServicesUpdate", endpoint_uu_id=endpoints_index["ServicesUpdate"])
ServicesEventClusterUpdate.add_event(SuperServiceUpdateEvent)
ServicesEventClusterDelete = EventCluster(name="ServicesDelete", endpoint_uu_id=endpoints_index["ServicesDelete"])
ServicesEventClusterDelete.add_event(SuperServiceDeleteEvent)
ServicesRouterCluster.set_event_cluster(ServicesEventClusterList)
ServicesRouterCluster.set_event_cluster(ServicesEventClusterCreate)
ServicesRouterCluster.set_event_cluster(ServicesEventClusterUpdate)
ServicesRouterCluster.set_event_cluster(ServicesEventClusterDelete)

View File

@@ -0,0 +1,105 @@
from typing import Any
from api_validations.defaults.validations import CommonHeaders
from api_initializer.event_clusters import Event
from api_validations.response import (
PaginateOnly,
Pagination,
PaginationResult,
PostgresResponseSingle,
PostgresResponse,
EndpointResponse
)
from schemas import (
Events,
Event2Employee,
Event2Occupant,
Event2EmployeeExtra,
Event2OccupantExtra,
Service2Events,
Services,
)
# List services endpoint
SuperServiceListEvent = Event(
name="super_service_list",
key="ea24f5e6-279a-47e7-a5bd-8a5c1bd72d05",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users List available events endpoint",
)
# Create service endpoint
SuperServiceCreateEvent = Event(
name="super_service_create",
key="086051f4-f1ec-4d56-b706-09ce53d5e66c",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users Create service endpoint",
)
# Update service endpoint
SuperServiceUpdateEvent = Event(
name="super_service_update",
key="267956e5-32b7-4b60-ab75-3b56b935d5c1",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users Update service endpoint",
)
# Delete service endpoint
SuperServiceDeleteEvent = Event(
name="super_service_delete",
key="6c333122-272e-4690-9d71-7f5e14cc64c8",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Super Users Delete service endpoint",
)
def super_service_list_callable(list_options: PaginateOnly, headers: CommonHeaders):
"""List available events with pagination and filtering options"""
return {
"message": "MSG0003-LIST",
"data": None,
"completed": True,
}
SuperServiceListEvent.event_callable = super_service_list_callable
def super_service_create_callable(data: Any, headers: CommonHeaders):
"""Create service"""
return {
"message": "MSG0003-CREATE",
"data": None,
"completed": True,
}
SuperServiceCreateEvent.event_callable = super_service_create_callable
def super_service_update_callable(data: Any, headers: CommonHeaders):
"""Update service"""
return {
"message": "MSG0003-UPDATE",
"data": None,
"completed": True,
}
SuperServiceUpdateEvent.event_callable = super_service_update_callable
def super_service_delete_callable(data: Any, headers: CommonHeaders):
"""Delete service"""
return {
"message": "MSG0003-DELETE",
"data": None,
"completed": True,
}
SuperServiceDeleteEvent.event_callable = super_service_delete_callable