feat: add backfills logic
This commit is contained in:
1 parent
4a471df8f1
commit
51093da660
12 files changed
+251
-63
No files matched your search
@@ -1,7 +1,7 @@
|
||||
from typing import Annotated
|
||||
|
||||
import asyncpg
|
||||
from dishka.integrations.fastapi import FromDishka, inject
|
||||
from dishka.integrations.fastapi import DishkaRoute, FromDishka
|
||||
from fastapi import APIRouter, HTTPException, Query
|
||||
from pydantic import BaseModel
|
||||
|
||||
@@ -15,7 +15,7 @@ from utils.policy.models import (
|
||||
)
|
||||
from utils.policy.resolver import resolve
|
||||
|
||||
router = APIRouter(prefix="/api/policy", tags=["policy"])
|
||||
router = APIRouter(prefix="/api/policy", tags=["policy"], route_class=DishkaRoute)
|
||||
|
||||
POLICY_CHANGED_CHANNEL = "policy_changed"
|
||||
|
||||
@@ -29,7 +29,6 @@ class EffectiveQuery(BaseModel):
|
||||
|
||||
|
||||
@router.get("")
|
||||
@inject
|
||||
async def list_policies(
|
||||
pool: FromDishka[asyncpg.Pool], account_id: Annotated[int, Query()]
|
||||
) -> list[PolicyRecord]:
|
||||
@@ -37,7 +36,6 @@ async def list_policies(
|
||||
|
||||
|
||||
@router.get("/effective")
|
||||
@inject
|
||||
async def effective_policy(
|
||||
pool: FromDishka[asyncpg.Pool], query: Annotated[EffectiveQuery, Query()]
|
||||
) -> CaptureToggles:
|
||||
@@ -53,7 +51,6 @@ async def effective_policy(
|
||||
|
||||
|
||||
@router.post("", status_code=201)
|
||||
@inject
|
||||
async def create_policy(
|
||||
pool: FromDishka[asyncpg.Pool], body: PolicyCreate
|
||||
) -> PolicyRecord:
|
||||
@@ -65,7 +62,6 @@ async def create_policy(
|
||||
|
||||
|
||||
@router.get("/{policy_id}")
|
||||
@inject
|
||||
async def get_policy(pool: FromDishka[asyncpg.Pool], policy_id: int) -> PolicyRecord:
|
||||
record = await repository.get_policy(pool, policy_id)
|
||||
if record is None:
|
||||
@@ -74,7 +70,6 @@ async def get_policy(pool: FromDishka[asyncpg.Pool], policy_id: int) -> PolicyRe
|
||||
|
||||
|
||||
@router.put("/{policy_id}")
|
||||
@inject
|
||||
async def update_policy(
|
||||
pool: FromDishka[asyncpg.Pool], policy_id: int, body: CaptureToggles
|
||||
) -> PolicyRecord:
|
||||
@@ -86,7 +81,6 @@ async def update_policy(
|
||||
|
||||
|
||||
@router.delete("/{policy_id}", status_code=204)
|
||||
@inject
|
||||
async def delete_policy(pool: FromDishka[asyncpg.Pool], policy_id: int) -> None:
|
||||
if not await repository.delete_policy(pool, policy_id):
|
||||
raise HTTPException(status_code=404, detail="policy not found")
|
||||
|
||||
Reference in new issue
Block a user