redis implemntations and api setup completed
This commit is contained in:
39
ApiLayers/ApiServices/Cluster/create_router.py
Normal file
39
ApiLayers/ApiServices/Cluster/create_router.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from fastapi import APIRouter
|
||||
import uuid
|
||||
from Events.Engine.abstract_class import CategoryCluster, MethodToEvent
|
||||
|
||||
|
||||
class CreateRouterFromCluster:
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.prefix = kwargs.get("prefix")
|
||||
self.tags = kwargs.get("tags")
|
||||
self.router = APIRouter(prefix=self.prefix, tags=self.tags)
|
||||
|
||||
|
||||
class CreateEndpointFromCluster:
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.router: CategoryCluster = kwargs.get("router")
|
||||
self.method_endpoint: MethodToEvent = kwargs.get("method_endpoint")
|
||||
self.unique_id = str(uuid.uuid4())[:8] # Use first 8 chars of UUID for brevity
|
||||
self.attach_router()
|
||||
|
||||
def attach_router(self):
|
||||
method = getattr(self.router, self.method_endpoint.METHOD.lower())
|
||||
|
||||
# Create a unique operation ID based on the endpoint path, method, and a unique identifier
|
||||
base_path = self.method_endpoint.URL.strip('/').replace('/', '_').replace('-', '_')
|
||||
operation_id = f"{base_path}_{self.method_endpoint.METHOD.lower()}_{self.unique_id}"
|
||||
|
||||
kwargs = {
|
||||
"path": self.method_endpoint.URL,
|
||||
"summary": self.method_endpoint.SUMMARY,
|
||||
"description": self.method_endpoint.DESCRIPTION,
|
||||
"operation_id": operation_id
|
||||
}
|
||||
|
||||
if hasattr(self.method_endpoint, 'RESPONSE_MODEL') and self.method_endpoint.RESPONSE_MODEL is not None:
|
||||
kwargs["response_model"] = self.method_endpoint.RESPONSE_MODEL
|
||||
|
||||
method(**kwargs)(self.method_endpoint.endpoint_callable)
|
||||
5
ApiLayers/ApiServices/Cluster/handle_cluster.py
Normal file
5
ApiLayers/ApiServices/Cluster/handle_cluster.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from Services.Redis import RedisActions, AccessToken
|
||||
from Services.Redis.Models.cluster import RedisList
|
||||
|
||||
redis_list = RedisList(redis_key="test")
|
||||
|
||||
Reference in New Issue
Block a user