events started
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
template related API endpoints.
|
||||
Account related API endpoints.
|
||||
"""
|
||||
from typing import Any, Dict
|
||||
from fastapi import Request
|
||||
@@ -9,43 +9,120 @@ from Events.base_request_model import EndpointBaseRequestModel, ContextRetriever
|
||||
from ApiLayers.Middleware.token_event_middleware import TokenEventMiddleware
|
||||
from ApiLayers.ApiValidations.Response.default_response import EndpointSuccessListResponse
|
||||
|
||||
from .api_events import account_insert_super_user_event
|
||||
from .function_handlers import AccountListEventMethods
|
||||
from .api_events import SuperUserAccountEvents
|
||||
|
||||
|
||||
AccountRecordsEventMethods = MethodToEvent(
|
||||
name="AccountRecordsEventMethods",
|
||||
AccountRecordsListEventMethods = MethodToEvent(
|
||||
name="AccountRecordsListEventMethods",
|
||||
events={
|
||||
account_insert_super_user_event.key: account_insert_super_user_event,
|
||||
SuperUserAccountEvents.SuperUserListEvent.key: SuperUserAccountEvents.SuperUserListEvent,
|
||||
},
|
||||
headers=[],
|
||||
errors=[],
|
||||
decorators_list=[TokenEventMiddleware.event_required],
|
||||
url="/list",
|
||||
method="POST",
|
||||
summary="Login via domain and access key : [email] | [phone]",
|
||||
description="Login to the system via domain, access key : [email] | [phone]",
|
||||
summary="List all accounts by given previligous",
|
||||
description="List all accounts by given previligous",
|
||||
)
|
||||
|
||||
|
||||
def account_insert_event_endpoint(
|
||||
def account_list_event_endpoint(
|
||||
request: Request, data: EndpointBaseRequestModel
|
||||
) -> Dict[str, Any]:
|
||||
context_retriever = ContextRetrievers(func=account_insert_event_endpoint)
|
||||
event_2_catch = AccountRecordsEventMethods.retrieve_event(
|
||||
event_function_code=f"{account_insert_super_user_event.key}"
|
||||
context_retriever = ContextRetrievers(func=account_list_event_endpoint)
|
||||
event_2_catch = AccountRecordsListEventMethods.retrieve_event(
|
||||
event_function_code=f"{SuperUserAccountEvents.SuperUserListEvent.key}"
|
||||
)
|
||||
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||
AccountListEventMethods.context_retriever = context_retriever
|
||||
pagination_result = event_2_catch.endpoint_callable(data=data)
|
||||
return EndpointSuccessListResponse(
|
||||
code="ACCOUNTS_LIST", lang=context_retriever.token.lang
|
||||
code=event_2_catch.static_key, lang=context_retriever.token.lang
|
||||
).as_dict(
|
||||
data=pagination_result.data, pagination=pagination_result.pagination.as_dict()
|
||||
)
|
||||
|
||||
|
||||
AccountRecordsEventMethods.endpoint_callable = (
|
||||
account_insert_event_endpoint
|
||||
AccountRecordsListEventMethods.endpoint_callable = (
|
||||
account_list_event_endpoint
|
||||
)
|
||||
|
||||
|
||||
AccountRecordsCreateEventMethods = MethodToEvent(
|
||||
name="AccountRecordsCreateEventMethods",
|
||||
events={
|
||||
SuperUserAccountEvents.SuperUserCreateEvent.key: SuperUserAccountEvents.SuperUserCreateEvent,
|
||||
},
|
||||
headers=[],
|
||||
errors=[],
|
||||
decorators_list=[TokenEventMiddleware.event_required],
|
||||
url="/create",
|
||||
method="POST",
|
||||
summary="Create Account via given data and previligous",
|
||||
description="Create Account via given data and previligous",
|
||||
)
|
||||
|
||||
|
||||
def account_create_event_endpoint(
|
||||
request: Request, data: EndpointBaseRequestModel
|
||||
) -> Dict[str, Any]:
|
||||
context_retriever = ContextRetrievers(func=account_create_event_endpoint)
|
||||
event_2_catch = AccountRecordsCreateEventMethods.retrieve_event(
|
||||
event_function_code=f"{SuperUserAccountEvents.SuperUserCreateEvent.key}"
|
||||
)
|
||||
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||
AccountListEventMethods.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()
|
||||
)
|
||||
|
||||
|
||||
AccountRecordsCreateEventMethods.endpoint_callable = (
|
||||
account_create_event_endpoint
|
||||
)
|
||||
|
||||
|
||||
AccountRecordsUpdateEventMethods = MethodToEvent(
|
||||
name="AccountRecordsUpdateEventMethods",
|
||||
events={
|
||||
SuperUserAccountEvents.SuperUserUpdateEvent.key: SuperUserAccountEvents.SuperUserUpdateEvent,
|
||||
},
|
||||
headers=[],
|
||||
errors=[],
|
||||
decorators_list=[TokenEventMiddleware.event_required],
|
||||
url="/update",
|
||||
method="POST",
|
||||
summary="Update Account via given data and previligous",
|
||||
description="Update Account via given data and previligous",
|
||||
)
|
||||
|
||||
|
||||
def account_update_event_endpoint(
|
||||
request: Request, data: EndpointBaseRequestModel
|
||||
) -> Dict[str, Any]:
|
||||
context_retriever = ContextRetrievers(func=account_update_event_endpoint)
|
||||
event_2_catch = AccountRecordsUpdateEventMethods.retrieve_event(
|
||||
event_function_code=f"{SuperUserAccountEvents.SuperUserUpdateEvent.key}"
|
||||
)
|
||||
context_retriever.RESPONSE_VALIDATOR = event_2_catch.RESPONSE_VALIDATOR
|
||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||
AccountListEventMethods.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()
|
||||
)
|
||||
|
||||
|
||||
AccountRecordsUpdateEventMethods.endpoint_callable = (
|
||||
account_update_event_endpoint
|
||||
)
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
from ApiLayers.ApiValidations.Request import ListOptions
|
||||
from ApiLayers.Schemas import AccountRecords
|
||||
# from ApiLayers.LanguageModels.Request import (
|
||||
# LoginRequestLanguageModel,
|
||||
# SelectRequestLanguageModel,
|
||||
# )
|
||||
from Events.Engine.abstract_class import Event
|
||||
|
||||
from .models import AccountRequestValidators
|
||||
from .function_handlers import (
|
||||
AccountListEventMethods,
|
||||
AccountCreateEventMethods,
|
||||
AccountUpdateEventMethods,
|
||||
)
|
||||
|
||||
#
|
||||
|
||||
# class SelectResponseAccount(BaseModel):
|
||||
# """
|
||||
# Response model for account list.
|
||||
@@ -24,8 +18,9 @@ from .function_handlers import (
|
||||
# type_description: str
|
||||
#
|
||||
|
||||
|
||||
# Auth Login
|
||||
account_insert_super_user_event = Event(
|
||||
account_list_super_user_event = Event(
|
||||
name="account_insert_super_user_event",
|
||||
key="36a165fe-a2f3-437b-80ee-1ee44670fe70",
|
||||
request_validator=AccountRequestValidators.ListAccountRecord,
|
||||
@@ -37,6 +32,45 @@ account_insert_super_user_event = Event(
|
||||
)
|
||||
|
||||
|
||||
account_insert_super_user_event.endpoint_callable = (
|
||||
account_list_super_user_event.endpoint_callable = (
|
||||
AccountListEventMethods.account_records_list
|
||||
)
|
||||
|
||||
|
||||
account_insert_super_user_event = Event(
|
||||
name="account_insert_super_user_event",
|
||||
key="3aa46155-72bc-4370-b4e7-b937b0f9b893",
|
||||
request_validator=AccountRequestValidators.InsertAccountRecord,
|
||||
# response_validator=SelectResponseAccount,
|
||||
# language_models=[AccountRecords.__language_model__],
|
||||
language_models=[],
|
||||
statics="ACCOUNT_CREATED",
|
||||
description="Create a new account by validation list options and queries.",
|
||||
)
|
||||
|
||||
|
||||
account_insert_super_user_event.endpoint_callable = (
|
||||
AccountCreateEventMethods.account_records_create
|
||||
)
|
||||
|
||||
|
||||
account_update_super_user_event = Event(
|
||||
name="account_insert_super_user_event",
|
||||
key="3aa46155-72bc-4370-b4e7-b937b0f9b893",
|
||||
request_validator=AccountRequestValidators.UpdateAccountRecord,
|
||||
# response_validator=SelectResponseAccount,
|
||||
# language_models=[AccountRecords.__language_model__],
|
||||
language_models=[],
|
||||
statics="ACCOUNT_UPDATED",
|
||||
description="Update a specific account by validation list options and queries.",
|
||||
)
|
||||
|
||||
account_update_super_user_event.endpoint_callable = (
|
||||
AccountUpdateEventMethods.account_records_update
|
||||
)
|
||||
|
||||
|
||||
class SuperUserAccountEvents:
|
||||
SuperUserListEvent = account_list_super_user_event
|
||||
SuperUserCreateEvent = account_insert_super_user_event
|
||||
SuperUserUpdateEvent = account_update_super_user_event
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
from Events.Engine.abstract_class import CategoryCluster
|
||||
|
||||
from .account_records import AccountRecordsEventMethods
|
||||
from .account_records import (
|
||||
AccountRecordsListEventMethods,
|
||||
AccountRecordsCreateEventMethods,
|
||||
AccountRecordsUpdateEventMethods,
|
||||
)
|
||||
from .info import account_page_info
|
||||
|
||||
|
||||
AccountCluster = CategoryCluster(
|
||||
name="AccountCluster",
|
||||
tags=["accounts"],
|
||||
tags=["Account Records"],
|
||||
prefix="/accounts",
|
||||
description="Account Cluster",
|
||||
pageinfo=account_page_info,
|
||||
endpoints={
|
||||
"AccountRecordsEventMethods": AccountRecordsEventMethods,
|
||||
"AccountRecordsListEventMethods": AccountRecordsListEventMethods,
|
||||
"AccountRecordsCreateEventMethods": AccountRecordsCreateEventMethods,
|
||||
"AccountRecordsUpdateEventMethods": AccountRecordsUpdateEventMethods,
|
||||
},
|
||||
include_in_schema=True,
|
||||
sub_category=[],
|
||||
is_client=True,
|
||||
)
|
||||
|
||||
@@ -291,3 +291,4 @@ class AccountUpdateEventMethods(BaseRouteModel):
|
||||
# cls_object=AccountRecords,
|
||||
# response_model=UpdateAccountRecord,
|
||||
# )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user