Compare commits

...

5 Commits

Author SHA1 Message Date
Pascal Scheiben
0a14e9abf2 Arranging imports 2025-09-18 13:49:54 +02:00
Pascal Scheiben
d5c2ee172f Fixing typos 2025-09-18 12:10:29 +02:00
Pascal Scheiben
2fb893df90 Enhancing comments, adding stub for business logic 2025-09-18 12:09:33 +02:00
Pascal Scheiben
3d15b89b95 Rewriting comments 2025-09-18 12:05:03 +02:00
Pascal Scheiben
d00c35ccb5 Adding config endpoint 2025-09-18 11:49:34 +02:00
11 changed files with 76 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
from src.example.router import router as example_router from src.example.router import router as example_router
from .aggregate_router import router as aggregate_router from .aggregate_router import router as aggregate_router
__all__ = ["example_router", "aggregate_router"] __all__ = ["example_router", "aggregate_router"]

View File

@@ -1,7 +1,9 @@
# contains the router for the aggregates endpoint # contains the router for the aggregates endpoint
from fastapi import APIRouter, Query
from enum import Enum from enum import Enum
from typing import List from typing import List
from fastapi import APIRouter, Query
from .aggregate_schema import AggregateSchema from .aggregate_schema import AggregateSchema
from .aggregate_service import get_aggregates from .aggregate_service import get_aggregates

View File

@@ -1,5 +1,6 @@
# contains the business logic for aggregates # contains the business logic for aggregates
from typing import List from typing import List
from .aggregate_schema import AggregateSchema from .aggregate_schema import AggregateSchema

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!"
}
]
}
###

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

@@ -0,0 +1,22 @@
import logging
from fastapi import APIRouter
from .schema import ConfigReturnSchema, ConfigSchema
logger = logging.getLogger("uvicorn")
router = APIRouter(tags=["config"])
@router.post(
"/config", summary="Upload a configuration", response_model=ConfigReturnSchema
)
async def create_config(config: ConfigSchema) -> ConfigSchema:
"""
Endpoint to receive and store configuration data.
⚠️ at this time the configuration is not stored anywhere. It's like logging to /dev/null
"""
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 config 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]

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

@@ -0,0 +1,2 @@
# contains the business logic for the config service
async def save_config() -> None: ...

View File

@@ -1,5 +1,6 @@
# contains the router for the aggregate endpoint # contains the router for the aggregate endpoint
from fastapi import APIRouter from fastapi import APIRouter
from .schema import ExampleSchema from .schema import ExampleSchema
router = APIRouter(tags=["aggregate"]) router = APIRouter(tags=["aggregate"])

View File

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

View File

@@ -1,6 +1,7 @@
from dotenv import dotenv_values
import logging import logging
from dotenv import dotenv_values
from src.schema import ConfigSchema from src.schema import ConfigSchema
logger = logging.getLogger("uvicorn") logger = logging.getLogger("uvicorn")