99 lines
2.9 KiB
Python
99 lines
2.9 KiB
Python
from ApiControllers.abstracts.event_clusters import Event
|
|
from Validations.people.validations import (
|
|
REQUESTAWMXNTKMGPPOJWRCTZUBADNFLQDBDYVQAORFAVCSXUUHEBQHCEPCSKFBADBODFDBPYKOVINV,
|
|
)
|
|
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
|
from Controllers.Postgres.response import EndpointResponse
|
|
from Schemas import People
|
|
|
|
|
|
SupersPeopleCreateEvent = Event(
|
|
name="supers_people_create",
|
|
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",
|
|
)
|
|
|
|
# Update endpoint
|
|
SupersPeopleUpdateEvent = 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",
|
|
)
|
|
|
|
# List endpoint
|
|
SupersPeopleListEvent = 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_create_callable(list_options):
|
|
"""
|
|
Example callable method
|
|
"""
|
|
|
|
return {
|
|
"completed": True,
|
|
"message": "Example callable method 2",
|
|
"info": {
|
|
"host": "example_host",
|
|
"user_agent": "example_user_agent",
|
|
},
|
|
}
|
|
|
|
|
|
SupersPeopleCreateEvent.event_callable = supers_people_create_callable
|
|
|
|
|
|
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",
|
|
},
|
|
}
|
|
|
|
|
|
SupersPeopleUpdateEvent.event_callable = supers_people_update_callable
|
|
|
|
|
|
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:
|
|
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
|
|
|
|
|
|
SupersPeopleListEvent.event_callable = supers_people_list_callable
|