validations endpoint build started
This commit is contained in:
23
Events/AllEvents/template/template/api_events.py
Normal file
23
Events/AllEvents/template/template/api_events.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from Events.Engine.abstract_class import Event
|
||||
from ApiLayers.LanguageModels.Request import (
|
||||
LoginRequestLanguageModel,
|
||||
)
|
||||
|
||||
from models import TemplateResponseModels, TemplateRequestModels
|
||||
from function_handlers import TemplateFunctions
|
||||
|
||||
|
||||
# Auth Login
|
||||
template_event = Event(
|
||||
name="authentication_login_super_user_event",
|
||||
key="a5d2d0d1-3e9b-4b0f-8c7d-6d4a4b4c4d4e",
|
||||
request_validator=TemplateRequestModels.TemplateRequestModelX,
|
||||
language_models=[LoginRequestLanguageModel],
|
||||
response_validation_static="LOGIN_SUCCESS",
|
||||
description="Login super user",
|
||||
)
|
||||
|
||||
|
||||
template_event.endpoint_callable = (
|
||||
TemplateFunctions.template_example_function()
|
||||
)
|
||||
14
Events/AllEvents/template/template/cluster.py
Normal file
14
Events/AllEvents/template/template/cluster.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from Events.Engine.abstract_class import CategoryCluster
|
||||
from info import template_page_info
|
||||
|
||||
|
||||
TemplateCluster = CategoryCluster(
|
||||
name="TemplateCluster",
|
||||
tags=["template"],
|
||||
prefix="/template",
|
||||
description="Template cluster",
|
||||
pageinfo=template_page_info,
|
||||
endpoints={},
|
||||
include_in_schema=True,
|
||||
sub_category=[],
|
||||
)
|
||||
21
Events/AllEvents/template/template/function_handlers.py
Normal file
21
Events/AllEvents/template/template/function_handlers.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import Any, Union
|
||||
from fastapi import Request
|
||||
|
||||
from Events.base_request_model import TokenDictType, BaseRouteModel
|
||||
|
||||
|
||||
class Handlers:
|
||||
"""Class for handling authentication functions"""
|
||||
|
||||
@classmethod # Requires no auth context
|
||||
def handle_function(cls, **kwargs):
|
||||
"""Handle function with kwargs"""
|
||||
return
|
||||
|
||||
|
||||
class TemplateFunctions(BaseRouteModel):
|
||||
"""Class for handling authentication functions"""
|
||||
|
||||
@classmethod
|
||||
def template_example_function(cls):
|
||||
return
|
||||
11
Events/AllEvents/template/template/info.py
Normal file
11
Events/AllEvents/template/template/info.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from Events.Engine.abstract_class import PageInfo
|
||||
|
||||
|
||||
template_page_info = PageInfo(
|
||||
name="template",
|
||||
title={"en": "template"},
|
||||
description={"en": "template"},
|
||||
icon="",
|
||||
parent="",
|
||||
url=""
|
||||
)
|
||||
12
Events/AllEvents/template/template/models.py
Normal file
12
Events/AllEvents/template/template/models.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from ApiLayers.ApiValidations.Request import (
|
||||
BaseModelRegular
|
||||
)
|
||||
|
||||
|
||||
class TemplateRequestModels:
|
||||
TemplateRequestModelX = BaseModelRegular
|
||||
|
||||
|
||||
|
||||
class TemplateResponseModels:
|
||||
TemplateResponseModelsX = BaseModelRegular
|
||||
39
Events/AllEvents/template/template/template.py
Normal file
39
Events/AllEvents/template/template/template.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
template 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 api_events import template_event
|
||||
|
||||
|
||||
AuthenticationLoginEventMethods = MethodToEvent(
|
||||
name="AuthenticationLoginEventMethods",
|
||||
events={
|
||||
template_event.key: template_event,
|
||||
},
|
||||
headers=[],
|
||||
errors=[],
|
||||
url="/login",
|
||||
method="POST",
|
||||
summary="Login via domain and access key : [email] | [phone]",
|
||||
description="Login to the system via domain, access key : [email] | [phone]",
|
||||
)
|
||||
|
||||
|
||||
def authentication_login_with_domain_and_creds_endpoint(
|
||||
request: Request, data: EndpointBaseRequestModel
|
||||
) -> Dict[str, Any]:
|
||||
event_2_catch = AuthenticationLoginEventMethods.retrieve_event(
|
||||
event_function_code=f"{template_event.key}"
|
||||
)
|
||||
data = event_2_catch.REQUEST_VALIDATOR(**data.data)
|
||||
return event_2_catch.endpoint_callable(request=request, data=data)
|
||||
|
||||
|
||||
AuthenticationLoginEventMethods.endpoint_callable = (
|
||||
authentication_login_with_domain_and_creds_endpoint
|
||||
)
|
||||
Reference in New Issue
Block a user