event and service sendpoints added
This commit is contained in:
@@ -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)
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user