148 lines
7.5 KiB
Python
148 lines
7.5 KiB
Python
from typing import Any
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from index import endpoints_index
|
|
from events.application.cluster import ApplicationRouterCluster
|
|
|
|
from Validations.defaults.validations import CommonHeaders
|
|
from Validations.response.pagination import PaginateOnly
|
|
from Extensions.Middlewares.token_provider import TokenProvider
|
|
|
|
|
|
application_endpoint_route = APIRouter(prefix="/application", tags=["Application Cluster"])
|
|
|
|
|
|
application_list_all = "ApplicationListAll"
|
|
@application_endpoint_route.post(
|
|
path="/list/all",
|
|
description="List all applications endpoint",
|
|
operation_id=endpoints_index[application_list_all],
|
|
)
|
|
def application_list_all_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_list_all)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|
|
|
|
|
|
application_list_available = "ApplicationListAvailable"
|
|
@application_endpoint_route.post(
|
|
path="/list/available",
|
|
description="List available applications endpoint",
|
|
operation_id=endpoints_index[application_list_available],
|
|
)
|
|
def application_list_available_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_list_available)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|
|
|
|
|
|
application_list_appended = "ApplicationListAppended"
|
|
@application_endpoint_route.post(
|
|
path="/list/appended",
|
|
description="List appended applications endpoint",
|
|
operation_id=endpoints_index[application_list_appended],
|
|
)
|
|
def application_list_appended_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_list_appended)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|
|
|
|
|
|
application_register_service = "ApplicationRegisterService"
|
|
@application_endpoint_route.post(
|
|
path="/register/service",
|
|
description="Register service endpoint",
|
|
operation_id=endpoints_index[application_register_service],
|
|
)
|
|
def application_register_service_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_register_service)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|
|
|
|
|
|
application_unregister_service = "ApplicationUnRegisterService"
|
|
@application_endpoint_route.post(
|
|
path="/unregister/service",
|
|
description="Unregister service endpoint",
|
|
operation_id=endpoints_index[application_unregister_service],
|
|
)
|
|
def application_unregister_service_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_unregister_service)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|
|
|
|
|
|
application_create = "ApplicationCreate"
|
|
@application_endpoint_route.post(
|
|
path="/create",
|
|
description="Create application endpoint",
|
|
operation_id=endpoints_index[application_create],
|
|
)
|
|
def application_create_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_create)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|
|
|
|
|
|
application_update = "ApplicationUpdate"
|
|
@application_endpoint_route.post(
|
|
path="/update/{application_uuid}",
|
|
description="Update application endpoint",
|
|
operation_id=endpoints_index[application_update],
|
|
)
|
|
def application_update_route(application_uuid: str, data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_update)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|
|
|
|
|
|
application_bind_employee = "ApplicationBindEmployee"
|
|
@application_endpoint_route.post(
|
|
path="/bind/employee",
|
|
description="Bind employee endpoint",
|
|
operation_id=endpoints_index[application_bind_employee],
|
|
)
|
|
def application_bind_employee_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_bind_employee)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|
|
|
|
|
|
application_bind_occupant = "ApplicationBindOccupant"
|
|
@application_endpoint_route.post(
|
|
path="/bind/occupant",
|
|
description="Bind occupant endpoint",
|
|
operation_id=endpoints_index[application_bind_occupant],
|
|
)
|
|
def application_bind_occupant_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)):
|
|
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(application_bind_occupant)
|
|
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
|
return event_cluster_matched.event_callable(list_options=data)
|