Adding config endpoint

This commit is contained in:
Pascal Scheiben
2025-09-18 11:49:34 +02:00
parent 1592333ef8
commit d00c35ccb5
6 changed files with 59 additions and 0 deletions

3
src/config/__init__.py Normal file
View File

@@ -0,0 +1,3 @@
from src.config.router import router as config_router
__all__ = ["config_router"]

14
src/config/config.http Normal file
View File

@@ -0,0 +1,14 @@
POST http://127.0.0.1:8000/config
Content-Type: application/json
{
"cluster_list": [
{
"hostname": "cluster1.demo.netapp.com",
"username": "admin",
"password": "Netapp1!"
}
]
}
###

16
src/config/router.py Normal file
View File

@@ -0,0 +1,16 @@
from fastapi import APIRouter
from .schema import ConfigSchema, ConfigReturnSchema
import logging
logger = logging.getLogger("uvicorn")
router = APIRouter(tags=["config"])
@router.post("/config", response_model=ConfigReturnSchema)
async def create_config(config: ConfigSchema) -> ConfigSchema:
"""
Endpoint to receive and return configuration data.
"""
logger.info("Received configuration data")
return config

21
src/config/schema.py Normal file
View File

@@ -0,0 +1,21 @@
# contains the schema definitions for the aggregate service
from pydantic import BaseModel
class ConfigEntrySchema(BaseModel):
hostname: str
username: str
password: str
class ConfigOutSchema(BaseModel):
hostname: str
username: str
class ConfigReturnSchema(BaseModel):
cluster_list: list[ConfigOutSchema]
class ConfigSchema(BaseModel):
cluster_list: list[ConfigEntrySchema]

3
src/config/service.py Normal file
View File

@@ -0,0 +1,3 @@
# contains the business logic for the aggregate service
async def example_service() -> str:
return "This is an aggregate service"

View File

@@ -2,6 +2,7 @@ from src.service import load_config
from fastapi import FastAPI
import logging
from src.aggregate import aggregate_router
from src.config import config_router
logger = logging.getLogger("uvicorn")
@@ -10,6 +11,7 @@ config = load_config()
app = FastAPI()
app.include_router(aggregate_router)
app.include_router(config_router)
@app.get("/")