updated Api Defaults
This commit is contained in:
@@ -17,7 +17,7 @@ SupersPeopleCreateEvent = Event(
|
||||
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",
|
||||
description="Super Users Create events of people endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
@@ -26,7 +26,7 @@ SupersPeopleUpdateEvent = Event(
|
||||
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",
|
||||
description="Super Users Update events of people endpoint",
|
||||
)
|
||||
|
||||
# List endpoint
|
||||
@@ -35,7 +35,7 @@ SupersPeopleListEvent = Event(
|
||||
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",
|
||||
description="Super Users List events of people endpoint",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ SuperUsersListEvent = Event(
|
||||
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",
|
||||
description="Super User List events of users endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
@@ -19,7 +19,7 @@ SuperUsersCreateEvent = Event(
|
||||
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",
|
||||
description="Super User Create events of users endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
@@ -28,7 +28,7 @@ SuperUsersUpdateEvent = Event(
|
||||
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",
|
||||
description="Super User Update events of users endpoint",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ 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 Controllers.Postgres.response import EndpointResponse, CreateEndpointResponse
|
||||
from Schemas import Applications
|
||||
from Validations.application.validations import (
|
||||
RequestApplication,
|
||||
@@ -66,18 +66,18 @@ def application_create_route(
|
||||
created_application = Applications.find_or_create(
|
||||
db=db_session,
|
||||
include_args=[
|
||||
Applications.application_for == data.application_for,
|
||||
Applications.application_code == data.application_code,
|
||||
Applications.site_url == data.site_url,
|
||||
]
|
||||
** created_application_dict,
|
||||
Applications.application_for,
|
||||
Applications.application_code,
|
||||
Applications.site_url,
|
||||
],
|
||||
**created_application_dict,
|
||||
)
|
||||
if created_application.meta_data.created:
|
||||
return EndpointResponse(
|
||||
return CreateEndpointResponse(
|
||||
message="MSG0001-INSERT",
|
||||
data=created_application,
|
||||
).response
|
||||
return EndpointResponse(
|
||||
return CreateEndpointResponse(
|
||||
message="MSG0002-FOUND",
|
||||
data=created_application,
|
||||
).response
|
||||
@@ -98,23 +98,23 @@ def application_update_route(
|
||||
"""
|
||||
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
|
||||
with Applications.new_session() as db_session:
|
||||
updated_application_dict = data.model_dump()
|
||||
updated_application_dict = data.model_dump(exclude_unset=True, exclude_none=True)
|
||||
found_application = Applications.filter_one(
|
||||
Applications.uu_id == application_uuid, db=db_session
|
||||
).data
|
||||
if not found_application:
|
||||
return EndpointResponse(
|
||||
return CreateEndpointResponse(
|
||||
message="MSG0002-FOUND",
|
||||
data=found_application,
|
||||
).response
|
||||
updated_application = found_application.update(**updated_application_dict)
|
||||
updated_application = found_application.update(db=db_session,**updated_application_dict)
|
||||
updated_application.save(db_session)
|
||||
if updated_application.meta_data.updated:
|
||||
return EndpointResponse(
|
||||
return CreateEndpointResponse(
|
||||
message="MSG0003-UPDATE",
|
||||
data=updated_application,
|
||||
).response
|
||||
return EndpointResponse(
|
||||
return CreateEndpointResponse(
|
||||
message="MSG0003-UPDATE",
|
||||
data=updated_application,
|
||||
).response
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from typing import Any
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from ApiControllers.abstracts.default_validations import CommonHeaders
|
||||
from ApiControllers.providers.token_provider import TokenProvider
|
||||
|
||||
@@ -14,7 +14,7 @@ ApplicationListEvent = Event(
|
||||
key="b4efda1e-bde7-4659-ab1a-ef74c0fd88b6",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List events of users endpoint",
|
||||
description="Super Users List applications endpoint",
|
||||
)
|
||||
|
||||
# Create endpoint
|
||||
@@ -23,7 +23,7 @@ ApplicationCreateEvent = Event(
|
||||
key="f53ca9aa-5536-4d77-9129-78d67e61db4a",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Create events of users endpoint",
|
||||
description="Super Users Create applications endpoint",
|
||||
)
|
||||
|
||||
# Update endpoint
|
||||
@@ -32,7 +32,7 @@ ApplicationUpdateEvent = Event(
|
||||
key="0e9a855e-4e69-44b5-8ac2-825daa32840c",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Update events of users endpoint",
|
||||
description="Super Users Update applications endpoint",
|
||||
)
|
||||
|
||||
#Bind Application to employee
|
||||
@@ -41,7 +41,7 @@ ApplicationBindEmployeeEvent = Event(
|
||||
key="26a96c2d-bca8-41cb-8ac1-f3ca8124434b",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Bind events of users endpoint",
|
||||
description="Super Users Application Bind employee endpoint",
|
||||
)
|
||||
|
||||
#Bind Application to occupant
|
||||
@@ -50,7 +50,7 @@ ApplicationBindOccupantEvent = Event(
|
||||
key="4eaf2bb0-2a42-4d21-ae65-a9259ebee189",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Bind events of users endpoint",
|
||||
description="Super Users Application Bind occupant endpoint",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ EventsListEvent = Event(
|
||||
key="0a08c64b-ce20-4791-b1e9-014db6b75ea7",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List services endpoint",
|
||||
description="Super Users List services endpoint",
|
||||
)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ EventRegisterServiceEvent = Event(
|
||||
key="e18e7f89-5708-4a15-9258-99b0903ed43d",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Register service endpoint",
|
||||
description="Super Users Register service endpoint",
|
||||
)
|
||||
|
||||
# Bind employee extra endpoint
|
||||
@@ -37,7 +37,7 @@ EventBindEmployeeExtraEvent = Event(
|
||||
key="cd452928-4256-4fb4-b81e-0ca41d723616",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Bind service to employee extra endpoint",
|
||||
description="Super Users Bind service to employee extra endpoint",
|
||||
)
|
||||
|
||||
# Bind occupant extra endpoint
|
||||
@@ -46,7 +46,7 @@ EventBindOccupantExtraEvent = Event(
|
||||
key="cb11a150-8049-45c9-8cf3-d5290ffd2e4a",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Bind service to occupant extra endpoint",
|
||||
description="Super Users Bind service to occupant extra endpoint",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ ServiceEndpointListEvent = Event(
|
||||
key="7da6ceac-925a-4faa-9cc5-3f34396b5684",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="List services endpoint",
|
||||
description="Super Users List services endpoint",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /
|
||||
|
||||
# Install system dependencies and Poetry
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir poetry
|
||||
|
||||
# Copy Poetry configuration
|
||||
COPY /pyproject.toml ./pyproject.toml
|
||||
|
||||
# Configure Poetry and install dependencies with optimizations
|
||||
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main \
|
||||
&& pip cache purge && rm -rf ~/.cache/pypoetry
|
||||
|
||||
# Copy application code
|
||||
COPY /ApiControllers /ApiControllers
|
||||
COPY /ApiDefaults /ApiDefaults
|
||||
COPY /Controllers /Controllers
|
||||
COPY /Schemas /Schemas
|
||||
|
||||
COPY /ApiServices/IdentityService/Endpoints /ApiDefaults/Endpoints
|
||||
COPY /ApiServices/IdentityService/Events /ApiDefaults/Events
|
||||
COPY /ApiServices/IdentityService/Validations /ApiDefaults/Validations
|
||||
|
||||
# Set Python path to include app directory
|
||||
ENV PYTHONPATH=/ PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Run the application using the configured uvicorn server
|
||||
CMD ["poetry", "run", "python", "ApiDefaults/app.py"]
|
||||
@@ -1,67 +0,0 @@
|
||||
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
|
||||
from Events.people.cluster import PeopleRouterCluster
|
||||
|
||||
|
||||
people_route = APIRouter(prefix="/people", tags=["People"])
|
||||
|
||||
|
||||
@people_route.post(
|
||||
path="/list",
|
||||
description="List people endpoint",
|
||||
operation_id="f102db46-031a-43e4-966a-dae6896f985b",
|
||||
)
|
||||
def people_route_list(
|
||||
data: PaginateOnly,
|
||||
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
|
||||
):
|
||||
"""
|
||||
List people endpoint
|
||||
"""
|
||||
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 = PeopleRouterCluster.get_event_cluster("PeopleList")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
|
||||
@people_route.post(
|
||||
path="/create",
|
||||
description="Create people endpoint",
|
||||
operation_id="eb465fde-337f-4b81-94cf-28c6d4f2b1b6",
|
||||
)
|
||||
def people_route_create(
|
||||
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
|
||||
):
|
||||
"""
|
||||
Create people endpoint
|
||||
"""
|
||||
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 = PeopleRouterCluster.get_event_cluster("PeopleCreate")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable()
|
||||
|
||||
|
||||
@people_route.post(
|
||||
path="/update",
|
||||
description="Update people endpoint",
|
||||
operation_id="c9e5ba69-6915-43f5-8f9c-a5c2aa865b89",
|
||||
)
|
||||
def people_route_update(
|
||||
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
|
||||
):
|
||||
"""
|
||||
Update people endpoint
|
||||
"""
|
||||
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 = PeopleRouterCluster.get_event_cluster("PeopleUpdate")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable()
|
||||
@@ -1,18 +0,0 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
|
||||
def get_routes() -> list[APIRouter]:
|
||||
from .people.route import people_route
|
||||
from .user.route import user_route
|
||||
|
||||
return [user_route, people_route]
|
||||
|
||||
|
||||
def get_safe_endpoint_urls() -> list[tuple[str, str]]:
|
||||
return [
|
||||
("/", "GET"),
|
||||
("/docs", "GET"),
|
||||
("/redoc", "GET"),
|
||||
("/openapi.json", "GET"),
|
||||
("/metrics", "GET"),
|
||||
]
|
||||
@@ -1,72 +0,0 @@
|
||||
import uuid
|
||||
|
||||
from fastapi import APIRouter, Header
|
||||
from typing import Any
|
||||
|
||||
from ApiDefaults.config import api_config
|
||||
from Events.user.cluster import UserRouterCluster
|
||||
from ApiControllers.providers.token_provider import TokenProvider
|
||||
from ApiControllers.abstracts.default_validations import CommonHeaders
|
||||
from Controllers.Postgres.pagination import PaginateOnly
|
||||
|
||||
user_route = APIRouter(prefix="/user", tags=["User"])
|
||||
|
||||
|
||||
@user_route.post(
|
||||
path="/list",
|
||||
description="List users endpoint",
|
||||
operation_id="1aca3094-fe80-4e0f-a460-1a506419082a",
|
||||
)
|
||||
def user_list_route(
|
||||
data: PaginateOnly,
|
||||
headers: CommonHeaders,
|
||||
):
|
||||
"""
|
||||
List users endpoint
|
||||
"""
|
||||
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 = UserRouterCluster.get_event_cluster("UserList")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
|
||||
@user_route.post(
|
||||
path="/create",
|
||||
description="Create users endpoint",
|
||||
operation_id="9686211f-4260-485d-8076-186c22c053aa",
|
||||
)
|
||||
def user_create_route(
|
||||
data: Any,
|
||||
headers: CommonHeaders,
|
||||
):
|
||||
"""
|
||||
Create users endpoint
|
||||
"""
|
||||
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 = UserRouterCluster.get_event_cluster("UserCreate")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
|
||||
@user_route.post(
|
||||
path="/update",
|
||||
description="Update users endpoint",
|
||||
operation_id="268e887b-5ff5-4f99-b1be-7e127e28a198",
|
||||
)
|
||||
def user_update_route(
|
||||
data: Any,
|
||||
headers: CommonHeaders,
|
||||
):
|
||||
"""
|
||||
Update users endpoint
|
||||
"""
|
||||
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 = UserRouterCluster.get_event_cluster("UserUpdate")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
@@ -1,8 +0,0 @@
|
||||
from .people.cluster import PeopleRouterCluster
|
||||
from .user.cluster import UserRouterCluster
|
||||
|
||||
|
||||
__all__ = [
|
||||
"PeopleRouterCluster",
|
||||
"UserRouterCluster",
|
||||
]
|
||||
@@ -1,25 +0,0 @@
|
||||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
SupersPeopleCreateEvent,
|
||||
SupersPeopleUpdateEvent,
|
||||
SupersPeopleListEvent,
|
||||
)
|
||||
|
||||
PeopleRouterCluster = RouterCluster(name="PeopleRouterCluster")
|
||||
|
||||
PeopleEventClusterList = EventCluster(
|
||||
name="PeopleList", endpoint_uu_id="f102db46-031a-43e4-966a-dae6896f985b"
|
||||
)
|
||||
PeopleEventClusterList.add_event(SupersPeopleListEvent)
|
||||
PeopleEventClusterCreate = EventCluster(
|
||||
name="PeopleCreate", endpoint_uu_id="eb465fde-337f-4b81-94cf-28c6d4f2b1b6"
|
||||
)
|
||||
PeopleEventClusterCreate.add_event(SupersPeopleCreateEvent)
|
||||
PeopleEventClusterUpdate = EventCluster(
|
||||
name="PeopleUpdate", endpoint_uu_id="c9e5ba69-6915-43f5-8f9c-a5c2aa865b89"
|
||||
)
|
||||
PeopleEventClusterUpdate.add_event(SupersPeopleUpdateEvent)
|
||||
|
||||
PeopleRouterCluster.set_event_cluster(PeopleEventClusterList)
|
||||
PeopleRouterCluster.set_event_cluster(PeopleEventClusterCreate)
|
||||
PeopleRouterCluster.set_event_cluster(PeopleEventClusterUpdate)
|
||||
@@ -1,103 +0,0 @@
|
||||
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.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():
|
||||
"""
|
||||
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(data: PaginateOnly):
|
||||
"""
|
||||
Example callable method
|
||||
"""
|
||||
list_options = PaginateOnly(**data.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
|
||||
@@ -1,27 +0,0 @@
|
||||
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="1aca3094-fe80-4e0f-a460-1a506419082a"
|
||||
)
|
||||
UserEventClusterList.add_event(SuperUsersListEvent)
|
||||
|
||||
UserEventClusterCreate = EventCluster(
|
||||
name="UserCreate", endpoint_uu_id="9686211f-4260-485d-8076-186c22c053aa"
|
||||
)
|
||||
UserEventClusterCreate.add_event(SuperUsersCreateEvent)
|
||||
|
||||
UserEventClusterUpdate = EventCluster(
|
||||
name="UserUpdate", endpoint_uu_id="268e887b-5ff5-4f99-b1be-7e127e28a198"
|
||||
)
|
||||
UserEventClusterUpdate.add_event(SuperUsersUpdateEvent)
|
||||
|
||||
UserRouterCluster.set_event_cluster(UserEventClusterList)
|
||||
UserRouterCluster.set_event_cluster(UserEventClusterCreate)
|
||||
UserRouterCluster.set_event_cluster(UserEventClusterUpdate)
|
||||
@@ -1,94 +0,0 @@
|
||||
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
|
||||
@@ -1,26 +0,0 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class ListOptions(BaseModel):
|
||||
"""
|
||||
Query for list option abilities
|
||||
"""
|
||||
|
||||
page: Optional[int] = 1
|
||||
size: Optional[int] = 10
|
||||
order_field: Optional[str] = "id"
|
||||
order_type: Optional[str] = "asc"
|
||||
# include_joins: Optional[list] = None
|
||||
query: Optional[dict] = None
|
||||
|
||||
|
||||
class PaginateOnly(BaseModel):
|
||||
"""
|
||||
Query for list option abilities
|
||||
"""
|
||||
|
||||
page: Optional[int] = 1
|
||||
size: Optional[int] = 10
|
||||
order_field: Optional[str] = "id"
|
||||
order_type: Optional[str] = "asc"
|
||||
@@ -1,24 +0,0 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class REQUESTAWMXNTKMGPPOJWRCTZUBADNFLQDBDYVQAORFAVCSXUUHEBQHCEPCSKFBADBODFDBPYKOVINV(
|
||||
BaseModel
|
||||
):
|
||||
uu_id: str
|
||||
created_at: str
|
||||
updated_at: str
|
||||
person_tag: str
|
||||
expiry_starts: str
|
||||
expiry_ends: str
|
||||
firstname: str
|
||||
middle_name: str
|
||||
surname: str
|
||||
birth_date: str
|
||||
birth_place: str
|
||||
sex_code: str
|
||||
country_code: str
|
||||
tax_no: str
|
||||
active: bool
|
||||
deleted: bool
|
||||
is_confirmed: bool
|
||||
is_notification_send: bool
|
||||
@@ -1,33 +0,0 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class FF7C859A068EB4583A47AB5924EC8C19A033881823FBA42EAAD089BF7AC8059CE(BaseModel):
|
||||
"""
|
||||
a13143ade48954c2ba3f86869e027de5b28c8a9b619bf4ef28264a8e375371601
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class F1B82565925FF4F5DAD2A36370788305A0A362E031EAC4A9E8BDFF4F35E265A6C(BaseModel):
|
||||
"""
|
||||
aa487ab3bfd9e4e6abc2db714ac6197f60bbc9068ac6541e7a815d5b1e969796b
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class F3117E7D66FE6471C8452B97AB504EF0C29822B6395CA4D65A18FDD563F0EC8D7(BaseModel):
|
||||
"""
|
||||
a1bf55a214b684438a97a47e4f097ac7ae27b0dff03c4475cbd4301e24a032aac
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class F33B4DE316B8A456480DD6ED5B5E2D35A2E6FCAF74BAC40D7A2970D318B153F85(BaseModel):
|
||||
"""
|
||||
F33B4DE316B8A456480DD6ED5B5E2D35A2E6FCAF74BAC40D7A2970D318B153F85
|
||||
"""
|
||||
|
||||
pass
|
||||
Reference in New Issue
Block a user