event and service sendpoints added

This commit is contained in:
Berkay 2025-04-30 18:19:31 +03:00
parent 36e63960f8
commit e815251123
24 changed files with 441 additions and 79 deletions

View File

@ -304,7 +304,9 @@ def authentication_token_check_post(
status_code=status.HTTP_406_NOT_ACCEPTABLE,
headers=headers,
)
if AuthHandlers.LoginHandler.authentication_check_token_valid(domain=domain,access_token=token):
if AuthHandlers.LoginHandler.authentication_check_token_valid(
domain=domain, access_token=token
):
return JSONResponse(
content={"message": "MSG_0001"},
status_code=status.HTTP_202_ACCEPTED,

View File

@ -172,7 +172,9 @@ class LoginHandler:
)
other_domains_list, main_domain = [], ""
with mongo_handler.collection(f"{str(found_user.related_company)}*Domain") as collection:
with mongo_handler.collection(
f"{str(found_user.related_company)}*Domain"
) as collection:
result = collection.find_one({"user_uu_id": str(found_user.uu_id)})
if not result:
raise ValueError("EYS_00087")
@ -180,7 +182,7 @@ class LoginHandler:
main_domain = result.get("main_domain", None)
if domain not in other_domains_list or not main_domain:
raise ValueError("EYS_00088")
if not user_handler.check_password_valid(
domain=main_domain,
id_=str(found_user.uu_id),
@ -298,7 +300,9 @@ class LoginHandler:
access_key=data.access_key, db_session=db_session
)
other_domains_list, main_domain = [], ""
with mongo_handler.collection(f"{str(found_user.related_company)}*Domain") as collection:
with mongo_handler.collection(
f"{str(found_user.related_company)}*Domain"
) as collection:
result = collection.find_one({"user_uu_id": str(found_user.uu_id)})
if not result:
raise ValueError("EYS_00087")
@ -314,7 +318,6 @@ class LoginHandler:
password_hashed=found_user.hash_password,
):
raise ValueError("EYS_0005")
occupants_selection_dict: Dict[str, Any] = {}
living_spaces: list[BuildLivingSpace] = BuildLivingSpace.filter_all(

View File

@ -9,7 +9,14 @@ def get_routes() -> list[APIRouter]:
from .spaces.route import spaces_route
from .type.route import build_types_route
return [building_route, area_route, sites_route, parts_route, spaces_route, build_types_route]
return [
building_route,
area_route,
sites_route,
parts_route,
spaces_route,
build_types_route,
]
def get_safe_endpoint_urls() -> list[tuple[str, str]]:

View File

@ -25,7 +25,9 @@ def spaces_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 = BuildLivingSpaceRouterCluster.get_event_cluster("BuildLivingSpaceList")
FoundCluster = BuildLivingSpaceRouterCluster.get_event_cluster(
"BuildLivingSpaceList"
)
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
return event_cluster_matched.event_callable(data=data)
@ -45,7 +47,9 @@ def spaces_create_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 = BuildLivingSpaceRouterCluster.get_event_cluster("BuildLivingSpaceCreate")
FoundCluster = BuildLivingSpaceRouterCluster.get_event_cluster(
"BuildLivingSpaceCreate"
)
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
return event_cluster_matched.event_callable(data=data)
@ -65,6 +69,8 @@ def spaces_update_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 = BuildLivingSpaceRouterCluster.get_event_cluster("BuildLivingSpaceUpdate")
FoundCluster = BuildLivingSpaceRouterCluster.get_event_cluster(
"BuildLivingSpaceUpdate"
)
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
return event_cluster_matched.event_callable(data=data)

View File

@ -7,9 +7,15 @@ from .supers_events import (
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 = 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)

View File

@ -71,8 +71,8 @@ def build_area_create_callable(data: dict):
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
},
}
BuildAreaCreateEvent.event_callable = build_area_create_callable
@ -89,8 +89,8 @@ def build_area_update_callable(data: dict):
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
},
}
BuildAreaUpdateEvent.event_callable = build_area_update_callable

View File

@ -71,8 +71,8 @@ def build_sites_create_callable(data: dict):
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
},
}
BuildSitesCreateEvent.event_callable = build_sites_create_callable
@ -89,8 +89,8 @@ def build_sites_update_callable(data: dict):
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
},
}
BuildSitesUpdateEvent.event_callable = build_sites_update_callable

View File

@ -71,8 +71,8 @@ def build_living_space_create_callable(data: dict):
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
},
}
BuildLivingSpaceCreateEvent.event_callable = build_living_space_create_callable
@ -89,8 +89,8 @@ def build_living_space_update_callable(data: dict):
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
},
}
BuildLivingSpaceUpdateEvent.event_callable = build_living_space_update_callable

View File

@ -71,8 +71,8 @@ def build_type_create_callable(data: dict):
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
},
}
BuildTypeCreateEvent.event_callable = build_type_create_callable
@ -89,8 +89,8 @@ def build_type_update_callable(data: dict):
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
},
}
BuildTypeUpdateEvent.event_callable = build_type_update_callable

View File

@ -1,9 +1,10 @@
from pydantic import BaseModel
from typing import Optional
class REQUESTEWFAZCDMPVZHIWOKZEJBIEUDAFBNXFEEAEGSELVGGCDMWLQPYMRAEEABSRQJUFBIMFEEADXK(BaseModel):
class REQUESTEWFAZCDMPVZHIWOKZEJBIEUDAFBNXFEEAEGSELVGGCDMWLQPYMRAEEABSRQJUFBIMFEEADXK(
BaseModel
):
gov_address_code: str
build_name: str
build_no: str
@ -24,10 +25,13 @@ class REQUESTEWFAZCDMPVZHIWOKZEJBIEUDAFBNXFEEAEGSELVGGCDMWLQPYMRAEEABSRQJUFBIMFE
address_uu_id: str
class REQUESTOCARDAJXLDANCXQAJWDBDIWXHUAEKQNUOSBZOCWXDAFGLAAVRBSADHUBDXAREUSESYGNGKBR(BaseModel):
class REQUESTOCARDAJXLDANCXQAJWDBDIWXHUAEKQNUOSBZOCWXDAFGLAAVRBSADHUBDXAREUSESYGNGKBR(
BaseModel
):
pass
class REQUESTAEKUDAILSFMCCLOERBHBFRCIKFCSNCBOSENCAEOIDACPRFZCCWGEDBHBFBMZBFCJHCBVKEFC(BaseModel):
class REQUESTAEKUDAILSFMCCLOERBHBFRCIKFCSNCBOSENCAEOIDACPRFZCCWGEDBHBFBMZBFCJHCBVKEFC(
BaseModel
):
pass

View File

@ -2,7 +2,12 @@ from ApiControllers.abstracts.event_clusters import Event
from Validations.people.validations import (
REQUESTAWMXNTKMGPPOJWRCTZUBADNFLQDBDYVQAORFAVCSXUUHEBQHCEPCSKFBADBODFDBPYKOVINV,
)
from Controllers.Postgres.pagination import ListOptions, Pagination, PaginationResult, PaginateOnly
from Controllers.Postgres.pagination import (
ListOptions,
Pagination,
PaginationResult,
PaginateOnly,
)
from Controllers.Postgres.response import EndpointResponse
from Schemas import People

View File

@ -444,7 +444,9 @@ def create_application_defaults(db_session):
f"{str(company_management.uu_id)}*Domain",
)
with mongo_handler.collection(collection_name) as mongo_engine:
existing_record = mongo_engine.find_one({"user_uu_id": str(gen_manager_user.uu_id)})
existing_record = mongo_engine.find_one(
{"user_uu_id": str(gen_manager_user.uu_id)}
)
if not existing_record:
mongo_engine.insert_one(
document={
@ -457,11 +459,13 @@ def create_application_defaults(db_session):
else:
mongo_engine.update_one(
{"user_uu_id": str(gen_manager_user.uu_id)},
{"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
{
"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}
},
)
app_manager_user = Users.find_or_create(
@ -483,7 +487,9 @@ def create_application_defaults(db_session):
app_manager_user.password_token = PasswordModule.generate_refresher_token()
with mongo_handler.collection(collection_name) as mongo_engine:
existing_record = mongo_engine.find_one({"user_uu_id": str(app_manager_user.uu_id)})
existing_record = mongo_engine.find_one(
{"user_uu_id": str(app_manager_user.uu_id)}
)
if not existing_record:
mongo_engine.insert_one(
document={
@ -496,11 +502,13 @@ def create_application_defaults(db_session):
else:
mongo_engine.update_one(
{"user_uu_id": str(app_manager_user.uu_id)},
{"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
{
"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}
},
)
sup_manager_employee = Users.find_or_create(
@ -524,9 +532,11 @@ def create_application_defaults(db_session):
sup_manager_employee.password_expiry_begins = str(arrow.now())
sup_manager_employee.password_token = PasswordModule.generate_refresher_token()
with mongo_handler.collection(collection_name) as mongo_engine:
existing_record = mongo_engine.find_one({"user_uu_id": str(sup_manager_employee.uu_id)})
existing_record = mongo_engine.find_one(
{"user_uu_id": str(sup_manager_employee.uu_id)}
)
if not existing_record:
print('insert sup existing record',existing_record)
print("insert sup existing record", existing_record)
mongo_engine.insert_one(
document={
"user_uu_id": str(sup_manager_employee.uu_id),
@ -536,15 +546,17 @@ def create_application_defaults(db_session):
}
)
else:
print('update sup existing record',existing_record)
print("update sup existing record", existing_record)
# Optionally update the existing record if needed
mongo_engine.update_one(
{"user_uu_id": str(sup_manager_employee.uu_id)},
{"$set": {
"other_domains_list": [main_domain, "management.com.tr"],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
{
"$set": {
"other_domains_list": [main_domain, "management.com.tr"],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}
},
)
db_session.commit()

View File

@ -239,7 +239,9 @@ def create_occupant_defaults(db_session):
user_tenant.password_token = PasswordModule.generate_refresher_token()
with mongo_handler.collection(collection_name) as mongo_engine:
existing_record = mongo_engine.find_one({"user_uu_id": str(user_build_manager.uu_id)})
existing_record = mongo_engine.find_one(
{"user_uu_id": str(user_build_manager.uu_id)}
)
if not existing_record:
mongo_engine.insert_one(
document={
@ -252,11 +254,13 @@ def create_occupant_defaults(db_session):
else:
mongo_engine.update_one(
{"user_uu_id": str(user_build_manager.uu_id)},
{"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
{
"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}
},
)
with mongo_handler.collection(collection_name) as mongo_engine:
@ -273,11 +277,13 @@ def create_occupant_defaults(db_session):
else:
mongo_engine.update_one(
{"user_uu_id": str(user_owner.uu_id)},
{"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
{
"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}
},
)
with mongo_handler.collection(collection_name) as mongo_engine:
@ -294,11 +300,13 @@ def create_occupant_defaults(db_session):
else:
mongo_engine.update_one(
{"user_uu_id": str(user_tenant.uu_id)},
{"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
{
"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}
},
)
created_build_living_space_prs = BuildLivingSpace.find_or_create(

View File

@ -5,9 +5,7 @@ from ApiControllers.providers.token_provider import TokenProvider
from Controllers.Postgres.pagination import PaginateOnly, Pagination, PaginationResult
from Controllers.Postgres.response import EndpointResponse
from Schemas import (
Applications
)
from Schemas import Applications
from Validations.application.validations import (
RequestApplication,
)
@ -71,7 +69,7 @@ def application_create_route(
Applications.application_code == data.application_code,
Applications.site_url == data.site_url,
]
**created_application_dict
** created_application_dict,
)
if created_application.meta_data.created:
return EndpointResponse(

View File

@ -0,0 +1,71 @@
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, Pagination, PaginationResult
from Controllers.Postgres.response import EndpointResponse
from Validations.service_endpoints.validations import Event2Employee, Event2Occupant
# Create API router
event_endpoint_route = APIRouter(prefix="/events", tags=["Event Actions"])
@event_endpoint_route.post(
path="/list",
description="List events endpoint",
operation_id="0659d5e4-671f-466c-a84f-47a1290a6f0d",
)
def event_list_route(
data: PaginateOnly,
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
):
"""
List events with pagination and filtering options
"""
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")
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="",
)
def event_bind_employee_route(
data: Event2Employee,
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
):
"""
Bind event to employee
"""
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")
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="",
)
def event_bind_occupant_route(
data: Event2Occupant,
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
):
"""
Bind event to occupant
"""
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")
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
return event_cluster_matched.event_callable(data=data)

View File

@ -0,0 +1,31 @@
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, Pagination, PaginationResult
from Controllers.Postgres.response import EndpointResponse
# Create API router
service_endpoint_route = APIRouter(prefix="/service", tags=["Service Actions"])
@service_endpoint_route.post(
path="/list",
description="List services endpoint",
operation_id="f4e4d332-70b1-4121-9fcc-a08850b72aaa",
)
def service_list_route(
data: PaginateOnly,
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
):
"""
List services with pagination and filtering options
"""
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 = ServiceEndpointRouterCluster.get_event_cluster("ServiceList")
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
return event_cluster_matched.event_callable(data=data)

View File

@ -0,0 +1,26 @@
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, Pagination, PaginationResult
from Controllers.Postgres.response import EndpointResponse
from Schemas import (
Services,
Employees,
Event2Employee,
Users,
Events,
Service2Events,
Applications,
Application2Employee,
Application2Occupant,
)
from Validations.application.validations import (
RequestApplication,
)
# Create API router
service_management_route = APIRouter(
prefix="/managements/service", tags=["Service Management"]
)

View File

@ -1,3 +1 @@
__all__ = []
__all__ = []

View File

@ -0,0 +1,27 @@
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
from .supers_events import (
SuperUsersListEvent,
SuperUsersCreateEvent,
SuperUsersUpdateEvent,
)
UserRouterCluster = RouterCluster(name="UserRouterCluster")
UserEventClusterList = EventCluster(
name="UserList", endpoint_uu_id="5bc09312-d3f2-4f47-baba-17c928706da8"
)
UserEventClusterList.add_event(SuperUsersListEvent)
UserEventClusterCreate = EventCluster(
name="UserCreate", endpoint_uu_id="08d4b572-1584-47bb-aa42-8d068e5514e7"
)
UserEventClusterCreate.add_event(SuperUsersCreateEvent)
UserEventClusterUpdate = EventCluster(
name="UserUpdate", endpoint_uu_id="b641236a-928d-4f19-a1d2-5edf611d1e56"
)
UserEventClusterUpdate.add_event(SuperUsersUpdateEvent)
UserRouterCluster.set_event_cluster(UserEventClusterList)
UserRouterCluster.set_event_cluster(UserEventClusterCreate)
UserRouterCluster.set_event_cluster(UserEventClusterUpdate)

View File

@ -0,0 +1,94 @@
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
# List endpoint
SuperUsersListEvent = Event(
name="supers_users_list",
key="341b394f-9f11-4abb-99e7-4b27fa6bf012",
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",
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",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Update events of users endpoint",
)
def supers_users_list_callable(list_options: PaginateOnly):
"""
Example callable method
"""
list_options = PaginateOnly(**list_options.model_dump())
with Users.new_session() as db_session:
if list_options.query:
users_list = Users.filter_all(
*Users.convert(list_options.query), db=db_session
)
else:
users_list = Users.filter_all(db=db_session)
pagination = Pagination(data=users_list)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(
data=users_list,
pagination=pagination,
# response_model="",
).pagination.as_dict
return EndpointResponse(
message="MSG0003-LIST",
pagination_result=pagination_result,
).response
SuperUsersListEvent.event_callable = supers_users_list_callable
def supers_users_create_callable():
"""
Example callable method
"""
return {
"completed": True,
"message": "Example callable method 2",
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
SuperUsersCreateEvent.event_callable = supers_users_create_callable
def supers_users_update_callable():
"""
Example callable method
"""
return {
"completed": True,
"message": "Example callable method 2",
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
SuperUsersUpdateEvent.event_callable = supers_users_update_callable

View File

@ -0,0 +1,11 @@
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
from .supers_events import (
ServiceEndpointListEvent,
)
ServiceEndpointRouterCluster = RouterCluster(name="ServiceEndpointRouterCluster")
ServiceEndpointEventClusterList = EventCluster(
name="ServiceList", endpoint_uu_id="82ef3444-a26a-499d-8c77-ca2e95d6ceb9"
)
ServiceEndpointEventClusterList.add_event(ServiceEndpointListEvent)
ServiceEndpointRouterCluster.set_event_cluster(ServiceEndpointEventClusterList)

View File

@ -0,0 +1,42 @@
from ApiControllers.abstracts.event_clusters import Event
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
from Controllers.Postgres.response import EndpointResponse
from Schemas import Services
# List endpoint
ServiceEndpointListEvent = Event(
name="service_endpoint_list",
key="7da6ceac-925a-4faa-9cc5-3f34396b5684",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="List services endpoint",
)
def service_endpoint_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
ServiceEndpointListEvent.event_callable = service_endpoint_list_callable

View File

@ -1,12 +1,15 @@
from pydantic import BaseModel, Field
from typing import Optional
class RequestApplication(BaseModel):
"""Base model for application data"""
name: str = Field(..., description="Application name")
application_code: str = Field(..., description="Unique application code")
site_url: str = Field(..., description="Application site URL")
application_type: str = Field(..., description="Application type (info, Dash, Admin)")
application_type: str = Field(
..., description="Application type (info, Dash, Admin)"
)
application_for: str = Field(..., description="Application for (EMP, OCC)")
description: Optional[str] = Field(None, description="Application description")

View File

@ -0,0 +1,8 @@
class Event2Employee:
pass
class Event2Occupant:
pass