Compare commits
5 Commits
main
...
0a14e9abf2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a14e9abf2 | ||
|
|
d5c2ee172f | ||
|
|
2fb893df90 | ||
|
|
3d15b89b95 | ||
|
|
d00c35ccb5 |
@@ -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"]
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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
3
src/config/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from src.config.router import router as config_router
|
||||||
|
|
||||||
|
__all__ = ["config_router"]
|
||||||
14
src/config/config.http
Normal file
14
src/config/config.http
Normal 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
22
src/config/router.py
Normal 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
21
src/config/schema.py
Normal 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
2
src/config/service.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# contains the business logic for the config service
|
||||||
|
async def save_config() -> None: ...
|
||||||
@@ -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"])
|
||||||
|
|||||||
@@ -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("/")
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user