Files
wag-managment-api-service-v…/Events/AllEvents/events/building/building/building.py

59 lines
1.9 KiB
Python

"""
Account related API endpoints.
"""
from typing import Any, Dict
from fastapi import Request
from Events.Engine.abstract_class import MethodToEvent
from Events.base_request_model import EndpointBaseRequestModel, ContextRetrievers
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
from ApiLayers.ApiValidations.Response.default_response import (
EndpointSuccessListResponse,
)
# from .function_handlers import (
# AddressListFunctions,
# AddressUpdateFunctions,
# AddressSearchFunctions,
# AddressCreateFunctions,
# )
from .api_events import BuildingSuperUserEvents
BuildingListEventMethods = MethodToEvent(
name="BuildingListEventMethods",
events={
BuildingSuperUserEvents.BuildingEvent.key: BuildingSuperUserEvents.BuildingEvent,
},
headers=[],
errors=[],
decorators_list=[TokenEventMiddleware.event_required],
url="/list",
method="POST",
summary="List all accounts by given previligous",
description="List all accounts by given previligous",
)
def account_list_event_endpoint(
request: Request, data: EndpointBaseRequestModel
) -> Dict[str, Any]:
context_retriever = ContextRetrievers(func=account_list_event_endpoint)
event_2_catch = BuildingListEventMethods.retrieve_event(
event_function_code=f"{BuildingSuperUserEvents.BuildingEvent.key}"
)
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
BuildingListFunctions.context_retriever = context_retriever
pagination_result = event_2_catch.endpoint_callable(data=data)
return EndpointSuccessListResponse(
code=event_2_catch.static_key, lang=context_retriever.token.lang
).as_dict(
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
)
BuildingListEventMethods.endpoint_callable = account_list_event_endpoint