prod-wag-backend-automate-s.../ApiServices/IdentityService/events/people/event.py

129 lines
3.8 KiB
Python

from ApiServices.IdentityService.initializer.event_clusters import EventCluster, Event
from ApiServices.IdentityService.validations.people.validations import (
REQUESTAWMXNTKMGPPOJWRCTZUBADNFLQDBDYVQAORFAVCSXUUHEBQHCEPCSKFBADBODFDBPYKOVINV,
)
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
from Controllers.Postgres.response import EndpointResponse
from Schemas.identity.identity import People
# Create endpoint
supers_people_create = Event(
name="supers_people_list",
key="ec4c2404-a61b-46c7-bbdf-ce3357e6cf41",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Create events of people endpoint",
)
def supers_people_create_callable(list_options):
"""
Example callable method
"""
return {
"completed": True,
"message": "Example callable method 2",
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
supers_people_create.event_callable = supers_people_create_callable
people_event_cluster_create = EventCluster(
endpoint_uu_id="eb465fde-337f-4b81-94cf-28c6d4f2b1b6"
)
people_event_cluster_create.add_event([supers_people_create])
# Update endpoint
supers_people_update = Event(
name="supers_people_update",
key="91e77de4-9f29-4309-b121-4aad256d440c",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="Update events of people endpoint",
)
def supers_people_update_callable():
"""
Example callable method
"""
return {
"completed": True,
"message": "Example callable method 2",
"info": {
"host": "example_host",
"user_agent": "example_user_agent",
},
}
supers_people_update.event_callable = supers_people_update_callable
people_event_cluster_update = EventCluster(
endpoint_uu_id="c9e5ba69-6915-43f5-8f9c-a5c2aa865b89"
)
people_event_cluster_update.add_event([supers_people_update])
# List endpoint
supers_people_list = Event(
name="supers_people_list",
key="6828d280-e587-400d-a622-c318277386c3",
request_validator=None, # TODO: Add request validator
response_validator=None, # TODO: Add response validator
description="List events of people endpoint",
)
def supers_people_list_callable(list_options: PaginateOnly):
"""
Example callable method
"""
list_options = PaginateOnly(**list_options.model_dump())
with People.new_session() as db_session:
People.pre_query = People.filter_all(
People.firstname.ilike("%B%"), db=db_session
).query
if list_options.query:
people_list = People.filter_all(
*People.convert(list_options.query), db=db_session
)
else:
people_list = People.filter_all(db=db_session)
pagination = Pagination(data=people_list)
pagination.change(**list_options.model_dump())
pagination_result = PaginationResult(
data=people_list,
pagination=pagination,
response_model=REQUESTAWMXNTKMGPPOJWRCTZUBADNFLQDBDYVQAORFAVCSXUUHEBQHCEPCSKFBADBODFDBPYKOVINV,
)
return EndpointResponse(
message="MSG0002-LIST",
pagination_result=pagination_result,
).response
supers_people_list.event_callable = supers_people_list_callable
people_event_cluster_list = EventCluster(
endpoint_uu_id="f102db46-031a-43e4-966a-dae6896f985b"
)
people_event_cluster_list.add_event([supers_people_list])
class PeopleCluster:
"""
People Clusters
"""
PeopleListCluster = people_event_cluster_list
PeopleCreateCluster = people_event_cluster_create
PeopleUpdateCluster = people_event_cluster_update