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 +1,5 @@
__all__ = []
from .service_endpoints.cluster import ServiceEndpointRouterCluster
from .event_endpoints.cluster import EventsEndpointRouterCluster
from .application.cluster import ApplicationRouterCluster
__all__ = ["ServiceEndpointRouterCluster", "EventsEndpointRouterCluster", "ApplicationRouterCluster"]

View File

@@ -1,27 +1,41 @@
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
from .supers_events import (
SuperUsersListEvent,
SuperUsersCreateEvent,
SuperUsersUpdateEvent,
ApplicationListEvent,
ApplicationCreateEvent,
ApplicationUpdateEvent,
ApplicationBindEmployeeEvent,
ApplicationBindOccupantEvent,
)
UserRouterCluster = RouterCluster(name="UserRouterCluster")
ApplicationRouterCluster = RouterCluster(name="ApplicationRouterCluster")
UserEventClusterList = EventCluster(
name="UserList", endpoint_uu_id="5bc09312-d3f2-4f47-baba-17c928706da8"
ApplicationEventClusterList = EventCluster(
name="ApplicationList", endpoint_uu_id="3189a049-bdb0-49f3-83ff-feb8cb4cb57a"
)
UserEventClusterList.add_event(SuperUsersListEvent)
ApplicationEventClusterList.add_event(ApplicationListEvent)
UserEventClusterCreate = EventCluster(
name="UserCreate", endpoint_uu_id="08d4b572-1584-47bb-aa42-8d068e5514e7"
ApplicationEventClusterCreate = EventCluster(
name="ApplicationCreate", endpoint_uu_id="5570be78-030a-438e-8674-7e751447608b"
)
UserEventClusterCreate.add_event(SuperUsersCreateEvent)
ApplicationEventClusterCreate.add_event(ApplicationCreateEvent)
UserEventClusterUpdate = EventCluster(
name="UserUpdate", endpoint_uu_id="b641236a-928d-4f19-a1d2-5edf611d1e56"
ApplicationEventClusterUpdate = EventCluster(
name="ApplicationUpdate", endpoint_uu_id="87cd4515-73dd-4d11-a01f-562e221d973c"
)
UserEventClusterUpdate.add_event(SuperUsersUpdateEvent)
ApplicationEventClusterUpdate.add_event(ApplicationUpdateEvent)
UserRouterCluster.set_event_cluster(UserEventClusterList)
UserRouterCluster.set_event_cluster(UserEventClusterCreate)
UserRouterCluster.set_event_cluster(UserEventClusterUpdate)
ApplicationEventClusterBindEmployee = EventCluster(
name="ApplicationBindEmployee", endpoint_uu_id="2bab94fa-becb-4d8e-80f1-f4631119a521"
)
ApplicationEventClusterBindEmployee.add_event(ApplicationBindEmployeeEvent)
ApplicationEventClusterBindOccupant = EventCluster(
name="ApplicationBindOccupant", endpoint_uu_id="fccf1a59-0650-4e5c-ba8d-f389dadce01c"
)
ApplicationEventClusterBindOccupant.add_event(ApplicationBindOccupantEvent)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterList)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterCreate)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterUpdate)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterBindEmployee)
ApplicationRouterCluster.set_event_cluster(ApplicationEventClusterBindOccupant)

View File

@@ -1,53 +1,75 @@
from ApiControllers.abstracts.event_clusters import Event
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
from Controllers.Postgres.response import EndpointResponse
from Schemas import Users
from Schemas import (
Applications,
Application2Employee,
Application2Occupant,
)
# List endpoint
SuperUsersListEvent = Event(
name="supers_users_list",
key="341b394f-9f11-4abb-99e7-4b27fa6bf012",
ApplicationListEvent = Event(
name="application_list",
key="b4efda1e-bde7-4659-ab1a-ef74c0fd88b6",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="List events of users endpoint",
)
# Create endpoint
SuperUsersCreateEvent = Event(
name="supers_users_create",
key="4e7e189e-e015-4ff8-902d-60138cbc77a6",
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="Create events of users endpoint",
)
# Update endpoint
SuperUsersUpdateEvent = Event(
name="supers_users_update",
key="efa4aa4a-d414-4391-91ee-97eb617b7755",
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="Update events of users endpoint",
)
#Bind Application to employee
ApplicationBindEmployeeEvent = Event(
name="application_bind_employee",
key="26a96c2d-bca8-41cb-8ac1-f3ca8124434b",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Bind events of users endpoint",
)
def supers_users_list_callable(list_options: PaginateOnly):
#Bind Application to occupant
ApplicationBindOccupantEvent = Event(
name="application_bind_occupant",
key="4eaf2bb0-2a42-4d21-ae65-a9259ebee189",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Bind events of users endpoint",
)
def application_list_callable(list_options: PaginateOnly):
"""
Example callable method
"""
list_options = PaginateOnly(**list_options.model_dump())
with Users.new_session() as db_session:
with Applications.new_session() as db_session:
if list_options.query:
users_list = Users.filter_all(
*Users.convert(list_options.query), db=db_session
applications_list = Applications.filter_all(
*Applications.convert(list_options.query), db=db_session
)
else:
users_list = Users.filter_all(db=db_session)
pagination = Pagination(data=users_list)
applications_list = Applications.filter_all(db=db_session)
pagination = Pagination(data=applications_list)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(
data=users_list,
data=applications_list,
pagination=pagination,
# response_model="",
).pagination.as_dict
@@ -57,10 +79,10 @@ def supers_users_list_callable(list_options: PaginateOnly):
).response
SuperUsersListEvent.event_callable = supers_users_list_callable
ApplicationListEvent.event_callable = application_list_callable
def supers_users_create_callable():
def application_create_callable():
"""
Example callable method
"""
@@ -74,10 +96,10 @@ def supers_users_create_callable():
}
SuperUsersCreateEvent.event_callable = supers_users_create_callable
ApplicationCreateEvent.event_callable = application_create_callable
def supers_users_update_callable():
def application_update_callable():
"""
Example callable method
"""
@@ -91,4 +113,36 @@ def supers_users_update_callable():
}
SuperUsersUpdateEvent.event_callable = supers_users_update_callable
ApplicationUpdateEvent.event_callable = application_update_callable
def application_bind_employee_callable():
"""
Example callable method
"""
return {
"completed": True,
"message": "Example callable method 2",
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
ApplicationBindEmployeeEvent.event_callable = application_bind_employee_callable
def application_bind_occupant_callable():
"""
Example callable method
"""
return {
"completed": True,
"message": "Example callable method 2",
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
ApplicationBindOccupantEvent.event_callable = application_bind_occupant_callable

View File

@@ -0,0 +1,35 @@
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
from .supers_events import (
EventsListEvent,
EventRegisterServiceEvent,
EventBindEmployeeExtraEvent,
EventBindOccupantExtraEvent,
)
EventsEndpointRouterCluster = RouterCluster(name="EventsEndpointRouterCluster")
EventsEndpointEventClusterList = EventCluster(
name="EventsList", endpoint_uu_id="0659d5e4-671f-466c-a84f-47a1290a6f0d"
)
EventsEndpointEventClusterList.add_event(EventsListEvent)
EventsEndpointEventClusterRegisterService = EventCluster(
name="EventRegisterService", endpoint_uu_id="c89a2150-db4d-4a8f-b6ec-9e0f09625f76"
)
EventsEndpointEventClusterRegisterService.add_event(EventRegisterServiceEvent)
EventsEndpointEventClusterBindEmployeeExtra = EventCluster(
name="EventBindEmployeeExtra", endpoint_uu_id="58ef3640-04ec-43f9-8f3e-f86be3ce4a24"
)
EventsEndpointEventClusterBindEmployeeExtra.add_event(EventBindEmployeeExtraEvent)
EventsEndpointEventClusterBindOccupantExtra = EventCluster(
name="EventBindOccupantExtra", endpoint_uu_id="7794a550-3073-43e3-b0c5-80128f8d3e4b"
)
EventsEndpointEventClusterBindOccupantExtra.add_event(EventBindOccupantExtraEvent)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterList)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterRegisterService)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterBindEmployeeExtra)
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterBindOccupantExtra)

View File

@@ -0,0 +1,107 @@
from ApiControllers.abstracts.event_clusters import Event
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
from Controllers.Postgres.response import EndpointResponse
from typing import Any
from Schemas import (
Events,
Event2Employee,
Event2Occupant,
Event2EmployeeExtra,
Event2OccupantExtra,
Service2Events,
)
# List endpoint
EventsListEvent = Event(
name="service_endpoint_list",
key="0a08c64b-ce20-4791-b1e9-014db6b75ea7",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="List services endpoint",
)
# Event Register endpoint
EventRegisterServiceEvent = Event(
name="service_endpoint_register_service",
key="e18e7f89-5708-4a15-9258-99b0903ed43d",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Register 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="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="Bind service to occupant extra endpoint",
)
def events_list_callable(list_options: PaginateOnly):
"""
Example callable method
"""
list_options = PaginateOnly(**list_options.model_dump())
with Services.new_session() as db_session:
if list_options.query:
services_list = Services.filter_all(
*Services.convert(list_options.query), db=db_session
)
else:
services_list = Services.filter_all(db=db_session)
pagination = Pagination(data=services_list)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(
data=services_list,
pagination=pagination,
# response_model="",
).pagination.as_dict
return EndpointResponse(
message="MSG0003-LIST",
pagination_result=pagination_result,
).response
EventsListEvent.event_callable = events_list_callable
def event_register_service_callable(data: Any):
"""
Example callable method
"""
return EndpointResponse(
message="MSG0003-REGISTER",
).response
EventRegisterServiceEvent.event_callable = event_register_service_callable
def event_bind_employee_extra_callable(data: Any):
"""
Example callable method
"""
return EndpointResponse(
message="MSG0003-BIND",
).response
EventBindEmployeeExtraEvent.event_callable = event_bind_employee_extra_callable
def event_bind_occupant_extra_callable(data: Any):
"""
Example callable method
"""
return EndpointResponse(
message="MSG0003-BIND",
).response
EventBindOccupantExtraEvent.event_callable = event_bind_occupant_extra_callable

View File

@@ -5,7 +5,7 @@ from .supers_events import (
ServiceEndpointRouterCluster = RouterCluster(name="ServiceEndpointRouterCluster")
ServiceEndpointEventClusterList = EventCluster(
name="ServiceList", endpoint_uu_id="82ef3444-a26a-499d-8c77-ca2e95d6ceb9"
name="ServiceList", endpoint_uu_id="f4e4d332-70b1-4121-9fcc-a08850b72aaa"
)
ServiceEndpointEventClusterList.add_event(ServiceEndpointListEvent)
ServiceEndpointRouterCluster.set_event_cluster(ServiceEndpointEventClusterList)