from fastapi import APIRouter, Depends from ApiControllers.abstracts.default_validations import CommonHeaders from ApiControllers.providers.token_provider import TokenProvider from Controllers.Postgres.pagination import PaginateOnly from Events.spaces.cluster import BuildLivingSpaceRouterCluster spaces_route = APIRouter(prefix="/building/spaces", tags=["Build Spaces"]) @spaces_route.post( path="/list", description="List build spaces endpoint", operation_id="9d072fd3-d727-4f71-bf0c-fd74e25ba507", ) def spaces_list_route( data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency), ): """ List build spaces 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 = BuildLivingSpaceRouterCluster.get_event_cluster("BuildLivingSpaceList") event_cluster_matched = FoundCluster.match_event(event_key=event_key) return event_cluster_matched.event_callable(data=data) @spaces_route.post( path="/create", description="Create build spaces endpoint", operation_id="4520cfb7-ed45-44d2-a706-e2a8be777419", ) def spaces_create_route( data: dict, headers: CommonHeaders = Depends(CommonHeaders.as_dependency), ): """ Create build spaces 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 = BuildLivingSpaceRouterCluster.get_event_cluster("BuildLivingSpaceCreate") event_cluster_matched = FoundCluster.match_event(event_key=event_key) return event_cluster_matched.event_callable(data=data) @spaces_route.post( path="/update", description="Update build spaces endpoint", operation_id="d8c90f64-0a4c-4a7c-a685-0e1894cbe1c4", ) def spaces_update_route( data: dict, headers: CommonHeaders = Depends(CommonHeaders.as_dependency), ): """ Update build spaces 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 = BuildLivingSpaceRouterCluster.get_event_cluster("BuildLivingSpaceUpdate") event_cluster_matched = FoundCluster.match_event(event_key=event_key) return event_cluster_matched.event_callable(data=data)