44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
import uuid
|
|
|
|
from fastapi.params import Depends
|
|
from sqlalchemy import select, insert, delete
|
|
from sqlalchemy.orm import Session
|
|
from starlette.exceptions import HTTPException
|
|
from starlette.requests import Request
|
|
from fastapi import APIRouter
|
|
from starlette.responses import JSONResponse
|
|
|
|
from pillar_tool.db.models.top_data import State, StateAssignment
|
|
from pillar_tool.schemas import PillarParams, get_model_from_query
|
|
from pillar_tool.util.validation import validate_state_name
|
|
|
|
router = APIRouter(
|
|
prefix="/pillar",
|
|
tags=["pillar"],
|
|
)
|
|
|
|
# Note: there is no list of all pillars, as this would not be helpful
|
|
|
|
@router.get("/{name}")
|
|
def state_get(req: Request, name: str, params: Depends(get_model_from_query(PillarParams))):
|
|
# TODO: implement
|
|
# this function should:
|
|
# - get the affected host hierarchy
|
|
# - get all the relevant pillar dictionaries
|
|
# - merge the pillar directories
|
|
# - return the merged pillar directory
|
|
# if any error happens, return non-200 status and an empty dictionary so that salt does not shit itself
|
|
db: Session = req.state.db
|
|
|
|
|
|
@router.post("/{name}")
|
|
def state_create(req: Request, name: str):
|
|
# TODO: implement
|
|
db = req.state.db
|
|
|
|
|
|
@router.delete("/{name}")
|
|
def state_delete(req: Request, name: str):
|
|
# TODO: implement
|
|
db = req.state.db
|