Initial commit: core-api service extraction from portainer-core
Build and Push / build (release) Successful in 43s

This commit is contained in:
2025-12-11 15:52:59 +01:00
commit 488a4e8a91
49 changed files with 9478 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
"""
Base controller class for Core-API
Provides common functionality for all controllers.
"""
from fastapi import APIRouter
from abc import ABC, abstractmethod
class BaseController(ABC):
"""
Base controller class with common functionality
All controllers should inherit from this class and implement
the create_router() method to define their endpoints.
"""
def __init__(self, prefix: str, tags: list[str]):
"""
Initialize base controller
Args:
prefix: URL prefix for this controller's routes
tags: OpenAPI tags for documentation grouping
"""
self.prefix = prefix
self.tags = tags
self._router = None
@abstractmethod
def create_router(self) -> APIRouter:
"""
Create and configure the FastAPI router for this controller
Returns:
Configured APIRouter instance with all endpoints
"""
pass
@property
def router(self) -> APIRouter:
"""
Get the router instance, creating it if needed
Returns:
APIRouter instance
"""
if self._router is None:
self._router = self.create_router()
return self._router