updated Identity and managment service

This commit is contained in:
2025-05-01 15:25:15 +03:00
parent e815251123
commit 1920c2a25d
69 changed files with 1672 additions and 462 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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]]: