created design pattern
This commit is contained in:
15
ApiServices/BuildingService/Events/__init__.py
Normal file
15
ApiServices/BuildingService/Events/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from .building.cluster import BuildRouterCluster
|
||||
from .area.cluster import BuildAreaRouterCluster
|
||||
from .parts.cluster import BuildPartsRouterCluster
|
||||
from .spaces.cluster import BuildLivingSpaceRouterCluster
|
||||
from .type.cluster import BuildTypeRouterCluster
|
||||
from .sites.cluster import BuildSitesRouterCluster
|
||||
|
||||
__all__ = [
|
||||
"BuildRouterCluster",
|
||||
"BuildAreaRouterCluster",
|
||||
"BuildPartsRouterCluster",
|
||||
"BuildLivingSpaceRouterCluster",
|
||||
"BuildTypeRouterCluster",
|
||||
"BuildSitesRouterCluster",
|
||||
]
|
||||
20
ApiServices/BuildingService/Events/area/cluster.py
Normal file
20
ApiServices/BuildingService/Events/area/cluster.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
BuildAreaListEvent,
|
||||
BuildAreaCreateEvent,
|
||||
BuildAreaUpdateEvent,
|
||||
)
|
||||
|
||||
BuildAreaRouterCluster = RouterCluster(name="BuildAreaRouterCluster")
|
||||
|
||||
BuildAreaEventClusterList = EventCluster(name="BuildAreaList", endpoint_uu_id="cc487a4f-9a45-4072-89c1-a1ad504c79ad")
|
||||
BuildAreaEventClusterCreate = EventCluster(name="BuildAreaCreate", endpoint_uu_id="bdd58d68-3a7c-4150-9f5b-e322db35b804")
|
||||
BuildAreaEventClusterUpdate = EventCluster(name="BuildAreaUpdate", endpoint_uu_id="cad0c4e2-36e3-4f80-9ad2-b06bf8cd8d1c")
|
||||
|
||||
BuildAreaEventClusterList.add_event(BuildAreaListEvent)
|
||||
BuildAreaEventClusterCreate.add_event(BuildAreaCreateEvent)
|
||||
BuildAreaEventClusterUpdate.add_event(BuildAreaUpdateEvent)
|
||||
|
||||
BuildAreaRouterCluster.set_event_cluster(BuildAreaEventClusterList)
|
||||
BuildAreaRouterCluster.set_event_cluster(BuildAreaEventClusterCreate)
|
||||
BuildAreaRouterCluster.set_event_cluster(BuildAreaEventClusterUpdate)
|
||||
96
ApiServices/BuildingService/Events/area/supers_events.py
Normal file
96
ApiServices/BuildingService/Events/area/supers_events.py
Normal file
@@ -0,0 +1,96 @@
|
||||
from ApiControllers.abstracts.event_clusters import Event
|
||||
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Schemas import BuildArea
|
||||
|
||||
|
||||
# List endpoint
|
||||
BuildAreaListEvent = Event(
|
||||
name="build_area_list",
|
||||
key="306e6e11-21da-4fbb-b3d6-3a5179ecfe71",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List events of build area endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
BuildAreaCreateEvent = Event(
|
||||
name="build_area_create",
|
||||
key="aa173f0f-7a97-4e91-97da-173626dd3257",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Create events of build area endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
BuildAreaUpdateEvent = Event(
|
||||
name="build_area_update",
|
||||
key="358404d0-fb80-4d58-8907-0c04948b364e",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Update events of build area endpoint",
|
||||
)
|
||||
|
||||
|
||||
def build_area_list_callable(list_options: PaginateOnly):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
with BuildArea.new_session() as db_session:
|
||||
if list_options.query:
|
||||
buildings_list = BuildArea.filter_all(
|
||||
*BuildArea.convert(list_options.query), db=db_session
|
||||
)
|
||||
else:
|
||||
buildings_list = BuildArea.filter_all(db=db_session)
|
||||
pagination = Pagination(data=buildings_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(
|
||||
data=buildings_list,
|
||||
pagination=pagination,
|
||||
# response_model="",
|
||||
).pagination.as_dict
|
||||
return EndpointResponse(
|
||||
message="MSG0003-LIST",
|
||||
pagination_result=pagination_result,
|
||||
).response
|
||||
|
||||
|
||||
BuildAreaListEvent.event_callable = build_area_list_callable
|
||||
|
||||
|
||||
def build_area_create_callable(data: dict):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
with BuildArea.new_session() as db_session:
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildAreaCreateEvent.event_callable = build_area_create_callable
|
||||
|
||||
|
||||
def build_area_update_callable(data: dict):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
with BuildArea.new_session() as db_session:
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildAreaUpdateEvent.event_callable = build_area_update_callable
|
||||
27
ApiServices/BuildingService/Events/building/cluster.py
Normal file
27
ApiServices/BuildingService/Events/building/cluster.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
BuildingListEvent,
|
||||
BuildingCreateEvent,
|
||||
BuildingUpdateEvent,
|
||||
)
|
||||
|
||||
BuildRouterCluster = RouterCluster(name="BuildRouterCluster")
|
||||
|
||||
BuildEventClusterList = EventCluster(
|
||||
name="BuildList", endpoint_uu_id="1a186985-ed2a-434b-af28-22d6773382e9"
|
||||
)
|
||||
BuildEventClusterList.add_event(BuildingListEvent)
|
||||
|
||||
BuildEventClusterCreate = EventCluster(
|
||||
name="BuildCreate", endpoint_uu_id="d545c5a9-bbbf-4795-a4de-467db0809a04"
|
||||
)
|
||||
BuildEventClusterCreate.add_event(BuildingCreateEvent)
|
||||
|
||||
BuildEventClusterUpdate = EventCluster(
|
||||
name="BuildUpdate", endpoint_uu_id="6166a28e-8da8-4a2c-96c8-0a1651739cf3"
|
||||
)
|
||||
BuildEventClusterUpdate.add_event(BuildingUpdateEvent)
|
||||
|
||||
BuildRouterCluster.set_event_cluster(BuildEventClusterList)
|
||||
BuildRouterCluster.set_event_cluster(BuildEventClusterCreate)
|
||||
BuildRouterCluster.set_event_cluster(BuildEventClusterUpdate)
|
||||
98
ApiServices/BuildingService/Events/building/supers_events.py
Normal file
98
ApiServices/BuildingService/Events/building/supers_events.py
Normal file
@@ -0,0 +1,98 @@
|
||||
from ApiControllers.abstracts.event_clusters import Event
|
||||
from Validations.building.building.validations import (
|
||||
REQUESTEWFAZCDMPVZHIWOKZEJBIEUDAFBNXFEEAEGSELVGGCDMWLQPYMRAEEABSRQJUFBIMFEEADXK,
|
||||
)
|
||||
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Schemas import Build
|
||||
|
||||
|
||||
# List endpoint
|
||||
BuildingListEvent = Event(
|
||||
name="building_list",
|
||||
key="e675d36a-6772-44a8-b153-9a8d55e0f560",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List events of buildings endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
BuildingCreateEvent = Event(
|
||||
name="building_create",
|
||||
key="d79e3bdc-8f75-41d0-8eeb-dd9893d7ea0d",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Create events of buildings endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
BuildingUpdateEvent = Event(
|
||||
name="building_update",
|
||||
key="45e1bb8c-c521-4013-9e99-d3a58204bc5f",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Update events of buildings endpoint",
|
||||
)
|
||||
|
||||
|
||||
def building_list_callable(list_options: PaginateOnly):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
with Build.new_session() as db_session:
|
||||
if list_options.query:
|
||||
buildings_list = Build.filter_all(
|
||||
*Build.convert(list_options.query), db=db_session
|
||||
)
|
||||
else:
|
||||
buildings_list = Build.filter_all(db=db_session)
|
||||
pagination = Pagination(data=buildings_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(
|
||||
data=buildings_list,
|
||||
pagination=pagination,
|
||||
# response_model="",
|
||||
).pagination.as_dict
|
||||
return EndpointResponse(
|
||||
message="MSG0003-LIST",
|
||||
pagination_result=pagination_result,
|
||||
request=REQUESTEWFAZCDMPVZHIWOKZEJBIEUDAFBNXFEEAEGSELVGGCDMWLQPYMRAEEABSRQJUFBIMFEEADXK,
|
||||
).response
|
||||
|
||||
|
||||
BuildingListEvent.event_callable = building_list_callable
|
||||
|
||||
|
||||
def building_create_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildingCreateEvent.event_callable = building_create_callable
|
||||
|
||||
|
||||
def building_update_callable():
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildingUpdateEvent.event_callable = building_update_callable
|
||||
27
ApiServices/BuildingService/Events/sites/cluster.py
Normal file
27
ApiServices/BuildingService/Events/sites/cluster.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
BuildSitesListEvent,
|
||||
BuildSitesCreateEvent,
|
||||
BuildSitesUpdateEvent,
|
||||
)
|
||||
|
||||
BuildSitesRouterCluster = RouterCluster(name="BuildSitesRouterCluster")
|
||||
|
||||
BuildSitesEventClusterList = EventCluster(
|
||||
name="BuildSitesList", endpoint_uu_id="1159fb39-ad5d-46fb-8b6b-461021a39da3"
|
||||
)
|
||||
BuildSitesEventClusterList.add_event(BuildSitesListEvent)
|
||||
|
||||
BuildSitesEventClusterCreate = EventCluster(
|
||||
name="BuildCreate", endpoint_uu_id="bc71d276-fd51-43bb-90f2-6f4245b59d72"
|
||||
)
|
||||
BuildSitesEventClusterCreate.add_event(BuildSitesCreateEvent)
|
||||
|
||||
BuildSitesEventClusterUpdate = EventCluster(
|
||||
name="BuildUpdate", endpoint_uu_id="eca87985-3074-44cb-a947-f01e30769019"
|
||||
)
|
||||
BuildSitesEventClusterUpdate.add_event(BuildSitesUpdateEvent)
|
||||
|
||||
BuildSitesRouterCluster.set_event_cluster(BuildSitesEventClusterList)
|
||||
BuildSitesRouterCluster.set_event_cluster(BuildSitesEventClusterCreate)
|
||||
BuildSitesRouterCluster.set_event_cluster(BuildSitesEventClusterUpdate)
|
||||
96
ApiServices/BuildingService/Events/sites/supers_events.py
Normal file
96
ApiServices/BuildingService/Events/sites/supers_events.py
Normal file
@@ -0,0 +1,96 @@
|
||||
from ApiControllers.abstracts.event_clusters import Event
|
||||
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Schemas import BuildSites
|
||||
|
||||
|
||||
# List endpoint
|
||||
BuildSitesListEvent = Event(
|
||||
name="build_sites_list",
|
||||
key="d16c692f-5597-493a-90fe-b2bfe0d1c163",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List events of build sites endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
BuildSitesCreateEvent = Event(
|
||||
name="build_sites_create",
|
||||
key="8ed0929e-9c96-4e81-b073-e3578ca13f37",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Create events of build sites endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
BuildSitesUpdateEvent = Event(
|
||||
name="build_sites_update",
|
||||
key="ece55fa6-afba-4c34-bd2e-f39a4cdd6b5c",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Update events of build sites endpoint",
|
||||
)
|
||||
|
||||
|
||||
def build_sites_list_callable(list_options: PaginateOnly):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
with BuildSites.new_session() as db_session:
|
||||
if list_options.query:
|
||||
buildings_list = BuildSites.filter_all(
|
||||
*BuildSites.convert(list_options.query), db=db_session
|
||||
)
|
||||
else:
|
||||
buildings_list = BuildSites.filter_all(db=db_session)
|
||||
pagination = Pagination(data=buildings_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(
|
||||
data=buildings_list,
|
||||
pagination=pagination,
|
||||
# response_model="",
|
||||
).pagination.as_dict
|
||||
return EndpointResponse(
|
||||
message="MSG0003-LIST",
|
||||
pagination_result=pagination_result,
|
||||
).response
|
||||
|
||||
|
||||
BuildSitesListEvent.event_callable = build_sites_list_callable
|
||||
|
||||
|
||||
def build_sites_create_callable(data: dict):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
with BuildSites.new_session() as db_session:
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildSitesCreateEvent.event_callable = build_sites_create_callable
|
||||
|
||||
|
||||
def build_sites_update_callable(data: dict):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
with BuildSites.new_session() as db_session:
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Example callable method 2",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildSitesUpdateEvent.event_callable = build_sites_update_callable
|
||||
27
ApiServices/BuildingService/Events/spaces/cluster.py
Normal file
27
ApiServices/BuildingService/Events/spaces/cluster.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
BuildLivingSpaceListEvent,
|
||||
BuildLivingSpaceCreateEvent,
|
||||
BuildLivingSpaceUpdateEvent,
|
||||
)
|
||||
|
||||
BuildLivingSpaceRouterCluster = RouterCluster(name="BuildLivingSpaceRouterCluster")
|
||||
|
||||
BuildLivingSpaceEventClusterList = EventCluster(
|
||||
name="BuildLivingSpaceList", endpoint_uu_id="ad17c019-3050-4c41-ab6f-9ce43290e81a"
|
||||
)
|
||||
BuildLivingSpaceEventClusterList.add_event(BuildLivingSpaceListEvent)
|
||||
|
||||
BuildLivingSpaceEventClusterCreate = EventCluster(
|
||||
name="BuildCreate", endpoint_uu_id="ed9a0303-14e2-46fe-bec0-d395c29801ff"
|
||||
)
|
||||
BuildLivingSpaceEventClusterCreate.add_event(BuildLivingSpaceCreateEvent)
|
||||
|
||||
BuildLivingSpaceEventClusterUpdate = EventCluster(
|
||||
name="BuildUpdate", endpoint_uu_id="c62bb3dc-03c0-406c-8bbc-0e1f75a6420c"
|
||||
)
|
||||
BuildLivingSpaceEventClusterUpdate.add_event(BuildLivingSpaceUpdateEvent)
|
||||
|
||||
BuildLivingSpaceRouterCluster.set_event_cluster(BuildLivingSpaceEventClusterList)
|
||||
BuildLivingSpaceRouterCluster.set_event_cluster(BuildLivingSpaceEventClusterCreate)
|
||||
BuildLivingSpaceRouterCluster.set_event_cluster(BuildLivingSpaceEventClusterUpdate)
|
||||
96
ApiServices/BuildingService/Events/spaces/supers_events.py
Normal file
96
ApiServices/BuildingService/Events/spaces/supers_events.py
Normal file
@@ -0,0 +1,96 @@
|
||||
from ApiControllers.abstracts.event_clusters import Event
|
||||
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Schemas import BuildLivingSpace
|
||||
|
||||
|
||||
# List endpoint
|
||||
BuildLivingSpaceListEvent = Event(
|
||||
name="build_living_space_list",
|
||||
key="d16c692f-5597-493a-90fe-b2bfe0d1c163",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List events of build living spaces endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
BuildLivingSpaceCreateEvent = Event(
|
||||
name="build_living_space_create",
|
||||
key="8ed0929e-9c96-4e81-b073-e3578ca13f37",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Create events of build living spaces endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
BuildLivingSpaceUpdateEvent = Event(
|
||||
name="build_living_space_update",
|
||||
key="ece55fa6-afba-4c34-bd2e-f39a4cdd6b5c",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Update events of build living spaces endpoint",
|
||||
)
|
||||
|
||||
|
||||
def build_living_space_list_callable(list_options: PaginateOnly):
|
||||
"""
|
||||
List callable method
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
with BuildLivingSpace.new_session() as db_session:
|
||||
if list_options.query:
|
||||
buildings_list = BuildLivingSpace.filter_all(
|
||||
*BuildLivingSpace.convert(list_options.query), db=db_session
|
||||
)
|
||||
else:
|
||||
buildings_list = BuildLivingSpace.filter_all(db=db_session)
|
||||
pagination = Pagination(data=buildings_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(
|
||||
data=buildings_list,
|
||||
pagination=pagination,
|
||||
# response_model="",
|
||||
).pagination.as_dict
|
||||
return EndpointResponse(
|
||||
message="MSG0003-LIST",
|
||||
pagination_result=pagination_result,
|
||||
).response
|
||||
|
||||
|
||||
BuildLivingSpaceListEvent.event_callable = build_living_space_list_callable
|
||||
|
||||
|
||||
def build_living_space_create_callable(data: dict):
|
||||
"""
|
||||
Create callable method
|
||||
"""
|
||||
with BuildLivingSpace.new_session() as db_session:
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Build living space created",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildLivingSpaceCreateEvent.event_callable = build_living_space_create_callable
|
||||
|
||||
|
||||
def build_living_space_update_callable(data: dict):
|
||||
"""
|
||||
Update callable method
|
||||
"""
|
||||
with BuildLivingSpace.new_session() as db_session:
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Build living space updated",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildLivingSpaceUpdateEvent.event_callable = build_living_space_update_callable
|
||||
27
ApiServices/BuildingService/Events/type/cluster.py
Normal file
27
ApiServices/BuildingService/Events/type/cluster.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
BuildTypeListEvent,
|
||||
BuildTypeCreateEvent,
|
||||
BuildTypeUpdateEvent,
|
||||
)
|
||||
|
||||
BuildTypeRouterCluster = RouterCluster(name="BuildTypeRouterCluster")
|
||||
|
||||
BuildTypeEventClusterList = EventCluster(
|
||||
name="BuildTypeList", endpoint_uu_id="14f076c2-b118-4cfb-b679-9f2168a2658c"
|
||||
)
|
||||
BuildTypeEventClusterList.add_event(BuildTypeListEvent)
|
||||
|
||||
BuildTypeEventClusterCreate = EventCluster(
|
||||
name="BuildCreate", endpoint_uu_id="4c90c4cf-8873-479a-a56b-d12f276efa9d"
|
||||
)
|
||||
BuildTypeEventClusterCreate.add_event(BuildTypeCreateEvent)
|
||||
|
||||
BuildTypeEventClusterUpdate = EventCluster(
|
||||
name="BuildUpdate", endpoint_uu_id="cde9db69-6795-4562-802d-540d0b03ceaa"
|
||||
)
|
||||
BuildTypeEventClusterUpdate.add_event(BuildTypeUpdateEvent)
|
||||
|
||||
BuildTypeRouterCluster.set_event_cluster(BuildTypeEventClusterList)
|
||||
BuildTypeRouterCluster.set_event_cluster(BuildTypeEventClusterCreate)
|
||||
BuildTypeRouterCluster.set_event_cluster(BuildTypeEventClusterUpdate)
|
||||
96
ApiServices/BuildingService/Events/type/supers_events.py
Normal file
96
ApiServices/BuildingService/Events/type/supers_events.py
Normal file
@@ -0,0 +1,96 @@
|
||||
from ApiControllers.abstracts.event_clusters import Event
|
||||
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Schemas import BuildTypes
|
||||
|
||||
|
||||
# List endpoint
|
||||
BuildTypeListEvent = Event(
|
||||
name="build_type_list",
|
||||
key="e013b43e-3845-4a95-b5b0-409343659c5f",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List events of build types endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
BuildTypeCreateEvent = Event(
|
||||
name="build_type_create",
|
||||
key="8119a07e-bbb2-4d4c-b529-f923e8cdcc60",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Create events of build types endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
BuildTypeUpdateEvent = Event(
|
||||
name="build_type_update",
|
||||
key="6b7b89d5-6406-4614-aba4-c942f0c081ac",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Update events of build types endpoint",
|
||||
)
|
||||
|
||||
|
||||
def build_type_list_callable(list_options: PaginateOnly):
|
||||
"""
|
||||
List callable method
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
with BuildTypes.new_session() as db_session:
|
||||
if list_options.query:
|
||||
buildings_list = BuildTypes.filter_all(
|
||||
*BuildTypes.convert(list_options.query), db=db_session
|
||||
)
|
||||
else:
|
||||
buildings_list = BuildTypes.filter_all(db=db_session)
|
||||
pagination = Pagination(data=buildings_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(
|
||||
data=buildings_list,
|
||||
pagination=pagination,
|
||||
# response_model="",
|
||||
).pagination.as_dict
|
||||
return EndpointResponse(
|
||||
message="MSG0003-LIST",
|
||||
pagination_result=pagination_result,
|
||||
).response
|
||||
|
||||
|
||||
BuildTypeListEvent.event_callable = build_type_list_callable
|
||||
|
||||
|
||||
def build_type_create_callable(data: dict):
|
||||
"""
|
||||
Create callable method
|
||||
"""
|
||||
with BuildTypes.new_session() as db_session:
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Build type created",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildTypeCreateEvent.event_callable = build_type_create_callable
|
||||
|
||||
|
||||
def build_type_update_callable(data: dict):
|
||||
"""
|
||||
Update callable method
|
||||
"""
|
||||
with BuildTypes.new_session() as db_session:
|
||||
return {
|
||||
"completed": True,
|
||||
"message": "Build type updated",
|
||||
"info": {
|
||||
"host": "example_host",
|
||||
"user_agent": "example_user_agent",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
BuildTypeUpdateEvent.event_callable = build_type_update_callable
|
||||
Reference in New Issue
Block a user